Implement a "fast" bsinc path
[openal-soft.git] / alc / bformatdec.h
blobedbb6d50c580f63a15c74d95aa64ef513227a31e
1 #ifndef BFORMATDEC_H
2 #define BFORMATDEC_H
4 #include <array>
5 #include <cstddef>
7 #include "AL/al.h"
9 #include "alcmain.h"
10 #include "almalloc.h"
11 #include "alspan.h"
12 #include "ambidefs.h"
13 #include "devformat.h"
14 #include "filters/splitter.h"
15 #include "vector.h"
17 struct AmbDecConf;
20 using ChannelDec = ALfloat[MAX_AMBI_CHANNELS];
22 class BFormatDec {
23 static constexpr size_t sHFBand{0};
24 static constexpr size_t sLFBand{1};
25 static constexpr size_t sNumBands{2};
27 bool mDualBand{false};
28 ALuint mEnabled{0u}; /* Bitfield of enabled channels. */
30 ALuint mNumChannels{0u};
31 union MatrixU {
32 ALfloat Dual[MAX_OUTPUT_CHANNELS][sNumBands][MAX_AMBI_CHANNELS];
33 ALfloat Single[MAX_OUTPUT_CHANNELS][MAX_AMBI_CHANNELS];
34 } mMatrix{};
36 /* NOTE: BandSplitter filters are unused with single-band decoding */
37 BandSplitter mXOver[MAX_AMBI_CHANNELS];
39 al::vector<FloatBufferLine, 16> mSamples;
40 /* These two alias into Samples */
41 FloatBufferLine *mSamplesHF{nullptr};
42 FloatBufferLine *mSamplesLF{nullptr};
44 public:
45 BFormatDec(const AmbDecConf *conf, const bool allow_2band, const ALuint inchans,
46 const ALuint srate, const ALuint (&chanmap)[MAX_OUTPUT_CHANNELS]);
47 BFormatDec(const ALuint inchans, const ALsizei chancount,
48 const ChannelDec (&chancoeffs)[MAX_OUTPUT_CHANNELS],
49 const ALuint (&chanmap)[MAX_OUTPUT_CHANNELS]);
51 /* Decodes the ambisonic input to the given output channels. */
52 void process(const al::span<FloatBufferLine> OutBuffer, const FloatBufferLine *InSamples,
53 const size_t SamplesToDo);
55 /* Retrieves per-order HF scaling factors for "upsampling" ambisonic data. */
56 static std::array<ALfloat,MAX_AMBI_ORDER+1> GetHFOrderScales(const ALuint in_order,
57 const ALuint out_order) noexcept;
59 DEF_NEWDEL(BFormatDec)
62 #endif /* BFORMATDEC_H */