diff options
author | Jean-Marc Valin <jean-marc.valin@usherbrooke.ca> | 2009-06-16 06:40:06 +0400 |
---|---|---|
committer | Jean-Marc Valin <jean-marc.valin@usherbrooke.ca> | 2009-06-16 06:40:06 +0400 |
commit | 9dff02188c03bdeabda9e6131d579e8208e769fd (patch) | |
tree | 5f9da53541e8cc5822ceb8dcd440f1f271e3a275 | |
parent | 9edb7b4213c583fee49c05ae815ffffc66532a0a (diff) |
Minor stuff: preventing float underflow in celt_exp2(), preventing the use of
intra energy for low bitrates, and a bit of very high bitrate tuning
-rw-r--r-- | libcelt/celt.c | 14 | ||||
-rw-r--r-- | libcelt/mathops.h | 2 | ||||
-rw-r--r-- | libcelt/modes.c | 4 |
3 files changed, 9 insertions, 11 deletions
diff --git a/libcelt/celt.c b/libcelt/celt.c index 3151ce0..b635dd4 100644 --- a/libcelt/celt.c +++ b/libcelt/celt.c @@ -670,15 +670,7 @@ int celt_encode_float(CELTEncoder * restrict st, const celt_sig_t * pcm, celt_si freq[i] = (1./(1<<mdct_weight_shift))*freq[i]; } #endif - /*printf ("%f\n", short_ratio);*/ - /*if (short_ratio < 1) - short_ratio = 1; - short_ratio = 1<<(int)floor(.5+log2(short_ratio)); - if (short_ratio>4) - short_ratio = 4;*/ - }/* else if (transient_shift) - printf ("8\n"); - else printf ("1\n");*/ + } compute_band_energies(st->mode, freq, bandE); for (i=0;i<st->mode->nbEBands*C;i++) @@ -689,6 +681,10 @@ int celt_encode_float(CELTEncoder * restrict st, const celt_sig_t * pcm, celt_si st->delayedIntra = 1; else st->delayedIntra = 0; + /* Don't use intra energy when we're operating at low bit-rate */ + if (nbCompressedBytes < 20) + intra_ener = 0; + /* Pitch analysis: we do it early to save on the peak stack space */ /* Don't use pitch if there isn't enough data available yet, or if we're using shortBlocks */ diff --git a/libcelt/mathops.h b/libcelt/mathops.h index dc1e222..62e8e4a 100644 --- a/libcelt/mathops.h +++ b/libcelt/mathops.h @@ -144,6 +144,8 @@ static inline float celt_exp2(float x) celt_uint32_t i; } res; integer = floor(x); + if (integer < -50) + return 0; frac = x-integer; /* K0 = 1, K1 = log(2), K2 = 3-4*log(2), K3 = 3*log(2) - 2 */ res.f = 1.f + frac * (0.696147f + frac * (0.224411f + 0.079442f*frac)); diff --git a/libcelt/modes.c b/libcelt/modes.c index 9893756..c3c21e0 100644 --- a/libcelt/modes.c +++ b/libcelt/modes.c @@ -122,8 +122,8 @@ static const int band_allocation[BARK_BANDS*BITALLOC_SIZE] = 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 8, 8, 10, 12, 12, 11, 11, 17, 12, 15, 15, 20, 18, 10, 1, 8, 7, 7, 7, 7, 7, 8, 8, 9, 10, 11, 12, 14, 17, 18, 21, 22, 27, 29, 39, 37, 38, 40, 35, 1, 7, 7, 7, 7, 7, 7, 10, 10, 10, 13, 14, 18, 20, 24, 28, 32, 32, 35, 38, 38, 42, 50, 59, 54, 31, - 8, 8, 8, 8, 8, 9, 10, 12, 14, 20, 22, 25, 28, 30, 35, 42, 46, 50, 55, 60, 62, 62, 62, 62, 62, - 12, 12, 12, 12, 12, 13, 15, 18, 22, 30, 32, 35, 40, 45, 55, 62, 66, 70, 85, 90, 92, 92, 92, 92, 92, + 8, 8, 8, 8, 8, 9, 10, 12, 14, 20, 22, 25, 28, 30, 35, 42, 46, 50, 55, 60, 62, 62, 72, 82, 62, + 9, 9, 9, 10, 12, 13, 15, 18, 22, 30, 32, 35, 40, 45, 55, 62, 66, 70, 85, 90, 92, 92, 92,102, 92, }; #endif |