aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-05-25 08:17:37 -0700
committerChris Robinson <[email protected]>2019-05-25 08:17:37 -0700
commitebf33b7c6b747b647eb2177080dc6f46db89867b (patch)
tree8956a70fe8b3153624129172c12ac12fffa603f3
parent219f818b165d6997d6a2f1f8f0c5f88ba68a5db2 (diff)
Avoid some uses of RESTRICT
-rw-r--r--Alc/alu.cpp27
-rw-r--r--Alc/effects/chorus.cpp45
-rw-r--r--Alc/hrtf.cpp3
-rw-r--r--Alc/mastering.cpp6
-rw-r--r--Alc/mixer/mixer_c.cpp18
5 files changed, 52 insertions, 47 deletions
diff --git a/Alc/alu.cpp b/Alc/alu.cpp
index d1e0772a..2bdfd092 100644
--- a/Alc/alu.cpp
+++ b/Alc/alu.cpp
@@ -1476,9 +1476,8 @@ void ProcessContext(ALCcontext *ctx, const ALsizei SamplesToDo)
}
-void ApplyStablizer(FrontStablizer *Stablizer, ALfloat (*RESTRICT Buffer)[BUFFERSIZE],
- int lidx, int ridx, int cidx, const ALsizei SamplesToDo,
- const ALsizei NumChannels)
+void ApplyStablizer(FrontStablizer *Stablizer, ALfloat (*Buffer)[BUFFERSIZE], const int lidx,
+ const int ridx, const int cidx, const ALsizei SamplesToDo, const ALsizei NumChannels)
{
ASSUME(SamplesToDo > 0);
ASSUME(NumChannels > 0);
@@ -1506,7 +1505,7 @@ void ApplyStablizer(FrontStablizer *Stablizer, ALfloat (*RESTRICT Buffer)[BUFFER
}
}
- SplitterAllpass &APFilter = Stablizer->APFilter;
+ const SplitterAllpass &APFilter = Stablizer->APFilter;
ALfloat (&lsplit)[2][BUFFERSIZE] = Stablizer->LSplit;
ALfloat (&rsplit)[2][BUFFERSIZE] = Stablizer->RSplit;
auto &tmpbuf = Stablizer->TempBuf;
@@ -1514,7 +1513,7 @@ void ApplyStablizer(FrontStablizer *Stablizer, ALfloat (*RESTRICT Buffer)[BUFFER
/* This applies the band-splitter, preserving phase at the cost of some
* delay. The shorter the delay, the more error seeps into the result.
*/
- auto apply_splitter = [&APFilter,&tmpbuf,SamplesToDo](const ALfloat *RESTRICT Buffer,
+ auto apply_splitter = [&APFilter,&tmpbuf,SamplesToDo](const ALfloat *Buffer,
ALfloat (&DelayBuf)[FrontStablizer::DelayLength], BandSplitter &Filter,
ALfloat (&splitbuf)[2][BUFFERSIZE]) -> void
{
@@ -1665,24 +1664,24 @@ template<> inline ALubyte SampleConv(ALfloat val) noexcept
{ return SampleConv<ALbyte>(val) + 128; }
template<DevFmtType T>
-void Write(const ALfloat (*InBuffer)[BUFFERSIZE], ALvoid *OutBuffer, ALsizei Offset,
- ALsizei SamplesToDo, ALsizei numchans)
+void Write(const ALfloat (*InBuffer)[BUFFERSIZE], ALvoid *OutBuffer, const ALsizei Offset,
+ const ALsizei SamplesToDo, const ALsizei numchans)
{
using SampleType = typename DevFmtTypeTraits<T>::Type;
+ ASSUME(Offset >= 0);
ASSUME(numchans > 0);
SampleType *outbase = static_cast<SampleType*>(OutBuffer) + Offset*numchans;
auto conv_channel = [&outbase,SamplesToDo,numchans](const ALfloat *inbuf) -> void
{
ASSUME(SamplesToDo > 0);
SampleType *out{outbase++};
- std::for_each<const ALfloat*RESTRICT>(inbuf, inbuf+SamplesToDo,
- [numchans,&out](const ALfloat s) noexcept -> void
- {
- *out = SampleConv<SampleType>(s);
- out += numchans;
- }
- );
+ auto conv_sample = [numchans,&out](const ALfloat s) noexcept -> void
+ {
+ *out = SampleConv<SampleType>(s);
+ out += numchans;
+ };
+ std::for_each(inbuf, inbuf+SamplesToDo, conv_sample);
};
std::for_each(InBuffer, InBuffer+numchans, conv_channel);
}
diff --git a/Alc/effects/chorus.cpp b/Alc/effects/chorus.cpp
index 74b46a10..d12d2484 100644
--- a/Alc/effects/chorus.cpp
+++ b/Alc/effects/chorus.cpp
@@ -44,28 +44,37 @@ enum class WaveForm {
Triangle
};
-void GetTriangleDelays(ALint *delays, ALsizei offset, ALsizei lfo_range, ALfloat lfo_scale,
- ALfloat depth, ALsizei delay, ALsizei todo)
+void GetTriangleDelays(ALint *delays, const ALsizei start_offset, const ALsizei lfo_range,
+ const ALfloat lfo_scale, const ALfloat depth, const ALsizei delay, const ALsizei todo)
{
- std::generate_n<ALint*RESTRICT>(delays, todo,
- [&offset,lfo_range,lfo_scale,depth,delay]() -> ALint
- {
- offset = (offset+1)%lfo_range;
- return fastf2i((1.0f - std::abs(2.0f - lfo_scale*offset)) * depth) + delay;
- }
- );
+ ASSUME(start_offset >= 0);
+ ASSUME(lfo_range > 0);
+ ASSUME(todo > 0);
+
+ ALsizei offset{start_offset};
+ auto gen_lfo = [&offset,lfo_range,lfo_scale,depth,delay]() -> ALint
+ {
+ offset = (offset+1)%lfo_range;
+ return fastf2i((1.0f - std::abs(2.0f - lfo_scale*offset)) * depth) + delay;
+ };
+ std::generate_n(delays, todo, gen_lfo);
}
-void GetSinusoidDelays(ALint *delays, ALsizei offset, ALsizei lfo_range, ALfloat lfo_scale,
- ALfloat depth, ALsizei delay, ALsizei todo)
+void GetSinusoidDelays(ALint *delays, const ALsizei start_offset, const ALsizei lfo_range,
+ const ALfloat lfo_scale, const ALfloat depth, const ALsizei delay, const ALsizei todo)
{
- std::generate_n<ALint*RESTRICT>(delays, todo,
- [&offset,lfo_range,lfo_scale,depth,delay]() -> ALint
- {
- offset = (offset+1)%lfo_range;
- return fastf2i(std::sin(lfo_scale*offset) * depth) + delay;
- }
- );
+ ASSUME(start_offset >= 0);
+ ASSUME(lfo_range > 0);
+ ASSUME(todo > 0);
+
+ ALsizei offset{start_offset};
+ auto gen_lfo = [&offset,lfo_range,lfo_scale,depth,delay]() -> ALint
+ {
+ ASSUME(delay >= 0);
+ offset = (offset+1)%lfo_range;
+ return fastf2i(std::sin(lfo_scale*offset) * depth) + delay;
+ };
+ std::generate_n(delays, todo, gen_lfo);
}
struct ChorusState final : public EffectState {
diff --git a/Alc/hrtf.cpp b/Alc/hrtf.cpp
index 427326d0..45f63c11 100644
--- a/Alc/hrtf.cpp
+++ b/Alc/hrtf.cpp
@@ -280,8 +280,7 @@ void GetHrtfCoeffs(const HrtfEntry *Hrtf, ALfloat elevation, ALfloat azimuth, AL
const ALfloat mult{blend[c]};
auto blend_coeffs = [mult](const ALfloat src, const ALfloat coeff) noexcept -> ALfloat
{ return src*mult + coeff; };
- std::transform<const ALfloat*RESTRICT>(srccoeffs, srccoeffs + irSize*2, coeffout,
- coeffout, blend_coeffs);
+ std::transform(srccoeffs, srccoeffs + irSize*2, coeffout, coeffout, blend_coeffs);
}
}
diff --git a/Alc/mastering.cpp b/Alc/mastering.cpp
index c71b3cc9..23386cf4 100644
--- a/Alc/mastering.cpp
+++ b/Alc/mastering.cpp
@@ -464,11 +464,7 @@ void Compressor::process(const ALsizei SamplesToDo, ALfloat (*OutBuffer)[BUFFERS
{
ALfloat *buffer{al::assume_aligned<16>(input)};
const ALfloat *gains{al::assume_aligned<16>(&sideChain[0])};
- /* Mark the gains "input-1 type" as restrict, so the compiler can
- * vectorize this loop (otherwise it assumes a write to buffer[n] can
- * change gains[n+1]).
- */
- std::transform<const ALfloat*RESTRICT>(gains, gains+SamplesToDo, buffer, buffer,
+ std::transform(gains, gains+SamplesToDo, buffer, buffer,
std::bind(std::multiplies<float>{}, _1, _2));
};
std::for_each(OutBuffer, OutBuffer+numChans, apply_comp);
diff --git a/Alc/mixer/mixer_c.cpp b/Alc/mixer/mixer_c.cpp
index 1c22115d..6ee5df88 100644
--- a/Alc/mixer/mixer_c.cpp
+++ b/Alc/mixer/mixer_c.cpp
@@ -12,13 +12,15 @@
#include "hrtfbase.h"
-static inline ALfloat do_point(const InterpState&, const ALfloat *RESTRICT vals, const ALsizei) noexcept
+namespace {
+
+inline ALfloat do_point(const InterpState&, const ALfloat *RESTRICT vals, const ALsizei) noexcept
{ return vals[0]; }
-static inline ALfloat do_lerp(const InterpState&, const ALfloat *RESTRICT vals, const ALsizei frac) noexcept
+inline ALfloat do_lerp(const InterpState&, const ALfloat *RESTRICT vals, const ALsizei frac) noexcept
{ return lerp(vals[0], vals[1], frac * (1.0f/FRACTIONONE)); }
-static inline ALfloat do_cubic(const InterpState&, const ALfloat *RESTRICT vals, const ALsizei frac) noexcept
+inline ALfloat do_cubic(const InterpState&, const ALfloat *RESTRICT vals, const ALsizei frac) noexcept
{ return cubic(vals[0], vals[1], vals[2], vals[3], frac * (1.0f/FRACTIONONE)); }
-static inline ALfloat do_bsinc(const InterpState &istate, const ALfloat *RESTRICT vals, const ALsizei frac) noexcept
+inline ALfloat do_bsinc(const InterpState &istate, const ALfloat *RESTRICT vals, const ALsizei frac) noexcept
{
ASSUME(istate.bsinc.m > 0);
@@ -42,9 +44,8 @@ static inline ALfloat do_bsinc(const InterpState &istate, const ALfloat *RESTRIC
using SamplerT = ALfloat(const InterpState&, const ALfloat*RESTRICT, const ALsizei);
template<SamplerT &Sampler>
-static const ALfloat *DoResample(const InterpState *state, const ALfloat *RESTRICT src,
- ALsizei frac, ALint increment, ALfloat *RESTRICT dst,
- ALsizei numsamples)
+const ALfloat *DoResample(const InterpState *state, const ALfloat *RESTRICT src,
+ ALsizei frac, ALint increment, ALfloat *RESTRICT dst, ALsizei numsamples)
{
ASSUME(numsamples > 0);
ASSUME(increment > 0);
@@ -61,11 +62,12 @@ static const ALfloat *DoResample(const InterpState *state, const ALfloat *RESTRI
return ret;
};
- std::generate_n<ALfloat*RESTRICT>(dst, numsamples, proc_sample);
+ std::generate_n(dst, numsamples, proc_sample);
return dst;
}
+} // namespace
template<>
const ALfloat *Resample_<CopyTag,CTag>(const InterpState* UNUSED(state),