diff mbox series

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

Message ID 20230417192955.25912-2-leo.izen@gmail.com
State New
Headers show
Series RGB mjpeg fixes | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Leo Izen April 17, 2023, 7:29 p.m. UTC
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 mbox series

Patch

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;