From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id F146C47B44 for ; Tue, 3 Oct 2023 04:07:40 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A0D3768CB19; Tue, 3 Oct 2023 07:07:37 +0300 (EEST) Received: from w4.tutanota.de (w4.tutanota.de [81.3.6.165]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A9B5568CAA7 for ; Tue, 3 Oct 2023 07:07:30 +0300 (EEST) Received: from tutadb.w10.tutanota.de (unknown [192.168.1.10]) by w4.tutanota.de (Postfix) with ESMTP id 23C8E1060148 for ; Tue, 3 Oct 2023 04:07:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1696306049; s=s1; d=lynne.ee; h=From:From:To:To:Subject:Subject:Content-Description:Content-ID:Content-Type:Content-Type:Content-Transfer-Encoding:Cc:Date:Date:In-Reply-To:MIME-Version:MIME-Version:Message-ID:Message-ID:Reply-To:References:Sender; bh=pt+6C0UbmYyK93zGGDbsmBt6hYJH4bBM77cWndlgKBc=; b=Xj1D3xHcnAj89dudKPBIGIdafZpmxDJVr4NnoruMU5b5Lz2inNQckX5QRsn0oiV6 wXxbwIAZlH5wQpndToC7MkTYBcZbGv66gb6BuVIo7+FxqC7erkEHhujpac2ABSAZoJD SbzSVXqVISbm+uEx7G0QKZo/bXmuj3xAxMHEcTmyfxqYkxOyVOBxCkBE+HsTbD4+isi Z+DgmU8+g0SM1ahmFgnqIaN1jB7z2MKMShIGwCJNg0DiYDCuNprr1Lg1i8pcasjhXBX Gnk5xhAgbuSLAZjIOtYY0gsG5kTovFYDg8Glf/KTeBUxMI9pNQBJOQGCZaUdnf7LySZ 2uYUQ9mjSg== Date: Tue, 3 Oct 2023 06:07:29 +0200 (CEST) From: Lynne To: Ffmpeg Devel Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_440837_184992619.1696306049892" Subject: [FFmpeg-devel] [PATCH] aacdec: padding skip improvements 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: ------=_Part_440837_184992619.1696306049892 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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 2048 samples of padding. Because this is also such a mess, make it an option to allow for users to configure the amount of padding. The FFmpeg encoder will be modified to also output 2048 samples of padding at the start, to make it in line with other encoders. Yes, this leaves FATE pretty sad. Will be fixed by another patch once the discussions have completed as to what should be the default. ------=_Part_440837_184992619.1696306049892 Content-Type: text/x-diff; charset=us-ascii; name=0001-aacdec-padding-skip-improvements.patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=0001-aacdec-padding-skip-improvements.patch >From dca29a894a60cdca1682fa6d0d3ee56c552b3d49 Mon Sep 17 00:00:00 2001 From: Lynne Date: Tue, 3 Oct 2023 05:57:50 +0200 Subject: [PATCH] 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 2048 samples of padding. The FFmpeg encoder will be modified to also output 2048 samples of padding at the start, to make it in line with other encoders. Yes, this leaves FATE pretty sad. Will fix it with the real version of the patch. --- 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 51a4cb2b66..70c5c6ab4c 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_samples = 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]; - int i, major, minor; +static int decode_fill(AACContext *ac, GetBitContext *gb, int len) +{ + uint8_t buf[256] = { 0 }; + int i, major, minor, micro; if (len < 13+7*8) goto unknown; - get_bits(gb, 13); len -= 13; + get_bits(gb, 13); + len -= 13; for(i=0; i+1=8; i++, len-=8) buf[i] = get_bits(gb, 8); @@ -2434,7 +2439,9 @@ static int decode_fill(AACContext *ac, GetBitContext *gb, int len) { 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; + ac->avctx->internal->skip_samples -= 1024; + } else if ((sscanf(buf, "avc %d.%d.%d", &major, &minor, µ) == 3)) { + 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 = 2048 }, 1024, 8192, AACDEC_FLAGS }, + {NULL}, }; -- 2.42.0 ------=_Part_440837_184992619.1696306049892 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ 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". ------=_Part_440837_184992619.1696306049892--