ref: 5c80391b3529bcb3fc8afd3b83d7562bae4991ae
parent: df6620eb0b691e68faf10a7311baabe2d11531c4
author: Jean-Marc Valin <[email protected]>
date: Thu Dec 16 09:11:48 EST 2010
Comments, low bit-rate busting avoidance
--- a/libcelt/bands.c
+++ b/libcelt/bands.c
@@ -830,7 +830,7 @@
{
if (spread==2 && B<=1)
{
- /* Folded spectrum */
+ /* Noise */
for (j=0;j<N;j++)
{
*seed = lcg_rand(*seed);
@@ -837,7 +837,7 @@
X[j] = (int)(*seed)>>20;
}
} else {
- /* Noise */
+ /* Folded spectrum */
for (j=0;j<N;j++)
X[j] = lowband[j];
}
--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -822,7 +822,7 @@
} while (++c<C);
#ifdef ENABLE_POSTFILTER
- if (LM != 0 && nbAvailableBytes>10)
+ if (LM != 0 && nbAvailableBytes>10*C)
{
VARDECL(celt_word16, pitch_buf);
ALLOC(pitch_buf, (COMBFILTER_MAXPERIOD+N)>>1, celt_word16);
@@ -946,7 +946,7 @@
tf_encode(st->start, st->end, isTransient, tf_res, LM, tf_select, enc);
- if (shortBlocks || st->complexity < 3)
+ if (shortBlocks || st->complexity < 3 || nbAvailableBytes < 10*C)
{
if (st->complexity == 0)
{
--- a/libcelt/rate.c
+++ b/libcelt/rate.c
@@ -141,7 +141,7 @@
#define ALLOC_STEPS 6
static inline int interp_bits2pulses(const CELTMode *m, int start, int end,
- int *bits1, int *bits2, const int *thresh, int total, int *bits,
+ const int *bits1, const int *bits2, const int *thresh, int total, int *bits,
int *ebits, int *fine_priority, int len, int _C, int LM, void *ec, int encode, int prev)
{
int psum;
@@ -357,7 +357,7 @@
return codedBands;
}
-int compute_allocation(const CELTMode *m, int start, int end, int *offsets, int alloc_trim,
+int compute_allocation(const CELTMode *m, int start, int end, const int *offsets, int alloc_trim,
int total, int *pulses, int *ebits, int *fine_priority, int _C, int LM, void *ec, int encode, int prev)
{
int lo, hi, len, j;
--- a/libcelt/rate.h
+++ b/libcelt/rate.h
@@ -102,7 +102,7 @@
@param pulses Number of pulses per band (returned)
@return Total number of bits allocated
*/
-int compute_allocation(const CELTMode *m, int start, int end, int *offsets, int alloc_trim,
+int compute_allocation(const CELTMode *m, int start, int end, const int *offsets, int alloc_trim,
int total, int *pulses, int *ebits, int *fine_priority, int _C, int LM, void *ec, int encode, int prev);