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 621AA4757A for ; Tue, 12 Sep 2023 06:10:27 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id F250468C972; Tue, 12 Sep 2023 09:10:24 +0300 (EEST) Received: from w4.tutanota.de (w4.tutanota.de [81.3.6.165]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 91DB468C946 for ; Tue, 12 Sep 2023 09:10:18 +0300 (EEST) Received: from tutadb.w10.tutanota.de (unknown [192.168.1.10]) by w4.tutanota.de (Postfix) with ESMTP id B311F106030B for ; Tue, 12 Sep 2023 06:10:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1694499017; 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=qsD1V8dl84e1dyqdgF8E5BIIV7s7wgW2dD8+gfMj+9s=; b=nvd22ojQAiozf99iJqRza3hpjiJzktk8VEVdqrbR7e9Efg/gTO/Wg2YIXIASte39 bHsiclqsqJ8ou5iSPpzpOmZ/9BODJSheGlA48u71nAirIE/tXKe14NeDvXf1i5FO07U KJeAXJlB4QkYLNXuqwQ7E3xb+OJfT07rJIPsDBv/BoFb72vWmuD2MWASG2/RP2uhJDb 0KXwFv3mDy79WX739sXTjMxAhRNKsC1yt8KrJiatX5iSLxOPqdcj6eHlDAbQb+pCRjd Uxc86SEQk1V6lFoZwLIpa4C0Ih+r96y8LOoOw3bqAZsV70IOezCj76eylIXtMk5NCk6 ty4GtlTxEg== Date: Tue, 12 Sep 2023 08:10:17 +0200 (CEST) From: Lynne To: Ffmpeg Devel Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_892903_32484720.1694499017444" Subject: [FFmpeg-devel] [RFC PATCH 1/3] aacdec: always skip the first 2048 samples if there's no side data 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_892903_32484720.1694499017444 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. 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. ------=_Part_892903_32484720.1694499017444 Content-Type: text/x-diff; charset=us-ascii; name=0001-aacdec-always-skip-the-first-2048-samples-if-there-s.patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=0001-aacdec-always-skip-the-first-2048-samples-if-there-s.patch >From 079235e1f1a9caeadfd2b8d78b3fe2273d86018a Mon Sep 17 00:00:00 2001 From: Lynne Date: Fri, 11 Aug 2023 17:50:54 +0200 Subject: [PATCH 1/3] aacdec: always skip the first 2048 samples if there's no side data 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. --- libavcodec/aacdec_template.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c index f8039e490b..0e4a274fea 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 = 2048; + 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) { +static int decode_fill(AACContext *ac, GetBitContext *gb, int len) +{ uint8_t buf[256]; - int i, major, minor; + 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,11 @@ 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; + } + + if ((sscanf(buf, "avc %d.%d.%d", &major, &minor, µ) == 3)) { + ac->avctx->internal->skip_samples -= 1024; } unknown: -- 2.40.1 ------=_Part_892903_32484720.1694499017444 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_892903_32484720.1694499017444--