diff options
author | Chris Robinson <chris.kcat@gmail.com> | 2023-09-03 08:34:15 -0700 |
---|---|---|
committer | Chris Robinson <chris.kcat@gmail.com> | 2023-09-03 08:34:15 -0700 |
commit | 8aaf9f44787f89aa35827723acc81a110f1c2024 (patch) | |
tree | 25d49b7ee8cb36a87909f14dc9087e558c40b48a /core/bformatdec.h | |
parent | 7d895a9b8b847df55e2a97a216ac7d04d757d1c8 (diff) |
Use a variant instead of a union+flag
Diffstat (limited to 'core/bformatdec.h')
-rw-r--r-- | core/bformatdec.h | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/core/bformatdec.h b/core/bformatdec.h index 42024bd9..3bb7f544 100644 --- a/core/bformatdec.h +++ b/core/bformatdec.h @@ -4,6 +4,7 @@ #include <array> #include <cstddef> #include <memory> +#include <variant> #include <vector> #include "almalloc.h" @@ -23,27 +24,20 @@ class BFormatDec { static constexpr size_t sLFBand{1}; static constexpr size_t sNumBands{2}; - struct ChannelDecoder { - union MatrixU { - float Dual[sNumBands][MAX_OUTPUT_CHANNELS]; - float Single[MAX_OUTPUT_CHANNELS]; - } mGains{}; + struct ChannelDecoderSingle { + float mGains[MAX_OUTPUT_CHANNELS]; + }; - /* NOTE: BandSplitter filter is unused with single-band decoding. */ + struct ChannelDecoderDual { BandSplitter mXOver; + float mGains[sNumBands][MAX_OUTPUT_CHANNELS]; }; alignas(16) std::array<FloatBufferLine,2> mSamples; const std::unique_ptr<FrontStablizer> mStablizer; - const bool mDualBand{false}; - - /* TODO: This should ideally be a FlexArray, since ChannelDecoder is rather - * small and only a few are needed (3, 4, 5, 7, typically). But that can - * only be used in a standard layout struct, and a std::unique_ptr member - * (mStablizer) causes GCC and Clang to warn it's not. - */ - std::vector<ChannelDecoder> mChannelDec; + + std::variant<std::vector<ChannelDecoderSingle>,std::vector<ChannelDecoderDual>> mChannelDec; public: BFormatDec(const size_t inchans, const al::span<const ChannelDec> coeffs, |