[FFmpeg-cvslog] avfft: wrap lavu/tx instead of ff_mdct

Lynne git at videolan.org
Sat Sep 2 01:00:14 EEST 2023


ffmpeg | branch: master | Lynne <dev at lynne.ee> | Thu Nov 10 11:26:33 2022 +0100| [517e4fcca6b81e73536d4ef5edfd22ad5886e783] | committer: Lynne

avfft: wrap lavu/tx instead of ff_mdct

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

 libavcodec/avfft.c | 43 ++++++++++++++++++++++++++++++-------------
 1 file changed, 30 insertions(+), 13 deletions(-)

diff --git a/libavcodec/avfft.c b/libavcodec/avfft.c
index e4b19af272..107b510828 100644
--- a/libavcodec/avfft.c
+++ b/libavcodec/avfft.c
@@ -75,43 +75,60 @@ av_cold void av_fft_end(FFTContext *s)
     }
 }
 
-#if CONFIG_MDCT
-
 FFTContext *av_mdct_init(int nbits, int inverse, double scale)
 {
-    FFTContext *s = av_malloc(sizeof(*s));
+    int ret;
+    float scale_f = scale;
+    AVTXWrapper *s = av_malloc(sizeof(*s));
+    if (!s)
+        return NULL;
 
-    if (s && ff_mdct_init(s, nbits, inverse, scale))
-        av_freep(&s);
+    ret = av_tx_init(&s->ctx, &s->fn, AV_TX_FLOAT_MDCT, inverse, 1 << (nbits - 1), &scale_f, 0);
+    if (ret < 0) {
+        av_free(s);
+        return NULL;
+    }
 
-    return s;
+    if (inverse) {
+        ret = av_tx_init(&s->ctx2, &s->fn2, AV_TX_FLOAT_MDCT, inverse, 1 << (nbits - 1),
+                         &scale_f, AV_TX_FULL_IMDCT);
+        if (ret < 0) {
+            av_tx_uninit(&s->ctx);
+            av_free(s);
+            return NULL;
+        }
+    }
+
+    return (FFTContext *)s;
 }
 
 void av_imdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input)
 {
-    s->imdct_calc(s, output, input);
+    AVTXWrapper *w = (AVTXWrapper *)s;
+    w->fn2(w->ctx2, output, (void *)input, sizeof(float));
 }
 
 void av_imdct_half(FFTContext *s, FFTSample *output, const FFTSample *input)
 {
-    s->imdct_half(s, output, input);
+    AVTXWrapper *w = (AVTXWrapper *)s;
+    w->fn(w->ctx, output, (void *)input, sizeof(float));
 }
 
 void av_mdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input)
 {
-    s->mdct_calc(s, output, input);
+    AVTXWrapper *w = (AVTXWrapper *)s;
+    w->fn(w->ctx, output, (void *)input, sizeof(float));
 }
 
 av_cold void av_mdct_end(FFTContext *s)
 {
     if (s) {
-        ff_mdct_end(s);
-        av_free(s);
+        AVTXWrapper *w = (AVTXWrapper *)s;
+        av_tx_uninit(&w->ctx);
+        av_free(w);
     }
 }
 
-#endif /* CONFIG_MDCT */
-
 #if CONFIG_RDFT
 
 RDFTContext *av_rdft_init(int nbits, enum RDFTransformType trans)



More information about the ffmpeg-cvslog mailing list