1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

mpeg12: do not fail on zero dimensions in the sequence header.

The total frame size is a combination of the 12 bits in the sequence
header and 2 more bits in the the sequence extension. While the
specification explicitly forbids the dimensions from the sequence header
from being 0 (thus ruling out multiples of 4096), such videos
apparrently exist in the wild so we should attempt to decode them.

Based on a patch by Michael Niedermayer <michaelni@gmx.at>

Fixes Bug 416.
This commit is contained in:
Anton Khirnov 2013-03-16 13:08:32 +01:00
parent 50c449ac24
commit ce0124acac

View File

@ -1974,8 +1974,12 @@ static int mpeg1_decode_sequence(AVCodecContext *avctx,
width = get_bits(&s->gb, 12);
height = get_bits(&s->gb, 12);
if (width <= 0 || height <= 0)
return -1;
if (width == 0 || height == 0) {
av_log(avctx, AV_LOG_WARNING, "Invalid horizontal or vertical size "
"value.\n");
if (avctx->err_recognition & AV_EF_BITSTREAM)
return AVERROR_INVALIDDATA;
}
s->aspect_ratio_info = get_bits(&s->gb, 4);
if (s->aspect_ratio_info == 0) {
av_log(avctx, AV_LOG_ERROR, "aspect ratio has forbidden 0 value\n");
@ -2271,6 +2275,12 @@ static int decode_chunks(AVCodecContext *avctx,
break;
case PICTURE_START_CODE:
if (s2->width <= 0 || s2->height <= 0) {
av_log(avctx, AV_LOG_ERROR, "Invalid frame dimensions %dx%d.\n",
s2->width, s2->height);
return AVERROR_INVALIDDATA;
}
if (HAVE_THREADS && (avctx->active_thread_type & FF_THREAD_SLICE) && s->slice_count) {
int i;