summaryrefslogtreecommitdiff
path: root/celt/fixed_debug.h
diff options
context:
space:
mode:
authorGregory Maxwell <greg@xiph.org>2012-07-11 00:04:24 -0400
committerGregory Maxwell <greg@xiph.org>2012-07-11 00:04:24 -0400
commit28b41ae5ae1acf6eb222858567952564838d48f5 (patch)
tree4f9f1c48748f499c8730515ca5b9b1c0633324d3 /celt/fixed_debug.h
parentc329045758ccd614284f0b7cca859bc046ba1ae3 (diff)
downloadopus-28b41ae5ae1acf6eb222858567952564838d48f5.tar.gz
Add OPUS_{GET|SET}_GAIN CTLs for adjusting output gain.
This CTL was requested by Nicolas George for FFmpeg.
Diffstat (limited to 'celt/fixed_debug.h')
-rw-r--r--celt/fixed_debug.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/celt/fixed_debug.h b/celt/fixed_debug.h
index 89b3cf72..ed95cba3 100644
--- a/celt/fixed_debug.h
+++ b/celt/fixed_debug.h
@@ -47,6 +47,8 @@ extern long long celt_mips;
/** 16x32 multiplication, followed by a 16-bit shift right. Results fits in 32 bits */
#define MULT16_32_Q16(a,b) ADD32(MULT16_16((a),SHR32((b),16)), SHR32(MULT16_16SU((a),((b)&0x0000ffff)),16))
+#define MULT16_32_P16(a,b) MULT16_32_PX(a,b,16)
+
#define QCONST16(x,bits) ((opus_val16)(.5+(x)*(((opus_val32)1)<<(bits))))
#define QCONST32(x,bits) ((opus_val32)(.5+(x)*(((opus_val32)1)<<(bits))))
@@ -459,6 +461,39 @@ static inline int MULT16_32_QX_(int a, long long b, int Q, char *file, int line)
return res;
}
+#define MULT16_32_PX(a, b, Q) MULT16_32_PX_(a, b, Q, __FILE__, __LINE__)
+static inline int MULT16_32_PX_(int a, long long b, int Q, char *file, int line)
+{
+ long long res;
+ if (!VERIFY_SHORT(a) || !VERIFY_INT(b))
+ {
+ fprintf (stderr, "MULT16_32_P%d: inputs are not short+int: %d %d in %s: line %d\n\n", Q, (int)a, (int)b, file, line);
+#ifdef FIXED_DEBUG_ASSERT
+ celt_assert(0);
+#endif
+ }
+ if (ABS32(b)>=((opus_val32)(1)<<(15+Q)))
+ {
+ fprintf (stderr, "MULT16_32_Q%d: second operand too large: %d %d in %s: line %d\n\n", Q, (int)a, (int)b, file, line);
+#ifdef FIXED_DEBUG_ASSERT
+ celt_assert(0);
+#endif
+ }
+ res = ((((long long)a)*(long long)b) + (((opus_val32)(1)<<Q)>>1))>> Q;
+ if (!VERIFY_INT(res))
+ {
+ fprintf (stderr, "MULT16_32_P%d: output is not int: %d*%d=%d in %s: line %d\n\n", Q, (int)a, (int)b,(int)res, file, line);
+#ifdef FIXED_DEBUG_ASSERT
+ celt_assert(0);
+#endif
+ }
+ if (Q==15)
+ celt_mips+=4;
+ else
+ celt_mips+=5;
+ return res;
+}
+
#define MULT16_32_Q15(a,b) MULT16_32_QX(a,b,15)
#define MAC16_32_Q15(c,a,b) (celt_mips-=2,ADD32((c),MULT16_32_Q15((a),(b))))