diff options
Diffstat (limited to 'apps/codecs/libspeex/stereo.c')
-rw-r--r-- | apps/codecs/libspeex/stereo.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/apps/codecs/libspeex/stereo.c b/apps/codecs/libspeex/stereo.c index 9fa812dd72..5f74197054 100644 --- a/apps/codecs/libspeex/stereo.c +++ b/apps/codecs/libspeex/stereo.c | |||
@@ -45,7 +45,7 @@ typedef struct RealSpeexStereoState { | |||
45 | spx_word32_t e_ratio; /**< Ratio of energies: E(left+right)/[E(left)+E(right)] */ | 45 | spx_word32_t e_ratio; /**< Ratio of energies: E(left+right)/[E(left)+E(right)] */ |
46 | spx_word32_t smooth_left; /**< Smoothed left channel gain */ | 46 | spx_word32_t smooth_left; /**< Smoothed left channel gain */ |
47 | spx_word32_t smooth_right; /**< Smoothed right channel gain */ | 47 | spx_word32_t smooth_right; /**< Smoothed right channel gain */ |
48 | spx_int32_t reserved1; /**< Reserved for future use */ | 48 | spx_uint32_t reserved1; /**< Reserved for future use */ |
49 | spx_int32_t reserved2; /**< Reserved for future use */ | 49 | spx_int32_t reserved2; /**< Reserved for future use */ |
50 | } RealSpeexStereoState; | 50 | } RealSpeexStereoState; |
51 | 51 | ||
@@ -53,15 +53,17 @@ typedef struct RealSpeexStereoState { | |||
53 | /*float e_ratio_quant[4] = {1, 1.26, 1.587, 2};*/ | 53 | /*float e_ratio_quant[4] = {1, 1.26, 1.587, 2};*/ |
54 | #ifndef FIXED_POINT | 54 | #ifndef FIXED_POINT |
55 | static const float e_ratio_quant[4] = {.25f, .315f, .397f, .5f}; | 55 | static const float e_ratio_quant[4] = {.25f, .315f, .397f, .5f}; |
56 | static const float e_ratio_quant_bounds[3] = {0.2825f, 0.356f, 0.4485f}; | ||
56 | #else | 57 | #else |
57 | static const spx_word16_t e_ratio_quant[4] = {8192, 10332, 13009, 16384}; | 58 | static const spx_word16_t e_ratio_quant[4] = {8192, 10332, 13009, 16384}; |
59 | static const spx_word16_t e_ratio_quant_bounds[3] = {9257, 11665, 14696}; | ||
58 | #endif | 60 | #endif |
59 | 61 | ||
60 | /* This is an ugly compatibility hack that properly resets the stereo state | 62 | /* This is an ugly compatibility hack that properly resets the stereo state |
61 | In case it it compiled in fixed-point, but initialised with the deprecated | 63 | In case it it compiled in fixed-point, but initialised with the deprecated |
62 | floating point static initialiser */ | 64 | floating point static initialiser */ |
63 | #ifdef FIXED_POINT | 65 | #ifdef FIXED_POINT |
64 | #define COMPATIBILITY_HACK(s) do {if ((s)->reserved1 != 0xdeadbeef) speex_stereo_state_init(s); } while (0); | 66 | #define COMPATIBILITY_HACK(s) do {if ((s)->reserved1 != 0xdeadbeef) speex_stereo_state_reset((SpeexStereoState*)s); } while (0); |
65 | #else | 67 | #else |
66 | #define COMPATIBILITY_HACK(s) | 68 | #define COMPATIBILITY_HACK(s) |
67 | #endif | 69 | #endif |
@@ -134,8 +136,8 @@ void speex_encode_stereo(float *data, int frame_size, SpeexBits *bits) | |||
134 | 136 | ||
135 | speex_bits_pack(bits, (int)balance, 5); | 137 | speex_bits_pack(bits, (int)balance, 5); |
136 | 138 | ||
137 | /* FIXME: Convert properly */ | 139 | /* FIXME: this is a hack */ |
138 | tmp=vq_index(&e_ratio, e_ratio_quant, 1, 4); | 140 | tmp=scal_quant(e_ratio*Q15_ONE, e_ratio_quant_bounds, 3); |
139 | speex_bits_pack(bits, tmp, 2); | 141 | speex_bits_pack(bits, tmp, 2); |
140 | } | 142 | } |
141 | 143 | ||
@@ -171,8 +173,8 @@ void speex_encode_stereo_int(spx_int16_t *data, int frame_size, SpeexBits *bits) | |||
171 | 173 | ||
172 | speex_bits_pack(bits, (int)balance, 5); | 174 | speex_bits_pack(bits, (int)balance, 5); |
173 | 175 | ||
174 | /* FIXME: Convert properly */ | 176 | /* FIXME: this is a hack */ |
175 | tmp=vq_index(&e_ratio, e_ratio_quant, 1, 4); | 177 | tmp=scal_quant(e_ratio*Q15_ONE, e_ratio_quant_bounds, 3); |
176 | speex_bits_pack(bits, tmp, 2); | 178 | speex_bits_pack(bits, tmp, 2); |
177 | } | 179 | } |
178 | #endif /* SPEEX_DISABLE_ENCODER */ | 180 | #endif /* SPEEX_DISABLE_ENCODER */ |