diff mbox series

[FFmpeg-devel] mjpegdec: handle lowres with AVID cropping

Message ID 20210301091313.330-1-anton@khirnov.net
State Accepted
Commit 2f004b357e6709083f741c6ed0f5a82d81784ac8
Headers show
Series [FFmpeg-devel] mjpegdec: handle lowres with AVID cropping | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Anton Khirnov March 1, 2021, 9:13 a.m. UTC
---
 libavcodec/mjpegdec.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

Comments

James Almer March 2, 2021, 8:20 p.m. UTC | #1
On 3/1/2021 6:13 AM, Anton Khirnov wrote:
> ---
>   libavcodec/mjpegdec.c | 14 +++++++-------
>   1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
> index 79c7d6e6cf..20f310fd70 100644
> --- a/libavcodec/mjpegdec.c
> +++ b/libavcodec/mjpegdec.c
> @@ -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;

Seems to work, so LGTM.
diff mbox series

Patch

diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 79c7d6e6cf..20f310fd70 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -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;