diff --git a/libcelt/bands.c b/libcelt/bands.c index 4334e7df4e752b73825dd9ad3fa455e735efd7d1..41b713b78859bcd7e818d551c241478e2280e5b9 100644 --- a/libcelt/bands.c +++ b/libcelt/bands.c @@ -895,6 +895,7 @@ void quant_all_bands(int encode, const CELTMode *m, int start, celt_norm *_X, ce int spread; celt_norm *lowband; int update_lowband = 1; + int C = _Y != NULL ? 2 : 1; SAVE_STACK; M = 1<<LM; @@ -935,6 +936,9 @@ void quant_all_bands(int encode, const CELTMode *m, int start, celt_norm *_X, ce b = IMIN(remaining_bits+1,pulses[i]+curr_balance); if (b<0) b = 0; + /* Prevents ridiculous bit depths */ + if (b > C*16*N<<BITRES) + b = C*16*N<<BITRES; if (M*eBands[i]-N >= M*eBands[start]) {