diff options
author | Jean-Marc Valin <jean-marc.valin@octasic.com> | 2009-04-03 19:52:04 +0400 |
---|---|---|
committer | Jean-Marc Valin <jean-marc.valin@octasic.com> | 2009-04-03 19:52:04 +0400 |
commit | b9534638a51b37dd2aaf592ffa45deff307a9f9f (patch) | |
tree | 80ac32ed604cda0c6c8d46e9959ae2705419b7e8 /libspeex | |
parent | 57ec3153b17b1c54cbaa8f06a364e45e73efdc2d (diff) |
VBR tuning (along with open-loop gamma2 tweak)
Diffstat (limited to 'libspeex')
-rw-r--r-- | libspeex/nb_celp.c | 4 | ||||
-rw-r--r-- | libspeex/vbr.c | 19 | ||||
-rw-r--r-- | libspeex/vbr.h | 1 |
3 files changed, 11 insertions, 13 deletions
diff --git a/libspeex/nb_celp.c b/libspeex/nb_celp.c index 6ee112d..ab2511d 100644 --- a/libspeex/nb_celp.c +++ b/libspeex/nb_celp.c @@ -517,8 +517,8 @@ int nb_encode(void *state, void *vin, SpeexBits *bits) int nol_pitch[6]; spx_word16_t nol_pitch_coef[6]; - bw_lpc(st->gamma1, interp_lpc, bw_lpc1, NB_ORDER); - bw_lpc(st->gamma2, interp_lpc, bw_lpc2, NB_ORDER); + bw_lpc(0.9, interp_lpc, bw_lpc1, NB_ORDER); + bw_lpc(0.55, interp_lpc, bw_lpc2, NB_ORDER); SPEEX_COPY(st->sw, st->winBuf, diff); SPEEX_COPY(st->sw+diff, in, NB_FRAME_SIZE-diff); diff --git a/libspeex/vbr.c b/libspeex/vbr.c index 5b7dd9b..73f4ad7 100644 --- a/libspeex/vbr.c +++ b/libspeex/vbr.c @@ -53,9 +53,9 @@ const float vbr_nb_thresh[9][11]={ {10.0f, 6.5f, 5.2f, 4.5f, 3.9f, 3.5f, 3.0f, 2.5f, 2.3f, 1.8f, 1.0f}, /* 6 kbps */ {11.0f, 8.8f, 7.5f, 6.5f, 5.0f, 3.9f, 3.9f, 3.9f, 3.5f, 3.0f, 1.0f}, /* 8 kbps */ {11.0f, 11.0f, 9.9f, 8.5f, 7.0f, 6.0f, 4.5f, 4.0f, 4.0f, 4.0f, 2.0f}, /* 11 kbps */ - {11.0f, 11.0f, 11.0f, 11.0f, 9.5f, 8.5f, 8.0f, 7.0f, 6.0f, 5.0f, 3.0f}, /* 15 kbps */ - {11.0f, 11.0f, 11.0f, 11.0f, 11.0f, 11.0f, 9.5f, 8.5f, 7.0f, 6.0f, 5.0f}, /* 18 kbps */ - {11.0f, 11.0f, 11.0f, 11.0f, 11.0f, 11.0f, 11.0f, 11.0f, 9.8f, 9.5f, 7.5f}, /* 24 kbps */ + {11.0f, 11.0f, 11.0f, 11.0f, 9.5f, 8.5f, 8.0f, 7.0f, 5.0f, 4.0f, 3.0f}, /* 15 kbps */ + {11.0f, 11.0f, 11.0f, 11.0f, 11.0f, 11.0f, 9.5f, 8.5f, 6.2f, 5.2f, 5.0f}, /* 18 kbps */ + {11.0f, 11.0f, 11.0f, 11.0f, 11.0f, 11.0f, 11.0f, 11.0f, 10.0f, 9.8f, 7.5f}, /* 24 kbps */ { 7.0f, 4.5f, 3.7f, 3.0f, 2.5f, 2.0f, 1.8f, 1.5f, 1.0f, 0.0f, 0.0f} /* 4 kbps */ }; @@ -77,10 +77,9 @@ void vbr_init(VBRState *vbr) { int i; - vbr->average_energy=0; + vbr->average_energy=1600000; vbr->last_energy=1; vbr->accum_sum=0; - vbr->energy_alpha=.1; vbr->soft_pitch=0; vbr->last_pitch_coef=0; vbr->last_quality=0; @@ -147,7 +146,7 @@ float vbr_analysis(VBRState *vbr, spx_word16_t *sig, int len, int pitch, float p non_st=1; voicing = 3*(pitch_coef-.4)*fabs(pitch_coef-.4); - vbr->average_energy = (1-vbr->energy_alpha)*vbr->average_energy + vbr->energy_alpha*ener; + vbr->average_energy = 0.9*vbr->average_energy + .1*ener; vbr->noise_level=vbr->noise_accum/vbr->noise_accum_count; pow_ener = pow(ener,NOISE_POW); if (vbr->noise_accum_count<.06 && ener>MIN_ENERGY) @@ -208,14 +207,14 @@ float vbr_analysis(VBRState *vbr, spx_word16_t *sig, int len, int pitch, float p { if (short_diff>5) short_diff=5; - qual += .5*short_diff; + qual += 1*short_diff; } /* Checking for energy increases */ if (ener2 > 1.6*ener1) qual += .5; } vbr->last_energy = ener; - vbr->soft_pitch = .6*vbr->soft_pitch + .4*pitch_coef; + vbr->soft_pitch = .8*vbr->soft_pitch + .2*pitch_coef; qual += 2.2*((pitch_coef-.4) + (vbr->soft_pitch-.4)); if (qual < vbr->last_quality) @@ -241,7 +240,7 @@ float vbr_analysis(VBRState *vbr, spx_word16_t *sig, int len, int pitch, float p if (qual<0) qual=0; - if (ener<60000) + if (ener<1600000) { if (vbr->consec_noise>2) qual-=0.5*(log(3.0 + vbr->consec_noise)-log(3)); @@ -249,7 +248,7 @@ float vbr_analysis(VBRState *vbr, spx_word16_t *sig, int len, int pitch, float p qual-=0.5*(log(3.0 + vbr->consec_noise)-log(3)); if (qual<0) qual=0; - qual += .3*log(.0001+ener/60000.0); + qual += .3*log(.0001+ener/1600000.0); } if (qual<-1) qual=-1; diff --git a/libspeex/vbr.h b/libspeex/vbr.h index ff1e3e4..8163440 100644 --- a/libspeex/vbr.h +++ b/libspeex/vbr.h @@ -47,7 +47,6 @@ extern const float vbr_uhb_thresh[2][11]; /** VBR state. */ typedef struct VBRState { - float energy_alpha; float average_energy; float last_energy; float last_log_energy[VBR_MEMORY_SIZE]; |