PR #25392 opened by JuanRomero
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25392
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25392.patch

Fixes #25391.

`ape_read_header()` expects the leading ID3v2 tag to have been skipped by 
`avformat_open_input()` ("Skip any leading junk such as id3v2 tags"), which 
stopped happening for the ape demuxer with 9d037c54f209. This flags the ape 
demuxer with `FF_INFMT_FLAG_ID3V2_AUTO`, like aac, flac, mp3, tta and wav.

Tested on master c4c791c2cd (aarch64, gcc 14.2, Raspberry Pi 4):

- real APE file with a leading ID3v2.3 tag: fails before, opens after; decoded 
audio byte-identical to 7.1.5;
- `fate-suite/lossless-audio/luckynight-mac380-c2000.ape` with a 25-byte ID3v2 
tag prepended: opens, `-f md5` identical to the untagged file;
- the 100 related FATE tests (lossless-monkeysaudio-*, cover-art-ape, id3v2*, 
...) pass before and after;
- full `make fate` with the fate-suite: 5732 tests, all pass.

The issue also lists wv, iff, aiff, caf and asf, which changed behaviour in the 
same way; they are intentionally not touched here (leading ID3v2 is 
non-standard for those formats), pending maintainers' opinion.


>From 0f3df7463fed9cbb95f6cf9330e96bbe5f08d103 Mon Sep 17 00:00:00 2001
From: JuanMRomeroC <[email protected]>
Date: Fri, 23 Oct 2026 08:59:01 -0600
Subject: [PATCH] avformat/ape: restore skipping of a leading ID3v2 tag

Since 9d037c54f209 ("avformat/demux: avoid unconditional ID3v2 tag
consumption"), avformat_open_input() only skips a leading ID3v2 tag for
demuxers flagged with FF_INFMT_FLAG_ID3V2_AUTO. ape_read_header() still
relies on that generic skip ("Skip any leading junk such as id3v2 tags")
and fails with AVERROR_INVALIDDATA when the file starts with an ID3v2
tag, although ape_probe() detects the format with score 100. Such files
open fine up to 8.0.

Flag the ape demuxer with FF_INFMT_FLAG_ID3V2_AUTO, as was done for the
aac, flac, mp3, tta and wav demuxers.

Fixes: #25391
Signed-off-by: JuanMRomeroC <[email protected]>
---
 libavformat/ape.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/ape.c b/libavformat/ape.c
index 3bf359cb1ff..ebfe80e091e 100644
--- a/libavformat/ape.c
+++ b/libavformat/ape.c
@@ -450,7 +450,7 @@ const FFInputFormat ff_ape_demuxer = {
     .p.long_name    = NULL_IF_CONFIG_SMALL("Monkey's Audio"),
     .p.extensions   = "ape,apl,mac",
     .priv_data_size = sizeof(APEContext),
-    .flags_internal = FF_INFMT_FLAG_INIT_CLEANUP,
+    .flags_internal = FF_INFMT_FLAG_INIT_CLEANUP | FF_INFMT_FLAG_ID3V2_AUTO,
     .read_probe     = ape_probe,
     .read_header    = ape_read_header,
     .read_packet    = ape_read_packet,
-- 
2.54.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to