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 62ddb7bce6890d3569fad2ff927b264dafc9050d
parent b4741180a21f983f6bfa08db0b772f811d539f10
Author: d.levin256@gmail.com <d.levin256@gmail.com>
Date:   Thu, 14 Sep 2023 17:10:03 +0100

Merge branch 'dev' of https://github.com/kfrlib/kfr into dev

Diffstat:
Minclude/kfr/base/expression.hpp | 4++--
Minclude/kfr/base/shape.hpp | 13++++++++-----
Minclude/kfr/graphics/geometry.hpp | 11++++++++---
Minclude/kfr/simd/impl/logical.hpp | 2++
Mtests/unit/dsp/ebu.cpp | 8++++----
Mtests/unit/graphics/geometry.cpp | 3++-
6 files changed, 26 insertions(+), 15 deletions(-)

diff --git a/include/kfr/base/expression.hpp b/include/kfr/base/expression.hpp @@ -759,7 +759,7 @@ static auto process(Out&& out, In&& in, shape<outdims> start = shape<outdims>(0) in_size = inshape[in_axis]; begin_pass(out, start, stop); - begin_pass(in, inshape.adapt(start), inshape.adapt(stop)); + begin_pass(in, inshape.adapt(start), inshape.adapt(stop, ctrue)); shape<outdims> outidx; if constexpr (outdims == 1) @@ -830,7 +830,7 @@ static auto process(Out&& out, In&& in, shape<outdims> start = shape<outdims>(0) outidx[out_axis] = stop[out_axis] - 1; } while (internal_generic::increment_indices(outidx, start, stop)); } - end_pass(in, inshape.adapt(start), inshape.adapt(stop)); + end_pass(in, inshape.adapt(start), inshape.adapt(stop, ctrue)); end_pass(out, start, stop); return stop; } diff --git a/include/kfr/base/shape.hpp b/include/kfr/base/shape.hpp @@ -276,11 +276,14 @@ struct shape : static_array_base<index_t, csizeseq_t<dims>> KFR_MEM_INTRINSIC constexpr index_t dot(const shape& other) const { return (*this)->dot(*other); } - template <index_t indims> - KFR_MEM_INTRINSIC constexpr shape adapt(const shape<indims>& other) const + template <index_t indims, bool stop = false> + KFR_MEM_INTRINSIC constexpr shape adapt(const shape<indims>& other, cbool_t<stop> = {}) const { static_assert(indims >= dims); - return other.template trim<dims>()->min(**this - 1); + if constexpr (stop) + return other.template trim<dims>()->min(**this); + else + return other.template trim<dims>()->min(**this - 1); } KFR_MEM_INTRINSIC constexpr index_t product() const { return (*this)->product(); } @@ -357,8 +360,8 @@ struct shape<0> KFR_MEM_INTRINSIC size_t to_flat(const shape<0>& indices) const { return 0; } KFR_MEM_INTRINSIC shape<0> from_flat(size_t index) const { return {}; } - template <index_t odims> - KFR_MEM_INTRINSIC shape<0> adapt(const shape<odims>& other) const + template <index_t odims, bool stop = false> + KFR_MEM_INTRINSIC shape<0> adapt(const shape<odims>& other, cbool_t<stop> = {}) const { return {}; } diff --git a/include/kfr/graphics/geometry.hpp b/include/kfr/graphics/geometry.hpp @@ -63,6 +63,7 @@ struct point constexpr explicit point(const vec<T, 2>& v) noexcept : v(v) {} constexpr point(T x, T y) noexcept : v(x, y) {} constexpr point(const size<T>& sz) noexcept : v(sz.v) {} + constexpr point(const point& p) noexcept : v(p.v) {} template <typename U> operator point<U>() const @@ -112,12 +113,12 @@ struct point { struct { - T x; - T y; + vec<T, 2> v; }; struct { - vec<T, 2> v; + T x; + T y; }; struct { @@ -144,6 +145,7 @@ struct size constexpr size(T x, T y) noexcept : v(x, y) {} constexpr explicit size(T xy) noexcept : v(xy, xy) {} constexpr size(const vec<T, 2>& v) noexcept : v(v) {} + constexpr size(const size& s) noexcept : v(s.v) {} template <typename U> operator size<U>() const noexcept @@ -216,6 +218,7 @@ struct border constexpr border(T h, T v) noexcept : v(h, v, h, v) {} constexpr border(T x1, T y1, T x2, T y2) noexcept : v(x1, y1, x2, y2) {} constexpr explicit border(const vec<T, 4>& v) : v(v) {} + constexpr border(const border& b) noexcept : v(b.v) {} template <typename U> operator border<U>() const @@ -281,6 +284,7 @@ struct rectangle constexpr rectangle(T x1, T y1, T x2, T y2) : v(x1, y1, x2, y2) {} constexpr explicit rectangle(const vec<T, 4>& v) : v(v) {} + constexpr rectangle(const rectangle& r) noexcept : v(r.v) {} template <typename U> operator rectangle<U>() const @@ -507,6 +511,7 @@ struct matrix2d matrix2d() : v{ 1, 0, 0, 1, 0, 0 } {} matrix2d(T a, T b, T c, T d, T e, T f) : v{ a, b, c, d, e, f } {} + constexpr matrix2d(const matrix2d& m) : v(m.v) {} explicit matrix2d(const vec<T, 6>& v) : v(v) {} diff --git a/include/kfr/simd/impl/logical.hpp b/include/kfr/simd/impl/logical.hpp @@ -209,6 +209,7 @@ KFR_INTRINSIC bool bittestany(const mu16neon& a) { return bittestany(bitcast<bit KFR_INTRINSIC bool bittestany(const mu64neon& a) { return bittestany(bitcast<bit<u32>>(a)); } KFR_INTRINSIC bool bittestany(const mi8neon& a) { return bittestany(bitcast<bit<u32>>(a)); } KFR_INTRINSIC bool bittestany(const mi16neon& a) { return bittestany(bitcast<bit<u32>>(a)); } +KFR_INTRINSIC bool bittestany(const mi32neon& a) { return bittestany(bitcast<bit<u32>>(a)); } KFR_INTRINSIC bool bittestany(const mi64neon& a) { return bittestany(bitcast<bit<u32>>(a)); } KFR_INTRINSIC bool bittestany(const mf32neon& a) { return bittestany(bitcast<bit<u32>>(a)); } KFR_INTRINSIC bool bittestany(const mf64neon& a) { return bittestany(bitcast<bit<u32>>(a)); } @@ -218,6 +219,7 @@ KFR_INTRINSIC bool bittestall(const mu16neon& a) { return bittestall(bitcast<bit KFR_INTRINSIC bool bittestall(const mu64neon& a) { return bittestall(bitcast<bit<u32>>(a)); } KFR_INTRINSIC bool bittestall(const mi8neon& a) { return bittestall(bitcast<bit<u32>>(a)); } KFR_INTRINSIC bool bittestall(const mi16neon& a) { return bittestall(bitcast<bit<u32>>(a)); } +KFR_INTRINSIC bool bittestall(const mi32neon& a) { return bittestall(bitcast<bit<u32>>(a)); } KFR_INTRINSIC bool bittestall(const mi64neon& a) { return bittestall(bitcast<bit<u32>>(a)); } KFR_INTRINSIC bool bittestall(const mf32neon& a) { return bittestall(bitcast<bit<u32>>(a)); } KFR_INTRINSIC bool bittestall(const mf64neon& a) { return bittestall(bitcast<bit<u32>>(a)); } diff --git a/tests/unit/dsp/ebu.cpp b/tests/unit/dsp/ebu.cpp @@ -120,22 +120,22 @@ static void ebu_test_multichannel(int sample_rate, if (!std::isnan(refM)) { testo::scope s(as_string("M = ", fmt<'f', -1, 2>(M))); - CHECK(std::abs(M - refM) < 0.05f); + CHECK(std::abs(M - refM) < 0.1f); } if (!std::isnan(refS)) { testo::scope s(as_string("S = ", fmt<'f', -1, 2>(S))); - CHECK(std::abs(S - refS) < 0.05f); + CHECK(std::abs(S - refS) < 0.1f); } if (!std::isnan(refI)) { testo::scope s(as_string("I = ", fmt<'f', -1, 2>(I))); - CHECK(std::abs(I - refI) < 0.05f); + CHECK(std::abs(I - refI) < 0.1f); } if (!std::isnan(refLRA)) { testo::scope s(as_string("LRA = ", fmt<'f', -1, 2>((RH - RL)))); - CHECK(std::abs((RH - RL) - refLRA) < 0.05f); + CHECK(std::abs((RH - RL) - refLRA) < 0.1f); } } diff --git a/tests/unit/graphics/geometry.cpp b/tests/unit/graphics/geometry.cpp @@ -12,7 +12,7 @@ inline namespace CMT_ARCH_NAME { TEST(point) { - testo::eplison_scope<void> e(10); + testo::eplison_scope<void> e(100); f32point p{ 0.f, 0.5f }; CHECK(p.distance(i32point{ 1, 2 }) == 1.80277563773f); @@ -47,6 +47,7 @@ TEST(border) TEST(rectangle) { + testo::eplison_scope<void> e(100); CHECK(f32rectangle{ f32point{ 1, 2 }, f32size{ 2, 2 } } == f32rectangle{ 1, 2, 3, 4 }); CHECK(f32rectangle{ f32point{ 1, 2 }, f32point{ 3, 4 } } == f32rectangle{ 1, 2, 3, 4 }); CHECK(f32rectangle{ f32point{ 1, 2 }, f32size{ 3, 4 }, f32point{ 0.5f, 0.5f } } ==