kfrlib / kfr

Fast, modern C++ DSP framework, FFT, Sample Rate Conversion, FIR/IIR/Biquad Filters (SSE, AVX, AVX-512, ARM NEON)
https://www.kfrlib.com
GNU General Public License v2.0
1.67k stars 256 forks source link

Overflow for small input lengths in zero latency biquad #10

Closed codingkeith closed 7 years ago

codingkeith commented 7 years ago

In the zero latency biquad expression the begin_block may overflow if the input source is less than the number of filters - 1:

This line: https://github.com/kfrlib/kfr/blob/master/include/kfr/dsp/biquad.hpp#L178

This code block assumes the input source will be greater than or equal to filters - 1 in length:

    CMT_INLINE void begin_block(cinput_t cinput, size_t size) const
    {
        block_end = size;
        for (size_t i = 0; i < filters - 1; i++)
        {
            const vec<T, 1> in = this->argument_first(cinput, i, vec_t<T, 1>());
            state.out = process(bq, state, insertleft(in[0], state.out));
        }
    }

For real time audio applications this isn't going to be a good assumption for large numbers of filters.

dancazarin commented 7 years ago

Thank you for the catch. I will add the fix soon.

codingkeith commented 7 years ago

Is this project dead?

dancazarin commented 7 years ago

KFR 2.0 will be released about February 20. The release will include many new functions, optimizations, better Visual Studio support and new examples of library use.

RGates94 commented 7 years ago

@dlevin256 I would like to ask about the status of the KFR 2.0 release you mentioned in your previous post, as a project I work with is considering adding KFR to replace some outdated code and it wouldn't make much sense to integrate the 1.0 version if 2.0 is right around the corner.

dancazarin commented 7 years ago

KFR 2.0 will be released next week. This release will add new features and more optimizations for Visual Studio/GCC compilers. There are no significant breaking changes since the current master version. Some header files are renamed, but old versions exist too with redirects, so the code relied on KFR 1.x will work ok. Anyway, you can post an issue or ask support if something goes wrong after the update.