Showing the changes to libavcodec (1 of 1 file). Show all
Unified · Split
| @@ -18,38 +18,60 @@ · 17 unmodified lines | ||
| 18 | 18 | |
| 19 | 19 | #include "libavutil/attributes.h" |
| 20 | 20 | #include "libavutil/mem.h" |
| 21 | +#include "libavutil/tx.h" | |
| 21 | 22 | #include "avfft.h" |
| 22 | 23 | #include "fft.h" |
| 23 | 24 | #include "rdft.h" |
| 24 | 25 | #include "dct.h" |
| 25 | 26 | |
| 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 | + | |
| 26 | 37 | /* FFT */ |
| 27 | 38 | |
| 28 | 39 | FFTContext *av_fft_init(int nbits, int inverse) |
| 29 | 40 | { |
| 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 | + } | |
| 34 | 53 | |
| 35 | − return s; | |
| 54 | + return (FFTContext *)s; | |
| 36 | 55 | } |
| 37 | 56 | |
| 38 | 57 | void av_fft_permute(FFTContext *s, FFTComplex *z) |
| 39 | 58 | { |
| 40 | − s->fft_permute(s, z); | |
| 59 | + /* Empty */ | |
| 41 | 60 | } |
| 42 | 61 | |
| 43 | 62 | void av_fft_calc(FFTContext *s, FFTComplex *z) |
| 44 | 63 | { |
| 45 | − s->fft_calc(s, z); | |
| 64 | + AVTXWrapper *w = (AVTXWrapper *)s; | |
| 65 | + w->fn(w->ctx, z, (void *)z, sizeof(AVComplexFloat)); | |
| 46 | 66 | } |
| 47 | 67 | |
| 48 | 68 | av_cold void av_fft_end(FFTContext *s) |
| 49 | 69 | { |
| 50 | 70 | 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); | |
| 53 | 75 | } |
| 54 | 76 | } |
| 55 | 77 | |