Commit a58779b2e7 for ffmpeg
commit a58779b2e7f6ec18f0eaa81eadb9c88eef0bd962
Author: Wojciech Dzierżanowski <wdzierzanowski@opera.com>
Date: Wed Oct 14 10:28:15 2026 +0200
avformat/aacdec: mark ADTS packets as keyframes
Since 40bd6d8355 ("avcodec/codec_desc: remove Intra Only prop for
AAC") removed AV_CODEC_PROP_INTRA_ONLY from AAC, compute_pkt_fields()
in libavformat/demux.c no longer sets AV_PKT_FLAG_KEY on packets
produced by AAC demuxers.
64bb91fd3b ("avcodec/aac_parser: set key_frame and profile") restored
this at the packet level for builds that use the AAC parser, and
faea08b722 ("avcodec/aac/aacdec: set keyframe flag in output frames")
together with 281b7fc02e ("avcodec/libfdk-aacdec: set keyframe flag
and profile in output frames") did the same for decoder output frames.
None of these help the ADTS demuxer's own packets when no parser is
involved, e.g. in a build configured with --disable-parser=aac, or
when demuxing with -fflags +noparse.
Without the keyframe flag, the generic index is never populated, so
seeking in raw ADTS streams fails, and ffmpeg -c copy discards every
packet as a leading non-keyframe.
This change restores the keyframe flag directly within the ADTS demuxer
so that packet-level keyframe information is available even when the
AAC parser is not used. We can flag every packet unconditionally here:
xHE-AAC is not among the profiles possible in an ADTS stream.
Add fate-adts-noparse-demux, which demuxes with -fflags +noparse to
reach this code path directly, since a build with the AAC parser
enabled otherwise masks the bug.
diff --git a/libavformat/aacdec.c b/libavformat/aacdec.c
index 7968e52c3a..7873a97336 100644
--- a/libavformat/aacdec.c
+++ b/libavformat/aacdec.c
@@ -201,6 +201,8 @@ retry:
return AVERROR_INVALIDDATA;
ret = av_append_packet(s->pb, pkt, fsize - pkt->size);
+ if (ret >= 0)
+ pkt->flags |= AV_PKT_FLAG_KEY;
return ret;
}
diff --git a/tests/fate/demux.mak b/tests/fate/demux.mak
index 1b6da35cdb..44d9ab5f9d 100644
--- a/tests/fate/demux.mak
+++ b/tests/fate/demux.mak
@@ -7,6 +7,9 @@ fate-adts-id3v1-demux: CMD = framecrc -f aac -i $(TARGET_SAMPLES)/aac/id3v1.aac
fate-adts-id3v2-demux: CMD = framecrc -f aac -i $(TARGET_SAMPLES)/aac/id3v2.aac -c:a copy
fate-adts-id3v2-two-tags-demux: CMD = framecrc -i $(TARGET_SAMPLES)/aac/id3v2_two_tags.aac -c:a copy
+FATE_FFPROBE_DEMUX-$(call DEMDEC, AAC, AAC) += fate-adts-noparse-demux
+fate-adts-noparse-demux: CMD = ffprobe_demux $(TARGET_SAMPLES)/aac/id3v1.aac -f aac -fflags +noparse
+
FATE_SAMPLES_DEMUX-$(call FRAMECRC, AA,, SIPR_PARSER) += fate-aa-demux
fate-aa-demux: CMD = framecrc -i $(TARGET_SAMPLES)/aa/bush.aa -c:a copy
diff --git a/tests/ref/fate/adts-noparse-demux b/tests/ref/fate/adts-noparse-demux
new file mode 100644
index 0000000000..67c77ff27d
--- /dev/null
+++ b/tests/ref/fate/adts-noparse-demux
@@ -0,0 +1,7 @@
+packet|codec_type=audio|stream_index=0|pts=0|pts_time=0.000000|dts=0|dts_time=0.000000|duration=602112|duration_time=0.021333|size=474|pos=253|flags=K__|data_hash=CRC32:f2ac1b7c
+packet|codec_type=audio|stream_index=0|pts=602112|pts_time=0.021333|dts=602112|dts_time=0.021333|duration=602112|duration_time=0.021333|size=471|pos=727|flags=K__|data_hash=CRC32:61143e35
+packet|codec_type=audio|stream_index=0|pts=1204224|pts_time=0.042667|dts=1204224|dts_time=0.042667|duration=602112|duration_time=0.021333|size=502|pos=1198|flags=K__|data_hash=CRC32:b614d97e
+packet|codec_type=audio|stream_index=0|pts=1806336|pts_time=0.064000|dts=1806336|dts_time=0.064000|duration=602112|duration_time=0.021333|size=495|pos=1700|flags=K__|data_hash=CRC32:dffd387b
+packet|codec_type=audio|stream_index=0|pts=2408448|pts_time=0.085333|dts=2408448|dts_time=0.085333|duration=602112|duration_time=0.021333|size=493|pos=2195|flags=K__|data_hash=CRC32:119f413d
+stream|index=0|codec_name=aac|profile=1|level=-99|codec_type=audio|codec_tag_string=[0][0][0][0]|codec_tag=0x0000|mime_codec_string=mp4a.40.2|sample_fmt=fltp|sample_rate=48000|channels=2|channel_layout=stereo|bits_per_sample=0|initial_padding=0|id=N/A|r_frame_rate=0/0|avg_frame_rate=0/0|time_base=1/28224000|start_pts=N/A|start_time=N/A|duration_ts=N/A|duration=N/A|bit_rate=N/A|max_bit_rate=N/A|bits_per_raw_sample=N/A|nb_frames=N/A|nb_read_frames=N/A|nb_read_packets=5|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_thumbnails=0|disposition:non_diegetic=0|disposition:captions=0|disposition:descriptions=0|disposition:metadata=0|disposition:dependent=0|disposition:still_image=0|disposition:multilayer=0
+format|filename=id3v1.aac|nb_streams=1|nb_programs=0|nb_stream_groups=0|format_name=aac|start_time=N/A|duration=N/A|size=2816|bit_rate=N/A|probe_score=0|tag:title=Title|tag:artist=Artist|tag:genre=Blues