Return non-const from the resampler function
This commit is contained in:
+4
-14
@@ -615,21 +615,11 @@ void Voice::mix(const State vstate, ALCcontext *Context, const uint SamplesToDo)
|
||||
chandata.mPrevSamples.size(), chandata.mPrevSamples.begin());
|
||||
|
||||
/* Resample, then apply ambisonic upsampling as needed. */
|
||||
const float *ResampledData{Resample(&mResampleState,
|
||||
&SrcData[MaxResamplerPadding>>1], DataPosFrac, increment,
|
||||
{Device->ResampledData, DstBufferSize})};
|
||||
float *ResampledData{Resample(&mResampleState, &SrcData[MaxResamplerPadding>>1],
|
||||
DataPosFrac, increment, {Device->ResampledData, DstBufferSize})};
|
||||
if((mFlags&VoiceIsAmbisonic))
|
||||
{
|
||||
const float hfscale{chandata.mAmbiScale};
|
||||
/* Beware the evil const_cast. It's safe since it's pointing to
|
||||
* either SourceData or ResampledData (both non-const), but the
|
||||
* resample method takes the source as const float* and may
|
||||
* return it without copying to output, making it currently
|
||||
* unavoidable.
|
||||
*/
|
||||
const al::span<float> samples{const_cast<float*>(ResampledData), DstBufferSize};
|
||||
chandata.mAmbiSplitter.processHfScale(samples, hfscale);
|
||||
}
|
||||
chandata.mAmbiSplitter.processHfScale({ResampledData, DstBufferSize},
|
||||
chandata.mAmbiScale);
|
||||
|
||||
/* Now filter and mix to the appropriate outputs. */
|
||||
float (&FilterBuf)[BufferLineSize] = Device->FilteredData;
|
||||
|
||||
+7
-6
@@ -59,15 +59,15 @@ union InterpState {
|
||||
BsincState bsinc;
|
||||
};
|
||||
|
||||
using ResamplerFunc = const float*(*)(const InterpState *state, const float *RESTRICT src,
|
||||
uint frac, uint increment, const al::span<float> dst);
|
||||
using ResamplerFunc = float*(*)(const InterpState *state, float *RESTRICT src, uint frac,
|
||||
uint increment, const al::span<float> dst);
|
||||
|
||||
ResamplerFunc PrepareResampler(Resampler resampler, uint increment, InterpState *state);
|
||||
|
||||
|
||||
template<typename TypeTag, typename InstTag>
|
||||
const float *Resample_(const InterpState *state, const float *RESTRICT src, uint frac,
|
||||
uint increment, const al::span<float> dst);
|
||||
float *Resample_(const InterpState *state, float *RESTRICT src, uint frac, uint increment,
|
||||
const al::span<float> dst);
|
||||
|
||||
template<typename InstTag>
|
||||
void Mix_(const al::span<const float> InSamples, const al::span<FloatBufferLine> OutBuffer,
|
||||
@@ -85,11 +85,12 @@ void MixDirectHrtf_(FloatBufferLine &LeftOut, FloatBufferLine &RightOut,
|
||||
float *TempBuf, HrtfChannelState *ChanState, const size_t IrSize, const size_t BufferSize);
|
||||
|
||||
/* Vectorized resampler helpers */
|
||||
inline void InitPosArrays(uint frac, uint increment, uint *frac_arr, uint *pos_arr, size_t size)
|
||||
template<size_t N>
|
||||
inline void InitPosArrays(uint frac, uint increment, uint (&frac_arr)[N], uint (&pos_arr)[N])
|
||||
{
|
||||
pos_arr[0] = 0;
|
||||
frac_arr[0] = frac;
|
||||
for(size_t i{1};i < size;i++)
|
||||
for(size_t i{1};i < N;i++)
|
||||
{
|
||||
const uint frac_tmp{frac_arr[i-1] + increment};
|
||||
pos_arr[i] = pos_arr[i-1] + (frac_tmp>>MixerFracBits);
|
||||
|
||||
+13
-13
@@ -68,8 +68,8 @@ inline float do_fastbsinc(const InterpState &istate, const float *RESTRICT vals,
|
||||
|
||||
using SamplerT = float(&)(const InterpState&, const float*RESTRICT, const uint);
|
||||
template<SamplerT Sampler>
|
||||
const float *DoResample(const InterpState *state, const float *RESTRICT src, uint frac,
|
||||
uint increment, const al::span<float> dst)
|
||||
float *DoResample(const InterpState *state, float *RESTRICT src, uint frac, uint increment,
|
||||
const al::span<float> dst)
|
||||
{
|
||||
const InterpState istate{*state};
|
||||
for(float &out : dst)
|
||||
@@ -97,7 +97,7 @@ inline void ApplyCoeffs(float2 *RESTRICT Values, const size_t IrSize, const Hrir
|
||||
} // namespace
|
||||
|
||||
template<>
|
||||
const float *Resample_<CopyTag,CTag>(const InterpState*, const float *RESTRICT src, uint, uint,
|
||||
float *Resample_<CopyTag,CTag>(const InterpState*, float *RESTRICT src, uint, uint,
|
||||
const al::span<float> dst)
|
||||
{
|
||||
#if defined(HAVE_SSE) || defined(HAVE_NEON)
|
||||
@@ -110,28 +110,28 @@ const float *Resample_<CopyTag,CTag>(const InterpState*, const float *RESTRICT s
|
||||
}
|
||||
|
||||
template<>
|
||||
const float *Resample_<PointTag,CTag>(const InterpState *state, const float *RESTRICT src,
|
||||
uint frac, uint increment, const al::span<float> dst)
|
||||
float *Resample_<PointTag,CTag>(const InterpState *state, float *RESTRICT src, uint frac,
|
||||
uint increment, const al::span<float> dst)
|
||||
{ return DoResample<do_point>(state, src, frac, increment, dst); }
|
||||
|
||||
template<>
|
||||
const float *Resample_<LerpTag,CTag>(const InterpState *state, const float *RESTRICT src,
|
||||
uint frac, uint increment, const al::span<float> dst)
|
||||
float *Resample_<LerpTag,CTag>(const InterpState *state, float *RESTRICT src, uint frac,
|
||||
uint increment, const al::span<float> dst)
|
||||
{ return DoResample<do_lerp>(state, src, frac, increment, dst); }
|
||||
|
||||
template<>
|
||||
const float *Resample_<CubicTag,CTag>(const InterpState *state, const float *RESTRICT src,
|
||||
uint frac, uint increment, const al::span<float> dst)
|
||||
float *Resample_<CubicTag,CTag>(const InterpState *state, float *RESTRICT src, uint frac,
|
||||
uint increment, const al::span<float> dst)
|
||||
{ return DoResample<do_cubic>(state, src-1, frac, increment, dst); }
|
||||
|
||||
template<>
|
||||
const float *Resample_<BSincTag,CTag>(const InterpState *state, const float *RESTRICT src,
|
||||
uint frac, uint increment, const al::span<float> dst)
|
||||
float *Resample_<BSincTag,CTag>(const InterpState *state, float *RESTRICT src, uint frac,
|
||||
uint increment, const al::span<float> dst)
|
||||
{ return DoResample<do_bsinc>(state, src-state->bsinc.l, frac, increment, dst); }
|
||||
|
||||
template<>
|
||||
const float *Resample_<FastBSincTag,CTag>(const InterpState *state, const float *RESTRICT src,
|
||||
uint frac, uint increment, const al::span<float> dst)
|
||||
float *Resample_<FastBSincTag,CTag>(const InterpState *state, float *RESTRICT src, uint frac,
|
||||
uint increment, const al::span<float> dst)
|
||||
{ return DoResample<do_fastbsinc>(state, src-state->bsinc.l, frac, increment, dst); }
|
||||
|
||||
|
||||
|
||||
@@ -24,8 +24,7 @@ namespace {
|
||||
|
||||
inline float32x4_t set_f4(float l0, float l1, float l2, float l3)
|
||||
{
|
||||
float32x4_t ret{};
|
||||
ret = vsetq_lane_f32(l0, ret, 0);
|
||||
float32x4_t ret{vmovq_n_f32(l0)};
|
||||
ret = vsetq_lane_f32(l1, ret, 1);
|
||||
ret = vsetq_lane_f32(l2, ret, 2);
|
||||
ret = vsetq_lane_f32(l3, ret, 3);
|
||||
@@ -40,8 +39,7 @@ inline void ApplyCoeffs(float2 *RESTRICT Values, const size_t IrSize, const Hrir
|
||||
{
|
||||
float32x4_t leftright4;
|
||||
{
|
||||
float32x2_t leftright2 = vdup_n_f32(0.0);
|
||||
leftright2 = vset_lane_f32(left, leftright2, 0);
|
||||
float32x2_t leftright2{vmov_n_f32(left)};
|
||||
leftright2 = vset_lane_f32(right, leftright2, 1);
|
||||
leftright4 = vcombine_f32(leftright2, leftright2);
|
||||
}
|
||||
@@ -61,7 +59,7 @@ inline void ApplyCoeffs(float2 *RESTRICT Values, const size_t IrSize, const Hrir
|
||||
} // namespace
|
||||
|
||||
template<>
|
||||
const float *Resample_<LerpTag,NEONTag>(const InterpState*, const float *RESTRICT src, uint frac,
|
||||
float *Resample_<LerpTag,NEONTag>(const InterpState*, float *RESTRICT src, uint frac,
|
||||
uint increment, const al::span<float> dst)
|
||||
{
|
||||
const int32x4_t increment4 = vdupq_n_s32(static_cast<int>(increment*4));
|
||||
@@ -70,7 +68,7 @@ const float *Resample_<LerpTag,NEONTag>(const InterpState*, const float *RESTRIC
|
||||
alignas(16) uint pos_[4], frac_[4];
|
||||
int32x4_t pos4, frac4;
|
||||
|
||||
InitPosArrays(frac, increment, frac_, pos_, 4);
|
||||
InitPosArrays(frac, increment, frac_, pos_);
|
||||
frac4 = vld1q_s32(reinterpret_cast<int*>(frac_));
|
||||
pos4 = vld1q_s32(reinterpret_cast<int*>(pos_));
|
||||
|
||||
@@ -114,8 +112,8 @@ const float *Resample_<LerpTag,NEONTag>(const InterpState*, const float *RESTRIC
|
||||
}
|
||||
|
||||
template<>
|
||||
const float *Resample_<BSincTag,NEONTag>(const InterpState *state, const float *RESTRICT src,
|
||||
uint frac, uint increment, const al::span<float> dst)
|
||||
float *Resample_<BSincTag,NEONTag>(const InterpState *state, float *RESTRICT src, uint frac,
|
||||
uint increment, const al::span<float> dst)
|
||||
{
|
||||
const float *const filter{state->bsinc.filter};
|
||||
const float32x4_t sf4{vdupq_n_f32(state->bsinc.sf)};
|
||||
@@ -160,8 +158,8 @@ const float *Resample_<BSincTag,NEONTag>(const InterpState *state, const float *
|
||||
}
|
||||
|
||||
template<>
|
||||
const float *Resample_<FastBSincTag,NEONTag>(const InterpState *state,
|
||||
const float *RESTRICT src, uint frac, uint increment, const al::span<float> dst)
|
||||
float *Resample_<FastBSincTag,NEONTag>(const InterpState *state, float *RESTRICT src, uint frac,
|
||||
uint increment, const al::span<float> dst)
|
||||
{
|
||||
const float *const filter{state->bsinc.filter};
|
||||
const size_t m{state->bsinc.m};
|
||||
|
||||
@@ -77,8 +77,8 @@ inline void ApplyCoeffs(float2 *RESTRICT Values, const size_t IrSize, const Hrir
|
||||
} // namespace
|
||||
|
||||
template<>
|
||||
const float *Resample_<BSincTag,SSETag>(const InterpState *state, const float *RESTRICT src,
|
||||
uint frac, uint increment, const al::span<float> dst)
|
||||
float *Resample_<BSincTag,SSETag>(const InterpState *state, float *RESTRICT src, uint frac,
|
||||
uint increment, const al::span<float> dst)
|
||||
{
|
||||
const float *const filter{state->bsinc.filter};
|
||||
const __m128 sf4{_mm_set1_ps(state->bsinc.sf)};
|
||||
@@ -124,8 +124,8 @@ const float *Resample_<BSincTag,SSETag>(const InterpState *state, const float *R
|
||||
}
|
||||
|
||||
template<>
|
||||
const float *Resample_<FastBSincTag,SSETag>(const InterpState *state, const float *RESTRICT src,
|
||||
uint frac, uint increment, const al::span<float> dst)
|
||||
float *Resample_<FastBSincTag,SSETag>(const InterpState *state, float *RESTRICT src, uint frac,
|
||||
uint increment, const al::span<float> dst)
|
||||
{
|
||||
const float *const filter{state->bsinc.filter};
|
||||
const size_t m{state->bsinc.m};
|
||||
|
||||
@@ -35,7 +35,7 @@ struct LerpTag;
|
||||
#endif
|
||||
|
||||
template<>
|
||||
const float *Resample_<LerpTag,SSE2Tag>(const InterpState*, const float *RESTRICT src, uint frac,
|
||||
float *Resample_<LerpTag,SSE2Tag>(const InterpState*, float *RESTRICT src, uint frac,
|
||||
uint increment, const al::span<float> dst)
|
||||
{
|
||||
const __m128i increment4{_mm_set1_epi32(static_cast<int>(increment*4))};
|
||||
@@ -43,7 +43,7 @@ const float *Resample_<LerpTag,SSE2Tag>(const InterpState*, const float *RESTRIC
|
||||
const __m128i fracMask4{_mm_set1_epi32(MixerFracMask)};
|
||||
|
||||
alignas(16) uint pos_[4], frac_[4];
|
||||
InitPosArrays(frac, increment, frac_, pos_, 4);
|
||||
InitPosArrays(frac, increment, frac_, pos_);
|
||||
__m128i frac4{_mm_setr_epi32(static_cast<int>(frac_[0]), static_cast<int>(frac_[1]),
|
||||
static_cast<int>(frac_[2]), static_cast<int>(frac_[3]))};
|
||||
__m128i pos4{_mm_setr_epi32(static_cast<int>(pos_[0]), static_cast<int>(pos_[1]),
|
||||
|
||||
@@ -36,7 +36,7 @@ struct LerpTag;
|
||||
#endif
|
||||
|
||||
template<>
|
||||
const float *Resample_<LerpTag,SSE4Tag>(const InterpState*, const float *RESTRICT src, uint frac,
|
||||
float *Resample_<LerpTag,SSE4Tag>(const InterpState*, float *RESTRICT src, uint frac,
|
||||
uint increment, const al::span<float> dst)
|
||||
{
|
||||
const __m128i increment4{_mm_set1_epi32(static_cast<int>(increment*4))};
|
||||
@@ -44,7 +44,7 @@ const float *Resample_<LerpTag,SSE4Tag>(const InterpState*, const float *RESTRIC
|
||||
const __m128i fracMask4{_mm_set1_epi32(MixerFracMask)};
|
||||
|
||||
alignas(16) uint pos_[4], frac_[4];
|
||||
InitPosArrays(frac, increment, frac_, pos_, 4);
|
||||
InitPosArrays(frac, increment, frac_, pos_);
|
||||
__m128i frac4{_mm_setr_epi32(static_cast<int>(frac_[0]), static_cast<int>(frac_[1]),
|
||||
static_cast<int>(frac_[2]), static_cast<int>(frac_[3]))};
|
||||
__m128i pos4{_mm_setr_epi32(static_cast<int>(pos_[0]), static_cast<int>(pos_[1]),
|
||||
|
||||
Reference in New Issue
Block a user