diff mbox series

[FFmpeg-devel,1/3] avfft: wrap lavu/tx instead of ff_fft

Message ID NaG5X1Z--3-9@lynne.ee
State New
Headers show
Series [FFmpeg-devel,1/3] avfft: wrap lavu/tx instead of ff_fft | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Lynne July 26, 2023, 7:29 a.m. UTC
Patch attached.
diff mbox series

Patch

From 3a595d6f177617ce89cc2709eca61b7cf486ce22 Mon Sep 17 00:00:00 2001
From: Lynne <dev@lynne.ee>
Date: Thu, 10 Nov 2022 11:23:38 +0100
Subject: [PATCH 1/3] avfft: wrap lavu/tx instead of ff_fft

---
 libavcodec/avfft.c | 40 +++++++++++++++++++++++++++++++---------
 1 file changed, 31 insertions(+), 9 deletions(-)

diff --git a/libavcodec/avfft.c b/libavcodec/avfft.c
index 2200f37708..e4b19af272 100644
--- a/libavcodec/avfft.c
+++ b/libavcodec/avfft.c
@@ -18,38 +18,60 @@ 
 
 #include "libavutil/attributes.h"
 #include "libavutil/mem.h"
+#include "libavutil/tx.h"
 #include "avfft.h"
 #include "fft.h"
 #include "rdft.h"
 #include "dct.h"
 
+typedef struct AVTXWrapper {
+    AVTXContext *ctx;
+    av_tx_fn fn;
+
+    AVTXContext *ctx2;
+    av_tx_fn fn2;
+
+    ptrdiff_t stride;
+} AVTXWrapper;
+
 /* FFT */
 
 FFTContext *av_fft_init(int nbits, int inverse)
 {
-    FFTContext *s = av_mallocz(sizeof(*s));
-
-    if (s && ff_fft_init(s, nbits, inverse))
-        av_freep(&s);
+    int ret;
+    float scale = 1.0f;
+    AVTXWrapper *s = av_malloc(sizeof(*s));
+    if (!s)
+        return NULL;
+
+    ret = av_tx_init(&s->ctx, &s->fn, AV_TX_FLOAT_FFT, inverse, 1 << nbits,
+                     &scale, AV_TX_INPLACE);
+    if (ret < 0) {
+        av_free(s);
+        return NULL;
+    }
 
-    return s;
+    return (FFTContext *)s;
 }
 
 void av_fft_permute(FFTContext *s, FFTComplex *z)
 {
-    s->fft_permute(s, z);
+    /* Empty */
 }
 
 void av_fft_calc(FFTContext *s, FFTComplex *z)
 {
-    s->fft_calc(s, z);
+    AVTXWrapper *w = (AVTXWrapper *)s;
+    w->fn(w->ctx, z, (void *)z, sizeof(AVComplexFloat));
 }
 
 av_cold void av_fft_end(FFTContext *s)
 {
     if (s) {
-        ff_fft_end(s);
-        av_free(s);
+        AVTXWrapper *w = (AVTXWrapper *)s;
+        av_tx_uninit(&w->ctx);
+        av_tx_uninit(&w->ctx2);
+        av_free(w);
     }
 }
 
-- 
2.40.1