summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/rbcodec/codecs/libopus/celt/fixed_generic.h18
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/rbcodec/codecs/libopus/celt/fixed_generic.h b/lib/rbcodec/codecs/libopus/celt/fixed_generic.h
index 5682a6793d..53f513b67b 100644
--- a/lib/rbcodec/codecs/libopus/celt/fixed_generic.h
+++ b/lib/rbcodec/codecs/libopus/celt/fixed_generic.h
@@ -71,9 +71,23 @@ static inline int32_t MULT16_32_Q15(int32_t a, int32_t b)
71#define MULT16_32_Q15(a,b) ADD32(SHL(MULT16_16((a),SHR((b),16)),1), SHR(MULT16_16SU((a),((b)&0x0000ffff)),15)) 71#define MULT16_32_Q15(a,b) ADD32(SHL(MULT16_16((a),SHR((b),16)),1), SHR(MULT16_16SU((a),((b)&0x0000ffff)),15))
72#endif 72#endif
73 73
74/** 32x32 multiplication, followed by a 31-bit shift right. Results fits in 32 bits */ 74#if defined(CPU_ARM)
75#define MULT32_32_Q31(a,b) ADD32(ADD32(SHL(MULT16_16(SHR((a),16),SHR((b),16)),1), SHR(MULT16_16SU(SHR((a),16),((b)&0x0000ffff)),15)), SHR(MULT16_16SU(SHR((b),16),((a)&0x0000ffff)),15)) 75static inline int32_t MULT32_32_Q31(int32_t a, int32_t b)
76{
77 int32_t lo, hi;
78 asm volatile("smull %[lo], %[hi], %[a], %[b] \n\t"
79 "mov %[lo], %[lo], lsr #31 \n\t"
80 "orr %[hi], %[lo], %[hi], lsl #1 \n\t"
81 : [lo] "=&r" (lo), [hi] "=&r" (hi)
82 : [a] "r" (a), [b] "r" (b) );
83 return(hi);
84}
76 85
86#else
87/** 32x32 multiplication, followed by a 31-bit shift right. Results fits in 32 bits */
88//#define MULT32_32_Q31(a,b) ADD32(ADD32(SHL(MULT16_16(SHR((a),16),SHR((b),16)),1), SHR(MULT16_16SU(SHR((a),16),((b)&0x0000ffff)),15)), SHR(MULT16_16SU(SHR((b),16),((a)&0x0000ffff)),15))
89#define MULT32_32_Q31(a,b) (opus_val32)((((int64_t)(a)) * ((int64_t)(b)))>>31)
90#endif
77/** Compile-time conversion of float constant to 16-bit value */ 91/** Compile-time conversion of float constant to 16-bit value */
78#define QCONST16(x,bits) ((opus_val16)(.5+(x)*(((opus_val32)1)<<(bits)))) 92#define QCONST16(x,bits) ((opus_val16)(.5+(x)*(((opus_val32)1)<<(bits))))
79 93