From 8b6945327c4adc0fb58be991162b39621fa17eda Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Sat, 15 Sep 2018 16:42:38 +0200 Subject: [PATCH] src/spectral/dct.c: check if accelerate support size --- src/spectral/dct.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/spectral/dct.c b/src/spectral/dct.c index 1920a54c..1a2e5109 100644 --- a/src/spectral/dct.c +++ b/src/spectral/dct.c @@ -83,12 +83,18 @@ aubio_dct_t* new_aubio_dct (uint_t size) { aubio_dct_t * s = AUBIO_NEW(aubio_dct_t); if ((sint_t)size <= 0) goto beach; #if defined(HAVE_ACCELERATE) - // TODO check // vDSP supports sizes = f * 2 ** n, where n >= 4 and f in [1, 3, 5, 15] // see https://developer.apple.com/documentation/accelerate/1449930-vdsp_dct_createsetup - if (aubio_is_power_of_two(size/16) != 1 - || (size/16 != 3 && size/16 != 5 && size/16 != 15)) { - goto plain; + { + uint_t radix = size; + uint_t order = 0; + while ((radix / 2) * 2 == radix) { + radix /= 2; + order++; + } + if (order < 4 || (radix != 1 && radix != 3 && radix != 5 && radix != 15)) { + goto plain; + } } s->dct = (void *)new_aubio_dct_accelerate (size); if (s->dct) { -- 2.11.0