diff mbox series

[FFmpeg-devel] avcodec/mjpegdec: add support for decoding jpeg rgb file with subsampling

Message ID ME3PR01MB56246FF97C049257887E5368DA8A9@ME3PR01MB5624.ausprd01.prod.outlook.com
State New
Headers show
Series [FFmpeg-devel] avcodec/mjpegdec: add support for decoding jpeg rgb file with subsampling | expand

Checks

Context Check Description
andriy/configure_x86 warning Failed to apply patch

Commit Message

Wang Chuan March 26, 2023, 2:13 a.m. UTC
Fixes ticket #10190

Signed-off-by: Wang Chuan <ouchuanm@outlook.com>
---
  libavcodec/mjpegdec.c | 21 +++++++++++++++++++++
  1 file changed, 21 insertions(+)

AVCOL_RANGE_JPEG;
              break;
          case 0x11000000:

Comments

Leo Izen March 26, 2023, 11:28 a.m. UTC | #1
On 3/25/23 22:13, Wang Chuan wrote:
> Fixes ticket #10190
> 
> Signed-off-by: Wang Chuan <ouchuanm@outlook.com>
> ---
>   libavcodec/mjpegdec.c | 21 +++++++++++++++++++++
>   1 file changed, 21 insertions(+)
> 
> diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
> index c833d66c4d..aa58f336d4 100644
> --- a/libavcodec/mjpegdec.c
> +++ b/libavcodec/mjpegdec.c
> @@ -574,6 +574,27 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
>               if (s->bits <= 8) s->avctx->pix_fmt = s->cs_itu601 ? 
> AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P;
>               else
>                   goto unk_pixfmt;
> +            if (s->component_id[0] == 'R' && s->component_id[1] == 'G' 
> && s->component_id[2] == 'B') {
> +                if (s->bits <= 8)
> +                    s->avctx->pix_fmt = AV_PIX_FMT_GBRP;
> +                else
> +                    goto unk_pixfmt;
> +                if (pix_fmt_id == 0x22221100) {
> +                    s->upscale_h[0] = s->upscale_v[0] = 0;
> +                    s->upscale_h[1] = s->upscale_v[1] = 1;
> +                    s->upscale_h[2] = s->upscale_v[2] = 0;
> +                } else if (pix_fmt_id == 0x22112200) {
> +                    s->upscale_h[0] = s->upscale_v[0] = 1;
> +                    s->upscale_h[1] = s->upscale_v[1] = 0;
> +                    s->upscale_h[2] = s->upscale_v[2] = 0;
> +                } else if (pix_fmt_id == 0x11222200) {
> +                    s->upscale_h[0] = s->upscale_v[0] = 0;
> +                    s->upscale_h[1] = s->upscale_v[1] = 0;
> +                    s->upscale_h[2] = s->upscale_v[2] = 1;
> +                } else {
> +                    goto unk_pixfmt;
> +                }
> +            }
>               s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : 
> AVCOL_RANGE_JPEG;
>               break;
>           case 0x11000000:

This doesn't work with progressive JPEGs, which still produce the 
"patches welcome" message.

FWIW I already have a patch on the ML to fix this exact issue.

- Leo Izen (thebombzen)
Wang Chuan March 27, 2023, 6:06 a.m. UTC | #2
Ok, thx for your reminder:)

I hadn't noticed your patch that time

On 3/26/2023 7:28 PM, Leo Izen wrote:
> On 3/25/23 22:13, Wang Chuan wrote:
>> Fixes ticket #10190
>>
>> Signed-off-by: Wang Chuan <ouchuanm@outlook.com>
>> ---
>>   libavcodec/mjpegdec.c | 21 +++++++++++++++++++++
>>   1 file changed, 21 insertions(+)
>>
>> diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
>> index c833d66c4d..aa58f336d4 100644
>> --- a/libavcodec/mjpegdec.c
>> +++ b/libavcodec/mjpegdec.c
>> @@ -574,6 +574,27 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
>>               if (s->bits <= 8) s->avctx->pix_fmt = s->cs_itu601 ? 
>> AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P;
>>               else
>>                   goto unk_pixfmt;
>> +            if (s->component_id[0] == 'R' && s->component_id[1] == 
>> 'G' && s->component_id[2] == 'B') {
>> +                if (s->bits <= 8)
>> +                    s->avctx->pix_fmt = AV_PIX_FMT_GBRP;
>> +                else
>> +                    goto unk_pixfmt;
>> +                if (pix_fmt_id == 0x22221100) {
>> +                    s->upscale_h[0] = s->upscale_v[0] = 0;
>> +                    s->upscale_h[1] = s->upscale_v[1] = 1;
>> +                    s->upscale_h[2] = s->upscale_v[2] = 0;
>> +                } else if (pix_fmt_id == 0x22112200) {
>> +                    s->upscale_h[0] = s->upscale_v[0] = 1;
>> +                    s->upscale_h[1] = s->upscale_v[1] = 0;
>> +                    s->upscale_h[2] = s->upscale_v[2] = 0;
>> +                } else if (pix_fmt_id == 0x11222200) {
>> +                    s->upscale_h[0] = s->upscale_v[0] = 0;
>> +                    s->upscale_h[1] = s->upscale_v[1] = 0;
>> +                    s->upscale_h[2] = s->upscale_v[2] = 1;
>> +                } else {
>> +                    goto unk_pixfmt;
>> +                }
>> +            }
>>               s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG 
>> : AVCOL_RANGE_JPEG;
>>               break;
>>           case 0x11000000:
>
> This doesn't work with progressive JPEGs, which still produce the 
> "patches welcome" message.
>
> FWIW I already have a patch on the ML to fix this exact issue.
>
> - Leo Izen (thebombzen)
>
> _______________________________________________
> 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".
diff mbox series

Patch

diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index c833d66c4d..aa58f336d4 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -574,6 +574,27 @@  int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
              if (s->bits <= 8) s->avctx->pix_fmt = s->cs_itu601 ? 
AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P;
              else
                  goto unk_pixfmt;
+            if (s->component_id[0] == 'R' && s->component_id[1] == 'G' 
&& s->component_id[2] == 'B') {
+                if (s->bits <= 8)
+                    s->avctx->pix_fmt = AV_PIX_FMT_GBRP;
+                else
+                    goto unk_pixfmt;
+                if (pix_fmt_id == 0x22221100) {
+                    s->upscale_h[0] = s->upscale_v[0] = 0;
+                    s->upscale_h[1] = s->upscale_v[1] = 1;
+                    s->upscale_h[2] = s->upscale_v[2] = 0;
+                } else if (pix_fmt_id == 0x22112200) {
+                    s->upscale_h[0] = s->upscale_v[0] = 1;
+                    s->upscale_h[1] = s->upscale_v[1] = 0;
+                    s->upscale_h[2] = s->upscale_v[2] = 0;
+                } else if (pix_fmt_id == 0x11222200) {
+                    s->upscale_h[0] = s->upscale_v[0] = 0;
+                    s->upscale_h[1] = s->upscale_v[1] = 0;
+                    s->upscale_h[2] = s->upscale_v[2] = 1;
+                } else {
+                    goto unk_pixfmt;
+                }
+            }
              s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG :