mpeg12dec: Prevent f_code from becoming invalid.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2012-04-07 19:32:45 +02:00
parent 6c3d6a214c
commit a931d87727
1 changed files with 7 additions and 0 deletions

View File

@ -1368,6 +1368,7 @@ static int mpeg1_decode_picture(AVCodecContext *avctx,
f_code = get_bits(&s->gb, 3);
if (f_code == 0 && (avctx->err_recognition & (AV_EF_BITSTREAM|AV_EF_COMPLIANT)))
return -1;
f_code += !f_code;
s->mpeg_f_code[0][0] = f_code;
s->mpeg_f_code[0][1] = f_code;
}
@ -1376,6 +1377,7 @@ static int mpeg1_decode_picture(AVCodecContext *avctx,
f_code = get_bits(&s->gb, 3);
if (f_code == 0 && (avctx->err_recognition & (AV_EF_BITSTREAM|AV_EF_COMPLIANT)))
return -1;
f_code += !f_code;
s->mpeg_f_code[1][0] = f_code;
s->mpeg_f_code[1][1] = f_code;
}
@ -1536,6 +1538,11 @@ static void mpeg_decode_picture_coding_extension(Mpeg1Context *s1)
s->current_picture.f.pict_type = s->pict_type;
s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I;
}
s->mpeg_f_code[0][0] += !s->mpeg_f_code[0][0];
s->mpeg_f_code[0][1] += !s->mpeg_f_code[0][1];
s->mpeg_f_code[1][0] += !s->mpeg_f_code[1][0];
s->mpeg_f_code[1][1] += !s->mpeg_f_code[1][1];
s->intra_dc_precision = get_bits(&s->gb, 2);
s->picture_structure = get_bits(&s->gb, 2);
s->top_field_first = get_bits1(&s->gb);