diff mbox series

[FFmpeg-devel,v3,2/3] avcodec/mjpeg: fix weird RGB-subsampled baseline JPEGs

Message ID 20230419181126.38662-3-leo.izen@gmail.com
State New
Headers show
Series RGB mjpeg fixes (with FATE tests) | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Leo Izen April 19, 2023, 6:11 p.m. UTC
These were broken before any of the recent RGB JPEG commits. This is an
additional fix to bring them in line with the rest of the RGB jpegs,
which should now all work after the previous patch.

Fixes #10190.
---
 libavcodec/mjpegdec.c | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox series

Patch

diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 1e3ddb72fb..330c5da5a8 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -576,6 +576,12 @@  int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
             if (s->adobe_transform == 0 || s->component_id[0] == 'R' &&
                     s->component_id[1] == 'G' && s->component_id[2] == 'B') {
                 s->avctx->pix_fmt = AV_PIX_FMT_GBRP;
+                if (!s->progressive) {
+                    for (int i = 0; i < 2; i++) {
+                        FFSWAP(int, s->upscale_h[i], s->upscale_h[(i + 2) % 3]);
+                        FFSWAP(int, s->upscale_v[i], s->upscale_v[(i + 2) % 3]);
+                    }
+                }
             } else {
                 s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P;
                 s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;