aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-08-20 00:27:28 -0700
committerChris Robinson <[email protected]>2019-08-20 00:27:28 -0700
commit8fd90334a13608a781e36fc830cd79bf746edd42 (patch)
treecefd2023a67138e29db07a32d114dd1ed5a00b9a
parent34a61122f64d6295f50508cc6945350a5be04924 (diff)
Pass the MixRow buffer size as a span
-rw-r--r--alc/alu.h4
-rw-r--r--alc/bformatdec.cpp13
-rw-r--r--alc/effects/reverb.cpp32
-rw-r--r--alc/mixer/defs.h3
-rw-r--r--alc/mixer/mixer_c.cpp14
-rw-r--r--alc/mixer/mixer_neon.cpp25
-rw-r--r--alc/mixer/mixer_sse.cpp27
7 files changed, 57 insertions, 61 deletions
diff --git a/alc/alu.h b/alc/alu.h
index 117c932d..c63e33fd 100644
--- a/alc/alu.h
+++ b/alc/alu.h
@@ -317,8 +317,8 @@ struct ALvoice {
using MixerFunc = void(*)(const ALfloat *data, const al::span<FloatBufferLine> OutBuffer,
ALfloat *CurrentGains, const ALfloat *TargetGains, const ALsizei Counter, const ALsizei OutPos,
const ALsizei BufferSize);
-using RowMixerFunc = void(*)(ALfloat *OutBuffer, const al::span<const ALfloat> Gains,
- const ALfloat *InSamples, const ALsizei InStride, const ALsizei BufferSize);
+using RowMixerFunc = void(*)(const al::span<float> OutBuffer, const al::span<const float> Gains,
+ const float *InSamples, const size_t InStride);
using HrtfMixerFunc = void(*)(FloatBufferLine &LeftOut, FloatBufferLine &RightOut,
const ALfloat *InSamples, float2 *AccumSamples, const ALsizei OutPos, const ALsizei IrSize,
MixHrtfFilter *hrtfparams, const ALsizei BufferSize);
diff --git a/alc/bformatdec.cpp b/alc/bformatdec.cpp
index ce4c4b3b..7d681bc6 100644
--- a/alc/bformatdec.cpp
+++ b/alc/bformatdec.cpp
@@ -162,10 +162,11 @@ void BFormatDec::process(const al::span<FloatBufferLine> OutBuffer,
{
if LIKELY(enabled&1)
{
- MixRowSamples(outbuf.data(), {(*mixmtx)[sHFBand], mNumChannels},
- mSamplesHF->data(), mSamplesHF->size(), SamplesToDo);
- MixRowSamples(outbuf.data(), {(*mixmtx)[sLFBand], mNumChannels},
- mSamplesLF->data(), mSamplesLF->size(), SamplesToDo);
+ const al::span<float> outspan{outbuf.data(), outbuf.data()+SamplesToDo};
+ MixRowSamples(outspan, {(*mixmtx)[sHFBand], mNumChannels}, mSamplesHF->data(),
+ mSamplesHF->size());
+ MixRowSamples(outspan, {(*mixmtx)[sLFBand], mNumChannels}, mSamplesLF->data(),
+ mSamplesLF->size());
}
++mixmtx;
enabled >>= 1;
@@ -178,8 +179,8 @@ void BFormatDec::process(const al::span<FloatBufferLine> OutBuffer,
for(FloatBufferLine &outbuf : OutBuffer)
{
if LIKELY(enabled&1)
- MixRowSamples(outbuf.data(), {*mixmtx, mNumChannels}, InSamples->data(),
- InSamples->size(), SamplesToDo);
+ MixRowSamples({outbuf.data(), outbuf.data()+SamplesToDo}, {*mixmtx, mNumChannels},
+ InSamples->data(), InSamples->size());
++mixmtx;
enabled >>= 1;
}
diff --git a/alc/effects/reverb.cpp b/alc/effects/reverb.cpp
index 8ff4feac..5f8daabe 100644
--- a/alc/effects/reverb.cpp
+++ b/alc/effects/reverb.cpp
@@ -421,19 +421,20 @@ struct ReverbState final : public EffectState {
ASSUME(todo > 0);
/* Convert back to B-Format, and mix the results to output. */
+ const al::span<float> tmpspan{mTempLine.begin(), mTempLine.begin()+todo};
for(size_t c{0u};c < NUM_LINES;c++)
{
- std::fill_n(mTempLine.begin(), todo, 0.0f);
- MixRowSamples(mTempLine.data(), {A2B[c], NUM_LINES}, mEarlySamples[0].data(),
- mEarlySamples[0].size(), todo);
+ std::fill(tmpspan.begin(), tmpspan.end(), 0.0f);
+ MixRowSamples(tmpspan, {A2B[c], NUM_LINES}, mEarlySamples[0].data(),
+ mEarlySamples[0].size());
MixSamples(mTempLine.data(), samplesOut, mEarly.CurrentGain[c],
mEarly.PanGain[c], counter, offset, todo);
}
for(size_t c{0u};c < NUM_LINES;c++)
{
- std::fill_n(mTempLine.begin(), todo, 0.0f);
- MixRowSamples(mTempLine.data(), {A2B[c], NUM_LINES}, mLateSamples[0].data(),
- mLateSamples[0].size(), todo);
+ std::fill(tmpspan.begin(), tmpspan.end(), 0.0f);
+ MixRowSamples(tmpspan, {A2B[c], NUM_LINES}, mLateSamples[0].data(),
+ mLateSamples[0].size());
MixSamples(mTempLine.data(), samplesOut, mLate.CurrentGain[c], mLate.PanGain[c],
counter, offset, todo);
}
@@ -444,11 +445,12 @@ struct ReverbState final : public EffectState {
{
ASSUME(todo > 0);
+ const al::span<float> tmpspan{mTempLine.begin(), mTempLine.begin()+todo};
for(size_t c{0u};c < NUM_LINES;c++)
{
- std::fill_n(mTempLine.begin(), todo, 0.0f);
- MixRowSamples(mTempLine.data(), {A2B[c], NUM_LINES}, mEarlySamples[0].data(),
- mEarlySamples[0].size(), todo);
+ std::fill(tmpspan.begin(), tmpspan.end(), 0.0f);
+ MixRowSamples(tmpspan, {A2B[c], NUM_LINES}, mEarlySamples[0].data(),
+ mEarlySamples[0].size());
/* Apply scaling to the B-Format's HF response to "upsample" it to
* higher-order output.
@@ -461,9 +463,9 @@ struct ReverbState final : public EffectState {
}
for(size_t c{0u};c < NUM_LINES;c++)
{
- std::fill_n(mTempLine.begin(), todo, 0.0f);
- MixRowSamples(mTempLine.data(), {A2B[c], NUM_LINES}, mLateSamples[0].data(),
- mLateSamples[0].size(), todo);
+ std::fill(tmpspan.begin(), tmpspan.end(), 0.0f);
+ MixRowSamples(tmpspan, {A2B[c], NUM_LINES}, mLateSamples[0].data(),
+ mLateSamples[0].size());
const ALfloat hfscale{(c==0) ? mOrderScales[0] : mOrderScales[1]};
mAmbiSplitter[1][c].applyHfScale(mTempLine.data(), hfscale, todo);
@@ -1457,11 +1459,11 @@ void ReverbState::process(const ALsizei samplesToDo, const FloatBufferLine *REST
ASSUME(offset >= 0);
/* Convert B-Format to A-Format for processing. */
+ const al::span<float> tmpspan{mTempLine.begin(), mTempLine.begin()+samplesToDo};
for(size_t c{0u};c < NUM_LINES;c++)
{
- std::fill_n(mTempLine.begin(), samplesToDo, 0.0f);
- MixRowSamples(mTempLine.data(), {B2A[c], B2A[c]+numInput}, samplesIn->data(),
- samplesIn->size(), samplesToDo);
+ std::fill(tmpspan.begin(), tmpspan.end(), 0.0f);
+ MixRowSamples(tmpspan, {B2A[c], B2A[c]+numInput}, samplesIn->data(), samplesIn->size());
/* Band-pass the incoming samples and feed the initial delay line. */
mFilter[c].Lp.process(mTempLine.data(), mTempLine.data(), samplesToDo);
diff --git a/alc/mixer/defs.h b/alc/mixer/defs.h
index 19fb42d0..adaed8f5 100644
--- a/alc/mixer/defs.h
+++ b/alc/mixer/defs.h
@@ -32,7 +32,8 @@ const ALfloat *Resample_(const InterpState *state, const ALfloat *RESTRICT src,
template<InstSetType InstTag>
void Mix_(const ALfloat *data, const al::span<FloatBufferLine> OutBuffer, ALfloat *CurrentGains, const ALfloat *TargetGains, const ALsizei Counter, const ALsizei OutPos, const ALsizei BufferSize);
template<InstSetType InstTag>
-void MixRow_(ALfloat *OutBuffer, const al::span<const ALfloat> Gains, const ALfloat *InSamples, const ALsizei InStride, const ALsizei BufferSize);
+void MixRow_(const al::span<float> OutBuffer, const al::span<const float> Gains,
+ const float *InSamples, const size_t InStride);
template<InstSetType InstTag>
void MixHrtf_(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, const ALfloat *InSamples, float2 *AccumSamples, const ALsizei OutPos, const ALsizei IrSize, MixHrtfFilter *hrtfparams, const ALsizei BufferSize);
diff --git a/alc/mixer/mixer_c.cpp b/alc/mixer/mixer_c.cpp
index 4985933c..dd094040 100644
--- a/alc/mixer/mixer_c.cpp
+++ b/alc/mixer/mixer_c.cpp
@@ -189,20 +189,18 @@ void Mix_<CTag>(const ALfloat *data, const al::span<FloatBufferLine> OutBuffer,
* stepping is necessary.
*/
template<>
-void MixRow_<CTag>(ALfloat *OutBuffer, const al::span<const ALfloat> Gains,
- const ALfloat *InSamples, const ALsizei InStride, const ALsizei BufferSize)
+void MixRow_<CTag>(const al::span<float> OutBuffer, const al::span<const float> Gains,
+ const float *InSamples, const size_t InStride)
{
- ASSUME(BufferSize > 0);
-
- for(const ALfloat gain : Gains)
+ for(const float gain : Gains)
{
- const ALfloat *RESTRICT src{InSamples};
+ const float *RESTRICT src{InSamples};
InSamples += InStride;
if(!(std::fabs(gain) > GAIN_SILENCE_THRESHOLD))
continue;
- for(ALsizei i{0};i < BufferSize;i++)
- OutBuffer[i] += src[i] * gain;
+ std::transform(OutBuffer.begin(), OutBuffer.end(), src, OutBuffer.begin(),
+ [gain](const ALfloat cur, const ALfloat src) -> ALfloat { return cur + src*gain; });
}
}
diff --git a/alc/mixer/mixer_neon.cpp b/alc/mixer/mixer_neon.cpp
index c6ea2c60..829d4ea1 100644
--- a/alc/mixer/mixer_neon.cpp
+++ b/alc/mixer/mixer_neon.cpp
@@ -276,11 +276,9 @@ void Mix_<NEONTag>(const ALfloat *data, const al::span<FloatBufferLine> OutBuffe
}
template<>
-void MixRow_<NEONTag>(ALfloat *OutBuffer, const al::span<const ALfloat> Gains,
- const ALfloat *InSamples, const ALsizei InStride, const ALsizei BufferSize)
+void MixRow_<NEONTag>(const al::span<ALfloat> OutBuffer, const al::span<const ALfloat> Gains,
+ const ALfloat *InSamples, const ALsizei InStride)
{
- ASSUME(BufferSize > 0);
-
for(const ALfloat gain : Gains)
{
const ALfloat *RESTRICT src{InSamples};
@@ -289,20 +287,19 @@ void MixRow_<NEONTag>(ALfloat *OutBuffer, const al::span<const ALfloat> Gains,
if(!(std::fabs(gain) > GAIN_SILENCE_THRESHOLD))
continue;
- ALsizei pos{0};
- if LIKELY(BufferSize > 3)
+ auto out_iter = OutBuffer.begin();
+ if(size_t todo{OutBuffer.size() >> 2})
{
- ALsizei todo{BufferSize >> 2};
- float32x4_t gain4{vdupq_n_f32(gain)};
+ const float32x4_t gain4{vdupq_n_f32(gain)};
do {
- const float32x4_t val4 = vld1q_f32(&src[pos]);
- float32x4_t dry4 = vld1q_f32(&OutBuffer[pos]);
+ const float32x4_t val4 = vld1q_f32(src);
+ float32x4_t dry4 = vld1q_f32(out_iter);
dry4 = vmlaq_f32(dry4, val4, gain4);
- vst1q_f32(&OutBuffer[pos], dry4);
- pos += 4;
+ vst1q_f32(out_iter, dry4);
+ out_iter += 4; src += 4;
} while(--todo);
}
- for(;pos < BufferSize;pos++)
- OutBuffer[pos] += src[pos]*gain;
+ std::transform(out_iter, OutBuffer.end(), src, out_iter,
+ [gain](const ALfloat cur, const ALfloat src) -> ALfloat { return cur + src*gain; });
}
}
diff --git a/alc/mixer/mixer_sse.cpp b/alc/mixer/mixer_sse.cpp
index b5958c8e..b3454898 100644
--- a/alc/mixer/mixer_sse.cpp
+++ b/alc/mixer/mixer_sse.cpp
@@ -229,33 +229,30 @@ void Mix_<SSETag>(const ALfloat *data, const al::span<FloatBufferLine> OutBuffer
}
template<>
-void MixRow_<SSETag>(ALfloat *OutBuffer, const al::span<const ALfloat> Gains,
- const ALfloat *InSamples, const ALsizei InStride, const ALsizei BufferSize)
+void MixRow_<SSETag>(const al::span<float> OutBuffer, const al::span<const float> Gains,
+ const float *InSamples, const size_t InStride)
{
- ASSUME(BufferSize > 0);
-
- for(const ALfloat gain : Gains)
+ for(const float gain : Gains)
{
- const ALfloat *RESTRICT src{InSamples};
+ const float *RESTRICT src{InSamples};
InSamples += InStride;
if(!(std::fabs(gain) > GAIN_SILENCE_THRESHOLD))
continue;
- ALsizei pos{0};
- if LIKELY(BufferSize > 3)
+ auto out_iter = OutBuffer.begin();
+ if(size_t todo{OutBuffer.size() >> 2})
{
- ALsizei todo{BufferSize >> 2};
const __m128 gain4 = _mm_set1_ps(gain);
do {
- const __m128 val4{_mm_load_ps(&src[pos])};
- __m128 dry4{_mm_load_ps(&OutBuffer[pos])};
+ const __m128 val4{_mm_load_ps(src)};
+ __m128 dry4{_mm_load_ps(out_iter)};
dry4 = _mm_add_ps(dry4, _mm_mul_ps(val4, gain4));
- _mm_store_ps(&OutBuffer[pos], dry4);
- pos += 4;
+ _mm_store_ps(out_iter, dry4);
+ out_iter += 4; src += 4;
} while(--todo);
}
- for(;pos < BufferSize;pos++)
- OutBuffer[pos] += src[pos]*gain;
+ std::transform(out_iter, OutBuffer.end(), src, out_iter,
+ [gain](const ALfloat cur, const ALfloat src) -> ALfloat { return cur + src*gain; });
}
}