diff options
Diffstat (limited to 'apps/codecs/libspeex/nb_celp.c')
-rw-r--r-- | apps/codecs/libspeex/nb_celp.c | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/apps/codecs/libspeex/nb_celp.c b/apps/codecs/libspeex/nb_celp.c index 7dc4920ede..49e2403d8b 100644 --- a/apps/codecs/libspeex/nb_celp.c +++ b/apps/codecs/libspeex/nb_celp.c | |||
@@ -45,7 +45,7 @@ | |||
45 | #include "vq.h" | 45 | #include "vq.h" |
46 | #include <speex/speex_bits.h> | 46 | #include <speex/speex_bits.h> |
47 | #include "vbr.h" | 47 | #include "vbr.h" |
48 | #include "misc.h" | 48 | #include "arch.h" |
49 | #include "math_approx.h" | 49 | #include "math_approx.h" |
50 | #include "os_support.h" | 50 | #include "os_support.h" |
51 | #include <speex/speex_callbacks.h> | 51 | #include <speex/speex_callbacks.h> |
@@ -108,6 +108,7 @@ const float exc_gain_quant_scal1[2]={0.70469f, 1.05127f}; | |||
108 | 108 | ||
109 | #define sqr(x) ((x)*(x)) | 109 | #define sqr(x) ((x)*(x)) |
110 | 110 | ||
111 | extern const spx_word16_t lag_window[]; | ||
111 | extern const spx_word16_t lpc_window[]; | 112 | extern const spx_word16_t lpc_window[]; |
112 | #ifndef SPEEX_DISABLE_ENCODER | 113 | #ifndef SPEEX_DISABLE_ENCODER |
113 | void *nb_encoder_init(const SpeexMode *m) | 114 | void *nb_encoder_init(const SpeexMode *m) |
@@ -137,7 +138,6 @@ void *nb_encoder_init(const SpeexMode *m) | |||
137 | st->gamma2=mode->gamma2; | 138 | st->gamma2=mode->gamma2; |
138 | st->min_pitch=mode->pitchStart; | 139 | st->min_pitch=mode->pitchStart; |
139 | st->max_pitch=mode->pitchEnd; | 140 | st->max_pitch=mode->pitchEnd; |
140 | st->lag_factor=mode->lag_factor; | ||
141 | st->lpc_floor = mode->lpc_floor; | 141 | st->lpc_floor = mode->lpc_floor; |
142 | 142 | ||
143 | st->submodes=mode->submodes; | 143 | st->submodes=mode->submodes; |
@@ -166,17 +166,13 @@ void *nb_encoder_init(const SpeexMode *m) | |||
166 | st->window= lpc_window; | 166 | st->window= lpc_window; |
167 | 167 | ||
168 | /* Create the window for autocorrelation (lag-windowing) */ | 168 | /* Create the window for autocorrelation (lag-windowing) */ |
169 | st->lagWindow = (spx_word16_t*)speex_alloc((st->lpcSize+1)*sizeof(spx_word16_t)); | 169 | st->lagWindow = lag_window; |
170 | for (i=0;i<st->lpcSize+1;i++) | ||
171 | st->lagWindow[i]=16384*exp(-.5*sqr(2*M_PI*st->lag_factor*i)); | ||
172 | 170 | ||
173 | st->old_lsp = (spx_lsp_t*)speex_alloc((st->lpcSize)*sizeof(spx_lsp_t)); | 171 | st->old_lsp = (spx_lsp_t*)speex_alloc((st->lpcSize)*sizeof(spx_lsp_t)); |
174 | st->old_qlsp = (spx_lsp_t*)speex_alloc((st->lpcSize)*sizeof(spx_lsp_t)); | 172 | st->old_qlsp = (spx_lsp_t*)speex_alloc((st->lpcSize)*sizeof(spx_lsp_t)); |
175 | st->first = 1; | 173 | st->first = 1; |
176 | for (i=0;i<st->lpcSize;i++) | 174 | for (i=0;i<st->lpcSize;i++) |
177 | { | 175 | st->old_lsp[i]= DIV32(MULT16_16(QCONST16(3.1415927f, LSP_SHIFT), i+1), st->lpcSize+1); |
178 | st->old_lsp[i]=LSP_SCALING*(M_PI*((float)(i+1)))/(st->lpcSize+1); | ||
179 | } | ||
180 | 176 | ||
181 | st->mem_sp = (spx_mem_t*)speex_alloc((st->lpcSize)*sizeof(spx_mem_t)); | 177 | st->mem_sp = (spx_mem_t*)speex_alloc((st->lpcSize)*sizeof(spx_mem_t)); |
182 | st->mem_sw = (spx_mem_t*)speex_alloc((st->lpcSize)*sizeof(spx_mem_t)); | 178 | st->mem_sw = (spx_mem_t*)speex_alloc((st->lpcSize)*sizeof(spx_mem_t)); |
@@ -225,8 +221,6 @@ void nb_encoder_destroy(void *state) | |||
225 | speex_free (st->old_qlsp); | 221 | speex_free (st->old_qlsp); |
226 | speex_free (st->swBuf); | 222 | speex_free (st->swBuf); |
227 | 223 | ||
228 | speex_free (st->lagWindow); | ||
229 | |||
230 | speex_free (st->old_lsp); | 224 | speex_free (st->old_lsp); |
231 | speex_free (st->mem_sp); | 225 | speex_free (st->mem_sp); |
232 | speex_free (st->mem_sw); | 226 | speex_free (st->mem_sw); |
@@ -274,7 +268,7 @@ int nb_encode(void *state, void *vin, SpeexBits *bits) | |||
274 | char *stack; | 268 | char *stack; |
275 | VARDECL(spx_word16_t *syn_resp); | 269 | VARDECL(spx_word16_t *syn_resp); |
276 | VARDECL(spx_word16_t *real_exc); | 270 | VARDECL(spx_word16_t *real_exc); |
277 | 271 | ||
278 | spx_word32_t ener=0; | 272 | spx_word32_t ener=0; |
279 | spx_word16_t fine_gain; | 273 | spx_word16_t fine_gain; |
280 | spx_word16_t *in = (spx_word16_t*)vin; | 274 | spx_word16_t *in = (spx_word16_t*)vin; |
@@ -591,6 +585,8 @@ int nb_encode(void *state, void *vin, SpeexBits *bits) | |||
591 | if (SUBMODE(forced_pitch_gain)) | 585 | if (SUBMODE(forced_pitch_gain)) |
592 | { | 586 | { |
593 | int quant; | 587 | int quant; |
588 | /* This just damps the pitch a bit, because it tends to be too aggressive when forced */ | ||
589 | ol_pitch_coef = MULT16_16_Q15(QCONST16(.9,15), ol_pitch_coef); | ||
594 | #ifdef FIXED_POINT | 590 | #ifdef FIXED_POINT |
595 | quant = PSHR16(MULT16_16_16(15, ol_pitch_coef),GAIN_SHIFT); | 591 | quant = PSHR16(MULT16_16_16(15, ol_pitch_coef),GAIN_SHIFT); |
596 | #else | 592 | #else |
@@ -1120,7 +1116,7 @@ int nb_decode(void *state, SpeexBits *bits, void *vout) | |||
1120 | VARDECL(spx_coef_t *ak); | 1116 | VARDECL(spx_coef_t *ak); |
1121 | VARDECL(spx_lsp_t *qlsp); | 1117 | VARDECL(spx_lsp_t *qlsp); |
1122 | spx_word16_t pitch_average=0; | 1118 | spx_word16_t pitch_average=0; |
1123 | 1119 | ||
1124 | spx_word16_t *out = (spx_word16_t*)vout; | 1120 | spx_word16_t *out = (spx_word16_t*)vout; |
1125 | VARDECL(spx_lsp_t *interp_qlsp); | 1121 | VARDECL(spx_lsp_t *interp_qlsp); |
1126 | 1122 | ||
@@ -1724,7 +1720,7 @@ int nb_encoder_ctl(void *state, int request, void *ptr) | |||
1724 | st->bounded_pitch = 1; | 1720 | st->bounded_pitch = 1; |
1725 | st->first = 1; | 1721 | st->first = 1; |
1726 | for (i=0;i<st->lpcSize;i++) | 1722 | for (i=0;i<st->lpcSize;i++) |
1727 | st->old_lsp[i]=(M_PI*((float)(i+1)))/(st->lpcSize+1); | 1723 | st->old_lsp[i]= DIV32(MULT16_16(QCONST16(3.1415927f, LSP_SHIFT), i+1), st->lpcSize+1); |
1728 | for (i=0;i<st->lpcSize;i++) | 1724 | for (i=0;i<st->lpcSize;i++) |
1729 | st->mem_sw[i]=st->mem_sw_whole[i]=st->mem_sp[i]=st->mem_exc[i]=0; | 1725 | st->mem_sw[i]=st->mem_sw_whole[i]=st->mem_sp[i]=st->mem_exc[i]=0; |
1730 | for (i=0;i<st->frameSize+st->max_pitch+1;i++) | 1726 | for (i=0;i<st->frameSize+st->max_pitch+1;i++) |