aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/mixer
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-05-29 21:58:37 -0700
committerChris Robinson <[email protected]>2019-05-29 21:58:37 -0700
commit893ffe9a84d497d38e6e472b0cffbd9c37e0c366 (patch)
treee86cb9f28857507a54aad958e8c4a9dd361c3e28 /Alc/mixer
parent8af7b4c6e0ddaf4d66455702a7ede0c9036f3825 (diff)
Use span<FloatBufferLine> for MixSamples
Diffstat (limited to 'Alc/mixer')
-rw-r--r--Alc/mixer/defs.h2
-rw-r--r--Alc/mixer/mixer_c.cpp19
-rw-r--r--Alc/mixer/mixer_neon.cpp19
-rw-r--r--Alc/mixer/mixer_sse.cpp19
4 files changed, 31 insertions, 28 deletions
diff --git a/Alc/mixer/defs.h b/Alc/mixer/defs.h
index e661b238..a86da8a1 100644
--- a/Alc/mixer/defs.h
+++ b/Alc/mixer/defs.h
@@ -32,7 +32,7 @@ template<typename TypeTag, typename InstTag>
const ALfloat *Resample_(const InterpState *state, const ALfloat *RESTRICT src, ALsizei frac, ALint increment, ALfloat *RESTRICT dst, ALsizei dstlen);
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);
+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<typename InstTag>
void MixRow_(FloatBufferLine &OutBuffer, const ALfloat *Gains, const al::span<const FloatBufferLine> InSamples, const ALsizei InPos, const ALsizei BufferSize);
diff --git a/Alc/mixer/mixer_c.cpp b/Alc/mixer/mixer_c.cpp
index d1bbd25e..9e8f2ad5 100644
--- a/Alc/mixer/mixer_c.cpp
+++ b/Alc/mixer/mixer_c.cpp
@@ -144,21 +144,20 @@ void MixDirectHrtf_<CTag>(FloatBufferLine &LeftOut, FloatBufferLine &RightOut,
template<>
-void Mix_<CTag>(const ALfloat *data, const ALsizei OutChans, ALfloat (*OutBuffer)[BUFFERSIZE],
+void Mix_<CTag>(const ALfloat *data, const al::span<FloatBufferLine> OutBuffer,
ALfloat *CurrentGains, const ALfloat *TargetGains, const ALsizei Counter, const ALsizei OutPos,
const ALsizei BufferSize)
{
- ASSUME(OutChans > 0);
ASSUME(BufferSize > 0);
const ALfloat delta{(Counter > 0) ? 1.0f / static_cast<ALfloat>(Counter) : 0.0f};
- for(ALsizei c{0};c < OutChans;c++)
+ for(FloatBufferLine &output : OutBuffer)
{
- ALfloat *RESTRICT dst{&OutBuffer[c][OutPos]};
- ALsizei pos{0};
- ALfloat gain{CurrentGains[c]};
+ ALfloat *RESTRICT dst{output.data()+OutPos};
+ ALfloat gain{*CurrentGains};
+ const ALfloat diff{*TargetGains - gain};
- const ALfloat diff{TargetGains[c] - gain};
+ ALsizei pos{0};
if(std::fabs(diff) > std::numeric_limits<float>::epsilon())
{
ALsizei minsize{mini(BufferSize, Counter)};
@@ -170,11 +169,13 @@ void Mix_<CTag>(const ALfloat *data, const ALsizei OutChans, ALfloat (*OutBuffer
step_count += 1.0f;
}
if(pos == Counter)
- gain = TargetGains[c];
+ gain = *TargetGains;
else
gain += step*step_count;
- CurrentGains[c] = gain;
+ *CurrentGains = gain;
}
+ ++CurrentGains;
+ ++TargetGains;
if(!(std::fabs(gain) > GAIN_SILENCE_THRESHOLD))
continue;
diff --git a/Alc/mixer/mixer_neon.cpp b/Alc/mixer/mixer_neon.cpp
index 300d421f..eaa09718 100644
--- a/Alc/mixer/mixer_neon.cpp
+++ b/Alc/mixer/mixer_neon.cpp
@@ -190,21 +190,20 @@ void MixDirectHrtf_<NEONTag>(FloatBufferLine &LeftOut, FloatBufferLine &RightOut
template<>
-void Mix_<NEONTag>(const ALfloat *data, const ALsizei OutChans, ALfloat (*OutBuffer)[BUFFERSIZE],
+void Mix_<NEONTag>(const ALfloat *data, const al::span<FloatBufferLine> OutBuffer,
ALfloat *CurrentGains, const ALfloat *TargetGains, const ALsizei Counter, const ALsizei OutPos,
const ALsizei BufferSize)
{
- ASSUME(OutChans > 0);
ASSUME(BufferSize > 0);
const ALfloat delta{(Counter > 0) ? 1.0f/(ALfloat)Counter : 0.0f};
- for(ALsizei c{0};c < OutChans;c++)
+ for(FloatBufferLine &output : OutBuffer)
{
- ALfloat *RESTRICT dst{al::assume_aligned<16>(&OutBuffer[c][OutPos])};
- ALsizei pos{0};
- ALfloat gain{CurrentGains[c]};
- const ALfloat diff{TargetGains[c] - gain};
+ ALfloat *RESTRICT dst{al::assume_aligned<16>(output.data()+OutPos)};
+ ALfloat gain{*CurrentGains};
+ const ALfloat diff{*TargetGains - gain};
+ ALsizei pos{0};
if(std::fabs(diff) > std::numeric_limits<float>::epsilon())
{
ALsizei minsize{mini(BufferSize, Counter)};
@@ -245,16 +244,18 @@ void Mix_<NEONTag>(const ALfloat *data, const ALsizei OutChans, ALfloat (*OutBuf
step_count += 1.0f;
}
if(pos == Counter)
- gain = TargetGains[c];
+ gain = *TargetGains;
else
gain += step*step_count;
- CurrentGains[c] = gain;
+ *CurrentGains = gain;
/* Mix until pos is aligned with 4 or the mix is done. */
minsize = mini(BufferSize, (pos+3)&~3);
for(;pos < minsize;pos++)
dst[pos] += data[pos]*gain;
}
+ ++CurrentGains;
+ ++TargetGains;
if(!(std::fabs(gain) > GAIN_SILENCE_THRESHOLD))
continue;
diff --git a/Alc/mixer/mixer_sse.cpp b/Alc/mixer/mixer_sse.cpp
index ac1c9b18..0f8b905f 100644
--- a/Alc/mixer/mixer_sse.cpp
+++ b/Alc/mixer/mixer_sse.cpp
@@ -147,21 +147,20 @@ void MixDirectHrtf_<SSETag>(FloatBufferLine &LeftOut, FloatBufferLine &RightOut,
template<>
-void Mix_<SSETag>(const ALfloat *data, const ALsizei OutChans, ALfloat (*OutBuffer)[BUFFERSIZE],
+void Mix_<SSETag>(const ALfloat *data, const al::span<FloatBufferLine> OutBuffer,
ALfloat *CurrentGains, const ALfloat *TargetGains, const ALsizei Counter, const ALsizei OutPos,
const ALsizei BufferSize)
{
- ASSUME(OutChans > 0);
ASSUME(BufferSize > 0);
const ALfloat delta{(Counter > 0) ? 1.0f / static_cast<ALfloat>(Counter) : 0.0f};
- for(ALsizei c{0};c < OutChans;c++)
+ for(FloatBufferLine &output : OutBuffer)
{
- ALfloat *RESTRICT dst{al::assume_aligned<16>(&OutBuffer[c][OutPos])};
- ALsizei pos{0};
- ALfloat gain{CurrentGains[c]};
- const ALfloat diff{TargetGains[c] - gain};
+ ALfloat *RESTRICT dst{al::assume_aligned<16>(output.data()+OutPos)};
+ ALfloat gain{*CurrentGains};
+ const ALfloat diff{*TargetGains - gain};
+ ALsizei pos{0};
if(std::fabs(diff) > std::numeric_limits<float>::epsilon())
{
ALsizei minsize{mini(BufferSize, Counter)};
@@ -199,16 +198,18 @@ void Mix_<SSETag>(const ALfloat *data, const ALsizei OutChans, ALfloat (*OutBuff
step_count += 1.0f;
}
if(pos == Counter)
- gain = TargetGains[c];
+ gain = *TargetGains;
else
gain += step*step_count;
- CurrentGains[c] = gain;
+ *CurrentGains = gain;
/* Mix until pos is aligned with 4 or the mix is done. */
minsize = mini(BufferSize, (pos+3)&~3);
for(;pos < minsize;pos++)
dst[pos] += data[pos]*gain;
}
+ ++CurrentGains;
+ ++TargetGains;
if(!(std::fabs(gain) > GAIN_SILENCE_THRESHOLD))
continue;