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

Submitted by Steve Lhomme on March 22, 2017, 9:41 a.m.

Details

Message ID 20170322094137.8108-1-robux4@gmail.com
State New
Headers show

Commit Message

Steve Lhomme March 22, 2017, 9:41 a.m.
---
 libavcodec/mpeg12dec.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

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 &&