]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/mpegvideo_enc: Don't segfault on unorthodox mpeg_quant
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>
Tue, 6 Apr 2021 13:45:42 +0000 (15:45 +0200)
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>
Thu, 8 Apr 2021 09:32:33 +0000 (11:32 +0200)
The (deprecated) field AVCodecContext.mpeg_quant has no range
restriction; MpegEncContext.mpeg_quant is restricted to 0..1.
If the former is set, the latter is overwritten with it without
checking the range. This can trigger an av_assert2() with the MPEG-4
encoder when writing said field.

Fix this by just setting MpegEncContext.mpeg_quant to 1 if
AVCodecContext.mpeg_quant is set.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
libavcodec/mpegvideo_enc.c

index 79c4071bad89db473ef3856b2f3ce87082a9ef4c..651b1b5325e8600701e4664c104dccb4287b1800 100644 (file)
@@ -627,7 +627,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 #if FF_API_PRIVATE_OPT
     FF_DISABLE_DEPRECATION_WARNINGS
     if (avctx->mpeg_quant)
-        s->mpeg_quant = avctx->mpeg_quant;
+        s->mpeg_quant = 1;
     FF_ENABLE_DEPRECATION_WARNINGS
 #endif