diff options
author | Chris Robinson <[email protected]> | 2018-11-22 05:37:35 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-11-22 05:37:35 -0800 |
commit | b3b42201828bb737c55c20bd46af10b40d10ef85 (patch) | |
tree | 52bfd41cfffba72af4d20cb479cbdc04d5fb2920 /Alc/bformatdec.h | |
parent | 671ed1abf8cc246c6e2b5f9ae3bac132fb9af519 (diff) |
Use unique_ptr for BFormatDec and AmbiUpsampler
Diffstat (limited to 'Alc/bformatdec.h')
-rw-r--r-- | Alc/bformatdec.h | 67 |
1 files changed, 49 insertions, 18 deletions
diff --git a/Alc/bformatdec.h b/Alc/bformatdec.h index 964a89f9..0d3fe611 100644 --- a/Alc/bformatdec.h +++ b/Alc/bformatdec.h @@ -2,10 +2,12 @@ #define BFORMATDEC_H #include "alMain.h" +#include "filters/splitter.h" +#include "almalloc.h" + + +struct AmbDecConf; -#ifdef __cplusplus -extern "C" { -#endif /* These are the necessary scales for first-order HF responses to play over * higher-order 2D (non-periphonic) decoders. @@ -32,33 +34,62 @@ extern const ALfloat SN3D2N3DScale[MAX_AMBI_COEFFS]; extern const ALfloat FuMa2N3DScale[MAX_AMBI_COEFFS]; -struct AmbDecConf; -struct BFormatDec; -struct AmbiUpsampler; +struct BFormatDec { + static constexpr size_t NumBands{2}; + + ALuint Enabled; /* Bitfield of enabled channels. */ + + union { + alignas(16) ALfloat Dual[MAX_OUTPUT_CHANNELS][NumBands][MAX_AMBI_COEFFS]; + alignas(16) ALfloat Single[MAX_OUTPUT_CHANNELS][MAX_AMBI_COEFFS]; + } Matrix; + + /* NOTE: BandSplitter filters are unused with single-band decoding */ + BandSplitter XOver[MAX_AMBI_COEFFS]; + al::vector<std::array<ALfloat,BUFFERSIZE>, 16> Samples; + /* These two alias into Samples */ + std::array<ALfloat,BUFFERSIZE> *SamplesHF; + std::array<ALfloat,BUFFERSIZE> *SamplesLF; -struct BFormatDec *bformatdec_alloc(); -void bformatdec_free(struct BFormatDec **dec); -void bformatdec_reset(struct BFormatDec *dec, const struct AmbDecConf *conf, ALsizei chancount, ALuint srate, const ALsizei chanmap[MAX_OUTPUT_CHANNELS]); + alignas(16) ALfloat ChannelMix[BUFFERSIZE]; + + struct { + BandSplitter XOver; + ALfloat Gains[NumBands]; + } UpSampler[4]; + + ALsizei NumChannels; + ALboolean DualBand; + + DEF_NEWDEL(BFormatDec) +}; + +void bformatdec_reset(BFormatDec *dec, const AmbDecConf *conf, ALsizei chancount, ALuint srate, const ALsizei chanmap[MAX_OUTPUT_CHANNELS]); /* Decodes the ambisonic input to the given output channels. */ -void bformatdec_process(struct BFormatDec *dec, ALfloat (*RESTRICT OutBuffer)[BUFFERSIZE], ALsizei OutChannels, const ALfloat (*RESTRICT InSamples)[BUFFERSIZE], ALsizei SamplesToDo); +void bformatdec_process(BFormatDec *dec, ALfloat (*RESTRICT OutBuffer)[BUFFERSIZE], ALsizei OutChannels, const ALfloat (*RESTRICT InSamples)[BUFFERSIZE], ALsizei SamplesToDo); /* Up-samples a first-order input to the decoder's configuration. */ -void bformatdec_upSample(struct BFormatDec *dec, ALfloat (*RESTRICT OutBuffer)[BUFFERSIZE], const ALfloat (*RESTRICT InSamples)[BUFFERSIZE], ALsizei InChannels, ALsizei SamplesToDo); +void bformatdec_upSample(BFormatDec *dec, ALfloat (*RESTRICT OutBuffer)[BUFFERSIZE], const ALfloat (*RESTRICT InSamples)[BUFFERSIZE], ALsizei InChannels, ALsizei SamplesToDo); /* Stand-alone first-order upsampler. Kept here because it shares some stuff * with bformatdec. Assumes a periphonic (4-channel) input mix! */ -struct AmbiUpsampler *ambiup_alloc(); -void ambiup_free(struct AmbiUpsampler **ambiup); -void ambiup_reset(struct AmbiUpsampler *ambiup, const ALCdevice *device, ALfloat w_scale, ALfloat xyz_scale); +struct AmbiUpsampler { + static constexpr size_t NumBands{2}; + + alignas(16) ALfloat Samples[NumBands][BUFFERSIZE]; + + BandSplitter XOver[4]; + + ALfloat Gains[4][MAX_OUTPUT_CHANNELS][NumBands]; -void ambiup_process(struct AmbiUpsampler *ambiup, ALfloat (*RESTRICT OutBuffer)[BUFFERSIZE], ALsizei OutChannels, const ALfloat (*RESTRICT InSamples)[BUFFERSIZE], ALsizei SamplesToDo); + DEF_NEWDEL(AmbiUpsampler) +}; -#ifdef __cplusplus -} // extern "C" -#endif +void ambiup_reset(AmbiUpsampler *ambiup, const ALCdevice *device, ALfloat w_scale, ALfloat xyz_scale); +void ambiup_process(AmbiUpsampler *ambiup, ALfloat (*RESTRICT OutBuffer)[BUFFERSIZE], ALsizei OutChannels, const ALfloat (*RESTRICT InSamples)[BUFFERSIZE], ALsizei SamplesToDo); #endif /* BFORMATDEC_H */ |