diff mbox series

[FFmpeg-devel] avcodec/mjpegdec: fix regression with baseline RGB JPEGs

Message ID 20230413124506.14319-1-leo.izen@gmail.com
State Accepted
Commit c3625ccfcd74bacff2ec6764dea8ef2beb5e9ef7
Headers show
Series [FFmpeg-devel] avcodec/mjpegdec: fix regression with baseline RGB JPEGs | 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 13, 2023, 12:45 p.m. UTC
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>
---
 libavcodec/mjpegdec.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Leo Izen April 17, 2023, 2:47 p.m. UTC | #1
On 4/13/23 08:45, Leo Izen wrote:
> 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>
> ---

Pushed as c3625ccfcd74bacff2ec6764dea8ef2beb5e9ef7.

- Leo Izen (Traneptora / thebombzen)
Michael Niedermayer April 19, 2023, 6:30 p.m. UTC | #2
On Thu, Apr 13, 2023 at 08:45:06AM -0400, Leo Izen wrote:
> 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>
> ---
>  libavcodec/mjpegdec.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)

Breaks:
./ffplay tickets/1651/prog_rgb_2.jpg


[...]
Michael Niedermayer April 19, 2023, 6:33 p.m. UTC | #3
On Wed, Apr 19, 2023 at 08:30:13PM +0200, Michael Niedermayer wrote:
> On Thu, Apr 13, 2023 at 08:45:06AM -0400, Leo Izen wrote:
> > 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>
> > ---
> >  libavcodec/mjpegdec.c | 5 ++++-
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> Breaks:
> ./ffplay tickets/1651/prog_rgb_2.jpg

also this:
tickets/850/sequential_RGB_24bpp.jpg

[...]
Leo Izen April 19, 2023, 7:36 p.m. UTC | #4
On 4/19/23 14:33, Michael Niedermayer wrote:
> On Wed, Apr 19, 2023 at 08:30:13PM +0200, Michael Niedermayer wrote:
>> On Thu, Apr 13, 2023 at 08:45:06AM -0400, Leo Izen wrote:
>>> 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>
>>> ---
>>>   libavcodec/mjpegdec.c | 5 ++++-
>>>   1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> Breaks:
>> ./ffplay tickets/1651/prog_rgb_2.jpg
> 
> also this:
> tickets/850/sequential_RGB_24bpp.jpg
> 
> [...]
> 
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

I tested both of these against the patch v3 sent earlier today and both 
work with that.

- Leo Izen (Traneptora / thebombzen)
diff mbox series

Patch

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]);