Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/quite/celt.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Marc Valin <jean-marc.valin@usherbrooke.ca>2011-02-03 23:47:10 +0300
committerJean-Marc Valin <jean-marc.valin@usherbrooke.ca>2011-02-03 23:47:10 +0300
commitef986e44211bc0fd3820700b61e552828a0d8c65 (patch)
tree5a0c47787b443623d54b8d6ee5d5a4756138ef32
parentc33c3d6ce59e0c51db98048161e65cc165c9565b (diff)
Increasing the pitch gain resolution
-rw-r--r--libcelt/celt.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/libcelt/celt.c b/libcelt/celt.c
index 7e7746a..720b375 100644
--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -1105,38 +1105,42 @@ int celt_encode_with_ec_float(CELTEncoder * restrict st, const celt_sig * pcm, i
pf_threshold = MAX16(pf_threshold, QCONST16(.2f,15));
if (gain1<pf_threshold)
{
- if(st->start==0 && tell+17<=total_bits)
+ if(st->start==0 && tell+16<=total_bits)
ec_enc_bit_logp(enc, 0, 1);
gain1 = 0;
pf_on = 0;
} else {
+ /*This block is not gated by a total bits check only because
+ of the nbAvailableBytes check above.*/
int qg;
int octave;
- if (gain1 > QCONST16(.6f,15))
- gain1 = QCONST16(.6f,15);
if (ABS16(gain1-st->prefilter_gain)<QCONST16(.1f,15))
gain1=st->prefilter_gain;
#ifdef FIXED_POINT
- qg = ((gain1+2048)>>12)-2;
+ qg = ((gain1+1536)>>10)/3-1;
#else
- qg = floor(.5+gain1*8)-2;
+ qg = floor(.5+gain1*32/3)-1;
#endif
+ qg = IMAX(0, IMIN(7, qg));
ec_enc_bit_logp(enc, 1, 1);
pitch_index += 1;
octave = EC_ILOG(pitch_index)-5;
ec_enc_uint(enc, octave, 6);
ec_enc_bits(enc, pitch_index-(16<<octave), 4+octave);
pitch_index -= 1;
- ec_enc_bits(enc, qg, 2);
- gain1 = QCONST16(.125f,15)*(qg+2);
- ec_enc_icdf(enc, prefilter_tapset, tapset_icdf, 2);
+ ec_enc_bits(enc, qg, 3);
+ if (ec_enc_tell(enc, 0)+2<=total_bits)
+ ec_enc_icdf(enc, prefilter_tapset, tapset_icdf, 2);
+ else
+ prefilter_tapset = 0;
+ gain1 = QCONST16(0.09375f,15)*(qg+1);
pf_on = 1;
}
/*printf("%d %f\n", pitch_index, gain1);*/
#else /* ENABLE_POSTFILTER */
- if(st->start==0 && tell+17<=total_bits)
+ if(st->start==0 && tell+16<=total_bits)
ec_enc_bit_logp(enc, 0, 1);
pf_on = 0;
#endif /* ENABLE_POSTFILTER */
@@ -2258,7 +2262,7 @@ int celt_decode_with_ec_float(CELTDecoder * restrict st, const unsigned char *da
postfilter_gain = 0;
postfilter_pitch = 0;
postfilter_tapset = 0;
- if (st->start==0 && tell+17 <= total_bits)
+ if (st->start==0 && tell+16 <= total_bits)
{
if(ec_dec_bit_logp(dec, 1))
{
@@ -2266,9 +2270,10 @@ int celt_decode_with_ec_float(CELTDecoder * restrict st, const unsigned char *da
int qg, octave;
octave = ec_dec_uint(dec, 6);
postfilter_pitch = (16<<octave)+ec_dec_bits(dec, 4+octave)-1;
- qg = ec_dec_bits(dec, 2);
- postfilter_tapset = ec_dec_icdf(dec, tapset_icdf, 2);
- postfilter_gain = QCONST16(.125f,15)*(qg+2);
+ qg = ec_dec_bits(dec, 3);
+ if (ec_dec_tell(dec, 0)+2<=total_bits)
+ postfilter_tapset = ec_dec_icdf(dec, tapset_icdf, 2);
+ postfilter_gain = QCONST16(.09375f,15)*(qg+1);
#else /* ENABLE_POSTFILTER */
RESTORE_STACK;
return CELT_CORRUPTED_DATA;