diff --git a/libcelt/bands.c b/libcelt/bands.c index 99d4b34347262d5ad4b860851735b05db9ff37c1..97daef941178634f462adf21b9a219b90ae0fe80 100644 --- a/libcelt/bands.c +++ b/libcelt/bands.c @@ -991,7 +991,7 @@ static unsigned quant_band(int encode, const CELTMode *m, int i, celt_norm *X, c lowband, resynth, ec, remaining_bits, LM, next_lowband_out1, NULL, next_level, seed, stereo ? Q15ONE : MULT16_16_P15(gain,mid), lowband_scratch, fill); rebalance = mbits - (rebalance-*remaining_bits); - if (rebalance > 3<<BITRES) + if (rebalance > 3<<BITRES && itheta!=0) sbits += rebalance - (3<<BITRES); /* For a stereo split, the high bits of fill are always zero, so no @@ -1006,7 +1006,7 @@ static unsigned quant_band(int encode, const CELTMode *m, int i, celt_norm *X, c next_lowband2, resynth, ec, remaining_bits, LM, NULL, NULL, next_level, seed, MULT16_16_P15(gain,side), NULL, fill>>B)<<(B0>>1&stereo-1); rebalance = sbits - (rebalance-*remaining_bits); - if (rebalance > 3<<BITRES) + if (rebalance > 3<<BITRES && itheta!=16384) mbits += rebalance - (3<<BITRES); /* In stereo mode, we do not apply a scaling to the mid because we need the normalized mid for folding later */ diff --git a/libcelt/modes.c b/libcelt/modes.c index 7c4cc8d2eb862076c082ccba0b59165700d95b3e..5f801ccc221bd21e405d64a43ae5daa74f9277b3 100644 --- a/libcelt/modes.c +++ b/libcelt/modes.c @@ -318,19 +318,19 @@ CELTMode *celt_mode_create(celt_int32 Fs, int frame_size, int *error) { mode->preemph[0] = QCONST16(0.3500061035f, 15); mode->preemph[1] = -QCONST16(0.1799926758f, 15); - mode->preemph[2] = QCONST16(0.2719726562f, SIG_SHIFT); + mode->preemph[2] = QCONST16(0.2719968125f, SIG_SHIFT); /* exact 1/preemph[3] */ mode->preemph[3] = QCONST16(3.6765136719f, 13); } else if(Fs < 24000) /* 16 kHz */ { mode->preemph[0] = QCONST16(0.6000061035f, 15); mode->preemph[1] = -QCONST16(0.1799926758f, 15); - mode->preemph[2] = QCONST16(0.4425048828f, SIG_SHIFT); - mode->preemph[3] = QCONST16(2.259887f, 13); + mode->preemph[2] = QCONST16(0.4424998650f, SIG_SHIFT); /* exact 1/preemph[3] */ + mode->preemph[3] = QCONST16(2.2598876953f, 13); } else if(Fs < 40000) /* 32 kHz */ { mode->preemph[0] = QCONST16(0.7799987793f, 15); mode->preemph[1] = -QCONST16(0.1000061035f, 15); - mode->preemph[2] = QCONST16(.75f, SIG_SHIFT); + mode->preemph[2] = QCONST16(0.7499771125f, SIG_SHIFT); /* exact 1/preemph[3] */ mode->preemph[3] = QCONST16(1.3333740234f, 13); } else /* 48 kHz */ {