Commit b9534638 authored by Jean-Marc Valin's avatar Jean-Marc Valin
Browse files

VBR tuning (along with open-loop gamma2 tweak)

parent 57ec3153
......@@ -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);
......
......@@ -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;
......
......@@ -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];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment