Avoid using ALfloat in the mixer functions

This commit is contained in:
Chris Robinson
2020-04-03 03:11:32 -07:00
parent 236564b54a
commit d9225083b4
6 changed files with 48 additions and 48 deletions
+1 -1
View File
@@ -30,7 +30,7 @@ enum ResampleType {
};
template<ResampleType TypeTag, InstSetType InstTag>
const ALfloat *Resample_(const InterpState *state, const ALfloat *RESTRICT src, ALuint frac,
const float *Resample_(const InterpState *state, const float *RESTRICT src, ALuint frac,
ALuint increment, const al::span<float> dst);
template<InstSetType InstTag>
+14 -14
View File
@@ -90,8 +90,8 @@ inline void ApplyCoeffs(float2 *RESTRICT Values, const ALuint IrSize, const Hrir
} // namespace
template<>
const ALfloat *Resample_<CopyTag,CTag>(const InterpState*, const ALfloat *RESTRICT src, ALuint,
ALuint, const al::span<float> dst)
const float *Resample_<CopyTag,CTag>(const InterpState*, const float *RESTRICT src, ALuint, ALuint,
const al::span<float> dst)
{
#if defined(HAVE_SSE) || defined(HAVE_NEON)
/* Avoid copying the source data if it's aligned like the destination. */
@@ -99,31 +99,31 @@ const ALfloat *Resample_<CopyTag,CTag>(const InterpState*, const ALfloat *RESTRI
return src;
#endif
std::copy_n(src, dst.size(), dst.begin());
return dst.begin();
return dst.data();
}
template<>
const ALfloat *Resample_<PointTag,CTag>(const InterpState *state, const ALfloat *RESTRICT src,
const float *Resample_<PointTag,CTag>(const InterpState *state, const float *RESTRICT src,
ALuint frac, ALuint increment, const al::span<float> dst)
{ return DoResample<do_point>(state, src, frac, increment, dst); }
template<>
const ALfloat *Resample_<LerpTag,CTag>(const InterpState *state, const ALfloat *RESTRICT src,
const float *Resample_<LerpTag,CTag>(const InterpState *state, const float *RESTRICT src,
ALuint frac, ALuint increment, const al::span<float> dst)
{ return DoResample<do_lerp>(state, src, frac, increment, dst); }
template<>
const ALfloat *Resample_<CubicTag,CTag>(const InterpState *state, const ALfloat *RESTRICT src,
const float *Resample_<CubicTag,CTag>(const InterpState *state, const float *RESTRICT src,
ALuint frac, ALuint increment, const al::span<float> dst)
{ return DoResample<do_cubic>(state, src-1, frac, increment, dst); }
template<>
const ALfloat *Resample_<BSincTag,CTag>(const InterpState *state, const ALfloat *RESTRICT src,
const float *Resample_<BSincTag,CTag>(const InterpState *state, const float *RESTRICT src,
ALuint frac, ALuint increment, const al::span<float> dst)
{ return DoResample<do_bsinc>(state, src-state->bsinc.l, frac, increment, dst); }
template<>
const ALfloat *Resample_<FastBSincTag,CTag>(const InterpState *state, const ALfloat *RESTRICT src,
const float *Resample_<FastBSincTag,CTag>(const InterpState *state, const float *RESTRICT src,
ALuint frac, ALuint increment, const al::span<float> dst)
{ return DoResample<do_fastbsinc>(state, src-state->bsinc.l, frac, increment, dst); }
@@ -152,22 +152,22 @@ template<>
void Mix_<CTag>(const al::span<const float> InSamples, const al::span<FloatBufferLine> OutBuffer,
float *CurrentGains, const float *TargetGains, const size_t Counter, const size_t OutPos)
{
const ALfloat delta{(Counter > 0) ? 1.0f / static_cast<ALfloat>(Counter) : 0.0f};
const float delta{(Counter > 0) ? 1.0f / static_cast<float>(Counter) : 0.0f};
const bool reached_target{InSamples.size() >= Counter};
const auto min_end = reached_target ? InSamples.begin() + Counter : InSamples.end();
for(FloatBufferLine &output : OutBuffer)
{
ALfloat *RESTRICT dst{al::assume_aligned<16>(output.data()+OutPos)};
ALfloat gain{*CurrentGains};
const ALfloat diff{*TargetGains - gain};
float *RESTRICT dst{al::assume_aligned<16>(output.data()+OutPos)};
float gain{*CurrentGains};
const float diff{*TargetGains - gain};
auto in_iter = InSamples.begin();
if(!(std::fabs(diff) > std::numeric_limits<float>::epsilon()))
gain = *TargetGains;
else
{
const ALfloat step{diff * delta};
ALfloat step_count{0.0f};
const float step{diff * delta};
float step_count{0.0f};
while(in_iter != min_end)
{
*(dst++) += *(in_iter++) * (gain + step*step_count);
+16 -16
View File
@@ -45,8 +45,8 @@ inline void ApplyCoeffs(float2 *RESTRICT Values, const ALuint IrSize, const Hrir
} // namespace
template<>
const ALfloat *Resample_<LerpTag,NEONTag>(const InterpState*, const ALfloat *RESTRICT src,
ALuint frac, ALuint increment, const al::span<float> dst)
const float *Resample_<LerpTag,NEONTag>(const InterpState*, const float *RESTRICT src, ALuint frac,
ALuint increment, const al::span<float> dst)
{
const int32x4_t increment4 = vdupq_n_s32(static_cast<int>(increment*4));
const float32x4_t fracOne4 = vdupq_n_f32(1.0f/FRACTIONONE);
@@ -95,11 +95,11 @@ const ALfloat *Resample_<LerpTag,NEONTag>(const InterpState*, const ALfloat *RES
frac &= FRACTIONMASK;
} while(dst_iter != dst.end());
}
return dst.begin();
return dst.data();
}
template<>
const ALfloat *Resample_<BSincTag,NEONTag>(const InterpState *state, const ALfloat *RESTRICT src,
const float *Resample_<BSincTag,NEONTag>(const InterpState *state, const float *RESTRICT src,
ALuint frac, ALuint increment, const al::span<float> dst)
{
const float *const filter{state->bsinc.filter};
@@ -142,12 +142,12 @@ const ALfloat *Resample_<BSincTag,NEONTag>(const InterpState *state, const ALflo
src += frac>>FRACTIONBITS;
frac &= FRACTIONMASK;
}
return dst.begin();
return dst.data();
}
template<>
const ALfloat *Resample_<FastBSincTag,NEONTag>(const InterpState *state,
const ALfloat *RESTRICT src, ALuint frac, ALuint increment, const al::span<float> dst)
const float *Resample_<FastBSincTag,NEONTag>(const InterpState *state,
const float *RESTRICT src, ALuint frac, ALuint increment, const al::span<float> dst)
{
const float *const filter{state->bsinc.filter};
const size_t m{state->bsinc.m};
@@ -184,7 +184,7 @@ const ALfloat *Resample_<FastBSincTag,NEONTag>(const InterpState *state,
src += frac>>FRACTIONBITS;
frac &= FRACTIONMASK;
}
return dst.begin();
return dst.data();
}
@@ -212,24 +212,24 @@ template<>
void Mix_<NEONTag>(const al::span<const float> InSamples, const al::span<FloatBufferLine> OutBuffer,
float *CurrentGains, const float *TargetGains, const size_t Counter, const size_t OutPos)
{
const ALfloat delta{(Counter > 0) ? 1.0f / static_cast<ALfloat>(Counter) : 0.0f};
const float delta{(Counter > 0) ? 1.0f / static_cast<float>(Counter) : 0.0f};
const bool reached_target{InSamples.size() >= Counter};
const auto min_end = reached_target ? InSamples.begin() + Counter : InSamples.end();
const auto aligned_end = minz(static_cast<uintptr_t>(min_end-InSamples.begin()+3) & ~3u,
InSamples.size()) + InSamples.begin();
for(FloatBufferLine &output : OutBuffer)
{
ALfloat *RESTRICT dst{al::assume_aligned<16>(output.data()+OutPos)};
ALfloat gain{*CurrentGains};
const ALfloat diff{*TargetGains - gain};
float *RESTRICT dst{al::assume_aligned<16>(output.data()+OutPos)};
float gain{*CurrentGains};
const float diff{*TargetGains - gain};
auto in_iter = InSamples.begin();
if(!(std::fabs(diff) > std::numeric_limits<float>::epsilon()))
gain = *TargetGains;
else
{
const ALfloat step{diff * delta};
ALfloat step_count{0.0f};
const float step{diff * delta};
float step_count{0.0f};
/* Mix with applying gain steps in aligned multiples of 4. */
if(ptrdiff_t todo{(min_end-in_iter) >> 2})
{
@@ -296,9 +296,9 @@ template<>
void MixRow_<NEONTag>(const al::span<float> OutBuffer, const al::span<const float> Gains,
const float *InSamples, const size_t InStride)
{
for(const ALfloat gain : Gains)
for(const float gain : Gains)
{
const ALfloat *RESTRICT input{InSamples};
const float *RESTRICT input{InSamples};
InSamples += InStride;
if(!(std::fabs(gain) > GAIN_SILENCE_THRESHOLD))
+11 -11
View File
@@ -71,7 +71,7 @@ inline void ApplyCoeffs(float2 *RESTRICT Values, const ALuint IrSize, const Hrir
} // namespace
template<>
const ALfloat *Resample_<BSincTag,SSETag>(const InterpState *state, const ALfloat *RESTRICT src,
const float *Resample_<BSincTag,SSETag>(const InterpState *state, const float *RESTRICT src,
ALuint frac, ALuint increment, const al::span<float> dst)
{
const float *const filter{state->bsinc.filter};
@@ -115,12 +115,12 @@ const ALfloat *Resample_<BSincTag,SSETag>(const InterpState *state, const ALfloa
src += frac>>FRACTIONBITS;
frac &= FRACTIONMASK;
}
return dst.begin();
return dst.data();
}
template<>
const ALfloat *Resample_<FastBSincTag,SSETag>(const InterpState *state,
const ALfloat *RESTRICT src, ALuint frac, ALuint increment, const al::span<float> dst)
const float *Resample_<FastBSincTag,SSETag>(const InterpState *state, const float *RESTRICT src,
ALuint frac, ALuint increment, const al::span<float> dst)
{
const float *const filter{state->bsinc.filter};
const size_t m{state->bsinc.m};
@@ -158,7 +158,7 @@ const ALfloat *Resample_<FastBSincTag,SSETag>(const InterpState *state,
src += frac>>FRACTIONBITS;
frac &= FRACTIONMASK;
}
return dst.begin();
return dst.data();
}
@@ -186,24 +186,24 @@ template<>
void Mix_<SSETag>(const al::span<const float> InSamples, const al::span<FloatBufferLine> OutBuffer,
float *CurrentGains, const float *TargetGains, const size_t Counter, const size_t OutPos)
{
const ALfloat delta{(Counter > 0) ? 1.0f / static_cast<ALfloat>(Counter) : 0.0f};
const float delta{(Counter > 0) ? 1.0f / static_cast<float>(Counter) : 0.0f};
const bool reached_target{InSamples.size() >= Counter};
const auto min_end = reached_target ? InSamples.begin() + Counter : InSamples.end();
const auto aligned_end = minz(static_cast<uintptr_t>(min_end-InSamples.begin()+3) & ~3u,
InSamples.size()) + InSamples.begin();
for(FloatBufferLine &output : OutBuffer)
{
ALfloat *RESTRICT dst{al::assume_aligned<16>(output.data()+OutPos)};
ALfloat gain{*CurrentGains};
const ALfloat diff{*TargetGains - gain};
float *RESTRICT dst{al::assume_aligned<16>(output.data()+OutPos)};
float gain{*CurrentGains};
const float diff{*TargetGains - gain};
auto in_iter = InSamples.begin();
if(!(std::fabs(diff) > std::numeric_limits<float>::epsilon()))
gain = *TargetGains;
else
{
const ALfloat step{diff * delta};
ALfloat step_count{0.0f};
const float step{diff * delta};
float step_count{0.0f};
/* Mix with applying gain steps in aligned multiples of 4. */
if(ptrdiff_t todo{(min_end-in_iter) >> 2})
{
+3 -3
View File
@@ -28,8 +28,8 @@
template<>
const ALfloat *Resample_<LerpTag,SSE2Tag>(const InterpState*, const ALfloat *RESTRICT src,
ALuint frac, ALuint increment, const al::span<float> dst)
const float *Resample_<LerpTag,SSE2Tag>(const InterpState*, const float *RESTRICT src, ALuint frac,
ALuint increment, const al::span<float> dst)
{
const __m128i increment4{_mm_set1_epi32(static_cast<int>(increment*4))};
const __m128 fracOne4{_mm_set1_ps(1.0f/FRACTIONONE)};
@@ -79,5 +79,5 @@ const ALfloat *Resample_<LerpTag,SSE2Tag>(const InterpState*, const ALfloat *RES
frac &= FRACTIONMASK;
} while(dst_iter != dst.end());
}
return dst.begin();
return dst.data();
}
+3 -3
View File
@@ -29,8 +29,8 @@
template<>
const ALfloat *Resample_<LerpTag,SSE4Tag>(const InterpState*, const ALfloat *RESTRICT src,
ALuint frac, ALuint increment, const al::span<float> dst)
const float *Resample_<LerpTag,SSE4Tag>(const InterpState*, const float *RESTRICT src, ALuint frac,
ALuint increment, const al::span<float> dst)
{
const __m128i increment4{_mm_set1_epi32(static_cast<int>(increment*4))};
const __m128 fracOne4{_mm_set1_ps(1.0f/FRACTIONONE)};
@@ -84,5 +84,5 @@ const ALfloat *Resample_<LerpTag,SSE4Tag>(const InterpState*, const ALfloat *RES
frac &= FRACTIONMASK;
} while(dst_iter != dst.end());
}
return dst.begin();
return dst.data();
}