diff options
author | jm <jm@0101bb08-14d6-0310-b084-bc0e0c8e3800> | 2003-11-10 09:56:53 +0300 |
---|---|---|
committer | jm <jm@0101bb08-14d6-0310-b084-bc0e0c8e3800> | 2003-11-10 09:56:53 +0300 |
commit | 77ba6ed5fd4d3c1455ec1b399fa52e97b7094b5b (patch) | |
tree | e978f14a56190c1522b61e8de00a4268a5475933 /libspeex | |
parent | ebcdcd46ccee18e0aa2d95eaa2fb6af58e162869 (diff) |
fixed-point: integerized lsp interpolation
git-svn-id: http://svn.xiph.org/trunk/speex@5547 0101bb08-14d6-0310-b084-bc0e0c8e3800
Diffstat (limited to 'libspeex')
-rw-r--r-- | libspeex/lsp.c | 28 | ||||
-rw-r--r-- | libspeex/lsp.h | 2 | ||||
-rw-r--r-- | libspeex/nb_celp.c | 11 |
3 files changed, 33 insertions, 8 deletions
diff --git a/libspeex/lsp.c b/libspeex/lsp.c index 0bfb0b4..a909efd 100644 --- a/libspeex/lsp.c +++ b/libspeex/lsp.c @@ -524,3 +524,31 @@ void lsp_enforce_margin(spx_lsp_t *lsp, int len, float margin) lsp[i]= .5* (lsp[i] + lsp[i+1]-LSP_SCALING*margin); } } + +#ifdef FIXED_POINT + + +void lsp_interpolate(spx_lsp_t *old_lsp, spx_lsp_t *new_lsp, spx_lsp_t *interp_lsp, int len, int subframe, int nb_subframes) +{ + int i; + spx_word16_t tmp = DIV32_16(SHL(1 + subframe,14),nb_subframes); + spx_word16_t tmp2 = 16384-tmp; + for (i=0;i<len;i++) + { + interp_lsp[i] = MULT16_16_P14(tmp2,old_lsp[i]) + MULT16_16_P14(tmp,new_lsp[i]); + } +} + +#else + +void lsp_interpolate(spx_lsp_t *old_lsp, spx_lsp_t *new_lsp, spx_lsp_t *interp_lsp, int len, int subframe, int nb_subframes) +{ + int i; + float tmp = (1.0 + subframe)/nb_subframes; + for (i=0;i<len;i++) + { + interp_lsp[i] = (1-tmp)*old_lsp[i] + tmp*new_lsp[i]; + } +} + +#endif diff --git a/libspeex/lsp.h b/libspeex/lsp.h index cfb4d7a..d23396f 100644 --- a/libspeex/lsp.h +++ b/libspeex/lsp.h @@ -55,4 +55,6 @@ void lsp_to_lpc(spx_lsp_t *freq, spx_coef_t *ak, int lpcrdr, char *stack); /*Added by JMV*/
void lsp_enforce_margin(spx_lsp_t *lsp, int len, float margin);
+void lsp_interpolate(spx_lsp_t *old_lsp, spx_lsp_t *new_lsp, spx_lsp_t *interp_lsp, int len, int subframe, int nb_subframes);
+
#endif /* __AK2LSPD__ */
diff --git a/libspeex/nb_celp.c b/libspeex/nb_celp.c index 67e04eb..b666f91 100644 --- a/libspeex/nb_celp.c +++ b/libspeex/nb_celp.c @@ -622,11 +622,8 @@ int nb_encode(void *state, short *in, SpeexBits *bits) /* LSP interpolation (quantized and unquantized) */ - tmp = (1.0 + sub)/st->nbSubframes; - for (i=0;i<st->lpcSize;i++) - st->interp_lsp[i] = (1-tmp)*st->old_lsp[i] + tmp*st->lsp[i]; - for (i=0;i<st->lpcSize;i++) - st->interp_qlsp[i] = (1-tmp)*st->old_qlsp[i] + tmp*st->qlsp[i]; + lsp_interpolate(st->old_lsp, st->lsp, st->interp_lsp, st->lpcSize, sub, st->nbSubframes); + lsp_interpolate(st->old_qlsp, st->qlsp, st->interp_qlsp, st->lpcSize, sub, st->nbSubframes); /* Make sure the filters are stable */ lsp_enforce_margin(st->interp_lsp, st->lpcSize, .002); @@ -1369,9 +1366,7 @@ int nb_decode(void *state, SpeexBits *bits, short *out) /* Excitation after post-filter*/ /* LSP interpolation (quantized and unquantized) */ - tmp = (1.0 + sub)/st->nbSubframes; - for (i=0;i<st->lpcSize;i++) - st->interp_qlsp[i] = (1-tmp)*st->old_qlsp[i] + tmp*st->qlsp[i]; + lsp_interpolate(st->old_qlsp, st->qlsp, st->interp_qlsp, st->lpcSize, sub, st->nbSubframes); /* Make sure the LSP's are stable */ lsp_enforce_margin(st->interp_qlsp, st->lpcSize, .002); |