ref: 6cbfbc383a22eb6a84f0dddb0b4991cb0ef6b022
parent: 425cfd3e15c9fe88b917c2c4956769763849112a
author: Jean-Marc Valin <[email protected]>
date: Tue Dec 14 06:53:39 EST 2010
Tuning for 2.5 ms frames
--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -598,7 +598,8 @@
ec_enc_bit_prob(enc, tf_res[i] ^ curr, isTransient ? 4096 : 2048);
curr = tf_res[i];
}
- ec_enc_bits(enc, tf_select, 1);
+ if (LM!=0)
+ ec_enc_bits(enc, tf_select, 1);
for (i=start;i<end;i++)
tf_res[i] = tf_select_table[LM][4*isTransient+2*tf_select+tf_res[i]];
/*printf("%d %d ", isTransient, tf_select); for(i=0;i<end;i++)printf("%d ", tf_res[i]);printf("\n");*/
@@ -614,7 +615,10 @@
tf_res[i] = ec_dec_bit_prob(dec, isTransient ? 4096 : 2048) ^ curr;
curr = tf_res[i];
}
- tf_select = ec_dec_bits(dec, 1);
+ if (LM!=0)
+ tf_select = ec_dec_bits(dec, 1);
+ else
+ tf_select = 0;
for (i=start;i<end;i++)
tf_res[i] = tf_select_table[LM][4*isTransient+2*tf_select+tf_res[i]];
}
@@ -743,7 +747,7 @@
int codedBands;
int tf_sum;
int alloc_trim;
- int pitch_index=0;
+ int pitch_index=COMBFILTER_MINPERIOD;
celt_word16 gain1 = 0;
int intensity=0;
int dual_stereo=0;
@@ -819,6 +823,7 @@
} while (++c<C);
#ifdef ENABLE_POSTFILTER
+ if (LM != 0 && nbAvailableBytes>10)
{
VARDECL(celt_word16, pitch_buf);
ALLOC(pitch_buf, (COMBFILTER_MAXPERIOD+N)>>1, celt_word16);
@@ -834,15 +839,17 @@
gain1 = remove_doubling(pitch_buf, COMBFILTER_MAXPERIOD, COMBFILTER_MINPERIOD,
N, &pitch_index, st->prefilter_period, st->prefilter_gain);
+ if (pitch_index > COMBFILTER_MAXPERIOD)
+ pitch_index = COMBFILTER_MAXPERIOD;
+ gain1 = MULT16_16_Q15(QCONST16(.7f,15),gain1);
+ if (gain1 > QCONST16(.6f,15))
+ gain1 = QCONST16(.6f,15);
+ if (ABS16(gain1-st->prefilter_gain)<QCONST16(.1,15))
+ gain1=st->prefilter_gain;
+ } else {
+ gain1 = 0;
}
- if (pitch_index > COMBFILTER_MAXPERIOD)
- pitch_index = COMBFILTER_MAXPERIOD;
- gain1 = MULT16_16_Q15(QCONST16(.7f,15),gain1);
- if (gain1 > QCONST16(.6f,15))
- gain1 = QCONST16(.6f,15);
- if (ABS16(gain1-st->prefilter_gain)<QCONST16(.1,15))
- gain1=st->prefilter_gain;
- if (gain1<QCONST16(.2f,15))
+ if (gain1<QCONST16(.2f,15) || (nbAvailableBytes<30 && gain1<QCONST16(.4f,15)))
{
ec_enc_bit_prob(enc, 0, 32768);
gain1 = 0;
@@ -1091,7 +1098,7 @@
/* effectiveRate in kb/s */
effectiveRate = 2*effectiveRate/5;
if (effectiveRate<35)
- intensity = 6;
+ intensity = 8;
else if (effectiveRate<50)
intensity = 12;
else if (effectiveRate<68)
--- a/libcelt/rate.c
+++ b/libcelt/rate.c
@@ -260,11 +260,7 @@
/* If we rounded down, make it a candidate for final fine energy pass */
fine_priority[j] = ebits[j]*(den<<BITRES) >= bits[j]+offset;
- /* Make sure the first bit is spent on fine energy */
- if (ebits[j] < 1)
- ebits[j] = 1;
- /* For N=1, all bits go to fine energy except for a single sign bit
- This takes precedence over giving the first bit to fine energy */
+ /* For N=1, all bits go to fine energy except for a single sign bit */
if (N==1)
ebits[j] = (bits[j]/C >> BITRES)-1;
@@ -278,8 +274,7 @@
/* The other bits are assigned to PVQ */
bits[j] -= C*ebits[j]<<BITRES;
- if (bits[j] < 0)
- bits[j] = 0;
+ celt_assert(bits[j] >= 0);
}
RESTORE_STACK;
return codedBands;
@@ -328,8 +323,8 @@
bits1[j] += offsets[j];
if (bits1[j] >= thresh[j])
psum += bits1[j];
- else if (bits1[j] >= 1<<BITRES)
- psum += 1<<BITRES;
+ else if (bits1[j] >= C<<BITRES)
+ psum += C<<BITRES;
/*printf ("%d ", bits[j]);*/
}