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

Leo Izen leo.izen at gmail.com
Wed Apr 19 21:11:25 EEST 2023


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 --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;
-- 
2.40.0



More information about the ffmpeg-devel mailing list