Correct patch attached.
>From 91ff271acffdb00bb8a7ace0ae1e811770104fc2 Mon Sep 17 00:00:00 2001 From: Lynne <d...@lynne.ee> Date: Thu, 19 Oct 2023 04:36:12 +0200 Subject: [PATCH 2/2] aacdec: padding skip improvements
For some reason, this was never set, which meant all **raw** AAC in ADTS streams, except faac, had extra samples at the start. Despite this being a standard MDCT-based codec with a frame size of 1024, hence a delay of 1024 samples at the start, all major encoders, excluding faac and ffmpeg, use different amounts of padding. --- libavcodec/aac.h | 1 + libavcodec/aacdec_template.c | 20 +++++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/libavcodec/aac.h b/libavcodec/aac.h index 285d3b7482..79bbb3cce5 100644 --- a/libavcodec/aac.h +++ b/libavcodec/aac.h @@ -298,6 +298,7 @@ struct AACContext { AVCodecContext *avctx; AVFrame *frame; + int override_padding; int is_saved; ///< Set if elements have stored overlap from previous frame. DynamicRangeControl che_drc; diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c index 954399f86b..d5855a4f98 100644 --- a/libavcodec/aacdec_template.c +++ b/libavcodec/aacdec_template.c @@ -1273,6 +1273,9 @@ static av_cold int aac_decode_init(AVCodecContext *avctx) if (ret < 0) return ret; + /* Usually overridden by side data */ + avctx->internal->skip_samples2 = ac->override_padding; + return 0; } @@ -2417,14 +2420,16 @@ static int decode_dynamic_range(DynamicRangeControl *che_drc, return n; } -static int decode_fill(AACContext *ac, GetBitContext *gb, int len) { - uint8_t buf[256]; +static int decode_fill(AACContext *ac, GetBitContext *gb, int len) +{ + uint8_t buf[256] = { 0 }; int i, major, minor; if (len < 13+7*8) goto unknown; - get_bits(gb, 13); len -= 13; + get_bits(gb, 13); + len -= 13; for(i=0; i+1<sizeof(buf) && len>=8; i++, len-=8) buf[i] = get_bits(gb, 8); @@ -2433,8 +2438,10 @@ static int decode_fill(AACContext *ac, GetBitContext *gb, int len) { if (ac->avctx->debug & FF_DEBUG_PICT_INFO) av_log(ac->avctx, AV_LOG_DEBUG, "FILL:%s\n", buf); - if (sscanf(buf, "libfaac %d.%d", &major, &minor) == 2){ - ac->avctx->internal->skip_samples = 1024; + if (!ac->override_padding) { + if (sscanf(buf, "libfaac %d.%d", &major, &minor) == 2){ + ac->avctx->internal->skip_samples = 1024; + } } unknown: @@ -3471,6 +3478,9 @@ static const AVOption options[] = { { "coded", "order in which the channels are coded in the bitstream", 0, AV_OPT_TYPE_CONST, { .i64 = CHANNEL_ORDER_CODED }, .flags = AACDEC_FLAGS, "channel_order" }, + { "padding", "Override the padding at the start of a stream.\n", + offsetof(AACContext, override_padding), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 8192, AACDEC_FLAGS }, + {NULL}, }; -- 2.42.0
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".