diff options
author | Lynne <dev@lynne.ee> | 2022-11-01 09:05:23 +0100 |
---|---|---|
committer | Lynne <dev@lynne.ee> | 2022-11-06 14:39:39 +0100 |
commit | 5f52094f3d4adc69745fc830bef9a1287ee0d92d (patch) | |
tree | 6b56398fd99fe85f36813e611ad9b025e8db3410 /libavcodec/atrac1.c | |
parent | 978963a77b27d52000f83c647ef46b6d0c390326 (diff) | |
download | ffmpeg-5f52094f3d4adc69745fc830bef9a1287ee0d92d.tar.gz |
atrac1: convert to lavu/tx
Diffstat (limited to 'libavcodec/atrac1.c')
-rw-r--r-- | libavcodec/atrac1.c | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/libavcodec/atrac1.c b/libavcodec/atrac1.c index fb83449c16..1309bb95a2 100644 --- a/libavcodec/atrac1.c +++ b/libavcodec/atrac1.c @@ -32,12 +32,12 @@ #include "libavutil/float_dsp.h" #include "libavutil/mem_internal.h" +#include "libavutil/tx.h" #include "avcodec.h" #include "codec_internal.h" #include "decode.h" #include "get_bits.h" -#include "fft.h" #include "sinewin.h" #include "atrac.h" @@ -80,7 +80,8 @@ typedef struct AT1Ctx { DECLARE_ALIGNED(32, float, mid)[256]; DECLARE_ALIGNED(32, float, high)[512]; float* bands[3]; - FFTContext mdct_ctx[3]; + AVTXContext *mdct_ctx[3]; + av_tx_fn mdct_fn[3]; void (*vector_fmul_window)(float *dst, const float *src0, const float *src1, const float *win, int len); } AT1Ctx; @@ -93,7 +94,8 @@ static const uint8_t mdct_long_nbits[3] = {7, 7, 8}; static void at1_imdct(AT1Ctx *q, float *spec, float *out, int nbits, int rev_spec) { - FFTContext* mdct_context = &q->mdct_ctx[nbits - 5 - (nbits > 6)]; + AVTXContext *mdct_context = q->mdct_ctx[nbits - 5 - (nbits > 6)]; + av_tx_fn mdct_fn = q->mdct_fn[nbits - 5 - (nbits > 6)]; int transf_size = 1 << nbits; if (rev_spec) { @@ -101,7 +103,7 @@ static void at1_imdct(AT1Ctx *q, float *spec, float *out, int nbits, for (i = 0; i < transf_size / 2; i++) FFSWAP(float, spec[i], spec[transf_size - 1 - i]); } - mdct_context->imdct_half(mdct_context, out, spec); + mdct_fn(mdct_context, out, spec, sizeof(float)); } @@ -322,9 +324,9 @@ static av_cold int atrac1_decode_end(AVCodecContext * avctx) { AT1Ctx *q = avctx->priv_data; - ff_mdct_end(&q->mdct_ctx[0]); - ff_mdct_end(&q->mdct_ctx[1]); - ff_mdct_end(&q->mdct_ctx[2]); + av_tx_uninit(&q->mdct_ctx[0]); + av_tx_uninit(&q->mdct_ctx[1]); + av_tx_uninit(&q->mdct_ctx[2]); return 0; } @@ -335,6 +337,7 @@ static av_cold int atrac1_decode_init(AVCodecContext *avctx) AT1Ctx *q = avctx->priv_data; AVFloatDSPContext *fdsp; int channels = avctx->ch_layout.nb_channels; + float scale = -1.0 / (1 << 15); int ret; avctx->sample_fmt = AV_SAMPLE_FMT_FLTP; @@ -351,12 +354,15 @@ static av_cold int atrac1_decode_init(AVCodecContext *avctx) } /* Init the mdct transforms */ - if ((ret = ff_mdct_init(&q->mdct_ctx[0], 6, 1, -1.0/ (1 << 15))) || - (ret = ff_mdct_init(&q->mdct_ctx[1], 8, 1, -1.0/ (1 << 15))) || - (ret = ff_mdct_init(&q->mdct_ctx[2], 9, 1, -1.0/ (1 << 15)))) { - av_log(avctx, AV_LOG_ERROR, "Error initializing MDCT\n"); + if ((ret = av_tx_init(&q->mdct_ctx[0], &q->mdct_fn[0], AV_TX_FLOAT_MDCT, + 1, 32, &scale, 0) < 0)) + return ret; + if ((ret = av_tx_init(&q->mdct_ctx[1], &q->mdct_fn[1], AV_TX_FLOAT_MDCT, + 1, 128, &scale, 0) < 0)) + return ret; + if ((ret = av_tx_init(&q->mdct_ctx[2], &q->mdct_fn[2], AV_TX_FLOAT_MDCT, + 1, 256, &scale, 0) < 0)) return ret; - } ff_init_ff_sine_windows(5); |