Code intensity offset relative to start.

The band where intensity stereo begins was being coded as an
 absolute value, rather than relative to start, even though the
 range of values in the bitstream was limited as if it was being
 coded relative to start (meaning there would be desync if
 intensity was sufficiently large).
This commit is contained in:
Timothy B. Terriberry 2010-12-30 09:06:22 -08:00 committed by Jean-Marc Valin
parent d6f6157192
commit 79d76a2e3a

View file

@ -1140,7 +1140,7 @@ int celt_encode_with_ec_float(CELTEncoder * restrict st, const celt_sig * pcm, i
else else
intensity = 100; intensity = 100;
intensity = IMIN(st->end,IMAX(st->start, intensity)); intensity = IMIN(st->end,IMAX(st->start, intensity));
ec_enc_uint(enc, intensity, 1+st->end-st->start); ec_enc_uint(enc, intensity-st->start, 1+st->end-st->start);
} }
/* Bit allocation */ /* Bit allocation */
@ -1883,7 +1883,7 @@ int celt_decode_with_ec_float(CELTDecoder * restrict st, const unsigned char *da
if (C==2) if (C==2)
{ {
dual_stereo = ec_dec_bit_logp(dec, 1); dual_stereo = ec_dec_bit_logp(dec, 1);
intensity = ec_dec_uint(dec, 1+st->end-st->start); intensity = st->start + ec_dec_uint(dec, 1+st->end-st->start);
} }
bits = (len*8<<BITRES) - ec_dec_tell(dec, BITRES) - 1; bits = (len*8<<BITRES) - ec_dec_tell(dec, BITRES) - 1;