Skip to content

Commit c157b87

Browse files
committed
Make the UHJ and TSME functions non-blocking
1 parent a1d7d53 commit c157b87

6 files changed

Lines changed: 25 additions & 18 deletions

File tree

core/decoderbase.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#include <cstddef>
55
#include <span>
66

7+
#include "opthelpers.h"
8+
79

810
struct DecoderBase {
911
static constexpr auto sMaxPadding = std::size_t{256};
@@ -20,7 +22,8 @@ struct DecoderBase {
2022
void operator=(const DecoderBase&) = delete;
2123
void operator=(DecoderBase&&) = delete;
2224

23-
virtual void decode(std::span<std::span<float>> samples, bool updateState) = 0;
25+
virtual void decode(std::span<std::span<float>> samples, bool updateState) noexcept NONBLOCKING
26+
= 0;
2427

2528
/**
2629
* The width factor for Super Stereo processing. Can be changed in between

core/encoderbase.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ struct EncoderBase {
1818

1919
/** Encodes a 2-channel output signal from a B-Format input signal. */
2020
virtual auto encode(std::span<float> LeftOut, std::span<float> RightOut,
21-
std::span<std::span<float const> const> InSamples) -> void = 0;
21+
std::span<std::span<float const> const> InSamples) noexcept NONBLOCKING -> void = 0;
2222
};
2323

2424
#endif /* CORE_ENCODERBASE_HPP */

core/tsmefilter.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ auto assume_aligned_span(std::span<T, N> const s) noexcept -> std::span<T, N>
136136

