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 C2B9748010 for ; Thu, 6 Jun 2024 05:13:16 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1CEEE68D6A6; Thu, 6 Jun 2024 08:12:57 +0300 (EEST) Received: from vidala.lynne.ee (vidala.pars.ee [116.203.72.101]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E81A468D504 for ; Thu, 6 Jun 2024 08:12:47 +0300 (EEST) To: ffmpeg-devel@ffmpeg.org Date: Thu, 6 Jun 2024 07:12:34 +0200 Message-ID: <20240606051243.3177266-3-dev@lynne.ee> X-Mailer: git-send-email 2.43.0.381.gb435a96ce8 In-Reply-To: <20240606051243.3177266-1-dev@lynne.ee> References: <20240606051243.3177266-1-dev@lynne.ee> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/4] aacdec_usac: decouple TNS active from TNS data present 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: The issue was that in case of common TNS parameters, TNS was entirely skipped, as tns.present was set to 0. --- libavcodec/aac/aacdec.h | 1 + libavcodec/aac/aacdec_usac.c | 25 +++++++++++++++---------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/libavcodec/aac/aacdec.h b/libavcodec/aac/aacdec.h index f0a33e7ac3..a2ef4a82e8 100644 --- a/libavcodec/aac/aacdec.h +++ b/libavcodec/aac/aacdec.h @@ -125,6 +125,7 @@ typedef struct LongTermPrediction { typedef struct AACUsacElemData { uint8_t core_mode; uint8_t scale_factor_grouping; + uint8_t tns_data_present; /* Timewarping ratio */ #define NUM_TW_NODES 16 diff --git a/libavcodec/aac/aacdec_usac.c b/libavcodec/aac/aacdec_usac.c index 9b28a9e90b..97655787ee 100644 --- a/libavcodec/aac/aacdec_usac.c +++ b/libavcodec/aac/aacdec_usac.c @@ -877,7 +877,7 @@ static int decode_usac_stereo_info(AACDecContext *ac, AACUSACConfig *usac, } us->tns_on_lr = 0; - sce1->tns.present = sce2->tns.present = 0; + ue1->tns_data_present = ue2->tns_data_present = 0; if (tns_active) { int common_tns = 0; if (us->common_window) @@ -889,15 +889,17 @@ static int decode_usac_stereo_info(AACDecContext *ac, AACUSACConfig *usac, if (ret < 0) return ret; memcpy(&sce2->tns, &sce1->tns, sizeof(sce1->tns)); - sce2->tns.present = 0; - sce1->tns.present = 0; + sce2->tns.present = 1; + sce1->tns.present = 1; + ue1->tns_data_present = 0; + ue2->tns_data_present = 0; } else { if (get_bits1(gb)) { - sce2->tns.present = 1; - sce1->tns.present = 1; + ue1->tns_data_present = 1; + ue2->tns_data_present = 1; } else { - sce2->tns.present = get_bits1(gb); - sce1->tns.present = !sce2->tns.present; + ue2->tns_data_present = get_bits1(gb); + ue1->tns_data_present = !ue2->tns_data_present; } } } @@ -1277,12 +1279,14 @@ static int decode_usac_core_coder(AACDecContext *ac, AACUSACConfig *usac, uint8_t global_gain; us->common_window = 0; - che->ch[0].tns.present = che->ch[1].tns.present = 0; for (int ch = 0; ch < nb_channels; ch++) { SingleChannelElement *sce = &che->ch[ch]; AACUsacElemData *ue = &sce->ue; + sce->tns.present = 0; + ue->tns_data_present = 0; + ue->core_mode = get_bits1(gb); } @@ -1306,7 +1310,7 @@ static int decode_usac_core_coder(AACDecContext *ac, AACUSACConfig *usac, if ((nb_channels == 1) || (che->ch[0].ue.core_mode != che->ch[1].ue.core_mode)) - sce->tns.present = get_bits1(gb); + ue->tns_data_present = get_bits1(gb); /* fd_channel_stream */ global_gain = get_bits(gb, 8); @@ -1351,7 +1355,8 @@ static int decode_usac_core_coder(AACDecContext *ac, AACUSACConfig *usac, ac->dsp.dequant_scalefactors(sce); - if (sce->tns.present) { + if (ue->tns_data_present) { + sce->tns.present = 1; ret = ff_aac_decode_tns(ac, &sce->tns, gb, ics); if (ret < 0) return ret; -- 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".