Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 1/3] avfft: wrap lavu/tx instead of ff_fft
@ 2023-07-26  7:29 Lynne
       [not found] ` <NaG5X1Z--3-9@lynne.ee-NaG5_-0----9>
  0 siblings, 1 reply; 3+ messages in thread
From: Lynne @ 2023-07-26  7:29 UTC (permalink / raw)
  To: Ffmpeg Devel

[-- Attachment #1: Type: text/plain, Size: 17 bytes --]

Patch attached.


[-- Attachment #2: 0001-avfft-wrap-lavu-tx-instead-of-ff_fft.patch --]
[-- Type: text/x-diff, Size: 1887 bytes --]

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


[-- Attachment #3: Type: text/plain, Size: 251 bytes --]

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [FFmpeg-devel] [PATCH 2/3] avfft: wrap lavu/tx instead of ff_mdct
       [not found] ` <NaG5X1Z--3-9@lynne.ee-NaG5_-0----9>
@ 2023-07-26  7:30   ` Lynne
  2023-07-26  7:30   ` [FFmpeg-devel] [PATCH 3/3] avfft: wrap lavu/tx instead of ff_rdft Lynne
  1 sibling, 0 replies; 3+ messages in thread
From: Lynne @ 2023-07-26  7:30 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

[-- Attachment #1: Type: text/plain, Size: 17 bytes --]

Patch attached.


[-- Attachment #2: 0002-avfft-wrap-lavu-tx-instead-of-ff_mdct.patch --]
[-- Type: text/x-diff, Size: 2306 bytes --]

From 593d95ce1d2510394c09ea64d8669973889d20e8 Mon Sep 17 00:00:00 2001
From: Lynne <dev@lynne.ee>
Date: Thu, 10 Nov 2022 11:26:33 +0100
Subject: [PATCH 2/3] avfft: wrap lavu/tx instead of ff_mdct

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

diff --git a/libavcodec/avfft.c b/libavcodec/avfft.c
index e4b19af272..ff5c739897 100644
--- a/libavcodec/avfft.c
+++ b/libavcodec/avfft.c
@@ -75,43 +75,56 @@ 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);
-    }
+    av_fft_end(s);
 }
 
-#endif /* CONFIG_MDCT */
-
 #if CONFIG_RDFT
 
 RDFTContext *av_rdft_init(int nbits, enum RDFTransformType trans)
-- 
2.40.1


[-- Attachment #3: Type: text/plain, Size: 251 bytes --]

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [FFmpeg-devel] [PATCH 3/3] avfft: wrap lavu/tx instead of ff_rdft
       [not found] ` <NaG5X1Z--3-9@lynne.ee-NaG5_-0----9>
  2023-07-26  7:30   ` [FFmpeg-devel] [PATCH 2/3] avfft: wrap lavu/tx instead of ff_mdct Lynne
@ 2023-07-26  7:30   ` Lynne
  1 sibling, 0 replies; 3+ messages in thread
From: Lynne @ 2023-07-26  7:30 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

[-- Attachment #1: Type: text/plain, Size: 17 bytes --]

Patch attached.


[-- Attachment #2: 0003-avfft-wrap-lavu-tx-instead-of-ff_rdft.patch --]
[-- Type: text/x-diff, Size: 1888 bytes --]

From 68781f3bc021fe96c4b4b4a355e03d7c5bd3539b Mon Sep 17 00:00:00 2001
From: Lynne <dev@lynne.ee>
Date: Thu, 10 Nov 2022 11:26:59 +0100
Subject: [PATCH 3/3] avfft: wrap lavu/tx instead of ff_rdft

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

diff --git a/libavcodec/avfft.c b/libavcodec/avfft.c
index ff5c739897..f5880f9932 100644
--- a/libavcodec/avfft.c
+++ b/libavcodec/avfft.c
@@ -125,33 +125,44 @@ av_cold void av_mdct_end(FFTContext *s)
     av_fft_end(s);
 }
 
-#if CONFIG_RDFT
-
 RDFTContext *av_rdft_init(int nbits, enum RDFTransformType trans)
 {
-    RDFTContext *s = av_malloc(sizeof(*s));
+    int ret;
+    float scale = 1.0f;
+    AVTXWrapper *s;
 
-    if (s && ff_rdft_init(s, nbits, trans))
-        av_freep(&s);
+    /* The other 2 modes are unconventional, do not form an orthogonal
+     * transform, have never been useful, and so they're not implemented. */
+    if (trans != IDFT_C2R && trans != DFT_R2C)
+        return NULL;
 
-    return s;
+    s = av_malloc(sizeof(*s));
+    if (!s)
+        return NULL;
+
+    ret = av_tx_init(&s->ctx, &s->fn, AV_TX_FLOAT_RDFT, trans == IDFT_C2R,
+                     1 << nbits, &scale, AV_TX_INPLACE);
+    if (ret < 0) {
+        av_free(s);
+        return NULL;
+    }
+
+    s->stride = (trans == DFT_C2R) ? sizeof(float) : sizeof(AVComplexFloat);
+
+    return (RDFTContext *)s;
 }
 
 void av_rdft_calc(RDFTContext *s, FFTSample *data)
 {
-    s->rdft_calc(s, data);
+    AVTXWrapper *w = (AVTXWrapper *)s;
+    w->fn(w->ctx, data, (void *)data, w->stride);
 }
 
 av_cold void av_rdft_end(RDFTContext *s)
 {
-    if (s) {
-        ff_rdft_end(s);
-        av_free(s);
-    }
+    av_fft_end((FFTContext *)s);
 }
 
-#endif /* CONFIG_RDFT */
-
 #if CONFIG_DCT
 
 DCTContext *av_dct_init(int nbits, enum DCTTransformType inverse)
-- 
2.40.1


[-- Attachment #3: Type: text/plain, Size: 251 bytes --]

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-07-26  7:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-26  7:29 [FFmpeg-devel] [PATCH 1/3] avfft: wrap lavu/tx instead of ff_fft Lynne
     [not found] ` <NaG5X1Z--3-9@lynne.ee-NaG5_-0----9>
2023-07-26  7:30   ` [FFmpeg-devel] [PATCH 2/3] avfft: wrap lavu/tx instead of ff_mdct Lynne
2023-07-26  7:30   ` [FFmpeg-devel] [PATCH 3/3] avfft: wrap lavu/tx instead of ff_rdft Lynne

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git