diff options
author | jep <jep@2b0047a9-a6d8-0310-accf-f7200b2a168c> | 2013-09-03 16:24:01 +0000 |
---|---|---|
committer | jep <jep@2b0047a9-a6d8-0310-accf-f7200b2a168c> | 2013-09-03 16:24:01 +0000 |
commit | e8489cabea320f370bebe713d90c6a7a8ca84d34 (patch) | |
tree | e7fa8f54b3bde54c080ccdc768f6de9abe506ca4 | |
parent | ab2678b50630b019288e42b35676893b799bd3d9 (diff) |
* src/bitstream.c: (h_rewindNbits):
Fixes decoding noise when dealing with slighly wrong encoded frames
with a missmatch between huffman read bits and size described in header.
git-svn-id: https://core.fluendo.com/gstreamer/svn/trunk/gst-fluendo-mp3@2503 2b0047a9-a6d8-0310-accf-f7200b2a168c
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | src/bitstream.c | 10 |
2 files changed, 11 insertions, 5 deletions
@@ -1,5 +1,11 @@ 2013-09-03 Josep Torra <josep@fluendo.com> + * src/bitstream.c: (h_rewindNbits): + Fixes decoding noise when dealing with slighly wrong encoded frames + with a missmatch between huffman read bits and size described in header. + +2013-09-03 Josep Torra <josep@fluendo.com> + * src/mp3-c.c: (III_huffman_decode), (III_dequantize_sample), (c_decode_mp3): * src/mp3-ipp.c: (ipp_decode_mp3): diff --git a/src/bitstream.c b/src/bitstream.c index ef17625..71a3d75 100644 --- a/src/bitstream.c +++ b/src/bitstream.c @@ -250,14 +250,14 @@ h_rewindNbits (huffdec_bitbuf * bb, guint N) { guint bits = 0; guint bytes = 0; - if (N <= (32 - bb->buf_bit_idx)) + if (N <= (BS_ACUM_SIZE - bb->buf_bit_idx)) bb->buf_bit_idx += N; else { - N -= (32 - bb->buf_bit_idx); + N -= (BS_ACUM_SIZE - bb->buf_bit_idx); bb->buf_bit_idx = 0; - bits = N % 8; - bytes = N / 8; - bb->buf -= bytes; + bits = 8 - (N % 8); + bytes = (N + 8 + BS_ACUM_SIZE) >> 3; + bb->buf_byte_idx -= bytes; bb->remaining += bytes; h_getbits (bb, bits); } |