diff --git a/libcelt/bands.c b/libcelt/bands.c index 703bbac5..b089f161 100644 --- a/libcelt/bands.c +++ b/libcelt/bands.c @@ -965,32 +965,7 @@ void quant_all_bands(int encode, const CELTMode *m, int start, int end, ALLOC(lowband_scratch, M*(eBands[m->nbEBands]-eBands[m->nbEBands-1]), celt_norm); norm = _norm; norm2 = norm + M*eBands[m->nbEBands]; -#if 0 - if (C==2) - { - int j; - int left = 0; - for (j=intensity;jeBands[codedBands]-m->eBands[start]); - for (j=start;jeBands[j+1]-m->eBands[j]); - left = left-(m->eBands[codedBands]-m->eBands[start])*perband; - for (j=start;jeBands[j+1]-m->eBands[j]); - pulses[j] += tmp; - left -= tmp; - } - } - } -#endif + if (encode) seed = ((ec_enc*)ec)->rng; else diff --git a/libcelt/quant_bands.c b/libcelt/quant_bands.c index ae25417c..937692f6 100644 --- a/libcelt/quant_bands.c +++ b/libcelt/quant_bands.c @@ -41,6 +41,7 @@ #include "arch.h" #include "mathops.h" #include "stack_alloc.h" +#include "rate.h" #ifdef FIXED_POINT /* Mean energy in each band quantized in Q6 */ @@ -384,7 +385,7 @@ void quant_energy_finalise(const CELTMode *m, int start, int end, celt_ener *eBa { for (i=start;i=C ;i++) { - if (fine_quant[i] >= 7 || fine_priority[i]!=prio) + if (fine_quant[i] >= MAX_FINE_BITS || fine_priority[i]!=prio) continue; c=0; do { @@ -495,7 +496,7 @@ void unquant_energy_finalise(const CELTMode *m, int start, int end, celt_ener *e { for (i=start;i=C ;i++) { - if (fine_quant[i] >= 8 || fine_priority[i]!=prio) + if (fine_quant[i] >= MAX_FINE_BITS || fine_priority[i]!=prio) continue; c=0; do { diff --git a/libcelt/rate.c b/libcelt/rate.c index 152cad46..7578bafd 100644 --- a/libcelt/rate.c +++ b/libcelt/rate.c @@ -366,9 +366,8 @@ static inline int interp_bits2pulses(const CELTMode *m, int start, int end, int if (C*ebits[j] > (bits[j]>>BITRES)) ebits[j] = bits[j] >> stereo >> BITRES; - /* More than 8 is useless because that's about as far as PVQ can go */ - if (ebits[j]>8) - ebits[j]=8; + /* More than that is useless because that's about as far as PVQ can go */ + ebits[j] = IMIN(ebits[j], MAX_FINE_BITS); /* If we rounded down or capped this band, make it a candidate for the final fine energy pass */ @@ -376,7 +375,7 @@ static inline int interp_bits2pulses(const CELTMode *m, int start, int end, int } else { /* For N=1, all bits go to fine energy except for a single sign bit */ - ebits[j] = IMIN(IMAX(0,(bits[j] >> stereo >> BITRES)-1),8); + ebits[j] = IMIN(IMAX(0,(bits[j] >> stereo >> BITRES)-1),MAX_FINE_BITS); fine_priority[j] = (ebits[j]+1)*C<= (bits[j]-balance); /* N=1 bands can't take advantage of the re-balancing in quant_all_bands() because they don't have shape, only fine energy. diff --git a/libcelt/rate.h b/libcelt/rate.h index 1c9415e6..858a4a74 100644 --- a/libcelt/rate.h +++ b/libcelt/rate.h @@ -38,6 +38,8 @@ #define MAX_PULSES 128 +#define MAX_FINE_BITS 8 + #define BITRES 3 #define FINE_OFFSET 21 #define QTHETA_OFFSET 4