Constify some parameters and remove an explicit loop
This commit is contained in:
parent
317206e8f3
commit
3683e31662
@ -49,7 +49,8 @@ inline auto GetAmbiScales(AmbDecScale scaletype) noexcept -> const std::array<fl
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|
||||||
void BFormatDec::reset(const AmbDecConf *conf, bool allow_2band, ALsizei inchans, ALuint srate, const ALsizei (&chanmap)[MAX_OUTPUT_CHANNELS])
|
void BFormatDec::reset(const AmbDecConf *conf, const bool allow_2band, const ALsizei inchans,
|
||||||
|
const ALuint srate, const ALsizei (&chanmap)[MAX_OUTPUT_CHANNELS])
|
||||||
{
|
{
|
||||||
mSamples.clear();
|
mSamples.clear();
|
||||||
mSamplesHF = nullptr;
|
mSamplesHF = nullptr;
|
||||||
@ -61,6 +62,7 @@ void BFormatDec::reset(const AmbDecConf *conf, bool allow_2band, ALsizei inchans
|
|||||||
mSamples.resize(2);
|
mSamples.resize(2);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
ASSUME(inchans > 0);
|
||||||
mSamples.resize(inchans * 2);
|
mSamples.resize(inchans * 2);
|
||||||
mSamplesHF = mSamples.data();
|
mSamplesHF = mSamples.data();
|
||||||
mSamplesLF = mSamplesHF + inchans;
|
mSamplesLF = mSamplesHF + inchans;
|
||||||
@ -122,7 +124,9 @@ void BFormatDec::reset(const AmbDecConf *conf, bool allow_2band, ALsizei inchans
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BFormatDec::reset(const ALsizei inchans, const ALsizei chancount, const ChannelDec (&chancoeffs)[MAX_OUTPUT_CHANNELS], const ALsizei (&chanmap)[MAX_OUTPUT_CHANNELS])
|
void BFormatDec::reset(const ALsizei inchans, const ALsizei chancount,
|
||||||
|
const ChannelDec (&chancoeffs)[MAX_OUTPUT_CHANNELS],
|
||||||
|
const ALsizei (&chanmap)[MAX_OUTPUT_CHANNELS])
|
||||||
{
|
{
|
||||||
mSamples.clear();
|
mSamples.clear();
|
||||||
mSamplesHF = nullptr;
|
mSamplesHF = nullptr;
|
||||||
@ -133,18 +137,22 @@ void BFormatDec::reset(const ALsizei inchans, const ALsizei chancount, const Cha
|
|||||||
mSamples.resize(2);
|
mSamples.resize(2);
|
||||||
mNumChannels = inchans;
|
mNumChannels = inchans;
|
||||||
|
|
||||||
|
ASSUME(chancount > 0);
|
||||||
mEnabled = std::accumulate(std::begin(chanmap), std::begin(chanmap)+chancount, 0u,
|
mEnabled = std::accumulate(std::begin(chanmap), std::begin(chanmap)+chancount, 0u,
|
||||||
[](ALuint mask, const ALsizei &chan) noexcept -> ALuint
|
[](ALuint mask, const ALsizei &chan) noexcept -> ALuint
|
||||||
{ return mask | (1 << chan); }
|
{ return mask | (1 << chan); }
|
||||||
);
|
);
|
||||||
|
|
||||||
for(ALsizei i{0};i < chancount;i++)
|
auto set_coeffs = [this,inchans,&chancoeffs](const ALsizei chanidx) noexcept -> void
|
||||||
{
|
{
|
||||||
const ALfloat (&coeffs)[MAX_AMBI_CHANNELS] = chancoeffs[chanmap[i]];
|
ASSUME(chanidx >= 0);
|
||||||
ALfloat (&mtx)[MAX_AMBI_CHANNELS] = mMatrix.Single[chanmap[i]];
|
const ALfloat (&coeffs)[MAX_AMBI_CHANNELS] = chancoeffs[chanidx];
|
||||||
|
ALfloat (&mtx)[MAX_AMBI_CHANNELS] = mMatrix.Single[chanidx];
|
||||||
|
|
||||||
|
ASSUME(inchans > 0);
|
||||||
std::copy_n(std::begin(coeffs), inchans, std::begin(mtx));
|
std::copy_n(std::begin(coeffs), inchans, std::begin(mtx));
|
||||||
}
|
};
|
||||||
|
std::for_each(chanmap, chanmap+chancount, set_coeffs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -36,15 +36,20 @@ class BFormatDec {
|
|||||||
ALboolean mDualBand;
|
ALboolean mDualBand;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void reset(const AmbDecConf *conf, bool allow_2band, ALsizei inchans, ALuint srate, const ALsizei (&chanmap)[MAX_OUTPUT_CHANNELS]);
|
void reset(const AmbDecConf *conf, const bool allow_2band, const ALsizei inchans,
|
||||||
|
const ALuint srate, const ALsizei (&chanmap)[MAX_OUTPUT_CHANNELS]);
|
||||||
|
|
||||||
void reset(const ALsizei inchans, const ALsizei chancount, const ChannelDec (&chancoeffs)[MAX_OUTPUT_CHANNELS], const ALsizei (&chanmap)[MAX_OUTPUT_CHANNELS]);
|
void reset(const ALsizei inchans, const ALsizei chancount,
|
||||||
|
const ChannelDec (&chancoeffs)[MAX_OUTPUT_CHANNELS],
|
||||||
|
const ALsizei (&chanmap)[MAX_OUTPUT_CHANNELS]);
|
||||||
|
|
||||||
/* Decodes the ambisonic input to the given output channels. */
|
/* Decodes the ambisonic input to the given output channels. */
|
||||||
void process(ALfloat (*OutBuffer)[BUFFERSIZE], const ALsizei OutChannels, const ALfloat (*InSamples)[BUFFERSIZE], const ALsizei SamplesToDo);
|
void process(ALfloat (*OutBuffer)[BUFFERSIZE], const ALsizei OutChannels,
|
||||||
|
const ALfloat (*InSamples)[BUFFERSIZE], const ALsizei SamplesToDo);
|
||||||
|
|
||||||
/* Retrieves per-order HF scaling factors for "upsampling" ambisonic data. */
|
/* Retrieves per-order HF scaling factors for "upsampling" ambisonic data. */
|
||||||
static std::array<ALfloat,MAX_AMBI_ORDER+1> GetHFOrderScales(const ALsizei in_order, const ALsizei out_order) noexcept;
|
static std::array<ALfloat,MAX_AMBI_ORDER+1> GetHFOrderScales(const ALsizei in_order,
|
||||||
|
const ALsizei out_order) noexcept;
|
||||||
|
|
||||||
DEF_NEWDEL(BFormatDec)
|
DEF_NEWDEL(BFormatDec)
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user