137137
template<std::size_t N>
138138
void TsmeEncoder<N>::encode(const std::span<float> LeftOut, const std::span<float> RightOut,
139-
const std::span<const std::span<const float>> InSamples)
139+
const std::span<const std::span<const float>> InSamples) noexcept NONBLOCKING
140140
{
141141
static_assert(sFftLength == gSegmentedFilter<N>.sFftLength);
142142
static_assert(sSegmentSize == gSegmentedFilter<N>.sSampleLength);
@@ -278,7 +278,7 @@ void TsmeEncoder<N>::encode(const std::span<float> LeftOut, const std::span<floa
278278
* details.
279279
*/
280280
void TsmeEncoderIIR::encode(const std::span<float> LeftOut, const std::span<float> RightOut,
281-
const std::span<const std::span<const float>> InSamples)
281+
const std::span<const std::span<const float>> InSamples) noexcept NONBLOCKING
282282
{
283283
const auto samplesToDo = InSamples[0].size();
284284
const auto winput = assume_aligned_span<16>(InSamples[0]);
@@ -349,7 +349,7 @@ void TsmeEncoderIIR::encode(const std::span<float> LeftOut, const std::span<floa
349349
*/
350350
template<std::size_t N>
351351
void TsmeStereoDecoder<N>::decode(std::span<std::span<float>> const samples,
352-
bool const updateState)
352+
bool const updateState) noexcept NONBLOCKING
353353
{
354354
static_assert(sInputPadding <= sMaxPadding, "Filter padding is too large");
355355

@@ -427,7 +427,7 @@ void TsmeStereoDecoder<N>::decode(std::span<std::span<float>> const samples,
427427
}
428428

429429
void TsmeStereoDecoderIIR::decode(std::span<std::span<float>> const samples,
430-
bool const updateState)
430+
bool const updateState) noexcept NONBLOCKING
431431
{
432432
static_assert(sInputPadding <= sMaxPadding, "Filter padding is too large");
433433

core/tsmefilter.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ struct TsmeEncoder final : EncoderBase {
6666
* channel ordering and N3D scaling.
6767
*/
6868
auto encode(std::span<float> LeftOut, std::span<float> RightOut,
69-
std::span<const std::span<const float>> InSamples) -> void final;
69+
std::span<const std::span<const float>> InSamples) noexcept NONBLOCKING -> void final;
7070
};
7171
using TsmeEncoder256 = TsmeEncoder<256>;
7272
using TsmeEncoder512 = TsmeEncoder<512>;
@@ -101,7 +101,7 @@ struct TsmeEncoderIIR final : EncoderBase {
101101
* channel ordering and N3D scaling.
102102
*/
103103
auto encode(std::span<float> LeftOut, std::span<float> RightOut,
104-
std::span<const std::span<const float>> InSamples) -> void final;
104+
std::span<const std::span<const float>> InSamples) noexcept NONBLOCKING -> void final;
105105
};
106106

107107
template<std::size_t N>
@@ -126,7 +126,7 @@ struct TsmeStereoDecoder final : DecoderBase {
126126
* should contain 3 channels, the first two being the left and right stereo
127127
* channels, and the third left empty.
128128
*/
129-
void decode(std::span<std::span<float>> samples, bool updateState) final;
129+
void decode(std::span<std::span<float>> samples, bool updateState) noexcept NONBLOCKING final;
130130
};
131131
using TsmeStereoDecoder256 = TsmeStereoDecoder<256>;
132132
using TsmeStereoDecoder512 = TsmeStereoDecoder<512>;
@@ -148,7 +148,7 @@ struct TsmeStereoDecoderIIR final : DecoderBase {
148148
AllPassFilter mFilter1D;
149149
AllPassFilter mFilter2S;
150150

151-
void decode(std::span<std::span<float>> samples, bool updateState) final;
151+
void decode(std::span<std::span<float>> samples, bool updateState) noexcept NONBLOCKING final;
152152
};
153153

154154
#endif /* CORE_TSMEFILTER_HPP */

core/uhjfilter.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ constexpr auto assume_aligned_span(const std::span<T,N> s) noexcept -> std::span
8181

8282
template<std::size_t N>
8383
void UhjEncoder<N>::encode(const std::span<float> LeftOut, const std::span<float> RightOut,
84-
const std::span<const std::span<const float>> InSamples)
84+
const std::span<const std::span<const float>> InSamples) noexcept NONBLOCKING
8585
{
8686
static_assert(sFftLength == gSegmentedFilter<N>.sFftLength);
8787
static_assert(sSegmentSize == gSegmentedFilter<N>.sSampleLength);
@@ -229,7 +229,7 @@ void UhjEncoder<N>::encode(const std::span<float> LeftOut, const std::span<float
229229
* inputs.
230230
*/
231231
void UhjEncoderIIR::encode(const std::span<float> LeftOut, const std::span<float> RightOut,
232-
const std::span<const std::span<const float>> InSamples)
232+
const std::span<const std::span<const float>> InSamples) noexcept NONBLOCKING
233233
{
234234
const auto samplesToDo = InSamples[0].size();
235235
const auto winput = assume_aligned_span<16>(InSamples[0]);
@@ -299,6 +299,7 @@ void UhjEncoderIIR::encode(const std::span<float> LeftOut, const std::span<float
299299
*/
300300
template<std::size_t N>
301301
void UhjDecoder<N>::decode(const std::span<std::span<float>> samples, const bool updateState)
302+
noexcept NONBLOCKING
302303
{
303304
static_assert(sInputPadding <= sMaxPadding, "Filter padding is too large");
304305

@@ -360,6 +361,7 @@ void UhjDecoder<N>::decode(const std::span<std::span<float>> samples, const bool
360361
}
361362

362363
void UhjDecoderIIR::decode(const std::span<std::span<float>> samples, const bool updateState)
364+
noexcept NONBLOCKING
363365
{
364366
static_assert(sInputPadding <= sMaxPadding, "Filter padding is too large");
365367

@@ -446,6 +448,7 @@ void UhjDecoderIIR::decode(const std::span<std::span<float>> samples, const bool
446448
*/
447449
template<std::size_t N>
448450
void UhjStereoDecoder<N>::decode(const std::span<std::span<float>> samples, const bool updateState)
451+
noexcept NONBLOCKING
449452
{
450453
static_assert(sInputPadding <= sMaxPadding, "Filter padding is too large");
451454

@@ -523,6 +526,7 @@ void UhjStereoDecoder<N>::decode(const std::span<std::span<float>> samples, cons
523526
}
524527

525528
void UhjStereoDecoderIIR::decode(const std::span<std::span<float>> samples, const bool updateState)
529+
noexcept NONBLOCKING
526530
{
527531
static_assert(sInputPadding <= sMaxPadding, "Filter padding is too large");
528532

core/uhjfilter.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ struct UhjEncoder final : EncoderBase {
6565
* signal. The input must use FuMa channel ordering and N3D scaling.
6666
*/
6767
auto encode(std::span<float> LeftOut, std::span<float> RightOut,
68-
std::span<const std::span<const float>> InSamples) -> void final;
68+
std::span<const std::span<const float>> InSamples) noexcept NONBLOCKING -> void final;
6969
};
7070
using UhjEncoder256 = UhjEncoder<256>;
7171
using UhjEncoder512 = UhjEncoder<512>;
@@ -99,7 +99,7 @@ struct UhjEncoderIIR final : EncoderBase {
9999
* signal. The input must use FuMa channel ordering and N3D scaling.
100100
*/
101101
auto encode(std::span<float> LeftOut, std::span<float> RightOut,
102-
std::span<const std::span<const float>> InSamples) -> void final;
102+
std::span<const std::span<const float>> InSamples) noexcept NONBLOCKING -> void final;
103103
};
104104

105105

@@ -127,7 +127,7 @@ struct UhjDecoder final : DecoderBase {
127127
* reconstructed from 2-channel UHJ should not be run through a normal
128128
* B-Format decoder, as it needs different shelf filters.
129129
*/
130-
void decode(std::span<std::span<float>> samples, bool updateState) final;
130+
void decode(std::span<std::span<float>> samples, bool updateState) noexcept NONBLOCKING final;
131131
};
132132
using UhjDecoder256 = UhjDecoder<256>;
133133
using UhjDecoder512 = UhjDecoder<512>;
@@ -154,7 +154,7 @@ struct UhjDecoderIIR final : DecoderBase {
154154
AllPassFilter mFilter2S;
155155
AllPassFilter mFilter1Q;
156156

157-
void decode(std::span<std::span<float>> samples, bool updateState) final;
157+
void decode(std::span<std::span<float>> samples, bool updateState) noexcept NONBLOCKING final;
158158
};
159159

160160
template<std::size_t N>
@@ -179,7 +179,7 @@ struct UhjStereoDecoder final : DecoderBase {
179179
* should contain 3 channels, the first two being the left and right stereo
180180
* channels, and the third left empty.
181181
*/
182-
void decode(std::span<std::span<float>> samples, bool updateState) final;
182+
void decode(std::span<std::span<float>> samples, bool updateState) noexcept NONBLOCKING final;
183183
};
184184
using UhjStereoDecoder256 = UhjStereoDecoder<256>;
185185
using UhjStereoDecoder512 = UhjStereoDecoder<512>;
@@ -201,7 +201,7 @@ struct UhjStereoDecoderIIR final : DecoderBase {
201201
AllPassFilter mFilter1D;
202202
AllPassFilter mFilter2S;
203203

204-
void decode(std::span<std::span<float>> samples, bool updateState) final;
204+
void decode(std::span<std::span<float>> samples, bool updateState) noexcept NONBLOCKING final;
205205
};
206206

207207
#endif /* CORE_UHJFILTER_H */

0 commit comments

Comments
 (0)