[FFmpeg-cvslog] mpegvideo: Initialize chroma_*_shift and codec_tag even if the size is 0

Martin Storsjö git at videolan.org
Thu Jan 16 23:26:51 CET 2014


ffmpeg | branch: release/0.10 | Martin Storsjö <martin at martin.st> | Tue Sep 24 12:02:39 2013 +0300| [371659d1ad71cac41732c5d9d7a32ee1cf173c95] | committer: Luca Barbato

mpegvideo: Initialize chroma_*_shift and codec_tag even if the size is 0

This fixes breakage in a few fate tests on certain setups
(that for some reason didn't break on OS X) after the previous
commit (8812a8057). Currently, some video streams are initialized
in ff_MPV_common_init with width/height set at 0 and only changed
to a proper video size with ff_MPV_common_frame_size_change later.

The breakage was diagnosed by Anton Khirnov.

Signed-off-by: Martin Storsjö <martin at martin.st>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=371659d1ad71cac41732c5d9d7a32ee1cf173c95
---

 libavcodec/mpegvideo.c |   18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index fa89886..8df3061 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -696,6 +696,15 @@ av_cold int MPV_common_init(MpegEncContext *s)
     s->flags  = s->avctx->flags;
     s->flags2 = s->avctx->flags2;
 
+    /* set chroma shifts */
+    avcodec_get_chroma_sub_sample(s->avctx->pix_fmt, &s->chroma_x_shift,
+                                  &s->chroma_y_shift);
+
+    /* convert fourcc to upper case */
+    s->codec_tag          = avpriv_toupper4(s->avctx->codec_tag);
+
+    s->stream_codec_tag   = avpriv_toupper4(s->avctx->stream_codec_tag);
+
     if (s->width && s->height) {
         s->mb_width   = (s->width + 15) / 16;
         s->mb_stride  = s->mb_width + 1;
@@ -704,10 +713,6 @@ av_cold int MPV_common_init(MpegEncContext *s)
         mb_array_size = s->mb_height * s->mb_stride;
         mv_table_size = (s->mb_height + 2) * s->mb_stride + 1;
 
-        /* set chroma shifts */
-        avcodec_get_chroma_sub_sample(s->avctx->pix_fmt, &s->chroma_x_shift,
-                                      &s->chroma_y_shift);
-
         /* set default edge pos, will be overriden
          * in decode_header if needed */
         s->h_edge_pos = s->mb_width * 16;
@@ -726,11 +731,6 @@ av_cold int MPV_common_init(MpegEncContext *s)
         c_size  = s->mb_stride * (s->mb_height + 1);
         yc_size = y_size + 2   * c_size;
 
-        /* convert fourcc to upper case */
-        s->codec_tag          = avpriv_toupper4(s->avctx->codec_tag);
-
-        s->stream_codec_tag   = avpriv_toupper4(s->avctx->stream_codec_tag);
-
         s->avctx->coded_frame = (AVFrame *)&s->current_picture;
 
         FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_index2xy, (s->mb_num + 1) * sizeof(int),



More information about the ffmpeg-cvslog mailing list