2016-03-15 05:08:05 -07:00
|
|
|
#ifndef BFORMATDEC_H
|
|
|
|
#define BFORMATDEC_H
|
|
|
|
|
2019-07-28 11:28:36 -07:00
|
|
|
#include <array>
|
|
|
|
#include <cstddef>
|
2020-01-15 10:33:56 -08:00
|
|
|
#include <memory>
|
2019-07-28 11:28:36 -07:00
|
|
|
|
|
|
|
#include "AL/al.h"
|
|
|
|
|
2019-07-28 18:33:29 -07:00
|
|
|
#include "alcmain.h"
|
2018-11-22 05:37:35 -08:00
|
|
|
#include "almalloc.h"
|
2019-07-28 11:28:36 -07:00
|
|
|
#include "alspan.h"
|
|
|
|
#include "ambidefs.h"
|
2019-08-05 18:36:39 -07:00
|
|
|
#include "devformat.h"
|
2019-07-28 11:28:36 -07:00
|
|
|
#include "filters/splitter.h"
|
2018-11-22 05:37:35 -08:00
|
|
|
|
|
|
|
struct AmbDecConf;
|
2016-03-15 05:08:05 -07:00
|
|
|
|
2017-01-24 19:03:51 -08:00
|
|
|
|
2020-05-06 14:53:27 -07:00
|
|
|
using ChannelDec = std::array<float,MAX_AMBI_CHANNELS>;
|
2019-01-05 19:21:25 -08:00
|
|
|
|
2018-12-08 02:50:34 -08:00
|
|
|
class BFormatDec {
|
2019-01-07 21:48:48 -08:00
|
|
|
static constexpr size_t sHFBand{0};
|
|
|
|
static constexpr size_t sLFBand{1};
|
2018-12-08 02:50:34 -08:00
|
|
|
static constexpr size_t sNumBands{2};
|
2018-11-22 05:37:35 -08:00
|
|
|
|
2020-01-15 10:09:41 -08:00
|
|
|
struct ChannelDecoder {
|
|
|
|
union MatrixU {
|
|
|
|
float Dual[sNumBands][MAX_OUTPUT_CHANNELS];
|
|
|
|
float Single[MAX_OUTPUT_CHANNELS];
|
|
|
|
} mGains{};
|
2018-11-22 05:37:35 -08:00
|
|
|
|
2020-01-15 10:09:41 -08:00
|
|
|
/* NOTE: BandSplitter filter is unused with single-band decoding. */
|
|
|
|
BandSplitter mXOver;
|
|
|
|
};
|
2016-03-15 05:08:05 -07:00
|
|
|
|
2020-01-14 23:08:04 -08:00
|
|
|
alignas(16) std::array<FloatBufferLine,2> mSamples;
|
2016-03-26 17:52:42 -07:00
|
|
|
|
2020-01-15 10:09:41 -08:00
|
|
|
bool mDualBand{false};
|
|
|
|
|
|
|
|
al::FlexArray<ChannelDecoder> mChannelDec;
|
|
|
|
|
2018-12-08 02:50:34 -08:00
|
|
|
public:
|
2020-05-06 14:53:27 -07:00
|
|
|
BFormatDec(const AmbDecConf *conf, const bool allow_2band, const size_t inchans,
|
2019-09-12 04:17:21 -07:00
|
|
|
const ALuint srate, const ALuint (&chanmap)[MAX_OUTPUT_CHANNELS]);
|
2020-05-07 03:15:46 -07:00
|
|
|
BFormatDec(const size_t inchans, const al::span<const ChannelDec> coeffs,
|
|
|
|
const al::span<const ChannelDec> coeffslf);
|
2018-11-22 05:37:35 -08:00
|
|
|
|
2018-12-08 02:50:34 -08:00
|
|
|
/* Decodes the ambisonic input to the given output channels. */
|
2019-07-03 22:59:29 -07:00
|
|
|
void process(const al::span<FloatBufferLine> OutBuffer, const FloatBufferLine *InSamples,
|
2019-08-25 15:36:40 -07:00
|
|
|
const size_t SamplesToDo);
|
2016-03-23 12:53:36 -07:00
|
|
|
|
2019-02-22 22:35:37 -08:00
|
|
|
/* Retrieves per-order HF scaling factors for "upsampling" ambisonic data. */
|
2020-01-14 13:10:01 -08:00
|
|
|
static std::array<float,MAX_AMBI_ORDER+1> GetHFOrderScales(const ALuint in_order,
|
2019-09-13 20:04:22 -07:00
|
|
|
const ALuint out_order) noexcept;
|
2019-01-06 17:45:44 -08:00
|
|
|
|
2020-01-15 10:33:56 -08:00
|
|
|
static std::unique_ptr<BFormatDec> Create(const AmbDecConf *conf, const bool allow_2band,
|
2020-05-06 14:53:27 -07:00
|
|
|
const size_t inchans, const ALuint srate, const ALuint (&chanmap)[MAX_OUTPUT_CHANNELS])
|
2020-01-15 10:33:56 -08:00
|
|
|
{
|
|
|
|
return std::unique_ptr<BFormatDec>{new(FamCount{inchans})
|
|
|
|
BFormatDec{conf, allow_2band, inchans, srate, chanmap}};
|
|
|
|
}
|
2020-05-06 14:53:27 -07:00
|
|
|
static std::unique_ptr<BFormatDec> Create(const size_t inchans,
|
2020-05-07 03:15:46 -07:00
|
|
|
const al::span<const ChannelDec> coeffs, const al::span<const ChannelDec> coeffslf)
|
|
|
|
{
|
|
|
|
return std::unique_ptr<BFormatDec>{new(FamCount{inchans})
|
|
|
|
BFormatDec{inchans, coeffs, coeffslf}};
|
|
|
|
}
|
2020-01-15 10:33:56 -08:00
|
|
|
|
2020-01-15 10:09:41 -08:00
|
|
|
DEF_FAM_NEWDEL(BFormatDec, mChannelDec)
|
2018-11-22 05:37:35 -08:00
|
|
|
};
|
2016-07-30 09:29:21 -07:00
|
|
|
|
2016-03-15 05:08:05 -07:00
|
|
|
#endif /* BFORMATDEC_H */
|