aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-05-29 20:45:33 -0700
committerChris Robinson <[email protected]>2019-05-29 20:45:33 -0700
commit8af7b4c6e0ddaf4d66455702a7ede0c9036f3825 (patch)
tree9df078b080f990aa692163f8b832d3098e4d09da
parent7e6b6d7ad90f95fc95efefe7cdf996b8e2cb90fb (diff)
Use FloatBufferLine and span<> for MixRowSamples
-rw-r--r--Alc/bformatdec.cpp15
-rw-r--r--Alc/effects/reverb.cpp20
-rw-r--r--Alc/mixer/defs.h2
-rw-r--r--Alc/mixer/mixer_c.cpp11
-rw-r--r--Alc/mixer/mixer_neon.cpp13
-rw-r--r--Alc/mixer/mixer_sse.cpp11
-rw-r--r--OpenAL32/Include/alu.h4
7 files changed, 30 insertions, 46 deletions
diff --git a/Alc/bformatdec.cpp b/Alc/bformatdec.cpp
index 33659e04..5d9b3503 100644
--- a/Alc/bformatdec.cpp
+++ b/Alc/bformatdec.cpp
@@ -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);
}
}
}
diff --git a/Alc/effects/reverb.cpp b/Alc/effects/reverb.cpp
index 1c9e72c0..74c9d3fc 100644
--- a/Alc/effects/reverb.cpp
+++ b/Alc/effects/reverb.cpp
@@ -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);
diff --git a/Alc/mixer/defs.h b/Alc/mixer/defs.h
index 3de6b01e..e661b238 100644
--- a/Alc/mixer/defs.h
+++ b/Alc/mixer/defs.h
@@ -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);
diff --git a/Alc/mixer/mixer_c.cpp b/Alc/mixer/mixer_c.cpp
index 8ad3aca3..d1bbd25e 100644
--- a/Alc/mixer/mixer_c.cpp
+++ b/Alc/mixer/mixer_c.cpp
@@ -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;
diff --git a/Alc/mixer/mixer_neon.cpp b/Alc/mixer/mixer_neon.cpp
index 6f4af98b..300d421f 100644
--- a/Alc/mixer/mixer_neon.cpp
+++ b/Alc/mixer/mixer_neon.cpp
@@ -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};
diff --git a/Alc/mixer/mixer_sse.cpp b/Alc/mixer/mixer_sse.cpp
index 156b3dab..ac1c9b18 100644
--- a/Alc/mixer/mixer_sse.cpp
+++ b/Alc/mixer/mixer_sse.cpp
@@ -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;
diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h
index 46fdb5a5..49abe0f3 100644
--- a/OpenAL32/Include/alu.h
+++ b/OpenAL32/Include/alu.h
@@ -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,