From 8cd46c48ac2e2b69fb58656c8df25a35c27d91ea Mon Sep 17 00:00:00 2001 From: Lynne Date: Sun, 30 Oct 2022 11:54:40 +0100 Subject: [PATCH] nellymoserenc: convert to lavu/tx --- configure | 2 +- libavcodec/nellymoserenc.c | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/configure b/configure index 7ff572f097..eea1ea3743 100755 --- a/configure +++ b/configure @@ -2914,7 +2914,7 @@ mvha_decoder_select="inflate_wrapper llviddsp" mwsc_decoder_select="inflate_wrapper" mxpeg_decoder_select="mjpeg_decoder" nellymoser_decoder_select="sinewin" -nellymoser_encoder_select="audio_frame_queue mdct sinewin" +nellymoser_encoder_select="audio_frame_queue sinewin" notchlc_decoder_select="lzf" nuv_decoder_select="idctdsp" on2avc_decoder_select="mdct" diff --git a/libavcodec/nellymoserenc.c b/libavcodec/nellymoserenc.c index 1831d36462..a550ae46c5 100644 --- a/libavcodec/nellymoserenc.c +++ b/libavcodec/nellymoserenc.c @@ -39,12 +39,12 @@ #include "libavutil/float_dsp.h" #include "libavutil/mathematics.h" #include "libavutil/thread.h" +#include "libavutil/tx.h" #include "audio_frame_queue.h" #include "avcodec.h" #include "codec_internal.h" #include "encode.h" -#include "fft.h" #include "nellymoser.h" #include "sinewin.h" @@ -59,7 +59,8 @@ typedef struct NellyMoserEncodeContext { AVCodecContext *avctx; int last_frame; AVFloatDSPContext *fdsp; - FFTContext mdct_ctx; + AVTXContext *mdct_ctx; + av_tx_fn mdct_fn; AudioFrameQueue afq; DECLARE_ALIGNED(32, float, mdct_out)[NELLY_SAMPLES]; DECLARE_ALIGNED(32, float, in_buff)[NELLY_SAMPLES]; @@ -126,18 +127,18 @@ static void apply_mdct(NellyMoserEncodeContext *s) s->fdsp->vector_fmul (s->in_buff, in0, ff_sine_128, NELLY_BUF_LEN); s->fdsp->vector_fmul_reverse(s->in_buff + NELLY_BUF_LEN, in1, ff_sine_128, NELLY_BUF_LEN); - s->mdct_ctx.mdct_calc(&s->mdct_ctx, s->mdct_out, s->in_buff); + s->mdct_fn(s->mdct_ctx, s->mdct_out, s->in_buff, sizeof(float)); s->fdsp->vector_fmul (s->in_buff, in1, ff_sine_128, NELLY_BUF_LEN); s->fdsp->vector_fmul_reverse(s->in_buff + NELLY_BUF_LEN, in2, ff_sine_128, NELLY_BUF_LEN); - s->mdct_ctx.mdct_calc(&s->mdct_ctx, s->mdct_out + NELLY_BUF_LEN, s->in_buff); + s->mdct_fn(s->mdct_ctx, s->mdct_out + NELLY_BUF_LEN, s->in_buff, sizeof(float)); } static av_cold int encode_end(AVCodecContext *avctx) { NellyMoserEncodeContext *s = avctx->priv_data; - ff_mdct_end(&s->mdct_ctx); + av_tx_uninit(&s->mdct_ctx); av_freep(&s->opt); av_freep(&s->path); @@ -169,6 +170,7 @@ static av_cold int encode_init(AVCodecContext *avctx) { static AVOnce init_static_once = AV_ONCE_INIT; NellyMoserEncodeContext *s = avctx->priv_data; + float scale = 32768.0; int ret; if (avctx->sample_rate != 8000 && avctx->sample_rate != 16000 && @@ -183,7 +185,7 @@ static av_cold int encode_init(AVCodecContext *avctx) avctx->initial_padding = NELLY_BUF_LEN; ff_af_queue_init(avctx, &s->afq); s->avctx = avctx; - if ((ret = ff_mdct_init(&s->mdct_ctx, 8, 0, 32768.0)) < 0) + if ((ret = av_tx_init(&s->mdct_ctx, &s->mdct_fn, AV_TX_FLOAT_MDCT, 0, 128, &scale, 0)) < 0) return ret; s->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT); if (!s->fdsp)