From 2a11952f457658d58303c8e5b4e10fb4599eef4f Mon Sep 17 00:00:00 2001 From: Dustin Brody Date: Wed, 27 Jul 2011 19:09:45 -0400 Subject: [PATCH] h263dec: Propagate AV_LOG_ERRORs from slice decoding through frame decoding with sufficient error recognition Signed-off-by: Ronald S. Bultje --- doc/ffmpeg.texi | 2 ++ libavcodec/avcodec.h | 1 + libavcodec/h263dec.c | 6 +++--- libavcodec/options.c | 1 + 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index 5a783e3..4dca5d8 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -470,6 +470,8 @@ FF_ER_COMPLIANT FF_ER_AGGRESSIVE @item 4 FF_ER_VERY_AGGRESSIVE +@item 5 +FF_ER_EXPLODE @end table @item -ec @var{bit_mask} diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index b6cac7c..75c107c 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -1446,6 +1446,7 @@ typedef struct AVCodecContext { #define FF_ER_COMPLIANT 2 #define FF_ER_AGGRESSIVE 3 #define FF_ER_VERY_AGGRESSIVE 4 +#define FF_ER_EXPLODE 5 /** * Called at the beginning of each frame to get a buffer for it. diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c index 6eea8de..a19e55c 100644 --- a/libavcodec/h263dec.c +++ b/libavcodec/h263dec.c @@ -638,7 +638,7 @@ retry: s->mb_x=0; s->mb_y=0; - decode_slice(s); + ret = decode_slice(s); while(s->mb_ymb_height){ if(s->msmpeg4_version){ if(s->slice_height==0 || s->mb_x!=0 || (s->mb_y%s->slice_height)!=0 || get_bits_count(&s->gb) > s->gb.size_in_bits) @@ -654,7 +654,7 @@ retry: if(s->msmpeg4_version<4 && s->h263_pred) ff_mpeg4_clean_buffers(s); - decode_slice(s); + if (decode_slice(s) < 0) ret = AVERROR_INVALIDDATA; } if (s->msmpeg4_version && s->msmpeg4_version<4 && s->pict_type==AV_PICTURE_TYPE_I) @@ -722,7 +722,7 @@ assert(s->current_picture.pict_type == s->pict_type); av_log(avctx, AV_LOG_DEBUG, "%"PRId64"\n", rdtsc()-time); #endif - return get_consumed_bytes(s, buf_size); + return (ret && avctx->error_recognition >= FF_ER_EXPLODE)?ret:get_consumed_bytes(s, buf_size); } AVCodec ff_h263_decoder = { diff --git a/libavcodec/options.c b/libavcodec/options.c index 4869046..0f0ca2a 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -184,6 +184,7 @@ static const AVOption options[]={ {"compliant", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_ER_COMPLIANT }, INT_MIN, INT_MAX, V|D, "er"}, {"aggressive", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_ER_AGGRESSIVE }, INT_MIN, INT_MAX, V|D, "er"}, {"very_aggressive", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_ER_VERY_AGGRESSIVE }, INT_MIN, INT_MAX, V|D, "er"}, +{"explode", "abort decoding on error recognition", 0, FF_OPT_TYPE_CONST, {.dbl = FF_ER_EXPLODE }, INT_MIN, INT_MAX, V|D, "er"}, {"has_b_frames", NULL, OFFSET(has_b_frames), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, {"block_align", NULL, OFFSET(block_align), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, {"parse_only", NULL, OFFSET(parse_only), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, -- 2.7.4