From ce0124acacd9acbfdc267464a4b52947a249b4bd Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 16 Mar 2013 13:08:32 +0100 Subject: [PATCH 1/2] 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 Fixes Bug 416. --- libavcodec/mpeg12.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c index c32055d609..bd018d377f 100644 --- a/libavcodec/mpeg12.c +++ b/libavcodec/mpeg12.c @@ -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; From 358628074c314c8ec6d433a740e9176e7aefa124 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 22 Feb 2013 23:01:54 +0100 Subject: [PATCH 2/2] print_options: do not generate docs for options without enc or dec flags Those are not usable from the avtools, so mentioning them in the manpages just confuses the reader. --- doc/print_options.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/print_options.c b/doc/print_options.c index 4283e6a86d..498a808946 100644 --- a/doc/print_options.c +++ b/doc/print_options.c @@ -39,6 +39,9 @@ static void print_usage(void) static void print_option(const AVOption *opts, const AVOption *o, int per_stream) { + if (!(o->flags & (AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_ENCODING_PARAM))) + return; + printf("@item -%s%s @var{", o->name, per_stream ? "[:stream_specifier]" : ""); switch (o->type) { case AV_OPT_TYPE_BINARY: printf("hexadecimal string"); break;