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 210B446B84 for ; Fri, 4 Aug 2023 19:23:19 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 849A668C755; Fri, 4 Aug 2023 22:23:16 +0300 (EEST) Received: from w4.tutanota.de (w4.tutanota.de [81.3.6.165]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B1C3E68C443 for ; Fri, 4 Aug 2023 22:23:09 +0300 (EEST) Received: from tutadb.w10.tutanota.de (unknown [192.168.1.10]) by w4.tutanota.de (Postfix) with ESMTP id C321D1060160 for ; Fri, 4 Aug 2023 19:23:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1691176989; 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:In-Reply-To:MIME-Version:MIME-Version:Message-ID:Message-ID:Reply-To:References:References:Sender; bh=JjcRS5MWMVchWMHYMeNipucu3NyHAGZyreCY0XhrQwI=; b=iy+FhqV0P0VTOsALHl/wp63tozJoiWOi+hswvvxP10Vu7W4nkCmqEnd1Hf2+XLRz 0q7t/+2HLU93k/kG/KypCiOukni9mcFVwIZ8vWvHTwmtcUz6F77FcjjLk9MlNlXyYkA pCz/LQun/WOQ3VlBc14O/BhMhaC+ZpIY19YcCbuTjMJBOXpf417t7j7gGx/WuDmY7B3 myHJ9L4DoaK33x8xhpPcO7Pad8/ElGN/C6YGCnRxVclI2KMpiRtaixtVICEffWJA4IG oSwD9GcP8B2rcl+70ZbAwyxeC5CB0mOcmTKE+RJKMPu/pHkKbJatZwS6jR2tv3dHGMM bgf9939jOw== Date: Fri, 4 Aug 2023 21:23:09 +0200 (CEST) From: Lynne To: FFmpeg development discussions and patches Message-ID: In-Reply-To: References: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_225205_1338026646.1691176989432" Subject: [FFmpeg-devel] [PATCH 2/2] wmavoice: convert DCT-I/DST-I to lavu/tx 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_225205_1338026646.1691176989432 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit This is the very last user of any lavc transform code. This also *corrects* wmavoice decoding, as the previous DCT/DST transforms were incorrect, bringing it closer to Microsoft's own wmavoice decoder. Note: this requires new FATE files, or for the tests to be modified to use a target error. ------=_Part_225205_1338026646.1691176989432 Content-Type: text/x-diff; charset=us-ascii; name=0002-wmavoice-convert-DCT-I-DST-I-to-lavu-tx.patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=0002-wmavoice-convert-DCT-I-DST-I-to-lavu-tx.patch >From c892079d2b816d2742aa3c192c090e2cb83952e7 Mon Sep 17 00:00:00 2001 From: Lynne Date: Fri, 4 Aug 2023 21:16:30 +0200 Subject: [PATCH 2/2] wmavoice: convert DCT-I/DST-I to lavu/tx This is the very last user of any lavc transform code. This also *corrects* wmavoice decoding, as the previous DCT/DST transforms were incorrect, bringing it closer to Microsoft's own wmavoice decoder. --- libavcodec/wmavoice.c | 29 +++++++++++++++++------------ tests/fate/wma.mak | 6 +++--- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/libavcodec/wmavoice.c b/libavcodec/wmavoice.c index 5ae92e2dbc..915315cb8a 100644 --- a/libavcodec/wmavoice.c +++ b/libavcodec/wmavoice.c @@ -42,8 +42,6 @@ #include "acelp_vectors.h" #include "acelp_filters.h" #include "lsp.h" -#include "dct.h" -#include "rdft.h" #include "sinewin.h" #define MAX_BLOCKS 8 ///< maximum number of blocks per frame @@ -266,8 +264,8 @@ typedef struct WMAVoiceContext { */ AVTXContext *rdft, *irdft; ///< contexts for FFT-calculation in the av_tx_fn rdft_fn, irdft_fn; ///< postfilter (for denoise filter) - DCTContext dct, dst; ///< contexts for phase shift (in Hilbert - ///< transform, part of postfilter) + AVTXContext *dct, *dst; ///< contexts for phase shift (in Hilbert + av_tx_fn dct_fn, dst_fn; ///< transform, part of postfilter) float sin[511], cos[511]; ///< 8-bit cosine/sine windows over [-pi,pi] ///< range float postfilter_agc; ///< gain control memory, used in @@ -391,10 +389,6 @@ static av_cold int wmavoice_decode_init(AVCodecContext *ctx) if (s->do_apf) { float scale = 1.0f; - if ((ret = ff_dct_init (&s->dct, 6, DCT_I)) < 0 || - (ret = ff_dct_init (&s->dst, 6, DST_I)) < 0) - return ret; - ret = av_tx_init(&s->rdft, &s->rdft_fn, AV_TX_FLOAT_RDFT, 0, 1 << 7, &scale, 0); if (ret < 0) return ret; @@ -403,6 +397,16 @@ static av_cold int wmavoice_decode_init(AVCodecContext *ctx) if (ret < 0) return ret; + scale = 1.0 / (1 << 6); + ret = av_tx_init(&s->dct, &s->dct_fn, AV_TX_FLOAT_DCT_I, 0, 1 << 6, &scale, 0); + if (ret < 0) + return ret; + + scale = 1.0 / (1 << 6); + ret = av_tx_init(&s->dst, &s->dst_fn, AV_TX_FLOAT_DST_I, 0, 1 << 6, &scale, 0); + if (ret < 0) + return ret; + ff_sine_window_init(s->cos, 256); memcpy(&s->sin[255], s->cos, 256 * sizeof(s->cos[0])); for (n = 0; n < 255; n++) { @@ -612,6 +616,7 @@ static void calc_input_response(WMAVoiceContext *s, float *lpcs_src, float irange, angle_mul, gain_mul, range, sq; LOCAL_ALIGNED_32(float, coeffs, [0x82]); LOCAL_ALIGNED_32(float, lpcs, [0x82]); + LOCAL_ALIGNED_32(float, lpcs_dct, [0x82]); int n, idx; memcpy(coeffs, coeffs_dst, 0x82*sizeof(float)); @@ -662,8 +667,8 @@ static void calc_input_response(WMAVoiceContext *s, float *lpcs_src, * is a sine input) by doing a phase shift (in theory, H(sin())=cos()). * Hilbert_Transform(RDFT(x)) = Laplace_Transform(x), which calculates the * "moment" of the LPCs in this filter. */ - s->dct.dct_calc(&s->dct, lpcs); - s->dst.dct_calc(&s->dst, lpcs); + s->dct_fn(s->dct, lpcs_dct, lpcs, sizeof(float)); + s->dst_fn(s->dst, lpcs, lpcs_dct, sizeof(float)); /* Split out the coefficient indexes into phase/magnitude pairs */ idx = 255 + av_clip(lpcs[64], -255, 255); @@ -2003,8 +2008,8 @@ static av_cold int wmavoice_decode_end(AVCodecContext *ctx) if (s->do_apf) { av_tx_uninit(&s->rdft); av_tx_uninit(&s->irdft); - ff_dct_end(&s->dct); - ff_dct_end(&s->dst); + av_tx_uninit(&s->dct); + av_tx_uninit(&s->dst); } return 0; diff --git a/tests/fate/wma.mak b/tests/fate/wma.mak index c13874ebfc..d23ea29c92 100644 --- a/tests/fate/wma.mak +++ b/tests/fate/wma.mak @@ -20,17 +20,17 @@ fate-wmapro: $(FATE_WMAPRO-yes) FATE_WMAVOICE-$(call DEMDEC, ASF, WMAVOICE) += fate-wmavoice-7k fate-wmavoice-7k: CMD = pcm -i $(TARGET_SAMPLES)/wmavoice/streaming_CBR-7K.wma -fate-wmavoice-7k: REF = $(SAMPLES)/wmavoice/streaming_CBR-7K.pcm +fate-wmavoice-7k: REF = $(SAMPLES)/wmavoice/streaming_CBR-7K_new.pcm fate-wmavoice-7k: FUZZ = 3 FATE_WMAVOICE-$(call DEMDEC, ASF, WMAVOICE) += fate-wmavoice-11k fate-wmavoice-11k: CMD = pcm -i $(TARGET_SAMPLES)/wmavoice/streaming_CBR-11K.wma -fate-wmavoice-11k: REF = $(SAMPLES)/wmavoice/streaming_CBR-11K.pcm +fate-wmavoice-11k: REF = $(SAMPLES)/wmavoice/streaming_CBR-11K_new.pcm fate-wmavoice-11k: FUZZ = 3 FATE_WMAVOICE-$(call DEMDEC, ASF, WMAVOICE) += fate-wmavoice-19k fate-wmavoice-19k: CMD = pcm -i $(TARGET_SAMPLES)/wmavoice/streaming_CBR-19K.wma -fate-wmavoice-19k: REF = $(SAMPLES)/wmavoice/streaming_CBR-19K.pcm +fate-wmavoice-19k: REF = $(SAMPLES)/wmavoice/streaming_CBR-19K_new.pcm fate-wmavoice-19k: FUZZ = 3 $(FATE_WMAVOICE-yes): CMP = stddev -- 2.40.1 ------=_Part_225205_1338026646.1691176989432 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_225205_1338026646.1691176989432--