From patchwork Wed Jul 13 17:59:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 36778 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:6da0:b0:8b:e47:9dbf with SMTP id wl32csp519921pzb; Wed, 13 Jul 2022 11:00:15 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tcvi3CfQhqMABSvQK12xEbZKGwVcADN3uryD/6aTw3JkKab66orBDF/c6PPndDkVVGSECU X-Received: by 2002:a05:6402:240a:b0:437:d2b6:3dde with SMTP id t10-20020a056402240a00b00437d2b63ddemr6728928eda.62.1657735215214; Wed, 13 Jul 2022 11:00:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657735215; cv=none; d=google.com; s=arc-20160816; b=W1cJeg6frSumcftgnTzJDJlth9TeD7i77qR7HQQ7dL+7J/LrXHQYgCA6Ga0UQSlb0R /8nFYzrnj+xgXyAAjFz+Z8Mg3v+QaDiDx8zfUHRFtHaJcV1LSbbyJdggPAoEdb9WMxRg QL6iDZtkSSX7H2TSbvQidFzTBpzQEyvHWtd1SJ39VFZ3BWK5LwDZzVfUTevO0xM3LQcI i47rDLqILGbF0XPDUUt2Yz7iDqaWBLemK/CbqXSk+CvGxIM/YjKJZgliH/qOBgJ1RCi4 58IJx77yYTzsNthWrkVaCeeCgqCfVxs6a/JUXLbvOLYRyEkurERcgI8u/wb7ql9KmE5w brnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=C2tDNikIp/3kEX2yMqeV54JqbKiZbsD3reI5ctgmSqA=; b=QemW8k3ODGhG3aRVijY8UMU4SQ/tHPQ/D5f2uf81uG3vLfkJVoWovsLr0kAxddit3+ nPkW7UHm3LoczCIkZX4F4BE4rr7V52Ooe3Omw1v55+I2EHykRMEDOuTbHUxPodA4U4GC vq8Jmi0hzDTSxIMQ9WC0sTvd6N47WTmg07nqQ1k2aNXtvOrWDRpYVhb04K1wpOpcY7y9 k3A2HerZlJULpp+KKfgB1jbzzVL8BII9vPbfuOZeQBI1FcTTpjsa5vVstL0RoX9v7gEU bkH+XzJPlxgxUWFabwkgOhGezKD8oh/uiuI96AfiwCVqhJ/J0GAa0y/sFV9Pd8BchnXF I9AQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=p1dzJcWN; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id hw10-20020a170907a0ca00b0072643608f99si3583746ejc.531.2022.07.13.11.00.14; Wed, 13 Jul 2022 11:00:15 -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=@gmail.com header.s=20210112 header.b=p1dzJcWN; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C07D768B9DE; Wed, 13 Jul 2022 21:00:10 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-oa1-f42.google.com (mail-oa1-f42.google.com [209.85.160.42]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5974B68B886 for ; Wed, 13 Jul 2022 21:00:03 +0300 (EEST) Received: by mail-oa1-f42.google.com with SMTP id 586e51a60fabf-10bd4812c29so14936802fac.11 for ; Wed, 13 Jul 2022 11:00:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=B83Ye8R8Xaqy5uNf1WCjGl6AYZdNzlENW989Y1ue/04=; b=p1dzJcWN83+IVbqzy4Z8hT11lxCUNJeBWJHTHwH9T2j4ehQX9x1xtdATKe1FMLghE/ D/GQlc+GpuJJxqMLvMaVpdGUaLPbVF8u9ompeySGZ4jjo5sq87eAk7cDZilIoKB28CTr 0G3oNpEzHhX27s1ae6G8Rece6g5xWdJ58WYiMfYegxeqe7vUQVQnyrMuOYvRWOhMgze8 xb/l73eU8TM04i7LG7K/9Nz+TaE8POoTLcaYV+bmU29aSAj0J3baomRBe5QbLh66x0v9 81b2E11BxpSzcz5uWJdj+AcSC/iSRtThRnwCnxllu/cE0RMNScKV9nvkusxZNBuOTiSs ee6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=B83Ye8R8Xaqy5uNf1WCjGl6AYZdNzlENW989Y1ue/04=; b=1TO4cDLnINqGMUKjviyjTar9nrij9RTPfZ4UEs0jX12Os4WK+0L8MUOmUpcJyOqx7I hfVZsQPXYuWS9ImVFU1M8ZnPHADO1AYPxWvCswvn114IOU3FwkgkpraqMDEDnT97ybAl ydWBumeTZplFR7bCQnIzK2hm4nTMRzLmkGzjlauK8fz4MnAlu++QW/vQwfZHg2eWN/T5 4HLqbTREZbmUWH8n0pFt7lzkMxPthquAUDvBo2a5CDbCxAPLKog5AZqNnKzJhQX1Sbo9 YPKRv0Wyui6efQ3l0nvHjA6kLE0H9WRwDc1KdIZdEln0ZqVKQPWGMVjzElzWn61+GjR1 o16A== X-Gm-Message-State: AJIora/gIQdb0QjSB8G+EtP2nDlq+CZsrFDHnsK1B4MaS6CqvUhP/RP9 Qgpru/p4a2L6ZD2rJ4qKjjph/nyK5fr2Lg== X-Received: by 2002:a05:6870:3292:b0:10c:d1fa:2e70 with SMTP id q18-20020a056870329200b0010cd1fa2e70mr2370384oac.281.1657735200809; Wed, 13 Jul 2022 11:00:00 -0700 (PDT) Received: from localhost.localdomain ([186.136.131.204]) by smtp.gmail.com with ESMTPSA id v7-20020acaac07000000b0032f63c4638esm5686630oie.2.2022.07.13.10.59.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Jul 2022 10:59:59 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Wed, 13 Jul 2022 14:59:48 -0300 Message-Id: <20220713175948.1955-1-jamrial@gmail.com> X-Mailer: git-send-email 2.37.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avcodec/aacdec: don't force HE-AACv2 profile if no PS info is present 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: B1r2lTKIs/y9 Should fix ticket #3361 Signed-off-by: James Almer --- This also needs an update to some fate ref samples i'll upload before pushing (fate-aac-al_sbr_ps_04_ur and fate-aac-al_sbr_ps_06_ur which are now decoded properly as he_aac mono, so the .s16 files need to be replaced). libavcodec/aacdec_template.c | 15 ++++++--------- libavcodec/aacsbr_template.c | 1 + tests/fate/gapless.mak | 14 +++++++------- .../audiomatch-afconvert-16000-stereo-he2-adts | 2 +- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c index 10fba3d3b2..15c20c07d6 100644 --- a/libavcodec/aacdec_template.c +++ b/libavcodec/aacdec_template.c @@ -967,8 +967,7 @@ static int decode_ga_specific_config(AACContext *ac, AVCodecContext *avctx, if (count_channels(layout_map, tags) > 1) { m4ac->ps = 0; - } else if (m4ac->sbr == 1 && m4ac->ps == -1) - m4ac->ps = 1; + } if (ac && (ret = output_configure(ac, layout_map, tags, OC_GLOBAL_HDR, 0))) return ret; @@ -2572,18 +2571,16 @@ static int decode_extension_payload(AACContext *ac, GetBitContext *gb, int cnt, av_log(ac->avctx, AV_LOG_ERROR, "Implicit SBR was found with a first occurrence after the first frame.\n"); skip_bits_long(gb, 8 * cnt - 4); return res; - } else if (ac->oc[1].m4ac.ps == -1 && ac->oc[1].status < OC_LOCKED && - ac->avctx->ch_layout.nb_channels == 1) { - ac->oc[1].m4ac.sbr = 1; - ac->oc[1].m4ac.ps = 1; - ac->avctx->profile = FF_PROFILE_AAC_HE_V2; - output_configure(ac, ac->oc[1].layout_map, ac->oc[1].layout_map_tags, - ac->oc[1].status, 1); } else { ac->oc[1].m4ac.sbr = 1; ac->avctx->profile = FF_PROFILE_AAC_HE; } res = AAC_RENAME(ff_decode_sbr_extension)(ac, &che->sbr, gb, crc_flag, cnt, elem_type); + if (ac->oc[1].m4ac.ps == 1 && ac->oc[1].status < OC_LOCKED && + ac->avctx->ch_layout.nb_channels == 1) { + output_configure(ac, ac->oc[1].layout_map, ac->oc[1].layout_map_tags, + ac->oc[1].status, 1); + } break; case EXT_DYNAMIC_RANGE: res = decode_dynamic_range(&ac->che_drc, gb); diff --git a/libavcodec/aacsbr_template.c b/libavcodec/aacsbr_template.c index b72c94b76d..f9925b40e5 100644 --- a/libavcodec/aacsbr_template.c +++ b/libavcodec/aacsbr_template.c @@ -954,6 +954,7 @@ static void read_sbr_extension(AACContext *ac, SpectralBandReplication *sbr, *num_bits_left = 0; } else { *num_bits_left -= ff_ps_read_data(ac->avctx, gb, &sbr->ps.common, *num_bits_left); + ac->oc[1].m4ac.ps = 1; ac->avctx->profile = FF_PROFILE_AAC_HE_V2; } break; diff --git a/tests/fate/gapless.mak b/tests/fate/gapless.mak index 68a396e187..7dd8ceb142 100644 --- a/tests/fate/gapless.mak +++ b/tests/fate/gapless.mak @@ -47,27 +47,27 @@ fate-audiomatch-square-aac: CMD = audio_match $(TARGET_SAMPLES)/audiomatch/squar fate-audiomatch-afconvert-16000-mono-lc-adts: CMD = audio_match $(TARGET_SAMPLES)/audiomatch/tones_afconvert_16000_mono_aac_lc.adts $(SAMPLES)/audiomatch/tones_16000_mono.wav fate-audiomatch-afconvert-16000-mono-lc-m4a: CMD = audio_match $(TARGET_SAMPLES)/audiomatch/tones_afconvert_16000_mono_aac_lc.m4a $(SAMPLES)/audiomatch/tones_16000_mono.wav -fate-audiomatch-afconvert-16000-mono-he-adts: CMD = audio_match $(TARGET_SAMPLES)/audiomatch/tones_afconvert_16000_mono_aac_he.adts $(SAMPLES)/audiomatch/tones_16000_mono.wav "-ac 1 -ar 16000" -fate-audiomatch-afconvert-16000-mono-he-m4a: CMD = audio_match $(TARGET_SAMPLES)/audiomatch/tones_afconvert_16000_mono_aac_he.m4a $(SAMPLES)/audiomatch/tones_16000_mono.wav "-ac 1 -ar 16000" +fate-audiomatch-afconvert-16000-mono-he-adts: CMD = audio_match $(TARGET_SAMPLES)/audiomatch/tones_afconvert_16000_mono_aac_he.adts $(SAMPLES)/audiomatch/tones_16000_mono.wav "-ar 16000" +fate-audiomatch-afconvert-16000-mono-he-m4a: CMD = audio_match $(TARGET_SAMPLES)/audiomatch/tones_afconvert_16000_mono_aac_he.m4a $(SAMPLES)/audiomatch/tones_16000_mono.wav "-ar 16000" fate-audiomatch-afconvert-16000-stereo-lc-adts: CMD = audio_match $(TARGET_SAMPLES)/audiomatch/tones_afconvert_16000_stereo_aac_lc.adts $(SAMPLES)/audiomatch/tones_16000_stereo.wav fate-audiomatch-afconvert-16000-stereo-lc-m4a: CMD = audio_match $(TARGET_SAMPLES)/audiomatch/tones_afconvert_16000_stereo_aac_lc.m4a $(SAMPLES)/audiomatch/tones_16000_stereo.wav fate-audiomatch-afconvert-16000-stereo-he-adts: CMD = audio_match $(TARGET_SAMPLES)/audiomatch/tones_afconvert_16000_stereo_aac_he.adts $(SAMPLES)/audiomatch/tones_16000_stereo.wav "-ar 16000" fate-audiomatch-afconvert-16000-stereo-he-m4a: CMD = audio_match $(TARGET_SAMPLES)/audiomatch/tones_afconvert_16000_stereo_aac_he.m4a $(SAMPLES)/audiomatch/tones_16000_stereo.wav "-ar 16000" -fate-audiomatch-afconvert-16000-stereo-he2-adts:CMD = audio_match $(TARGET_SAMPLES)/audiomatch/tones_afconvert_16000_stereo_aac_he2.adts $(SAMPLES)/audiomatch/tones_16000_stereo.wav "-ar 16000" +fate-audiomatch-afconvert-16000-stereo-he2-adts:CMD = audio_match $(TARGET_SAMPLES)/audiomatch/tones_afconvert_16000_stereo_aac_he2.adts $(SAMPLES)/audiomatch/tones_16000_stereo.wav "-ac 2 -ar 16000" fate-audiomatch-afconvert-16000-stereo-he2-m4a: CMD = audio_match $(TARGET_SAMPLES)/audiomatch/tones_afconvert_16000_stereo_aac_he2.m4a $(SAMPLES)/audiomatch/tones_16000_stereo.wav "-ar 16000" fate-audiomatch-afconvert-44100-mono-lc-adts: CMD = audio_match $(TARGET_SAMPLES)/audiomatch/tones_afconvert_44100_mono_aac_lc.adts $(SAMPLES)/audiomatch/tones_44100_mono.wav fate-audiomatch-afconvert-44100-mono-lc-m4a: CMD = audio_match $(TARGET_SAMPLES)/audiomatch/tones_afconvert_44100_mono_aac_lc.m4a $(SAMPLES)/audiomatch/tones_44100_mono.wav -fate-audiomatch-afconvert-44100-mono-he-adts: CMD = audio_match $(TARGET_SAMPLES)/audiomatch/tones_afconvert_44100_mono_aac_he.adts $(SAMPLES)/audiomatch/tones_44100_mono.wav "-ac 1" -fate-audiomatch-afconvert-44100-mono-he-m4a: CMD = audio_match $(TARGET_SAMPLES)/audiomatch/tones_afconvert_44100_mono_aac_he.m4a $(SAMPLES)/audiomatch/tones_44100_mono.wav "-ac 1" +fate-audiomatch-afconvert-44100-mono-he-adts: CMD = audio_match $(TARGET_SAMPLES)/audiomatch/tones_afconvert_44100_mono_aac_he.adts $(SAMPLES)/audiomatch/tones_44100_mono.wav +fate-audiomatch-afconvert-44100-mono-he-m4a: CMD = audio_match $(TARGET_SAMPLES)/audiomatch/tones_afconvert_44100_mono_aac_he.m4a $(SAMPLES)/audiomatch/tones_44100_mono.wav fate-audiomatch-afconvert-44100-stereo-lc-adts: CMD = audio_match $(TARGET_SAMPLES)/audiomatch/tones_afconvert_44100_stereo_aac_lc.adts $(SAMPLES)/audiomatch/tones_44100_stereo.wav fate-audiomatch-afconvert-44100-stereo-lc-m4a: CMD = audio_match $(TARGET_SAMPLES)/audiomatch/tones_afconvert_44100_stereo_aac_lc.m4a $(SAMPLES)/audiomatch/tones_44100_stereo.wav fate-audiomatch-afconvert-44100-stereo-he-adts: CMD = audio_match $(TARGET_SAMPLES)/audiomatch/tones_afconvert_44100_stereo_aac_he.adts $(SAMPLES)/audiomatch/tones_44100_stereo.wav fate-audiomatch-afconvert-44100-stereo-he-m4a: CMD = audio_match $(TARGET_SAMPLES)/audiomatch/tones_afconvert_44100_stereo_aac_he.m4a $(SAMPLES)/audiomatch/tones_44100_stereo.wav -fate-audiomatch-afconvert-44100-stereo-he2-adts:CMD = audio_match $(TARGET_SAMPLES)/audiomatch/tones_afconvert_44100_stereo_aac_he2.adts $(SAMPLES)/audiomatch/tones_44100_stereo.wav +fate-audiomatch-afconvert-44100-stereo-he2-adts:CMD = audio_match $(TARGET_SAMPLES)/audiomatch/tones_afconvert_44100_stereo_aac_he2.adts $(SAMPLES)/audiomatch/tones_44100_stereo.wav "-ac 2" fate-audiomatch-afconvert-44100-stereo-he2-m4a: CMD = audio_match $(TARGET_SAMPLES)/audiomatch/tones_afconvert_44100_stereo_aac_he2.m4a $(SAMPLES)/audiomatch/tones_44100_stereo.wav fate-audiomatch-dolby-44100-mono-lc-mp4: CMD = audio_match $(TARGET_SAMPLES)/audiomatch/tones_dolby_44100_mono_aac_lc.mp4 $(SAMPLES)/audiomatch/tones_44100_mono.wav -fate-audiomatch-dolby-44100-mono-he-mp4: CMD = audio_match $(TARGET_SAMPLES)/audiomatch/tones_dolby_44100_mono_aac_he.mp4 $(SAMPLES)/audiomatch/tones_44100_mono.wav "-ac 1" +fate-audiomatch-dolby-44100-mono-he-mp4: CMD = audio_match $(TARGET_SAMPLES)/audiomatch/tones_dolby_44100_mono_aac_he.mp4 $(SAMPLES)/audiomatch/tones_44100_mono.wav fate-audiomatch-dolby-44100-stereo-lc-mp4: CMD = audio_match $(TARGET_SAMPLES)/audiomatch/tones_dolby_44100_stereo_aac_lc.mp4 $(SAMPLES)/audiomatch/tones_44100_stereo.wav fate-audiomatch-dolby-44100-stereo-he-mp4: CMD = audio_match $(TARGET_SAMPLES)/audiomatch/tones_dolby_44100_stereo_aac_he.mp4 $(SAMPLES)/audiomatch/tones_44100_stereo.wav fate-audiomatch-dolby-44100-stereo-he2-mp4: CMD = audio_match $(TARGET_SAMPLES)/audiomatch/tones_dolby_44100_stereo_aac_he2.mp4 $(SAMPLES)/audiomatch/tones_44100_stereo.wav diff --git a/tests/ref/fate/audiomatch-afconvert-16000-stereo-he2-adts b/tests/ref/fate/audiomatch-afconvert-16000-stereo-he2-adts index 32b2627946..527c9acdba 100644 --- a/tests/ref/fate/audiomatch-afconvert-16000-stereo-he2-adts +++ b/tests/ref/fate/audiomatch-afconvert-16000-stereo-he2-adts @@ -1 +1 @@ -presig: 5186 postsig:446 c: 0.9839 lenerr:5632 +presig: 5154 postsig:446 c: 0.9839 lenerr:5600