[FFmpeg-devel] [PATCH] lavu: support arbitrary-point FFT and all even (i)MDCT transforms
James Almer
jamrial at gmail.com
Wed Jan 13 18:45:52 EET 2021
On 1/12/2021 4:18 AM, Lynne wrote:
> This patch adds support for arbitrary-point FFTs and all even MDCT
> transforms.
> Odd MDCTs are not supported yet as they're based on the DCT-II and DCT-III
> and they're very niche.
>
> With this we can now write tests.
>
> Patch attached.
[...]
> @@ -575,11 +651,13 @@ int TX_NAME(ff_tx_init_mdct_fft)(AVTXContext *s, av_tx_fn *tx,
> const void *scale, uint64_t flags)
> {
> const int is_mdct = ff_tx_type_is_mdct(type);
> - int err, n = 1, m = 1, max_ptwo = 1 << (FF_ARRAY_ELEMS(fft_dispatch) - 1);
> + int err, l, n = 1, m = 1, max_ptwo = 1 << (FF_ARRAY_ELEMS(fft_dispatch) - 1);
>
> if (is_mdct)
> len >>= 1;
>
> + l = len;
> +
> #define CHECK_FACTOR(DST, FACTOR, SRC) \
> if (DST == 1 && !(SRC % FACTOR)) { \
> DST = FACTOR; \
> @@ -601,12 +679,23 @@ int TX_NAME(ff_tx_init_mdct_fft)(AVTXContext *s, av_tx_fn *tx,
> s->inv = inv;
> s->type = type;
>
> - /* Filter out direct 3, 5 and 15 transforms, too niche */
> + /* If we weren't able to split the length into factors we can handle,
> + * resort to using the naive and slow FT. This also filters out
> + * direct 3, 5 and 15 transforms as they're too niche. */
> if (len > 1 || m == 1) {
> - av_log(NULL, AV_LOG_ERROR, "Unsupported transform size: n = %i, "
> - "m = %i, residual = %i!\n", n, m, len);
> - return AVERROR(EINVAL);
> - } else if (n > 1 && m > 1) { /* 2D transform case */
> + if (is_mdct && (l & 1)) /* Odd (i)MDCTs are not supported yet */
> + return AVERROR(ENOTSUP);
I think ENOTSUP is not portable, which is why we use ENOSYS to signal
unimplemented/unsupported features.
> + s->n = l;
> + s->m = 1;
> + *tx = naive_fft;
> + if (is_mdct) {
> + s->scale = *((SCALE_TYPE *)scale);
> + *tx = inv ? naive_imdct : naive_mdct;
> + }
> + return 0;
> + }
> +
> + if (n > 1 && m > 1) { /* 2D transform case */
> if ((err = ff_tx_gen_compound_mapping(s)))
> return err;
> if (!(s->tmp = av_malloc(n*m*sizeof(*s->tmp))))
> --
> 2.30.0.rc2
>
More information about the ffmpeg-devel
mailing list