[FFmpeg-cvslog] atrac1: convert to lavu/tx

Lynne git at videolan.org
Sun Nov 6 15:41:55 EET 2022


ffmpeg | branch: master | Lynne <dev at lynne.ee> | Tue Nov  1 09:05:23 2022 +0100| [5f52094f3d4adc69745fc830bef9a1287ee0d92d] | committer: Lynne

atrac1: convert to lavu/tx

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5f52094f3d4adc69745fc830bef9a1287ee0d92d
---

 configure           |  2 +-
 libavcodec/atrac1.c | 30 ++++++++++++++++++------------
 2 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/configure b/configure
index 820f88d2c9..930e8c1b5a 100755
--- a/configure
+++ b/configure
@@ -2791,7 +2791,7 @@ asv1_decoder_select="blockdsp bswapdsp idctdsp"
 asv1_encoder_select="aandcttables bswapdsp fdctdsp pixblockdsp"
 asv2_decoder_select="blockdsp bswapdsp idctdsp"
 asv2_encoder_select="aandcttables bswapdsp fdctdsp pixblockdsp"
-atrac1_decoder_select="mdct sinewin"
+atrac1_decoder_select="sinewin"
 atrac3_decoder_select="mdct"
 atrac3al_decoder_select="mdct"
 atrac3p_decoder_select="mdct sinewin"
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);
 



More information about the ffmpeg-cvslog mailing list