summaryrefslogtreecommitdiff
path: root/libavutil/tx.c
diff options
context:
space:
mode:
authorLynne <dev@lynne.ee>2022-01-21 07:50:53 +0100
committerLynne <dev@lynne.ee>2022-01-26 04:12:46 +0100
commitaf94ab7c7c004786084903bcf82b7617e88e3aa9 (patch)
tree022db61a65adcac1dce40157c341352dd0ed2ced /libavutil/tx.c
parentef4bd8161575a79f0ac247ad0aa2f05b8c20052b (diff)
lavu/tx: add an RDFT implementation
RDFTs are full of conventions that vary between implementations. What I've gone for here is what's most common between both fftw, avcodec's rdft and what we use, the equivalent of which is DFT_R2C for forward and IDFT_C2R for inverse. The other 2 conventions (IDFT_R2C and DFT_C2R) were not used at all in our code, and their names are also not appropriate. If there's a use for either, we can easily add a flag which would just flip the sign on one exptab. For some unknown reason, possibly to allow reusing FFT's exp tables, av_rdft's C2R output is 0.5x lower than what it should be to ensure a proper back-and-forth conversion. This code outputs its real samples at the correct level, which matches FFTW's level, and allows the user to change the level and insert arbitrary multiplies for free by setting the scale option.
Diffstat (limited to 'libavutil/tx.c')
-rw-r--r--libavutil/tx.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/libavutil/tx.c b/libavutil/tx.c
index c34d3d94fe..37785b33df 100644
--- a/libavutil/tx.c
+++ b/libavutil/tx.c
@@ -262,7 +262,7 @@ static av_cold int ff_tx_null_init(AVTXContext *s, const FFTXCodelet *cd,
int len, int inv, const void *scale)
{
/* Can only handle one sample+type to one sample+type transforms */
- if (TYPE_IS(MDCT, s->type))
+ if (TYPE_IS(MDCT, s->type) || TYPE_IS(RDFT, s->type))
return AVERROR(EINVAL);
return 0;
}
@@ -322,10 +322,13 @@ static void print_type(AVBPrint *bp, enum AVTXType type)
type == TX_TYPE_ANY ? "any" :
type == AV_TX_FLOAT_FFT ? "fft_float" :
type == AV_TX_FLOAT_MDCT ? "mdct_float" :
+ type == AV_TX_FLOAT_RDFT ? "rdft_float" :
type == AV_TX_DOUBLE_FFT ? "fft_double" :
type == AV_TX_DOUBLE_MDCT ? "mdct_double" :
+ type == AV_TX_DOUBLE_RDFT ? "rdft_double" :
type == AV_TX_INT32_FFT ? "fft_int32" :
type == AV_TX_INT32_MDCT ? "mdct_int32" :
+ type == AV_TX_INT32_RDFT ? "rdft_int32" :
"unknown");
}