[FFmpeg-devel] [PATCH 1/1] avcodec/mjpegdec: fix non-subsampled RGB JPEGs

Leo Izen leo.izen at gmail.com
Mon Apr 17 22:29:55 EEST 2023


The change introduced in b18a9c29713abc3a1b081de3f320ab53a47120c6
created a regression for non-subsampled progressive RGB jpegs. This
should fix that.
---
 libavcodec/mjpegdec.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 01537d4774..1e3ddb72fb 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -1698,7 +1698,8 @@ int ff_mjpeg_decode_sos(MJpegDecodeContext *s, const uint8_t *mb_bitmask,
         s->h_scount[i]  = s->h_count[index];
         s->v_scount[i]  = s->v_count[index];
 
-        if(nb_components == 3 && s->nb_components == 3 && s->avctx->pix_fmt == AV_PIX_FMT_GBRP)
+        if((nb_components == 3 || nb_components == 1) && s->nb_components == 3
+                && s->avctx->pix_fmt == AV_PIX_FMT_GBRP && !s->progressive)
             index = (index+2)%3;
 
         s->comp_index[i] = index;
-- 
2.40.0



More information about the ffmpeg-devel mailing list