Pass a span to BFormatDec::process

This commit is contained in:
Chris Robinson 2019-07-03 22:59:29 -07:00
parent 0a0704071a
commit 9a51ca0a78
3 changed files with 22 additions and 19 deletions

View File

@ -147,7 +147,7 @@ void ProcessHrtf(ALCdevice *device, const ALsizei SamplesToDo)
void ProcessAmbiDec(ALCdevice *device, const ALsizei SamplesToDo)
{
BFormatDec *ambidec{device->AmbiDecoder.get()};
ambidec->process(device->RealOut.Buffer, device->RealOut.NumChannels, device->Dry.Buffer,
ambidec->process({device->RealOut.Buffer, device->RealOut.NumChannels}, device->Dry.Buffer,
SamplesToDo);
}
@ -168,7 +168,7 @@ void ProcessBs2b(ALCdevice *device, const ALsizei SamplesToDo)
{
/* First, decode the ambisonic mix to the "real" output. */
BFormatDec *ambidec{device->AmbiDecoder.get()};
ambidec->process(device->RealOut.Buffer, device->RealOut.NumChannels, device->Dry.Buffer,
ambidec->process({device->RealOut.Buffer, device->RealOut.NumChannels}, device->Dry.Buffer,
SamplesToDo);
/* BS2B is stereo output only. */

View File

@ -146,12 +146,9 @@ BFormatDec::BFormatDec(const ALuint inchans, const ALsizei chancount,
}
void BFormatDec::process(FloatBufferLine *OutBuffer, const ALuint OutChannels,
void BFormatDec::process(const al::span<FloatBufferLine> OutBuffer,
const FloatBufferLine *InSamples, const ALsizei SamplesToDo)
{
ASSUME(OutChannels > 0);
ASSUME(mNumChannels > 0);
if(mDualBand)
{
for(ALuint i{0};i < mNumChannels;i++)
@ -160,24 +157,30 @@ void BFormatDec::process(FloatBufferLine *OutBuffer, const ALuint OutChannels,
const al::span<const FloatBufferLine> hfsamples{mSamplesHF, mNumChannels};
const al::span<const FloatBufferLine> lfsamples{mSamplesLF, mNumChannels};
for(ALuint chan{0};chan < OutChannels;chan++)
ALfloat (*mixmtx)[sNumBands][MAX_AMBI_CHANNELS]{mMatrix.Dual};
ALuint enabled{mEnabled};
for(FloatBufferLine &outbuf : OutBuffer)
{
if(UNLIKELY(!(mEnabled&(1<<chan))))
continue;
MixRowSamples(OutBuffer[chan], mMatrix.Dual[chan][sHFBand], hfsamples, 0, SamplesToDo);
MixRowSamples(OutBuffer[chan], mMatrix.Dual[chan][sLFBand], lfsamples, 0, SamplesToDo);
if(LIKELY(enabled&1))
{
MixRowSamples(outbuf, (*mixmtx)[sHFBand], hfsamples, 0, SamplesToDo);
MixRowSamples(outbuf, (*mixmtx)[sLFBand], lfsamples, 0, SamplesToDo);
}
++mixmtx;
enabled >>= 1;
}
}
else
{
const al::span<const FloatBufferLine> insamples{InSamples, mNumChannels};
for(ALuint chan{0};chan < OutChannels;chan++)
ALfloat (*mixmtx)[MAX_AMBI_CHANNELS]{mMatrix.Single};
ALuint enabled{mEnabled};
for(FloatBufferLine &outbuf : OutBuffer)
{
if(UNLIKELY(!(mEnabled&(1<<chan))))
continue;
MixRowSamples(OutBuffer[chan], mMatrix.Single[chan], insamples, 0, SamplesToDo);
if(LIKELY(enabled&1))
MixRowSamples(outbuf, *mixmtx, insamples, 0, SamplesToDo);
++mixmtx;
enabled >>= 1;
}
}
}

View File

@ -43,8 +43,8 @@ public:
const ALsizei (&chanmap)[MAX_OUTPUT_CHANNELS]);
/* Decodes the ambisonic input to the given output channels. */
void process(FloatBufferLine *OutBuffer, const ALuint OutChannels,
const FloatBufferLine *InSamples, const ALsizei SamplesToDo);
void process(const al::span<FloatBufferLine> OutBuffer, const FloatBufferLine *InSamples,
const ALsizei SamplesToDo);
/* Retrieves per-order HF scaling factors for "upsampling" ambisonic data. */
static std::array<ALfloat,MAX_AMBI_ORDER+1> GetHFOrderScales(const ALsizei in_order,