History

avfft: wrap lavu/tx instead of ff_fft

Lynne committed 4 years ago

Commit dfcd4bb1 parent 4acd08b1 file · +31 −9Browse files

Unified · Split

libavcodec/avfft.c+31−9
@@ -18,38 +18,60 @@ · 17 unmodified lines
1818
1919 #include "libavutil/attributes.h"
2020 #include "libavutil/mem.h"
21+#include "libavutil/tx.h"
2122 #include "avfft.h"
2223 #include "fft.h"
2324 #include "rdft.h"
2425 #include "dct.h"
2526
27+typedef struct AVTXWrapper {
28+ AVTXContext *ctx;
29+ av_tx_fn fn;
30+
31+ AVTXContext *ctx2;
32+ av_tx_fn fn2;
33+
34+ ptrdiff_t stride;
35+} AVTXWrapper;
36+
2637 /* FFT */
2738
2839 FFTContext *av_fft_init(int nbits, int inverse)
2940 {
30− FFTContext *s = av_mallocz(sizeof(*s));
31−
32− if (s && ff_fft_init(s, nbits, inverse))
33− av_freep(&s);
41+ int ret;
42+ float scale = 1.0f;
43+ AVTXWrapper *s = av_malloc(sizeof(*s));
44+ if (!s)
45+ return NULL;
46+
47+ ret = av_tx_init(&s->ctx, &s->fn, AV_TX_FLOAT_FFT, inverse, 1 << nbits,
48+ &scale, AV_TX_INPLACE);
49+ if (ret < 0) {
50+ av_free(s);
51+ return NULL;
52+ }
3453
35− return s;
54+ return (FFTContext *)s;
3655 }
3756
3857 void av_fft_permute(FFTContext *s, FFTComplex *z)
3958 {
40− s->fft_permute(s, z);
59+ /* Empty */
4160 }
4261
4362 void av_fft_calc(FFTContext *s, FFTComplex *z)
4463 {
45− s->fft_calc(s, z);
64+ AVTXWrapper *w = (AVTXWrapper *)s;
65+ w->fn(w->ctx, z, (void *)z, sizeof(AVComplexFloat));
4666 }
4767
4868 av_cold void av_fft_end(FFTContext *s)
4969 {
5070 if (s) {
51− ff_fft_end(s);
52− av_free(s);
71+ AVTXWrapper *w = (AVTXWrapper *)s;
72+ av_tx_uninit(&w->ctx);
73+ av_tx_uninit(&w->ctx2);
74+ av_free(w);
5375 }
5476 }
5577

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t