[FFmpeg-cvslog] mpeg12enc: check dimension validity

Michael Niedermayer git at videolan.org
Sun Jan 20 04:39:53 CET 2013


ffmpeg | branch: release/1.0 | Michael Niedermayer <michaelni at gmx.at> | Mon Jan  7 15:47:21 2013 +0100| [95f8701c32d8737afe5185e6b2f0fc54d976719f] | committer: Michael Niedermayer

mpeg12enc: check dimension validity

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
(cherry picked from commit 7fb87bc5f24b1be13269109506c05e4c54695b5e)

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

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

 libavcodec/mpeg12enc.c |   13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index 9726a30..9e31543 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -167,6 +167,19 @@ static av_cold int encode_init(AVCodecContext *avctx)
         }
     }
 
+    if ((avctx->width & 0xFFF) == 0 && (avctx->height & 0xFFF) == 1) {
+        av_log(avctx, AV_LOG_ERROR, "Width / Height is invalid for MPEG2\n");
+        return AVERROR(EINVAL);
+    }
+
+    if (s->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL) {
+        if ((avctx->width & 0xFFF) == 0 || (avctx->height & 0xFFF) == 0) {
+            av_log(avctx, AV_LOG_ERROR, "Width or Height are not allowed to be multiplies of 4096\n"
+                                        "add '-strict %d' if you want to use them anyway.\n", FF_COMPLIANCE_UNOFFICIAL);
+            return AVERROR(EINVAL);
+        }
+    }
+
     s->drop_frame_timecode = s->drop_frame_timecode || !!(avctx->flags2 & CODEC_FLAG2_DROP_FRAME_TIMECODE);
     if (s->drop_frame_timecode)
         s->tc.flags |= AV_TIMECODE_FLAG_DROPFRAME;



More information about the ffmpeg-cvslog mailing list