PR #23675 opened by James Almer (jamrial) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23675 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23675.patch
This is in line with other encoders, and is needed by the matroska muxer to properly signal end trimming samples. fate-gaplessenc-pcm-to-mov-aac changes as the mov muxer now uses this information when writing the edit list, so the shorter frame duration is not needed. >From 490c9042e45bed3f85099aeece48e6f4f105043c Mon Sep 17 00:00:00 2001 From: James Almer <[email protected]> Date: Wed, 1 Jul 2026 17:00:42 +0000 Subject: [PATCH] avcodec/aacenc: export discard padding side data when needed This is in line with other encoders, and is needed by the matroska muxer to properly signal end trimming samples. gaplessenc-pcm-to-mov-aac changes as the mov muxer now uses this information when writing the edit list, so the shorter frame duration is not needed. Signed-off-by: James Almer <[email protected]> --- libavcodec/aacenc.c | 9 +++++++++ tests/ref/fate/gaplessenc-pcm-to-mov-aac | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c index d5abb0aa77..a4243350eb 100644 --- a/libavcodec/aacenc.c +++ b/libavcodec/aacenc.c @@ -1415,6 +1415,15 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, ff_af_queue_remove(&s->afq, avctx->frame_size, &avpkt->pts, &avpkt->duration); + int discard_padding = avctx->frame_size - ff_samples_from_time_base(avctx, avpkt->duration); + if (discard_padding > 0) { + uint8_t *side_data = + av_packet_new_side_data(avpkt, AV_PKT_DATA_SKIP_SAMPLES, 10); + if (!side_data) + return AVERROR(ENOMEM); + AV_WL32(side_data + 4, discard_padding); + } + avpkt->flags |= AV_PKT_FLAG_KEY; *got_packet_ptr = 1; diff --git a/tests/ref/fate/gaplessenc-pcm-to-mov-aac b/tests/ref/fate/gaplessenc-pcm-to-mov-aac index 073f2ec0c1..2c2429e661 100644 --- a/tests/ref/fate/gaplessenc-pcm-to-mov-aac +++ b/tests/ref/fate/gaplessenc-pcm-to-mov-aac @@ -22,7 +22,7 @@ packet|pts=524288|dts=524288|duration=1024|flags=K__ packet|pts=525312|dts=525312|duration=1024|flags=K__ packet|pts=526336|dts=526336|duration=1024|flags=K__ packet|pts=527360|dts=527360|duration=1024|flags=K__ -packet|pts=528384|dts=528384|duration=816|flags=K__|side_datum/skip_samples:side_data_type=Skip Samples|side_datum/skip_samples:skip_samples=0|side_datum/skip_samples:discard_padding=208|side_datum/skip_samples:skip_reason=0|side_datum/skip_samples:discard_reason=0 +packet|pts=528384|dts=528384|duration=1024|flags=K__|side_datum/skip_samples:side_data_type=Skip Samples|side_datum/skip_samples:skip_samples=0|side_datum/skip_samples:discard_padding=208|side_datum/skip_samples:skip_reason=0|side_datum/skip_samples:discard_reason=0 stream|nb_read_packets=518 frame|pts=0|pkt_dts=0|best_effort_timestamp=0|nb_samples=1024 frame|pts=1024|pkt_dts=1024|best_effort_timestamp=1024|nb_samples=1024 -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
