Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-03-01 09:07:36 +0400
committerMichael Niedermayer <michaelni@gmx.at>2012-03-01 09:35:55 +0400
commita057ef6923fba7947d8ccf27b751bf91fde3a755 (patch)
tree72b69737903cfc173dd031339c1012a0543b40a4 /libavcodec/mpegaudiodec.c
parent436f866f92a9483717e376866783346bf8a00e58 (diff)
mpegaudiodec: change granule skip code to avoid false checked bitstream reader errors.
Code ported from qatar/master, please see there for per line authorship. Main authors AFAIK are Ronald and Justin. I have no authorship on this. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/mpegaudiodec.c')
-rw-r--r--libavcodec/mpegaudiodec.c35
1 files changed, 20 insertions, 15 deletions
diff --git a/libavcodec/mpegaudiodec.c b/libavcodec/mpegaudiodec.c
index 00565875fc..ddb7695446 100644
--- a/libavcodec/mpegaudiodec.c
+++ b/libavcodec/mpegaudiodec.c
@@ -1386,6 +1386,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);
int extrasize = av_clip(get_bits_left(&s->gb) >> 3, 0, EXTRABYTES);
assert((get_bits_count(&s->gb) & 7) == 0);
@@ -1399,25 +1400,29 @@ static int mp_decode_layer3(MPADecodeContext *s)
#if !UNCHECKED_BITSTREAM_READER
s->gb.size_in_bits_plus8 += FFMAX(extrasize, LAST_BUF_SIZE - s->last_buf_size) * 8;
#endif
- skip_bits_long(&s->gb, 8*(s->last_buf_size - main_data_begin));
+ s->last_buf_size <<= 3;
+ 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 = 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 = 0;
}
- for (gr = 0; gr < nb_granules; gr++) {
+ for (; gr < nb_granules; gr++) {
for (ch = 0; ch < s->nb_channels; ch++) {
g = &s->granules[ch][gr];
- if (get_bits_count(&s->gb) < 0) {
- av_log(s->avctx, AV_LOG_DEBUG, "mdb:%d, lastbuf:%d skipping granule %d\n",
- main_data_begin, s->last_buf_size, gr);
- skip_bits_long(&s->gb, g->part2_3_length);
- memset(g->sb_hybrid, 0, sizeof(g->sb_hybrid));
- 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);
- s->gb = s->in_gb;
- s->in_gb.buffer = NULL;
- }
- continue;
- }
-
bits_pos = get_bits_count(&s->gb);
if (!s->lsf) {