From 80821482006f0730ba70d3e0af63f77cb976285a Mon Sep 17 00:00:00 2001 From: Thom Johansen Date: Wed, 14 Nov 2007 12:11:13 +0000 Subject: Sync latest Speex stereo changes. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15617 a1c6a512-1295-4272-9138-f99709370657 --- apps/codecs/libspeex/stereo.c | 14 ++++++++------ apps/codecs/libspeex/vq.c | 23 ----------------------- apps/codecs/libspeex/vq.h | 1 - 3 files changed, 8 insertions(+), 30 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 { spx_word32_t e_ratio; /**< Ratio of energies: E(left+right)/[E(left)+E(right)] */ spx_word32_t smooth_left; /**< Smoothed left channel gain */ spx_word32_t smooth_right; /**< Smoothed right channel gain */ - spx_int32_t reserved1; /**< Reserved for future use */ + spx_uint32_t reserved1; /**< Reserved for future use */ spx_int32_t reserved2; /**< Reserved for future use */ } RealSpeexStereoState; @@ -53,15 +53,17 @@ typedef struct RealSpeexStereoState { /*float e_ratio_quant[4] = {1, 1.26, 1.587, 2};*/ #ifndef FIXED_POINT static const float e_ratio_quant[4] = {.25f, .315f, .397f, .5f}; +static const float e_ratio_quant_bounds[3] = {0.2825f, 0.356f, 0.4485f}; #else static const spx_word16_t e_ratio_quant[4] = {8192, 10332, 13009, 16384}; +static const spx_word16_t e_ratio_quant_bounds[3] = {9257, 11665, 14696}; #endif /* This is an ugly compatibility hack that properly resets the stereo state In case it it compiled in fixed-point, but initialised with the deprecated floating point static initialiser */ #ifdef FIXED_POINT -#define COMPATIBILITY_HACK(s) do {if ((s)->reserved1 != 0xdeadbeef) speex_stereo_state_init(s); } while (0); +#define COMPATIBILITY_HACK(s) do {if ((s)->reserved1 != 0xdeadbeef) speex_stereo_state_reset((SpeexStereoState*)s); } while (0); #else #define COMPATIBILITY_HACK(s) #endif @@ -134,8 +136,8 @@ void speex_encode_stereo(float *data, int frame_size, SpeexBits *bits) speex_bits_pack(bits, (int)balance, 5); - /* FIXME: Convert properly */ - tmp=vq_index(&e_ratio, e_ratio_quant, 1, 4); + /* FIXME: this is a hack */ + tmp=scal_quant(e_ratio*Q15_ONE, e_ratio_quant_bounds, 3); speex_bits_pack(bits, tmp, 2); } @@ -171,8 +173,8 @@ void speex_encode_stereo_int(spx_int16_t *data, int frame_size, SpeexBits *bits) speex_bits_pack(bits, (int)balance, 5); - /* FIXME: Convert properly */ - tmp=vq_index(&e_ratio, e_ratio_quant, 1, 4); + /* FIXME: this is a hack */ + tmp=scal_quant(e_ratio*Q15_ONE, e_ratio_quant_bounds, 3); speex_bits_pack(bits, tmp, 2); } #endif /* SPEEX_DISABLE_ENCODER */ diff --git a/apps/codecs/libspeex/vq.c b/apps/codecs/libspeex/vq.c index 1c66b32b16..fff470a588 100644 --- a/apps/codecs/libspeex/vq.c +++ b/apps/codecs/libspeex/vq.c @@ -70,29 +70,6 @@ int scal_quant32(spx_word32_t in, const spx_word32_t *boundary, int entries) return i; } -/*Finds the index of the entry in a codebook that best matches the input*/ -int vq_index(float *in, const float *codebook, int len, int entries) -{ - int i,j; - float min_dist=0; - int best_index=0; - for (i=0;i void vq_nbest(spx_word16_t *in, const __m128 *codebook, int len, int entries, __m128 *E, int N, int *nbest, spx_word32_t *best_dist, char *stack); -- cgit v1.2.3