[FFmpeg-devel] [PATCH 1/2] avcodec/mpeg12dec: set the coded dimensions with proper alignement

Steve Lhomme robux4 at gmail.com
Wed Mar 22 11:41:36 EET 2017


---
 libavcodec/mpeg12dec.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index e49167f89e..55fcac0cb2 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -1291,12 +1291,11 @@ static int mpeg_decode_postinit(AVCodecContext *avctx)
     }
 
     if ((s1->mpeg_enc_ctx_allocated == 0)                   ||
-        avctx->coded_width       != s->width                ||
-        avctx->coded_height      != s->height               ||
+        avctx->coded_width       != FFALIGN(s->width, 16)   ||
+        avctx->coded_height      != FFALIGN(s->height, s->progressive_sequence ? 16 : 32)  ||
         s1->save_width           != s->width                ||
         s1->save_height          != s->height               ||
         av_cmp_q(s1->save_aspect, s->avctx->sample_aspect_ratio) ||
-        (s1->save_progressive_seq != s->progressive_sequence && FFALIGN(s->height, 16) != FFALIGN(s->height, 32)) ||
         0) {
         if (s1->mpeg_enc_ctx_allocated) {
             ParseContext pc = s->parse_context;
@@ -1310,6 +1309,9 @@ static int mpeg_decode_postinit(AVCodecContext *avctx)
         if (ret < 0)
             return ret;
 
+        avctx->coded_width  = FFALIGN(avctx->coded_width, 16);
+        avctx->coded_height = FFALIGN(avctx->coded_height, s->progressive_sequence ? 16: 32);
+
         if (avctx->codec_id == AV_CODEC_ID_MPEG2VIDEO && s->bit_rate) {
             avctx->rc_max_rate = s->bit_rate;
         } else if (avctx->codec_id == AV_CODEC_ID_MPEG1VIDEO && s->bit_rate &&
-- 
2.11.1



More information about the ffmpeg-devel mailing list