Avoid some uses of RESTRICT
This commit is contained in:
parent
219f818b16
commit
ebf33b7c6b
27
Alc/alu.cpp
27
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);
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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),
|
||||
|
Loading…
x
Reference in New Issue
Block a user