aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/mjpegdec.c
diff options
context:
space:
mode:
authorLeo Izen <leo.izen@gmail.com>2023-04-13 08:45:06 -0400
committerLeo Izen <leo.izen@gmail.com>2023-04-17 10:44:31 -0400
commitc3625ccfcd74bacff2ec6764dea8ef2beb5e9ef7 (patch)
tree4ba7b2705c503e7a381c5f010951ff4f9c94ac46 /libavcodec/mjpegdec.c
parent0b0fa5c2a82d3b89d921f2808bc5f23a2e8e98aa (diff)
downloadffmpeg-c3625ccfcd74bacff2ec6764dea8ef2beb5e9ef7.tar.gz
avcodec/mjpegdec: fix regression with baseline RGB JPEGs
Commit b18a9c29713abc3a1b081de3f320ab53a47120c6 introduced a regression that broke some baseline RGB jpegs. (See Trac issue #4045). This fixes that. Signed-off-by: Leo Izen <leo.izen@gmail.com>
Diffstat (limited to 'libavcodec/mjpegdec.c')
-rw-r--r--libavcodec/mjpegdec.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 3fc18aac73..01537d4774 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -1698,6 +1698,9 @@ 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)
+ index = (index+2)%3;
+
s->comp_index[i] = index;
s->dc_index[i] = get_bits(&s->gb, 4);
@@ -2721,7 +2724,7 @@ the_end:
}
}
- if (s->avctx->pix_fmt == AV_PIX_FMT_GBRP) {
+ if (s->avctx->pix_fmt == AV_PIX_FMT_GBRP && s->progressive) {
av_assert0(s->nb_components == 3);
FFSWAP(uint8_t *, frame->data[0], frame->data[2]);
FFSWAP(uint8_t *, frame->data[0], frame->data[1]);