Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 0/1] More mjpeg pixel formats
@ 2023-04-23 22:21 Leo Izen
  2023-04-23 22:21 ` [FFmpeg-devel] [PATCH 1/1] avcodec/mjpegdec: support more " Leo Izen
  0 siblings, 1 reply; 4+ messages in thread
From: Leo Izen @ 2023-04-23 22:21 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: ceffmpeg, Leo Izen

Carl Eugen wrote some patches about 2 years ago and sent them
to the ML to add support for various files found in ticket #8930.
I've rebased those patches into one, and rebased them onto master
as well as made a few minor tweaks to them.

Fate test for these incoming soon as well.

Carl Eugen Hoyos (1):
  avcodec/mjpegdec: support more pixel formats

 libavcodec/mjpegdec.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

-- 
2.40.0

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [FFmpeg-devel] [PATCH 1/1] avcodec/mjpegdec: support more pixel formats
  2023-04-23 22:21 [FFmpeg-devel] [PATCH 0/1] More mjpeg pixel formats Leo Izen
@ 2023-04-23 22:21 ` Leo Izen
  2023-04-24 15:57   ` Michael Niedermayer
  0 siblings, 1 reply; 4+ messages in thread
From: Leo Izen @ 2023-04-23 22:21 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: ceffmpeg, leo.izen

From: Carl Eugen Hoyos <ceffmpeg@gmail.com>

Support pixel formats 0x11412100, 0x11311100, and 0x41211100, and add
logic to perform 4x horizontal upsampling. This should fix various JPEG
files found in Ticket #8930.

Co-authored-by: <leo.izen@gmail.com>
---
 libavcodec/mjpegdec.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 9b55002c4b..72d654080d 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -545,6 +545,18 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
             }
             av_assert0(s->nb_components == 4);
             break;
+        case 0x11412100:
+            if (s->bits > 8)
+                goto unk_pixfmt;
+            if (s->component_id[0] == 'R' && s->component_id[1] == 'G' && s->component_id[2] == 'B') {
+                s->avctx->pix_fmt = AV_PIX_FMT_GBRP;
+                s->upscale_h[0] = 4;
+                s->upscale_h[1] = 0;
+                s->upscale_h[2] = 1;
+            } else {
+                goto unk_pixfmt;
+            }
+            break;
         case 0x22111122:
         case 0x22111111:
             if (s->adobe_transform == 0 && s->bits <= 8) {
@@ -626,6 +638,15 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
                 s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
             }
             break;
+        case 0x11311100:
+            if (s->bits > 8)
+                goto unk_pixfmt;
+            if (s->component_id[0] == 'R' && s->component_id[1] == 'G' && s->component_id[2] == 'B')
+                s->avctx->pix_fmt = AV_PIX_FMT_GBRP;
+            else
+                goto unk_pixfmt;
+            s->upscale_h[0] = s->upscale_h[2] = 2;
+            break;
         case 0x31111100:
             if (s->bits > 8)
                 goto unk_pixfmt;
@@ -635,6 +656,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
             break;
         case 0x22121100:
         case 0x22111200:
+        case 0x41211100:
             if (s->bits <= 8) s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV422P : AV_PIX_FMT_YUVJ422P;
             else
                 goto unk_pixfmt;
@@ -2605,6 +2627,8 @@ the_end:
                    avctx->pix_fmt == AV_PIX_FMT_YUVJ440P ||
                    avctx->pix_fmt == AV_PIX_FMT_YUV440P  ||
                    avctx->pix_fmt == AV_PIX_FMT_YUVA444P ||
+                   avctx->pix_fmt == AV_PIX_FMT_YUVJ422P ||
+                   avctx->pix_fmt == AV_PIX_FMT_YUV422P  ||
                    avctx->pix_fmt == AV_PIX_FMT_YUVJ420P ||
                    avctx->pix_fmt == AV_PIX_FMT_YUV420P  ||
                    avctx->pix_fmt == AV_PIX_FMT_YUV420P16||
@@ -2654,6 +2678,24 @@ 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){
+                    if (is16bit) {
+                        uint16_t *line16 = (uint16_t *) line;
+                        line16[w - 1] = line16[(w - 1) >> 2];
+                        if (w > 1)
+                            line16[w - 2] = (line16[(w - 1) >> 2] * 3 + line16[(w - 2) >> 2]) >> 2;
+                        if (w > 2)
+                            line16[w - 3] = (line16[(w - 1) >> 2] + line16[(w - 2) >> 2]) >> 1;
+                    } else {
+                        line[w - 1] = line[(w - 1) >> 2];
+                        if (w > 1)
+                            line[w - 2] = (line[(w - 1) >> 2] * 3 + line[(w - 2) >> 2]) >> 2;
+                        if (w > 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];
             }
-- 
2.40.0

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/1] avcodec/mjpegdec: support more pixel formats
  2023-04-23 22:21 ` [FFmpeg-devel] [PATCH 1/1] avcodec/mjpegdec: support more " Leo Izen
@ 2023-04-24 15:57   ` Michael Niedermayer
  2023-04-24 20:24     ` Leo Izen
  0 siblings, 1 reply; 4+ messages in thread
From: Michael Niedermayer @ 2023-04-24 15:57 UTC (permalink / raw)
  To: FFmpeg development discussions and patches


[-- Attachment #1.1: Type: text/plain, Size: 650 bytes --]

On Sun, Apr 23, 2023 at 06:21:06PM -0400, Leo Izen wrote:
> From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
> 
> Support pixel formats 0x11412100, 0x11311100, and 0x41211100, and add
> logic to perform 4x horizontal upsampling. This should fix various JPEG
> files found in Ticket #8930.
> 
> Co-authored-by: <leo.izen@gmail.com>
> ---
>  libavcodec/mjpegdec.c | 42 ++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 42 insertions(+)

should be ok

thx

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

In a rich man's house there is no place to spit but his face.
-- Diogenes of Sinope

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

[-- Attachment #2: Type: text/plain, Size: 251 bytes --]

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/1] avcodec/mjpegdec: support more pixel formats
  2023-04-24 15:57   ` Michael Niedermayer
@ 2023-04-24 20:24     ` Leo Izen
  0 siblings, 0 replies; 4+ messages in thread
From: Leo Izen @ 2023-04-24 20:24 UTC (permalink / raw)
  To: ffmpeg-devel

On 4/24/23 11:57, Michael Niedermayer wrote:
> On Sun, Apr 23, 2023 at 06:21:06PM -0400, Leo Izen wrote:
>> From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
>>
>> Support pixel formats 0x11412100, 0x11311100, and 0x41211100, and add
>> logic to perform 4x horizontal upsampling. This should fix various JPEG
>> files found in Ticket #8930.
>>
>> Co-authored-by: <leo.izen@gmail.com>
>> ---
>>   libavcodec/mjpegdec.c | 42 ++++++++++++++++++++++++++++++++++++++++++
>>   1 file changed, 42 insertions(+)
> 
> should be ok
> 
> thx
> 
Thanks, applied. I'll send another patch with the fate tests when 
samples are uploaded

- Leo Izen (Traneptora / 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".

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-04-24 20:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-23 22:21 [FFmpeg-devel] [PATCH 0/1] More mjpeg pixel formats Leo Izen
2023-04-23 22:21 ` [FFmpeg-devel] [PATCH 1/1] avcodec/mjpegdec: support more " Leo Izen
2023-04-24 15:57   ` Michael Niedermayer
2023-04-24 20:24     ` Leo Izen

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git