ref: 2146e649c84ff7a96ac17d5e07d7828ee5d0a118
parent: 431e46469c0804f6f01cc4f5c90ab1daac7d3054
author: Jean-Marc Valin <[email protected]>
date: Mon Apr 21 11:08:57 EDT 2008
Disabling pitch when gain is very small.
--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -346,7 +346,7 @@
/* No pitch, so we just pretend we found a gain of zero */
for (i=0;i<st->mode->nbPBands;i++)
gains[i] = 0;
- ec_enc_uint(&st->enc, 0, 128);
+ ec_enc_bits(&st->enc, 0, 7);
for (i=0;i<C*N;i++)
P[i] = 0;
}
--- a/libcelt/quant_pitch.c
+++ b/libcelt/quant_pitch.c
@@ -95,11 +95,21 @@
int quant_pitch(celt_pgain_t *gains, int len, ec_enc *enc)
{
int i, id;
+ celt_word32_t gain_sum = 0;
/*for (i=0;i<len;i++) printf ("%f ", gains[i]);printf ("\n");*/
/* Convert to a representation where the MSE criterion should be near-optimal */
for (i=0;i<len;i++)
+ {
gains[i] = SHR16(Q15ONE-celt_sqrt(Q1515ONE-MULT16_16(gains[i],gains[i])),1);
- id = vq_index(gains, pgain_table, len, 128);
+ gain_sum = ADD32(gain_sum, EXTEND32(gains[i]));
+ }
+ /* Is it worth encoding the pitch? */
+ if (gain_sum > QCONST32(.3f,15))
+ {
+ id = vq_index(gains, pgain_table, len, 128);
+ } else {
+ id = 0;
+ }
ec_enc_bits(enc, id, 7);
/*for (i=0;i<len;i++) printf ("%f ", pgain_table[id*len+i]);printf ("\n");*/
id2gains(id, gains, len);