diff mbox series

[FFmpeg-devel] lavc/mjpegdec: Support pixel format 0x11412100

Message ID CAB0OVGqdim_-MK8Z8Ly=OddkCqEBAwfo_fOWigVaR-Bi1WEMRQ@mail.gmail.com
State New
Headers show
Series [FFmpeg-devel] lavc/mjpegdec: Support pixel format 0x11412100
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Carl Eugen Hoyos March 27, 2021, 11:35 p.m. UTC
Hi!

Attached patch fixes decoding of a sample mentioned in ticket #8930.

Please comment, Carl Eugen
Subject: [PATCH] lavc/mjpegdec: Support pixel format 0x11412100.

Fixes decoding of Nene421-rgb.jpg
---
 libavcodec/mjpegdec.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
diff mbox series

Patch

diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 5583d2aa35..3731b2fa1b 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -603,6 +603,19 @@  int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
                 s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
             }
             break;
+        case 0x11412100:
+            if (s->bits > 8)
+                goto unk_pixfmt;
+            if (s->component_id[0] == 'R' - 1 && s->component_id[1] == 'G' - 1 && s->component_id[2] == 'B' - 1) {
+                s->avctx->pix_fmt = AV_PIX_FMT_GBRP;
+                s->upscale_h[0] = 0;
+                s->upscale_h[1] = 1;
+                s->upscale_h[2] = 4;
+            } else {
+                goto unk_pixfmt;
+            }
+            s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
+            break;
         case 0x21111100:
             if (s->component_id[0] == 'Q' && s->component_id[1] == 'F' && s->component_id[2] == 'A') {
                 if (s->bits <= 8) s->avctx->pix_fmt = AV_PIX_FMT_GBRP;
@@ -2696,6 +2709,12 @@  the_end:
                     for (index = w - 3; index > 0; index--) {
                         line[index] = (line[index / 3] + line[(index + 1) / 3] + line[(index + 2) / 3] + 1) / 3;
                     }
+                } else if (s->upscale_h[p] == 4 && w >= 4 && !is16bit){
+                    line [w - 1] = line [w - 1 >> 2];
+                    line [w - 2] = line [w - 1 >> 2] * 3 + line [w - 2 >> 2] >> 2;
+                    line [w - 3] = line [w - 1 >> 2] + line [w - 2 >> 2] >> 1;
+                    for (index = w - 4; index > 0; index--)
+                        line[index] = (line[index + 3 >> 2] + line[index + 2 >> 2] + line[index + 1 >> 2] + line[index >> 2]) >> 2;
                 }
                 line += s->linesize[p];
             }