Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mumble-voip/speexdsp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libspeex/lsp.c28
-rw-r--r--libspeex/lsp.h2
-rw-r--r--libspeex/nb_celp.c11
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);