aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2011-12-31 19:24:30 -0500
committerJustin Ruggles <justin.ruggles@gmail.com>2012-01-01 22:37:50 -0500
commit03fafdec82a4dbe0cf1a7d4d3bb59c42d5019941 (patch)
tree02c6314f81041ae6e63b6555ffcc1793154a3d8c
parentaf9240cd3c6fb257ac2d0843334145f022ef5959 (diff)
downloadffmpeg-03fafdec82a4dbe0cf1a7d4d3bb59c42d5019941.tar.gz
mpegaudiodec: skip all channels when skipping granules
Also fix calculation of new position when switching buffers. This fixes "overread" error messages when seeking.
-rw-r--r--libavcodec/mpegaudiodec.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/libavcodec/mpegaudiodec.c b/libavcodec/mpegaudiodec.c
index ad3b199e24..1b50f9fd92 100644
--- a/libavcodec/mpegaudiodec.c
+++ b/libavcodec/mpegaudiodec.c
@@ -1539,6 +1539,7 @@ static int mp_decode_layer3(MPADecodeContext *s)
}
if (!s->adu_mode) {
+ int skip;
const uint8_t *ptr = s->gb.buffer + (get_bits_count(&s->gb)>>3);
assert((get_bits_count(&s->gb) & 7) == 0);
/* now we get bits from the main_data_begin offset */
@@ -1552,25 +1553,27 @@ static int mp_decode_layer3(MPADecodeContext *s)
s->gb.size_in_bits_plus8 += EXTRABYTES * 8;
#endif
s->last_buf_size <<= 3;
- for (gr = 0, ch = 0; gr < nb_granules && (s->last_buf_size >> 3) < main_data_begin; gr++, ch = 0) {
- for (; ch < s->nb_channels && (s->last_buf_size >> 3) < main_data_begin; ch++) {
+ for (gr = 0; gr < nb_granules && (s->last_buf_size >> 3) < main_data_begin; gr++) {
+ for (ch = 0; ch < s->nb_channels; ch++) {
g = &s->granules[ch][gr];
s->last_buf_size += g->part2_3_length;
memset(g->sb_hybrid, 0, sizeof(g->sb_hybrid));
}
}
- skip_bits_long(&s->gb, s->last_buf_size - 8 * main_data_begin);
- if (get_bits_count(&s->gb) >= s->gb.size_in_bits && s->in_gb.buffer) {
- skip_bits_long(&s->in_gb, get_bits_count(&s->gb) - s->gb.size_in_bits);
+ skip = s->last_buf_size - 8 * main_data_begin;
+ if (skip >= s->gb.size_in_bits && s->in_gb.buffer) {
+ skip_bits_long(&s->in_gb, skip - s->gb.size_in_bits);
s->gb = s->in_gb;
s->in_gb.buffer = NULL;
+ } else {
+ skip_bits_long(&s->gb, skip);
}
} else {
- gr = ch = 0;
+ gr = 0;
}
- for (; gr < nb_granules; gr++, ch = 0) {
- for (; ch < s->nb_channels; ch++) {
+ for (; gr < nb_granules; gr++) {
+ for (ch = 0; ch < s->nb_channels; ch++) {
g = &s->granules[ch][gr];
bits_pos = get_bits_count(&s->gb);