Use FloatBufferLine and span<> for MixRowSamples
This commit is contained in:
parent
7e6b6d7ad9
commit
8af7b4c6e0
@ -157,29 +157,26 @@ void BFormatDec::process(FloatBufferLine *OutBuffer, const ALsizei OutChannels,
|
||||
mXOver[i].process(mSamplesHF[i].data(), mSamplesLF[i].data(), InSamples[i].data(),
|
||||
SamplesToDo);
|
||||
|
||||
const al::span<const FloatBufferLine> hfsamples{mSamplesHF, mSamplesHF+mNumChannels};
|
||||
const al::span<const FloatBufferLine> lfsamples{mSamplesLF, mSamplesLF+mNumChannels};
|
||||
for(ALsizei chan{0};chan < OutChannels;chan++)
|
||||
{
|
||||
if(UNLIKELY(!(mEnabled&(1<<chan))))
|
||||
continue;
|
||||
|
||||
MixRowSamples(OutBuffer[chan].data(), mMatrix.Dual[chan][sHFBand],
|
||||
&reinterpret_cast<const ALfloat(&)[BUFFERSIZE]>(mSamplesHF[0]),
|
||||
mNumChannels, 0, SamplesToDo);
|
||||
MixRowSamples(OutBuffer[chan].data(), mMatrix.Dual[chan][sLFBand],
|
||||
&reinterpret_cast<const ALfloat(&)[BUFFERSIZE]>(mSamplesLF[0]),
|
||||
mNumChannels, 0, SamplesToDo);
|
||||
MixRowSamples(OutBuffer[chan], mMatrix.Dual[chan][sHFBand], hfsamples, 0, SamplesToDo);
|
||||
MixRowSamples(OutBuffer[chan], mMatrix.Dual[chan][sLFBand], lfsamples, 0, SamplesToDo);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const al::span<const FloatBufferLine> insamples{InSamples, InSamples+mNumChannels};
|
||||
for(ALsizei chan{0};chan < OutChannels;chan++)
|
||||
{
|
||||
if(UNLIKELY(!(mEnabled&(1<<chan))))
|
||||
continue;
|
||||
|
||||
MixRowSamples(OutBuffer[chan].data(), mMatrix.Single[chan],
|
||||
&reinterpret_cast<const ALfloat(&)[BUFFERSIZE]>(InSamples[0]), mNumChannels, 0,
|
||||
SamplesToDo);
|
||||
MixRowSamples(OutBuffer[chan], mMatrix.Single[chan], insamples, 0, SamplesToDo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -391,9 +391,7 @@ struct ReverbState final : public EffectState {
|
||||
for(ALsizei c{0};c < NUM_LINES;c++)
|
||||
{
|
||||
std::fill_n(mTempSamples[0].begin(), todo, 0.0f);
|
||||
MixRowSamples(mTempSamples[0].data(), A2B[c],
|
||||
&reinterpret_cast<const ALfloat(&)[BUFFERSIZE]>(mEarlyBuffer[0]), NUM_LINES, 0,
|
||||
todo);
|
||||
MixRowSamples(mTempSamples[0], A2B[c], mEarlyBuffer, 0, todo);
|
||||
MixSamples(mTempSamples[0].data(), numOutput,
|
||||
&reinterpret_cast<ALfloat(&)[BUFFERSIZE]>(samplesOut[0]), mEarly.CurrentGain[c],
|
||||
mEarly.PanGain[c], todo, 0, todo);
|
||||
@ -402,9 +400,7 @@ struct ReverbState final : public EffectState {
|
||||
for(ALsizei c{0};c < NUM_LINES;c++)
|
||||
{
|
||||
std::fill_n(mTempSamples[0].begin(), todo, 0.0f);
|
||||
MixRowSamples(mTempSamples[0].data(), A2B[c],
|
||||
&reinterpret_cast<const ALfloat(&)[BUFFERSIZE]>(mLateBuffer[0]), NUM_LINES, 0,
|
||||
todo);
|
||||
MixRowSamples(mTempSamples[0], A2B[c], mLateBuffer, 0, todo);
|
||||
MixSamples(mTempSamples[0].data(), numOutput,
|
||||
&reinterpret_cast<ALfloat(&)[BUFFERSIZE]>(samplesOut[0]), mLate.CurrentGain[c],
|
||||
mLate.PanGain[c], todo, 0, todo);
|
||||
@ -418,9 +414,7 @@ struct ReverbState final : public EffectState {
|
||||
for(ALsizei c{0};c < NUM_LINES;c++)
|
||||
{
|
||||
std::fill_n(mTempSamples[0].begin(), todo, 0.0f);
|
||||
MixRowSamples(mTempSamples[0].data(), A2B[c],
|
||||
&reinterpret_cast<const ALfloat(&)[BUFFERSIZE]>(mEarlyBuffer[0]), NUM_LINES, 0,
|
||||
todo);
|
||||
MixRowSamples(mTempSamples[0], A2B[c], mEarlyBuffer, 0, todo);
|
||||
|
||||
/* Apply scaling to the B-Format's HF response to "upsample" it to
|
||||
* higher-order output.
|
||||
@ -436,9 +430,7 @@ struct ReverbState final : public EffectState {
|
||||
for(ALsizei c{0};c < NUM_LINES;c++)
|
||||
{
|
||||
std::fill_n(mTempSamples[0].begin(), todo, 0.0f);
|
||||
MixRowSamples(mTempSamples[0].data(), A2B[c],
|
||||
&reinterpret_cast<const ALfloat(&)[BUFFERSIZE]>(mLateBuffer[0]), NUM_LINES, 0,
|
||||
todo);
|
||||
MixRowSamples(mTempSamples[0], A2B[c], mLateBuffer, 0, todo);
|
||||
|
||||
const ALfloat hfscale{(c==0) ? mOrderScales[0] : mOrderScales[1]};
|
||||
mAmbiSplitter[1][c].applyHfScale(mTempSamples[0].data(), hfscale, todo);
|
||||
@ -1465,9 +1457,7 @@ void ReverbState::process(const ALsizei samplesToDo, const FloatBufferLine *REST
|
||||
for(ALsizei c{0};c < NUM_LINES;c++)
|
||||
{
|
||||
std::fill_n(afmt[c].begin(), samplesToDo, 0.0f);
|
||||
MixRowSamples(afmt[c].data(), B2A[c],
|
||||
&reinterpret_cast<const ALfloat(&)[BUFFERSIZE]>(samplesIn[0]), numInput, 0,
|
||||
samplesToDo);
|
||||
MixRowSamples(afmt[c], B2A[c], {samplesIn, samplesIn+numInput}, 0, samplesToDo);
|
||||
|
||||
/* Band-pass the incoming samples. */
|
||||
mFilter[c].Lp.process(afmt[c].data(), afmt[c].data(), samplesToDo);
|
||||
|
@ -34,7 +34,7 @@ const ALfloat *Resample_(const InterpState *state, const ALfloat *RESTRICT src,
|
||||
template<typename InstTag>
|
||||
void Mix_(const ALfloat *data, const ALsizei OutChans, ALfloat (*OutBuffer)[BUFFERSIZE], ALfloat *CurrentGains, const ALfloat *TargetGains, const ALsizei Counter, const ALsizei OutPos, const ALsizei BufferSize);
|
||||
template<typename InstTag>
|
||||
void MixRow_(ALfloat *OutBuffer, const ALfloat *Gains, const ALfloat (*data)[BUFFERSIZE], const ALsizei InChans, const ALsizei InPos, const ALsizei BufferSize);
|
||||
void MixRow_(FloatBufferLine &OutBuffer, const ALfloat *Gains, const al::span<const FloatBufferLine> InSamples, const ALsizei InPos, const ALsizei BufferSize);
|
||||
|
||||
template<typename InstTag>
|
||||
void MixHrtf_(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, const ALfloat *InSamples, float2 *AccumSamples, const ALsizei OutPos, const ALsizei IrSize, MixHrtfParams *hrtfparams, const ALsizei BufferSize);
|
||||
|
@ -190,16 +190,15 @@ void Mix_<CTag>(const ALfloat *data, const ALsizei OutChans, ALfloat (*OutBuffer
|
||||
* stepping is necessary.
|
||||
*/
|
||||
template<>
|
||||
void MixRow_<CTag>(ALfloat *OutBuffer, const ALfloat *Gains, const ALfloat (*data)[BUFFERSIZE],
|
||||
const ALsizei InChans, const ALsizei InPos, const ALsizei BufferSize)
|
||||
void MixRow_<CTag>(FloatBufferLine &OutBuffer, const ALfloat *Gains,
|
||||
const al::span<const FloatBufferLine> InSamples, const ALsizei InPos, const ALsizei BufferSize)
|
||||
{
|
||||
ASSUME(InChans > 0);
|
||||
ASSUME(BufferSize > 0);
|
||||
|
||||
for(ALsizei c{0};c < InChans;c++)
|
||||
for(const FloatBufferLine &input : InSamples)
|
||||
{
|
||||
const ALfloat *RESTRICT src{&data[c][InPos]};
|
||||
const ALfloat gain{Gains[c]};
|
||||
const ALfloat *RESTRICT src{input.data()+InPos};
|
||||
const ALfloat gain{*(Gains++)};
|
||||
if(!(std::fabs(gain) > GAIN_SILENCE_THRESHOLD))
|
||||
continue;
|
||||
|
||||
|
@ -276,20 +276,19 @@ void Mix_<NEONTag>(const ALfloat *data, const ALsizei OutChans, ALfloat (*OutBuf
|
||||
}
|
||||
|
||||
template<>
|
||||
void MixRow_<NEONTag>(ALfloat *OutBuffer, const ALfloat *Gains, const ALfloat (*data)[BUFFERSIZE],
|
||||
const ALsizei InChans, const ALsizei InPos, const ALsizei BufferSize)
|
||||
void MixRow_<NEONTag>(FloatBufferLine &OutBuffer, const ALfloat *Gains,
|
||||
const al::span<const FloatBufferLine> InSamples, const ALsizei InPos, const ALsizei BufferSize)
|
||||
{
|
||||
ASSUME(InChans > 0);
|
||||
ASSUME(BufferSize > 0);
|
||||
|
||||
for(ALsizei c{0};c < InChans;c++)
|
||||
for(const FloatBufferLine &input : InSamples)
|
||||
{
|
||||
const ALfloat *RESTRICT src{al::assume_aligned<16>(&data[c][InPos])};
|
||||
ALsizei pos{0};
|
||||
const ALfloat gain{Gains[c]};
|
||||
const ALfloat *RESTRICT src{al::assume_aligned<16>(input.data()+InPos)};
|
||||
const ALfloat gain{*(Gains++)};
|
||||
if(!(std::fabs(gain) > GAIN_SILENCE_THRESHOLD))
|
||||
continue;
|
||||
|
||||
ALsizei pos{0};
|
||||
if(LIKELY(BufferSize > 3))
|
||||
{
|
||||
ALsizei todo{BufferSize >> 2};
|
||||
|
@ -230,16 +230,15 @@ void Mix_<SSETag>(const ALfloat *data, const ALsizei OutChans, ALfloat (*OutBuff
|
||||
}
|
||||
|
||||
template<>
|
||||
void MixRow_<SSETag>(ALfloat *OutBuffer, const ALfloat *Gains, const ALfloat (*data)[BUFFERSIZE],
|
||||
const ALsizei InChans, const ALsizei InPos, const ALsizei BufferSize)
|
||||
void MixRow_<SSETag>(FloatBufferLine &OutBuffer, const ALfloat *Gains,
|
||||
const al::span<const FloatBufferLine> InSamples, const ALsizei InPos, const ALsizei BufferSize)
|
||||
{
|
||||
ASSUME(InChans > 0);
|
||||
ASSUME(BufferSize > 0);
|
||||
|
||||
for(ALsizei c{0};c < InChans;c++)
|
||||
for(const FloatBufferLine &input : InSamples)
|
||||
{
|
||||
const ALfloat *RESTRICT src{al::assume_aligned<16>(&data[c][InPos])};
|
||||
const ALfloat gain{Gains[c]};
|
||||
const ALfloat *RESTRICT src{al::assume_aligned<16>(input.data()+InPos)};
|
||||
const ALfloat gain{*(Gains++)};
|
||||
if(!(std::fabs(gain) > GAIN_SILENCE_THRESHOLD))
|
||||
continue;
|
||||
|
||||
|
@ -296,8 +296,8 @@ void DeinitVoice(ALvoice *voice) noexcept;
|
||||
using MixerFunc = void(*)(const ALfloat *data, const ALsizei OutChans,
|
||||
ALfloat (*OutBuffer)[BUFFERSIZE], ALfloat *CurrentGains, const ALfloat *TargetGains,
|
||||
const ALsizei Counter, const ALsizei OutPos, const ALsizei BufferSize);
|
||||
using RowMixerFunc = void(*)(ALfloat *OutBuffer, const ALfloat *gains,
|
||||
const ALfloat (*data)[BUFFERSIZE], const ALsizei InChans, const ALsizei InPos,
|
||||
using RowMixerFunc = void(*)(FloatBufferLine &OutBuffer, const ALfloat *gains,
|
||||
const al::span<const FloatBufferLine> InSamples, const ALsizei InPos,
|
||||
const ALsizei BufferSize);
|
||||
using HrtfMixerFunc = void(*)(FloatBufferLine &LeftOut, FloatBufferLine &RightOut,
|
||||
const ALfloat *InSamples, float2 *AccumSamples, const ALsizei OutPos, const ALsizei IrSize,
|
||||
|
Loading…
x
Reference in New Issue
Block a user