kfr

Fast, modern C++ DSP framework, FFT, Sample Rate Conversion, FIR/IIR/Biquad Filters (SSE, AVX, AVX-512, ARM NEON)
Log | Files | Refs | README

commit 006818c91240609e579dd2d6599f8b106822e660
parent 89a709f523152bb8b9ee59455d099dae770f5373
Author: d.levin256@gmail.com <d.levin256@gmail.com>
Date:   Fri, 23 Nov 2018 04:50:56 +0000

DFT C API

Diffstat:
Minclude/kfr/dft/dft-src.cpp | 32++++++++++++++++----------------
Minclude/kfr/dft/dft_c.h | 16+++++++++++-----
Minclude/kfr/dft/fft.hpp | 13+++++++++++++
3 files changed, 40 insertions(+), 21 deletions(-)

diff --git a/include/kfr/dft/dft-src.cpp b/include/kfr/dft/dft-src.cpp @@ -1316,32 +1316,32 @@ extern "C" } void kfr_dft_execute_real_f32(KFR_DFT_REAL_PLAN_F32* plan, size_t size, float* out, const float* in, - uint8_t* temp) + uint8_t* temp, KFR_DFT_PACK_FORMAT pack_format) { - reinterpret_cast<kfr::dft_plan<float>*>(plan)->execute( - reinterpret_cast<kfr::complex<float>*>(out), reinterpret_cast<const kfr::complex<float>*>(in), - temp, kfr::cfalse); + reinterpret_cast<kfr::dft_plan_real<float>*>(plan)->execute( + reinterpret_cast<kfr::complex<float>*>(out), in, temp, + static_cast<kfr::dft_pack_format>(pack_format)); } void kfr_dft_execute_real_f64(KFR_DFT_REAL_PLAN_F64* plan, size_t size, double* out, const double* in, - uint8_t* temp) + uint8_t* temp, KFR_DFT_PACK_FORMAT pack_format) { - reinterpret_cast<kfr::dft_plan<double>*>(plan)->execute( - reinterpret_cast<kfr::complex<double>*>(out), reinterpret_cast<const kfr::complex<double>*>(in), - temp, kfr::cfalse); + reinterpret_cast<kfr::dft_plan_real<double>*>(plan)->execute( + reinterpret_cast<kfr::complex<double>*>(out), in, temp, + static_cast<kfr::dft_pack_format>(pack_format)); } void kfr_dft_execute_real_inverse_f32(KFR_DFT_REAL_PLAN_F32* plan, size_t size, float* out, - const float* in, uint8_t* temp) + const float* in, uint8_t* temp, KFR_DFT_PACK_FORMAT pack_format) { - reinterpret_cast<kfr::dft_plan<float>*>(plan)->execute( - reinterpret_cast<kfr::complex<float>*>(out), reinterpret_cast<const kfr::complex<float>*>(in), - temp, kfr::ctrue); + reinterpret_cast<kfr::dft_plan_real<float>*>(plan)->execute( + out, reinterpret_cast<const kfr::complex<float>*>(in), temp, + static_cast<kfr::dft_pack_format>(pack_format)); } void kfr_dft_execute_real_inverse__f64(KFR_DFT_REAL_PLAN_F64* plan, size_t size, double* out, - const double* in, uint8_t* temp) + const double* in, uint8_t* temp, KFR_DFT_PACK_FORMAT pack_format) { - reinterpret_cast<kfr::dft_plan<double>*>(plan)->execute( - reinterpret_cast<kfr::complex<double>*>(out), reinterpret_cast<const kfr::complex<double>*>(in), - temp, kfr::ctrue); + reinterpret_cast<kfr::dft_plan_real<double>*>(plan)->execute( + out, reinterpret_cast<const kfr::complex<double>*>(in), temp, + static_cast<kfr::dft_pack_format>(pack_format)); } void kfr_dft_delete_real_plan_f32(KFR_DFT_REAL_PLAN_F32* plan) diff --git a/include/kfr/dft/dft_c.h b/include/kfr/dft/dft_c.h @@ -25,8 +25,8 @@ */ #pragma once -#include <stdint.h> #include <stddef.h> +#include <stdint.h> #ifdef __cplusplus extern "C" @@ -57,6 +57,12 @@ extern "C" size_t size; } KFR_DFT_REAL_PLAN_F64; + enum KFR_DFT_PACK_FORMAT + { + Perm = 0, + CCs = 1 + }; + // Complex DFT plans KFR_DFT_PLAN_F32* kfr_dft_create_plan_f32(size_t size); @@ -80,14 +86,14 @@ extern "C" KFR_DFT_REAL_PLAN_F64* kfr_dft_create_real_plan_f64(size_t size); void kfr_dft_execute_real_f32(KFR_DFT_REAL_PLAN_F32* plan, size_t size, float* out, const float* in, - uint8_t* temp); + uint8_t* temp, KFR_DFT_PACK_FORMAT pack_format); void kfr_dft_execute_real_f64(KFR_DFT_REAL_PLAN_F64* plan, size_t size, double* out, const double* in, - uint8_t* temp); + uint8_t* temp, KFR_DFT_PACK_FORMAT pack_format); void kfr_dft_execute_real_inverse_f32(KFR_DFT_REAL_PLAN_F32* plan, size_t size, float* out, - const float* in, uint8_t* temp); + const float* in, uint8_t* temp, KFR_DFT_PACK_FORMAT pack_format); void kfr_dft_execute_real_inverse_f64(KFR_DFT_REAL_PLAN_F64* plan, size_t size, double* out, - const double* in, uint8_t* temp); + const double* in, uint8_t* temp, KFR_DFT_PACK_FORMAT pack_format); void kfr_dft_delete_real_plan_f32(KFR_DFT_REAL_PLAN_F32* plan); void kfr_dft_delete_real_plan_f64(KFR_DFT_REAL_PLAN_F64* plan); diff --git a/include/kfr/dft/fft.hpp b/include/kfr/dft/fft.hpp @@ -124,6 +124,19 @@ struct dft_plan_real : dft_plan<T> size_t size; dft_plan_real(size_t size, dft_type = dft_type::both); + void execute(complex<T>*, const complex<T>*, u8*, bool = false) const = delete; + + template <bool inverse> + void execute(complex<T>*, const complex<T>*, u8*, cbool_t<inverse>) const = delete; + + template <size_t Tag1, size_t Tag2, size_t Tag3> + void execute(univector<complex<T>, Tag1>&, const univector<complex<T>, Tag2>&, univector<u8, Tag3>&, + bool = false) const = delete; + + template <bool inverse, size_t Tag1, size_t Tag2, size_t Tag3> + void execute(univector<complex<T>, Tag1>&, const univector<complex<T>, Tag2>&, univector<u8, Tag3>&, + cbool_t<inverse>) const = delete; + KFR_INTRIN void execute(complex<T>* out, const T* in, u8* temp, dft_pack_format fmt = dft_pack_format::CCs) const {