bformatdec.h 1.8 KB

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