Skip to content

Commit

Permalink
lpc floor converted to fixed-point
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.xiph.org/trunk/speex@10143 0101bb08-14d6-0310-b084-bc0e0c8e3800
  • Loading branch information
jmvalin committed Oct 10, 2005
1 parent ef32f09 commit afaa98a
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 11 deletions.
3 changes: 3 additions & 0 deletions libspeex/arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ typedef float spx_word64_t;
#define VERY_LARGE32 1e15f
#define VERY_LARGE16 1e15f

#define QCONST16(x,bits) (x)
#define QCONST32(x,bits) (x)

#define NEG16(x) (-(x))
#define NEG32(x) (-(x))
#define EXTRACT16(x) (x)
Expand Down
3 changes: 3 additions & 0 deletions libspeex/fixed_generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
#ifndef FIXED_GENERIC_H
#define FIXED_GENERIC_H

#define QCONST16(x,bits) ((spx_word16_t)((x)*(1<<(bits))+(1<<((bits)-1))))
#define QCONST32(x,bits) ((spx_word32_t)((x)*(1<<(bits))+(1<<((bits)-1))))

#define NEG16(x) (-(x))
#define NEG32(x) (-(x))
#define EXTRACT16(x) ((spx_word16_t)x)
Expand Down
8 changes: 4 additions & 4 deletions libspeex/modes.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ static const SpeexNBMode nb_mode = {
0.9, 0.6, /* gamma1, gamma2 */
#endif
.012, /*lag_factor*/
.0002, /*lpc_floor*/
QCONST16(.0002,15), /*lpc_floor*/
#ifdef EPIC_48K
0,
#endif
Expand Down Expand Up @@ -543,7 +543,7 @@ static const SpeexSBMode sb_wb_mode = {
0.9, 0.6, /* gamma1, gamma2 */
#endif
.001, /*lag_factor*/
.0001, /*lpc_floor*/
QCONST16(.0001,15), /*lpc_floor*/
0.9,
{NULL, &wb_submode1, &wb_submode2, &wb_submode3, &wb_submode4, NULL, NULL, NULL},
3,
Expand Down Expand Up @@ -589,7 +589,7 @@ static const SpeexSBMode sb_uwb_mode = {
0.9, 0.6, /* gamma1, gamma2 */
#endif
.002, /*lag_factor*/
.0001, /*lpc_floor*/
QCONST16(.0001,15), /*lpc_floor*/
0.7,
{NULL, &wb_submode1, NULL, NULL, NULL, NULL, NULL, NULL},
1,
Expand Down Expand Up @@ -677,7 +677,7 @@ static const SpeexNBMode nb_48k_mode = {
0.9, /*gamma1*/
0.6, /*gamma2*/
.01, /*lag_factor*/
.0003, /*lpc_floor*/
QCONST16(.0003,15), /*lpc_floor*/
1,
{NULL, NULL, &nb_48k_submode, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
2,
Expand Down
4 changes: 2 additions & 2 deletions libspeex/modes.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ typedef struct SpeexNBMode {
spx_word16_t gamma1; /**< Perceptual filter parameter #1 */
spx_word16_t gamma2; /**< Perceptual filter parameter #2 */
float lag_factor; /**< Lag-windowing parameter */
float lpc_floor; /**< Noise floor for LPC analysis */
spx_word16_t lpc_floor; /**< Noise floor for LPC analysis */

#ifdef EPIC_48K
int lbr48k; /**< 1 for the special 4.8 kbps mode */
Expand All @@ -133,7 +133,7 @@ typedef struct SpeexSBMode {
spx_word16_t gamma1; /**< Perceptual filter parameter #1 */
spx_word16_t gamma2; /**< Perceptual filter parameter #1 */
float lag_factor; /**< Lag-windowing parameter */
float lpc_floor; /**< Noise floor for LPC analysis */
spx_word16_t lpc_floor; /**< Noise floor for LPC analysis */
float folding_gain;

const SpeexSubmode *submodes[SB_SUBMODES]; /**< Sub-mode data for the mode */
Expand Down
2 changes: 1 addition & 1 deletion libspeex/nb_celp.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ int nb_encode(void *state, void *vin, SpeexBits *bits)
/* Compute auto-correlation */
_spx_autocorr(w_sig, st->autocorr, st->lpcSize+1, st->windowSize);
}
st->autocorr[0] = ADD16(st->autocorr[0],(spx_word16_t) (st->autocorr[0]*st->lpc_floor)); /* Noise floor in auto-correlation domain */
st->autocorr[0] = ADD16(st->autocorr[0],MULT16_16_Q15(st->autocorr[0],st->lpc_floor)); /* Noise floor in auto-correlation domain */

/* Lag windowing: equivalent to filtering in the power-spectrum domain */
for (i=0;i<st->lpcSize+1;i++)
Expand Down
2 changes: 1 addition & 1 deletion libspeex/nb_celp.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ typedef struct EncState {
spx_word16_t gamma1; /**< Perceptual filter: A(z/gamma1) */
spx_word16_t gamma2; /**< Perceptual filter: A(z/gamma2) */
float lag_factor; /**< Lag windowing Gaussian width */
float lpc_floor; /**< Noise floor multiplier for A[0] in LPC analysis*/
spx_word16_t lpc_floor; /**< Noise floor multiplier for A[0] in LPC analysis*/
char *stack; /**< Pseudo-stack allocation for temporary memory */
spx_sig_t *inBuf; /**< Input buffer (original signal) */
spx_sig_t *frame; /**< Start of original frame */
Expand Down
3 changes: 1 addition & 2 deletions libspeex/sb_celp.c
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,7 @@ int sb_encode(void *state, void *vin, SpeexBits *bits)
/* Compute auto-correlation */
_spx_autocorr(w_sig, st->autocorr, st->lpcSize+1, st->windowSize);
}

st->autocorr[0] = ADD16(st->autocorr[0],(spx_word16_t) (st->autocorr[0]*st->lpc_floor)); /* Noise floor in auto-correlation domain */
st->autocorr[0] = ADD16(st->autocorr[0],MULT16_16_Q15(st->autocorr[0],st->lpc_floor)); /* Noise floor in auto-correlation domain */

/* Lag windowing: equivalent to filtering in the power-spectrum domain */
for (i=0;i<st->lpcSize+1;i++)
Expand Down
2 changes: 1 addition & 1 deletion libspeex/sb_celp.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ typedef struct SBEncState {
int bufSize; /**< Buffer size */
int first; /**< First frame? */
float lag_factor; /**< Lag-windowing control parameter */
float lpc_floor; /**< Controls LPC analysis noise floor */
spx_word16_t lpc_floor; /**< Controls LPC analysis noise floor */
spx_word16_t gamma1; /**< Perceptual weighting coef 1 */
spx_word16_t gamma2; /**< Perceptual weighting coef 2 */

Expand Down

0 comments on commit afaa98a

Please sign in to comment.