1
0
Fork 0
forked from len0rd/rockbox

Sync latest Speex stereo changes.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15617 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Thom Johansen 2007-11-14 12:11:13 +00:00
parent 017e148655
commit 8082148200
3 changed files with 8 additions and 30 deletions

View file

@ -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 */

View file

@ -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<entries;i++)
{
float dist=0;
for (j=0;j<len;j++)
{
float tmp = in[j]-*codebook++;
dist += tmp*tmp;
}
if (i==0 || dist<min_dist)
{
min_dist=dist;
best_index=i;
}
}
return best_index;
}
#ifndef OVERRIDE_VQ_NBEST
/*Finds the indices of the n-best entries in a codebook*/

View file

@ -40,7 +40,6 @@
int scal_quant(spx_word16_t in, const spx_word16_t *boundary, int entries);
int scal_quant32(spx_word32_t in, const spx_word32_t *boundary, int entries);
int vq_index(float *in, const float *codebook, int len, int entries);
#ifdef _USE_SSE
#include <xmmintrin.h>
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);