]> git.sesse.net Git - ffmpeg/commitdiff
mjpegdec: handle lowres with AVID cropping
authorAnton Khirnov <anton@khirnov.net>
Mon, 1 Mar 2021 09:10:54 +0000 (10:10 +0100)
committerAnton Khirnov <anton@khirnov.net>
Mon, 8 Mar 2021 08:29:50 +0000 (09:29 +0100)
libavcodec/mjpegdec.c

index 79c7d6e6cfe3872fa8bed79c1b97c76d4533eb18..20f310fd700d74ee15a766ff41adc5ddb991f130 100644 (file)
@@ -445,16 +445,16 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
         if (ret < 0)
             return ret;
 
+        if ((s->avctx->codec_tag == MKTAG('A', 'V', 'R', 'n') ||
+             s->avctx->codec_tag == MKTAG('A', 'V', 'D', 'J')) &&
+            s->orig_height < height)
+            s->avctx->height = AV_CEIL_RSHIFT(s->orig_height, s->avctx->lowres);
+
         s->first_picture = 0;
     } else {
         size_change = 0;
     }
 
-    if ((s->avctx->codec_tag == MKTAG('A', 'V', 'R', 'n') ||
-         s->avctx->codec_tag == MKTAG('A', 'V', 'D', 'J')) &&
-        s->orig_height < s->avctx->height)
-        s->avctx->height = s->orig_height;
-
     if (s->avctx->codec_id == AV_CODEC_ID_SMVJPEG) {
         s->avctx->height = s->avctx->coded_height / s->smv_frames_per_jpeg;
         if (s->avctx->height <= 0)
@@ -2863,8 +2863,8 @@ the_end:
     if ((avctx->codec_tag == MKTAG('A', 'V', 'R', 'n') ||
          avctx->codec_tag == MKTAG('A', 'V', 'D', 'J')) &&
         avctx->coded_height > s->orig_height) {
-        frame->height   = avctx->coded_height;
-        frame->crop_top = frame->height - s->orig_height;
+        frame->height   = AV_CEIL_RSHIFT(avctx->coded_height, avctx->lowres);
+        frame->crop_top = frame->height - avctx->height;
     }
 
     ret = 0;