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 0905846CD7 for ; Thu, 6 Jun 2024 05:12:57 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id AD0C968D5F9; Thu, 6 Jun 2024 08:12:54 +0300 (EEST) Received: from vidala.lynne.ee (vidala.pars.ee [116.203.72.101]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E17CB68D499 for ; Thu, 6 Jun 2024 08:12:47 +0300 (EEST) To: ffmpeg-devel@ffmpeg.org Date: Thu, 6 Jun 2024 07:12:32 +0200 Message-ID: <20240606051243.3177266-1-dev@lynne.ee> X-Mailer: git-send-email 2.43.0.381.gb435a96ce8 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/4] aacdec_usac: respect tns_on_lr flag 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: , From: Lynne via ffmpeg-devel Reply-To: FFmpeg development discussions and patches Cc: Lynne Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: This was left out, and due to av_unused, forgotten about. --- libavcodec/aac/aacdec.h | 1 + libavcodec/aac/aacdec_usac.c | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/libavcodec/aac/aacdec.h b/libavcodec/aac/aacdec.h index ee21a94007..f0a33e7ac3 100644 --- a/libavcodec/aac/aacdec.h +++ b/libavcodec/aac/aacdec.h @@ -230,6 +230,7 @@ typedef struct SingleChannelElement { typedef struct AACUsacStereo { uint8_t common_window; uint8_t common_tw; + uint8_t tns_on_lr; ///< Apply TNS before M/S and stereo prediction uint8_t ms_mask_mode; uint8_t config_idx; diff --git a/libavcodec/aac/aacdec_usac.c b/libavcodec/aac/aacdec_usac.c index 561734f930..3b4e980df4 100644 --- a/libavcodec/aac/aacdec_usac.c +++ b/libavcodec/aac/aacdec_usac.c @@ -876,14 +876,14 @@ static int decode_usac_stereo_info(AACDecContext *ac, AACUSACConfig *usac, return AVERROR_PATCHWELCOME; } + us->tns_on_lr = 0; sce1->tns.present = sce2->tns.present = 0; if (tns_active) { - av_unused int tns_on_lr; int common_tns = 0; if (us->common_window) common_tns = get_bits1(gb); - tns_on_lr = get_bits1(gb); + us->tns_on_lr = get_bits1(gb); if (common_tns) { ret = ff_aac_decode_tns(ac, &sce1->tns, gb, ics1); if (ret < 0) @@ -1214,6 +1214,14 @@ static void spectrum_decode(AACDecContext *ac, AACUSACConfig *usac, } if (nb_channels > 1 && us->common_window) { + for (int ch = 0; ch < nb_channels; ch++) { + SingleChannelElement *sce = &cpe->ch[ch]; + + /* Apply TNS, if the tns_on_lr bit is not set. */ + if (sce->tns.present && !us->tns_on_lr) + ac->dsp.apply_tns(sce->coeffs, &sce->tns, &sce->ics, 1); + } + if (us->ms_mask_mode == 3) { const float *filt; complex_stereo_downmix_cur(ac, cpe, us->dmix_re); @@ -1248,8 +1256,8 @@ static void spectrum_decode(AACDecContext *ac, AACUSACConfig *usac, for (int ch = 0; ch < nb_channels; ch++) { SingleChannelElement *sce = &cpe->ch[ch]; - /* Apply TNS */ - if (sce->tns.present) + /* Apply TNS, if it hasn't been applied yet. */ + if (sce->tns.present && ((nb_channels == 1) || (us->tns_on_lr))) ac->dsp.apply_tns(sce->coeffs, &sce->tns, &sce->ics, 1); ac->oc[1].m4ac.frame_length_short ? ac->dsp.imdct_and_windowing_768(ac, sce) : -- 2.43.0.381.gb435a96ce8 _______________________________________________ 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".