diff options
author | jm <jm@0101bb08-14d6-0310-b084-bc0e0c8e3800> | 2003-11-27 08:00:05 +0300 |
---|---|---|
committer | jm <jm@0101bb08-14d6-0310-b084-bc0e0c8e3800> | 2003-11-27 08:00:05 +0300 |
commit | 99b852464f4de1d148ae6401502b7c0eb56ada8c (patch) | |
tree | 5439649a1b21b3f524fe5bb775984245afe25125 | |
parent | 5800dfec6f035101ba64a9407d02638d680849e5 (diff) |
fixed-point: lsp_enforce_margin argument no longer a float
git-svn-id: http://svn.xiph.org/trunk/speex@5636 0101bb08-14d6-0310-b084-bc0e0c8e3800
-rw-r--r-- | libspeex/lsp.c | 8 | ||||
-rw-r--r-- | libspeex/lsp.h | 2 | ||||
-rw-r--r-- | libspeex/nb_celp.c | 31 | ||||
-rw-r--r-- | libspeex/sb_celp.c | 12 |
4 files changed, 32 insertions, 21 deletions
diff --git a/libspeex/lsp.c b/libspeex/lsp.c index aad4d84..4cf14ec 100644 --- a/libspeex/lsp.c +++ b/libspeex/lsp.c @@ -515,11 +515,11 @@ void lsp_to_lpc(spx_lsp_t *freq,spx_coef_t *ak,int lpcrdr, char *stack) #ifdef FIXED_POINT /*Makes sure the LSPs are stable*/ -void lsp_enforce_margin(spx_lsp_t *lsp, int len, float margin) +void lsp_enforce_margin(spx_lsp_t *lsp, int len, spx_word16_t margin) { int i; - spx_word16_t m = LSP_SCALING*margin; - spx_word16_t m2 = (LSP_SCALING*M_PI)-LSP_SCALING*margin; + spx_word16_t m = margin; + spx_word16_t m2 = 25736-margin; if (lsp[0]<m) lsp[0]=m; @@ -550,7 +550,7 @@ void lsp_interpolate(spx_lsp_t *old_lsp, spx_lsp_t *new_lsp, spx_lsp_t *interp_l #else /*Makes sure the LSPs are stable*/ -void lsp_enforce_margin(spx_lsp_t *lsp, int len, float margin) +void lsp_enforce_margin(spx_lsp_t *lsp, int len, spx_word16_t margin) { int i; if (lsp[0]<LSP_SCALING*margin) diff --git a/libspeex/lsp.h b/libspeex/lsp.h index d23396f..d563c9c 100644 --- a/libspeex/lsp.h +++ b/libspeex/lsp.h @@ -53,7 +53,7 @@ int lpc_to_lsp (spx_coef_t *a, int lpcrdr, spx_lsp_t *freq, int nb, float delta, 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_enforce_margin(spx_lsp_t *lsp, int len, spx_word16_t 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);
diff --git a/libspeex/nb_celp.c b/libspeex/nb_celp.c index 896eaff..413e560 100644 --- a/libspeex/nb_celp.c +++ b/libspeex/nb_celp.c @@ -56,27 +56,32 @@ #define SUBMODE(x) st->submodes[st->submodeID]->x -#ifdef FIXED_POINT -spx_word32_t ol_gain_table[32]={18900, 25150, 33468, 44536, 59265, 78865, 104946, 139653, 185838, 247297, 329081, 437913, 582736, 775454, 1031906, 1373169, 1827293, 2431601, 3235761, 4305867, 5729870, 7624808, 10146425, 13501971, 17967238, 23909222, 31816294, 42338330, 56340132, 74972501, 99766822, 132760927}; -#endif #ifdef FIXED_POINT +spx_word32_t ol_gain_table[32]={18900, 25150, 33468, 44536, 59265, 78865, 104946, 139653, 185838, 247297, 329081, 437913, 582736, 775454, 1031906, 1373169, 1827293, 2431601, 3235761, 4305867, 5729870, 7624808, 10146425, 13501971, 17967238, 23909222, 31816294, 42338330, 56340132, 74972501, 99766822, 132760927}; spx_word16_t exc_gain_quant_scal3_bound[7]={1841, 3883, 6051, 8062, 10444, 13580, 18560}; spx_word16_t exc_gain_quant_scal3[8]={1002, 2680, 5086, 7016, 9108, 11781, 15380, 21740}; -#else -float exc_gain_quant_scal3_bound[7]={0.112338, 0.236980, 0.369316, 0.492054, 0.637471, 0.828874, 1.132784}; -float exc_gain_quant_scal3[8]={0.061130, 0.163546, 0.310413, 0.428220, 0.555887, 0.719055, 0.938694, 1.326874}; -#endif - -#ifdef FIXED_POINT spx_word16_t exc_gain_quant_scal1_bound[1]={14385}; spx_word16_t exc_gain_quant_scal1[2]={11546, 17224}; + +#define LSP_MARGIN 16 +#define LSP_DELTA + #else + +float exc_gain_quant_scal3_bound[7]={0.112338, 0.236980, 0.369316, 0.492054, 0.637471, 0.828874, 1.132784}; +float exc_gain_quant_scal3[8]={0.061130, 0.163546, 0.310413, 0.428220, 0.555887, 0.719055, 0.938694, 1.326874}; float exc_gain_quant_scal1_bound[1]={0.87798}; float exc_gain_quant_scal1[2]={0.70469, 1.05127}; + +#define LSP_MARGIN .002 +#define LSP_DELTA + #endif + + #define sqr(x) ((x)*(x)) void *nb_encoder_init(SpeexMode *m) @@ -284,7 +289,7 @@ int nb_encode(void *state, short *in, SpeexBits *bits) else lsp_interpolate(st->old_lsp, st->lsp, st->interp_lsp, st->lpcSize, st->nbSubframes, st->nbSubframes<<1); - lsp_enforce_margin(st->interp_lsp, st->lpcSize, .002); + lsp_enforce_margin(st->interp_lsp, st->lpcSize, LSP_MARGIN); /* Compute interpolated LPCs (unquantized) for whole frame*/ lsp_to_lpc(st->interp_lsp, st->interp_lpc, st->lpcSize,stack); @@ -657,8 +662,8 @@ int nb_encode(void *state, short *in, SpeexBits *bits) 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); - lsp_enforce_margin(st->interp_qlsp, st->lpcSize, .002); + lsp_enforce_margin(st->interp_lsp, st->lpcSize, LSP_MARGIN); + lsp_enforce_margin(st->interp_qlsp, st->lpcSize, LSP_MARGIN); /* Compute interpolated LPCs (quantized and unquantized) */ lsp_to_lpc(st->interp_lsp, st->interp_lpc, st->lpcSize,stack); @@ -1402,7 +1407,7 @@ int nb_decode(void *state, SpeexBits *bits, short *out) 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); + lsp_enforce_margin(st->interp_qlsp, st->lpcSize, LSP_MARGIN); /* Compute interpolated LPCs (unquantized) */ diff --git a/libspeex/sb_celp.c b/libspeex/sb_celp.c index 083662c..6e146f2 100644 --- a/libspeex/sb_celp.c +++ b/libspeex/sb_celp.c @@ -55,6 +55,12 @@ #ifdef FIXED_POINT spx_word16_t gc_quant_bound[16] = {125, 164, 215, 282, 370, 484, 635, 832, 1090, 1428, 1871, 2452, 3213, 4210, 5516, 7228}; +#define LSP_MARGIN 410 + +#else + +#define LSP_MARGIN .05 + #endif #define QMF_ORDER 64 @@ -509,8 +515,8 @@ int sb_encode(void *state, short *in, SpeexBits *bits) 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); - lsp_enforce_margin(st->interp_lsp, st->lpcSize, .05); - lsp_enforce_margin(st->interp_qlsp, st->lpcSize, .05); + lsp_enforce_margin(st->interp_lsp, st->lpcSize, LSP_MARGIN); + lsp_enforce_margin(st->interp_qlsp, st->lpcSize, LSP_MARGIN); lsp_to_lpc(st->interp_lsp, st->interp_lpc, st->lpcSize,stack); lsp_to_lpc(st->interp_qlsp, st->interp_qlpc, st->lpcSize, stack); @@ -978,7 +984,7 @@ int sb_decode(void *state, SpeexBits *bits, short *out) /* LSP interpolation */ lsp_interpolate(st->old_qlsp, st->qlsp, st->interp_qlsp, st->lpcSize, sub, st->nbSubframes); - lsp_enforce_margin(st->interp_qlsp, st->lpcSize, .05); + lsp_enforce_margin(st->interp_qlsp, st->lpcSize, LSP_MARGIN); /* LSP to LPC */ lsp_to_lpc(st->interp_qlsp, st->interp_qlpc, st->lpcSize, stack); |