From patchwork Tue Sep 12 06:10:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lynne X-Patchwork-Id: 43706 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4e27:b0:149:dfde:5c0a with SMTP id gk39csp2583364pzb; Mon, 11 Sep 2023 23:10:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH+ZCCjJAFedEo+DZOX7KSWZcEFFcslyNVCgzkg+bj4ZdO8eVi2PAE5OQjOR0pUuYmt73lK X-Received: by 2002:a05:6512:3082:b0:4ff:83b2:42b7 with SMTP id z2-20020a056512308200b004ff83b242b7mr11149377lfd.42.1694499031958; Mon, 11 Sep 2023 23:10:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694499031; cv=none; d=google.com; s=arc-20160816; b=zECnIDaiGc3O/F9KvMTF+HSTDRO7Pl7oDTITDgwXxHUsWQ5Gt9TSGdQNmedG5IGyww 5bmAuePn3k4R4Rz1mbSF1a1YAscLW087iIAxeEdnMkPBxqoTMK/tu98SMtk2aKz1p4Eb QSzFzCISPS9wtpe8+5fbsLFWCCasavfBN5ALlQzuHcIVjID+vOGQvYWby6KUIaamsy1m d6U+mZolWpuZ0vy3JjZJXWSKYR6G1ej9fuZHRP+eDRv76QfHAGoOJs3L9gWJ4qGGQi3h xs1qq7S8ZlSxXiC0eCFoMDUYePCQQy7E3Wv7STwEhI1XgmXLKJdm0GAzuqxplvOZ2dQq 2RTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:message-id:to:from:date:dkim-signature:delivered-to; bh=wO/lKkaFb+2grICXPEjdduivK5mS6yRA/2uHAo3Aq4A=; fh=Q46kXK7oI5D1Jhi90JBr53c7NIaTxGaU4KPeRZyM/hI=; b=xHxfcLAaZqo8pGOo9UPk4C/a3eviobGT5lKO3MZVyRrrDzfOIjFcNIZMg9EYsBeezq 1ILEG9MddPyyGMRnFcb1Y/znsUidWKvK3LsX3ZGludTEQNBQRNu7M/jlQ4e1kRSsuBCl X36NdIiia68oadlVXgcAamDwkUg6eyjpaZcS5zNk/MtL6kKlOIctGUesn/DSzNTZJwZ+ RmuinQqxZflrVsdFr4Xj7VeVptYRNflMBvC2afGyzk2HB/W1iE/VNl2YIF8vdqxFUQTU wkMflgK3A4G4EaUtMaAT+BINuhD7Dt+WohN11MZe+lQV3oeorG9IPpDVryC5GSo6w8Jh 0slg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@lynne.ee header.s=s1 header.b=nvd22ojQ; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=lynne.ee Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id pv20-20020a170907209400b0099bd1531117si7902265ejb.33.2023.09.11.23.10.29; Mon, 11 Sep 2023 23:10:31 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@lynne.ee header.s=s1 header.b=nvd22ojQ; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=lynne.ee Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3AEEB68C59D; Tue, 12 Sep 2023 09:10:25 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org 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 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" X-TUID: 0oT9lom9Y8LT 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. 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