]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/mpegvideo: Update chroma_?_shift in ff_mpv_common_frame_size_change()
authorMichael Niedermayer <michael@niedermayer.cc>
Mon, 22 Mar 2021 14:22:35 +0000 (15:22 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Wed, 31 Mar 2021 21:09:35 +0000 (23:09 +0200)
Fixes: out of array access
Fixes: 31201/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPEG4_fuzzer-4627865612189696.fuzz
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/mpegvideo.c

index 988dd18a330acccc9ebf7cf139bab5740c35aed1..728e59195889ae6e833c8d28810898fc76b890ff 100644 (file)
@@ -1069,6 +1069,13 @@ int ff_mpv_common_frame_size_change(MpegEncContext *s)
         (err = av_image_check_size(s->width, s->height, 0, s->avctx)) < 0)
         return err;
 
+    /* set chroma shifts */
+    err = av_pix_fmt_get_chroma_sub_sample(s->avctx->pix_fmt,
+                                           &s->chroma_x_shift,
+                                           &s->chroma_y_shift);
+    if (err < 0)
+        return err;
+
     if ((err = init_context_frame(s)))
         return err;