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] avcodec/mjpegdec: skip scan copy and marker hunt for hwaccel
@ 2025-12-08 23:24 omar via ffmpeg-devel
  0 siblings, 0 replies; only message in thread
From: omar via ffmpeg-devel @ 2025-12-08 23:24 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: omar

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

diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 4d7cdfde12..4f65e329b7 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -2221,6 +2221,13 @@ int ff_mjpeg_find_marker(MJpegDecodeContext *s,
     int start_code;
     start_code = find_marker(buf_ptr, buf_end);
 
+    /* for hardware decoders we can just hand the raw scan to the accelerator */
+    if (s->avctx->hwaccel) {
+        *unescaped_buf_ptr  = *buf_ptr;
+        *unescaped_buf_size = buf_end - *buf_ptr;
+        return start_code;
+    }
+
     av_fast_padded_malloc(&s->buffer, &s->buffer_size, buf_end - *buf_ptr);
     if (!s->buffer)
         return AVERROR(ENOMEM);
@@ -2560,6 +2567,12 @@ eoi_parser:
             if ((ret = ff_mjpeg_decode_sos(s, NULL, 0, NULL)) < 0 &&
                 (avctx->err_recognition & AV_EF_EXPLODE))
                 goto fail;
+
+            /* hardware decoders consume the raw scan directly */
+            if (avctx->hwaccel) {
+                buf_ptr = buf_end;
+                goto eoi_parser;
+            }
             break;
         case DRI:
             if ((ret = mjpeg_decode_dri(s)) < 0)
-- 
2.51.2

_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-12-11  3:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-08 23:24 [FFmpeg-devel] [PATCH] avcodec/mjpegdec: skip scan copy and marker hunt for hwaccel omar via ffmpeg-devel

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