14 #include "devformat.h"
15 #include "filters/splitter.h"
18 struct FrontStablizer
;
21 using ChannelDec
= std::array
<float,MAX_AMBI_CHANNELS
>;
24 static constexpr size_t sHFBand
{0};
25 static constexpr size_t sLFBand
{1};
26 static constexpr size_t sNumBands
{2};
28 struct ChannelDecoder
{
30 float Dual
[sNumBands
][MAX_OUTPUT_CHANNELS
];
31 float Single
[MAX_OUTPUT_CHANNELS
];
34 /* NOTE: BandSplitter filter is unused with single-band decoding. */
38 alignas(16) std::array
<FloatBufferLine
,2> mSamples
;
40 const std::unique_ptr
<FrontStablizer
> mStablizer
;
41 const bool mDualBand
{false};
43 al::FlexArray
<ChannelDecoder
> mChannelDec
;
46 BFormatDec(const AmbDecConf
*conf
, const bool allow_2band
, const size_t inchans
,
47 const ALuint srate
, const ALuint (&chanmap
)[MAX_OUTPUT_CHANNELS
],
48 std::unique_ptr
<FrontStablizer
> stablizer
);
49 BFormatDec(const size_t inchans
, const al::span
<const ChannelDec
> coeffs
,
50 const al::span
<const ChannelDec
> coeffslf
, std::unique_ptr
<FrontStablizer
> stablizer
);
52 bool hasStablizer() const noexcept
{ return mStablizer
!= nullptr; };
54 /* Decodes the ambisonic input to the given output channels. */
55 void process(const al::span
<FloatBufferLine
> OutBuffer
, const FloatBufferLine
*InSamples
,
56 const size_t SamplesToDo
);
58 /* Decodes the ambisonic input to the given output channels with stablization. */
59 void processStablize(const al::span
<FloatBufferLine
> OutBuffer
,
60 const FloatBufferLine
*InSamples
, const size_t lidx
, const size_t ridx
, const size_t cidx
,
61 const size_t SamplesToDo
);
63 /* Retrieves per-order HF scaling factors for "upsampling" ambisonic data. */
64 static std::array
<float,MAX_AMBI_ORDER
+1> GetHFOrderScales(const ALuint in_order
,
65 const ALuint out_order
) noexcept
;
67 static std::unique_ptr
<BFormatDec
> Create(const AmbDecConf
*conf
, const bool allow_2band
,
68 const size_t inchans
, const ALuint srate
, const ALuint (&chanmap
)[MAX_OUTPUT_CHANNELS
],
69 std::unique_ptr
<FrontStablizer
> stablizer
);
70 static std::unique_ptr
<BFormatDec
> Create(const size_t inchans
,
71 const al::span
<const ChannelDec
> coeffs
, const al::span
<const ChannelDec
> coeffslf
,
72 std::unique_ptr
<FrontStablizer
> stablizer
);
74 DEF_FAM_NEWDEL(BFormatDec
, mChannelDec
)
77 #endif /* BFORMATDEC_H */