diff options
Diffstat (limited to 'lib/rbcodec/codecs/libopus/celt/fixed_generic.h')
-rw-r--r-- | lib/rbcodec/codecs/libopus/celt/fixed_generic.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/rbcodec/codecs/libopus/celt/fixed_generic.h b/lib/rbcodec/codecs/libopus/celt/fixed_generic.h index ac67d37ce8..5f4abda76e 100644 --- a/lib/rbcodec/codecs/libopus/celt/fixed_generic.h +++ b/lib/rbcodec/codecs/libopus/celt/fixed_generic.h | |||
@@ -37,16 +37,32 @@ | |||
37 | #define MULT16_16SU(a,b) ((opus_val32)(opus_val16)(a)*(opus_val32)(opus_uint16)(b)) | 37 | #define MULT16_16SU(a,b) ((opus_val32)(opus_val16)(a)*(opus_val32)(opus_uint16)(b)) |
38 | 38 | ||
39 | /** 16x32 multiplication, followed by a 16-bit shift right. Results fits in 32 bits */ | 39 | /** 16x32 multiplication, followed by a 16-bit shift right. Results fits in 32 bits */ |
40 | #if OPUS_FAST_INT64 | ||
41 | #define MULT16_32_Q16(a,b) ((opus_val32)SHR((opus_int64)((opus_val16)(a))*(b),16)) | ||
42 | #else | ||
40 | #define MULT16_32_Q16(a,b) ADD32(MULT16_16((a),SHR((b),16)), SHR(MULT16_16SU((a),((b)&0x0000ffff)),16)) | 43 | #define MULT16_32_Q16(a,b) ADD32(MULT16_16((a),SHR((b),16)), SHR(MULT16_16SU((a),((b)&0x0000ffff)),16)) |
44 | #endif | ||
41 | 45 | ||
42 | /** 16x32 multiplication, followed by a 16-bit shift right (round-to-nearest). Results fits in 32 bits */ | 46 | /** 16x32 multiplication, followed by a 16-bit shift right (round-to-nearest). Results fits in 32 bits */ |
47 | #if OPUS_FAST_INT64 | ||
48 | #define MULT16_32_P16(a,b) ((opus_val32)PSHR((opus_int64)((opus_val16)(a))*(b),16)) | ||
49 | #else | ||
43 | #define MULT16_32_P16(a,b) ADD32(MULT16_16((a),SHR((b),16)), PSHR(MULT16_16SU((a),((b)&0x0000ffff)),16)) | 50 | #define MULT16_32_P16(a,b) ADD32(MULT16_16((a),SHR((b),16)), PSHR(MULT16_16SU((a),((b)&0x0000ffff)),16)) |
51 | #endif | ||
44 | 52 | ||
45 | /** 16x32 multiplication, followed by a 15-bit shift right. Results fits in 32 bits */ | 53 | /** 16x32 multiplication, followed by a 15-bit shift right. Results fits in 32 bits */ |
54 | #if OPUS_FAST_INT64 | ||
55 | #define MULT16_32_Q15(a,b) ((opus_val32)SHR((opus_int64)((opus_val16)(a))*(b),15)) | ||
56 | #else | ||
46 | #define MULT16_32_Q15(a,b) ADD32(SHL(MULT16_16((a),SHR((b),16)),1), SHR(MULT16_16SU((a),((b)&0x0000ffff)),15)) | 57 | #define MULT16_32_Q15(a,b) ADD32(SHL(MULT16_16((a),SHR((b),16)),1), SHR(MULT16_16SU((a),((b)&0x0000ffff)),15)) |
58 | #endif | ||
47 | 59 | ||
48 | /** 32x32 multiplication, followed by a 31-bit shift right. Results fits in 32 bits */ | 60 | /** 32x32 multiplication, followed by a 31-bit shift right. Results fits in 32 bits */ |
61 | #if OPUS_FAST_INT64 | ||
62 | #define MULT32_32_Q31(a,b) ((opus_val32)SHR((opus_int64)(a)*(opus_int64)(b),31)) | ||
63 | #else | ||
49 | #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)) | 64 | #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)) |
65 | #endif | ||
50 | 66 | ||
51 | /** Compile-time conversion of float constant to 16-bit value */ | 67 | /** Compile-time conversion of float constant to 16-bit value */ |
52 | #define QCONST16(x,bits) ((opus_val16)(.5+(x)*(((opus_val32)1)<<(bits)))) | 68 | #define QCONST16(x,bits) ((opus_val16)(.5+(x)*(((opus_val32)1)<<(bits)))) |
@@ -88,6 +104,9 @@ | |||
88 | 104 | ||
89 | /** Shift by a and round-to-neareast 32-bit value. Result is a 16-bit value */ | 105 | /** Shift by a and round-to-neareast 32-bit value. Result is a 16-bit value */ |
90 | #define ROUND16(x,a) (EXTRACT16(PSHR32((x),(a)))) | 106 | #define ROUND16(x,a) (EXTRACT16(PSHR32((x),(a)))) |
107 | /** Shift by a and round-to-neareast 32-bit value. Result is a saturated 16-bit value */ | ||
108 | #define SROUND16(x,a) EXTRACT16(SATURATE(PSHR32(x,a), 32767)); | ||
109 | |||
91 | /** Divide by two */ | 110 | /** Divide by two */ |
92 | #define HALF16(x) (SHR16(x,1)) | 111 | #define HALF16(x) (SHR16(x,1)) |
93 | #define HALF32(x) (SHR32(x,1)) | 112 | #define HALF32(x) (SHR32(x,1)) |
@@ -101,6 +120,14 @@ | |||
101 | /** Subtract two 32-bit values */ | 120 | /** Subtract two 32-bit values */ |
102 | #define SUB32(a,b) ((opus_val32)(a)-(opus_val32)(b)) | 121 | #define SUB32(a,b) ((opus_val32)(a)-(opus_val32)(b)) |
103 | 122 | ||
123 | /** Add two 32-bit values, ignore any overflows */ | ||
124 | #define ADD32_ovflw(a,b) ((opus_val32)((opus_uint32)(a)+(opus_uint32)(b))) | ||
125 | /** Subtract two 32-bit values, ignore any overflows */ | ||
126 | #define SUB32_ovflw(a,b) ((opus_val32)((opus_uint32)(a)-(opus_uint32)(b))) | ||
127 | /* Avoid MSVC warning C4146: unary minus operator applied to unsigned type */ | ||
128 | /** Negate 32-bit value, ignore any overflows */ | ||
129 | #define NEG32_ovflw(a) ((opus_val32)(0-(opus_uint32)(a))) | ||
130 | |||
104 | /** 16x16 multiplication where the result fits in 16 bits */ | 131 | /** 16x16 multiplication where the result fits in 16 bits */ |
105 | #define MULT16_16_16(a,b) ((((opus_val16)(a))*((opus_val16)(b)))) | 132 | #define MULT16_16_16(a,b) ((((opus_val16)(a))*((opus_val16)(b)))) |
106 | 133 | ||