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/libjxldec: consume input on error (PR #20355)
@ 2025-08-27 15:55 Leo Izen via ffmpeg-devel
  0 siblings, 0 replies; only message in thread
From: Leo Izen via ffmpeg-devel @ 2025-08-27 15:55 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Leo Izen

PR #20355 opened by Leo Izen (Traneptora)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20355
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20355.patch

libjxl consumes no input if it returns an error, so this loops over
and over while it spits out the same error many times. If we got an
error from libjxl and consumed no input, then we instead consume the
whole packet.

Signed-off-by: Leo Izen <leo.izen@gmail.com>


>From d808b0fc63506f224182872a78e6d2646e4e177d Mon Sep 17 00:00:00 2001
From: Leo Izen <leo.izen@gmail.com>
Date: Wed, 27 Aug 2025 11:53:23 -0400
Subject: [PATCH] avcodec/libjxldec: consume input on error

libjxl consumes no input if it returns an error, so this loops over
and over while it spits out the same error many times. If we got an
error from libjxl and consumed no input, then we instead consume the
whole packet.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
---
 libavcodec/libjxldec.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/libavcodec/libjxldec.c b/libavcodec/libjxldec.c
index 8ce69015bf..6e42b3bb2c 100644
--- a/libavcodec/libjxldec.c
+++ b/libavcodec/libjxldec.c
@@ -414,12 +414,22 @@ static int libjxl_receive_frame(AVCodecContext *avctx, AVFrame *frame)
          * the number of bytes that it did read
          */
         remaining = JxlDecoderReleaseInput(ctx->decoder);
-        pkt->data += pkt->size - remaining;
+        size_t consumed = pkt->size - remaining;
+        pkt->data += consumed;
         pkt->size = remaining;
 
         switch(jret) {
         case JXL_DEC_ERROR:
             av_log(avctx, AV_LOG_ERROR, "Unknown libjxl decode error\n");
+            if (!consumed) {
+                /*
+                 * we consume all remaining input on error, if nothing was consumed
+                 * this prevents libjxl from consuming nothing forever
+                 * and just dumping the last error over and over
+                 */
+                pkt->data += pkt->size;
+                pkt->size = 0;
+            }
             return AVERROR_INVALIDDATA;
         case JXL_DEC_NEED_MORE_INPUT:
             av_log(avctx, AV_LOG_DEBUG, "NEED_MORE_INPUT event emitted\n");
-- 
2.49.1

_______________________________________________
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-08-27 15:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-08-27 15:55 [FFmpeg-devel] [PATCH] avcodec/libjxldec: consume input on error (PR #20355) Leo Izen 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