1 #ifndef CORE_BFORMATDEC_H
2 #define CORE_BFORMATDEC_H
11 #include "bufferline.h"
12 #include "devformat.h"
13 #include "filters/splitter.h"
16 struct FrontStablizer
;
19 using ChannelDec
= std::array
<float,MaxAmbiChannels
>;
22 static constexpr size_t sHFBand
{0};
23 static constexpr size_t sLFBand
{1};
24 static constexpr size_t sNumBands
{2};
26 struct ChannelDecoder
{
28 float Dual
[sNumBands
][MAX_OUTPUT_CHANNELS
];
29 float Single
[MAX_OUTPUT_CHANNELS
];
32 /* NOTE: BandSplitter filter is unused with single-band decoding. */
36 alignas(16) std::array
<FloatBufferLine
,2> mSamples
;
38 const std::unique_ptr
<FrontStablizer
> mStablizer
;
39 const bool mDualBand
{false};
41 /* TODO: This should ideally be a FlexArray, since ChannelDecoder is rather
42 * small and only a few are needed (3, 4, 5, 7, typically). But that can
43 * only be used in a standard layout struct, and a std::unique_ptr member
44 * (mStablizer) causes GCC and Clang to warn it's not.
46 al::vector
<ChannelDecoder
> mChannelDec
;
49 BFormatDec(const size_t inchans
, const al::span
<const ChannelDec
> coeffs
,
50 const al::span
<const ChannelDec
> coeffslf
, const float xover_f0norm
,
51 std::unique_ptr
<FrontStablizer
> stablizer
);
53 bool hasStablizer() const noexcept
{ return mStablizer
!= nullptr; }
55 /* Decodes the ambisonic input to the given output channels. */
56 void process(const al::span
<FloatBufferLine
> OutBuffer
, const FloatBufferLine
*InSamples
,
57 const size_t SamplesToDo
);
59 /* Decodes the ambisonic input to the given output channels with stablization. */
60 void processStablize(const al::span
<FloatBufferLine
> OutBuffer
,
61 const FloatBufferLine
*InSamples
, const size_t lidx
, const size_t ridx
, const size_t cidx
,
62 const size_t SamplesToDo
);
64 static std::unique_ptr
<BFormatDec
> Create(const size_t inchans
,
65 const al::span
<const ChannelDec
> coeffs
, const al::span
<const ChannelDec
> coeffslf
,
66 const float xover_f0norm
, std::unique_ptr
<FrontStablizer
> stablizer
);
68 DEF_NEWDEL(BFormatDec
)
71 #endif /* CORE_BFORMATDEC_H */