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 F323847660 for ; Thu, 19 Oct 2023 02:39:39 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 019DD68CAC7; Thu, 19 Oct 2023 05:39:38 +0300 (EEST) Received: from w4.tutanota.de (w4.tutanota.de [81.3.6.165]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6121268C6BF for ; Thu, 19 Oct 2023 05:39:32 +0300 (EEST) Received: from tutadb.w10.tutanota.de (unknown [192.168.1.10]) by w4.tutanota.de (Postfix) with ESMTP id 192A01060122 for ; Thu, 19 Oct 2023 02:39:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1697683172; 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:In-Reply-To:MIME-Version:MIME-Version:Message-ID:Message-ID:Reply-To:References:References:Sender; bh=hYlLurEq0Cf4O9zp8OEhYhw8wxNs8w7WJO4cA0f76MM=; b=at0jKjsOIxNfLVe66dUoaIFf10tTBCdv9zN5aJ8xq2fO3qh5c+nvwoA0OqLn/PkC AwwnqZJqdyJdz1CuxfjllqRruWoj0rOGHCLEn/dKrPNBugujbicJvBKyUQfLqOqM6qz dT24bliyHFjE4xw0P9rXLlR+2Hi22OESeW6mCRNkL8HNQcVUqKALJV/4vcxL97TSBoh iCGlJfJl/jaNElb6Sm7smDMZANwqR0ryK9ycz9ZKlCh5gkS0ivyx33JqVN1DXV1VRVM 8HTpuUYsp5hw+ihpPlPb8aLCtIdjZB5xMe8MR7yjd3OwudLP2q+PpD0cngkGmRZGS8O KioaVSbcaA== Date: Thu, 19 Oct 2023 04:39:32 +0200 (CEST) From: Lynne To: FFmpeg development discussions and patches Message-ID: In-Reply-To: References: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_345806_563426124.1697683172098" Subject: Re: [FFmpeg-devel] [PATCH 2/2] 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_345806_563426124.1697683172098 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Correct patch attached. ------=_Part_345806_563426124.1697683172098 Content-Type: text/x-diff; charset=us-ascii; name=0002-aacdec-padding-skip-improvements.patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=0002-aacdec-padding-skip-improvements.patch >From 91ff271acffdb00bb8a7ace0ae1e811770104fc2 Mon Sep 17 00:00:00 2001 From: Lynne 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=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 ------=_Part_345806_563426124.1697683172098 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_345806_563426124.1697683172098--