From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 3F8A24CEAC for ; Mon, 11 Aug 2025 16:58:09 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 137E368CBF0; Mon, 11 Aug 2025 19:58:06 +0300 (EEST) Received: from 472d2aa5cb20 (code.ffmpeg.org [188.245.149.3]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id 7F39068C6B2 for ; Mon, 11 Aug 2025 19:58:04 +0300 (EEST) MIME-Version: 1.0 From: ramiro To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] =?utf-8?q?=5BPATCH=5D_avcodec/mjpegdec=3A_decode_?= =?utf-8?q?only_SOF_fields_when_finding_stream_info_=28PR_=2320219=29?= X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Message-Id: <20250811165806.137E368CBF0@ffbox0-bg.ffmpeg.org> Date: Mon, 11 Aug 2025 19:58:06 +0300 (EEST) Archived-At: List-Archive: List-Post: PR #20219 opened by ramiro URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20219 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20219.patch When called from avformat_find_stream_info(), we are only interested in decoding SOF fields. This patch makes the decoder skip all other fields (including SOI, SOS, and EOI). This also prevents the decoder from incorrectly printing the warning "EOI missing, emulating" (which is the case since 2ae82788). Fixes: #20119 >From 5d7f8d5ec2e7e5c439ae6efcf4aa1db3520bcc4b Mon Sep 17 00:00:00 2001 From: Ramiro Polla Date: Mon, 11 Aug 2025 18:32:45 +0200 Subject: [PATCH] avcodec/mjpegdec: decode only SOF fields when finding stream info When called from avformat_find_stream_info(), we are only interested in decoding SOF fields. This patch makes the decoder skip all other fields (including SOI, SOS, and EOI). This also prevents the decoder from incorrectly printing the warning "EOI missing, emulating" (which is the case since 2ae82788). Fixes: #20119 --- libavcodec/mjpegdec.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index 15a4ebc7f1..87d1d02077 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -2463,9 +2463,6 @@ redo_for_pal8: case SOF2: case SOF3: case SOF48: - case SOI: - case SOS: - case EOI: break; default: goto skip; @@ -2541,7 +2538,7 @@ FF_ENABLE_DEPRECATION_WARNINGS break; case EOI: eoi_parser: - if (!avctx->hwaccel && avctx->skip_frame != AVDISCARD_ALL && + if (!avctx->hwaccel && s->progressive && s->cur_scan && s->got_picture) mjpeg_idct_scan_progressive_ac(s); s->cur_scan = 0; @@ -2556,10 +2553,6 @@ eoi_parser: if (s->bottom_field == !s->interlace_polarity) break; } - if (avctx->skip_frame == AVDISCARD_ALL) { - s->got_picture = 0; - goto the_end_no_picture; - } if (avctx->hwaccel) { ret = FF_HW_SIMPLE_CALL(avctx, end_frame); if (ret < 0) @@ -2588,10 +2581,6 @@ eoi_parser: s->raw_scan_buffer_size = buf_end - buf_ptr; s->cur_scan++; - if (avctx->skip_frame == AVDISCARD_ALL) { - skip_bits(&s->gb, get_bits_left(&s->gb)); - break; - } if ((ret = ff_mjpeg_decode_sos(s, NULL, 0, NULL)) < 0 && (avctx->err_recognition & AV_EF_EXPLODE)) @@ -2616,6 +2605,18 @@ eoi_parser: break; } + if (avctx->skip_frame == AVDISCARD_ALL) { + switch(start_code) { + case SOF0: + case SOF1: + case SOF2: + case SOF3: + case SOF48: + s->got_picture = 0; + goto the_end_no_picture; + } + } + skip: /* eof process start code */ buf_ptr += (get_bits_count(&s->gb) + 7) / 8; -- 2.49.1 _______________________________________________ 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".