[FFmpeg-devel] [PATCH] h264: update avctx width/height when flushing

Andreas Cadhalpun andreas.cadhalpun at googlemail.com
Tue Jun 9 23:53:03 CEST 2015


Inconsistencies between the dimensions of avctx and the frame can
confuse API users. For example this can crash the demuxing_decoding
example.

Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com>
---
 libavcodec/h264.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 9a00214..d1eaa5e 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -1757,6 +1757,8 @@ static int h264_decode_frame(AVCodecContext *avctx, void *data,
             if (ret < 0)
                 return ret;
             *got_frame = 1;
+            avctx->width  = pict->width;
+            avctx->height = pict->height;
         }
 
         return buf_index;
@@ -1830,6 +1832,8 @@ static int h264_decode_frame(AVCodecContext *avctx, void *data,
             if (ret < 0)
                 return ret;
             *got_frame = 1;
+            avctx->width  = pict->width;
+            avctx->height = pict->height;
             if (CONFIG_MPEGVIDEO) {
                 ff_print_debug_info2(h->avctx, pict, NULL,
                                     h->next_output_pic->mb_type,
-- 
2.1.4


More information about the ffmpeg-devel mailing list