aboutsummaryrefslogtreecommitdiffstats
path: root/alc
diff options
context:
space:
mode:
Diffstat (limited to 'alc')
-rw-r--r--alc/alu.h5
-rw-r--r--alc/converter.cpp2
-rw-r--r--alc/mixer/defs.h2
-rw-r--r--alc/mixer/mixer_c.cpp32
-rw-r--r--alc/mixer/mixer_neon.cpp31
-rw-r--r--alc/mixer/mixer_sse.cpp9
-rw-r--r--alc/mixer/mixer_sse2.cpp17
-rw-r--r--alc/mixer/mixer_sse41.cpp17
-rw-r--r--alc/mixvoice.cpp2
9 files changed, 57 insertions, 60 deletions
diff --git a/alc/alu.h b/alc/alu.h
index 7bde7b03..4ab093d2 100644
--- a/alc/alu.h
+++ b/alc/alu.h
@@ -80,9 +80,8 @@ union InterpState {
BsincState bsinc;
};
-using ResamplerFunc = const ALfloat*(*)(const InterpState *state,
- const ALfloat *RESTRICT src, ALsizei frac, ALint increment,
- ALfloat *RESTRICT dst, ALsizei dstlen);
+using ResamplerFunc = const ALfloat*(*)(const InterpState *state, const ALfloat *RESTRICT src,
+ ALsizei frac, ALint increment, const al::span<float> dst);
void BsincPrepare(const ALuint increment, BsincState *state, const BSincTable *table);
diff --git a/alc/converter.cpp b/alc/converter.cpp
index e66e5929..de61415a 100644
--- a/alc/converter.cpp
+++ b/alc/converter.cpp
@@ -299,7 +299,7 @@ ALuint SampleConverter::convert(const ALvoid **src, ALuint *srcframes, ALvoid *d
/* Now resample, and store the result in the output buffer. */
const ALfloat *ResampledData{mResample(&mState, SrcData+MAX_RESAMPLE_PADDING,
- DataPosFrac, increment, DstData, DstSize)};
+ DataPosFrac, increment, {DstData, DstSize})};
StoreSamples(DstSamples, ResampledData, mChan.size(), mDstType, DstSize);
}
diff --git a/alc/mixer/defs.h b/alc/mixer/defs.h
index 9d4fd063..bdb208c4 100644
--- a/alc/mixer/defs.h
+++ b/alc/mixer/defs.h
@@ -27,7 +27,7 @@ enum ResampleType {
};
template<ResampleType TypeTag, InstSetType InstTag>
-const ALfloat *Resample_(const InterpState *state, const ALfloat *RESTRICT src, ALsizei frac, ALint increment, ALfloat *RESTRICT dst, ALsizei dstlen);
+const ALfloat *Resample_(const InterpState *state, const ALfloat *RESTRICT src, ALsizei frac, ALint increment, const al::span<float> dst);
template<InstSetType InstTag>
void Mix_(const al::span<const float> InSamples, const al::span<FloatBufferLine> OutBuffer,
diff --git a/alc/mixer/mixer_c.cpp b/alc/mixer/mixer_c.cpp
index e7ca23d5..743431da 100644
--- a/alc/mixer/mixer_c.cpp
+++ b/alc/mixer/mixer_c.cpp
@@ -44,9 +44,8 @@ inline ALfloat do_bsinc(const InterpState &istate, const ALfloat *RESTRICT vals,
using SamplerT = ALfloat(const InterpState&, const ALfloat*RESTRICT, const ALsizei);
template<SamplerT &Sampler>
const ALfloat *DoResample(const InterpState *state, const ALfloat *RESTRICT src,
- ALsizei frac, ALint increment, ALfloat *RESTRICT dst, ALsizei numsamples)
+ ALsizei frac, ALint increment, const al::span<float> dst)
{
- ASSUME(numsamples > 0);
ASSUME(increment > 0);
ASSUME(frac >= 0);
@@ -61,46 +60,45 @@ const ALfloat *DoResample(const InterpState *state, const ALfloat *RESTRICT src,
return ret;
};
- std::generate_n(dst, numsamples, proc_sample);
+ std::generate(dst.begin(), dst.end(), proc_sample);
- return dst;
+ return dst.begin();
}
} // namespace
template<>
const ALfloat *Resample_<CopyTag,CTag>(const InterpState*, const ALfloat *RESTRICT src, ALsizei,
- ALint, ALfloat *RESTRICT dst, ALsizei dstlen)
+ ALint, const al::span<float> dst)
{
- ASSUME(dstlen > 0);
#if defined(HAVE_SSE) || defined(HAVE_NEON)
/* Avoid copying the source data if it's aligned like the destination. */
- if((reinterpret_cast<intptr_t>(src)&15) == (reinterpret_cast<intptr_t>(dst)&15))
+ if((reinterpret_cast<intptr_t>(src)&15) == (reinterpret_cast<intptr_t>(dst.data())&15))
return src;
#endif
- std::copy_n(src, dstlen, dst);
- return dst;
+ std::copy_n(src, dst.size(), dst.begin());
+ return dst.begin();
}
template<>
const ALfloat *Resample_<PointTag,CTag>(const InterpState *state, const ALfloat *RESTRICT src,
- ALsizei frac, ALint increment, ALfloat *RESTRICT dst, ALsizei dstlen)
-{ return DoResample<do_point>(state, src, frac, increment, dst, dstlen); }
+ ALsizei frac, ALint 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,
- ALsizei frac, ALint increment, ALfloat *RESTRICT dst, ALsizei dstlen)
-{ return DoResample<do_lerp>(state, src, frac, increment, dst, dstlen); }
+ ALsizei frac, ALint 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,
- ALsizei frac, ALint increment, ALfloat *RESTRICT dst, ALsizei dstlen)
-{ return DoResample<do_cubic>(state, src-1, frac, increment, dst, dstlen); }
+ ALsizei frac, ALint 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,
- ALsizei frac, ALint increment, ALfloat *RESTRICT dst, ALsizei dstlen)
-{ return DoResample<do_bsinc>(state, src-state->bsinc.l, frac, increment, dst, dstlen); }
+ ALsizei frac, ALint increment, const al::span<float> dst)
+{ return DoResample<do_bsinc>(state, src-state->bsinc.l, frac, increment, dst); }
static inline void ApplyCoeffs(ALsizei /*Offset*/, float2 *RESTRICT Values, const ALsizei IrSize,
diff --git a/alc/mixer/mixer_neon.cpp b/alc/mixer/mixer_neon.cpp
index 1c4466c2..53b2fe8d 100644
--- a/alc/mixer/mixer_neon.cpp
+++ b/alc/mixer/mixer_neon.cpp
@@ -16,25 +16,24 @@
template<>
const ALfloat *Resample_<LerpTag,NEONTag>(const InterpState*, const ALfloat *RESTRICT src,
- ALsizei frac, ALint increment, ALfloat *RESTRICT dst, ALsizei dstlen)
+ ALsizei frac, ALint increment, const al::span<float> dst)
{
const int32x4_t increment4 = vdupq_n_s32(increment*4);
const float32x4_t fracOne4 = vdupq_n_f32(1.0f/FRACTIONONE);
const int32x4_t fracMask4 = vdupq_n_s32(FRACTIONMASK);
alignas(16) ALsizei pos_[4], frac_[4];
int32x4_t pos4, frac4;
- ALsizei todo, pos, i;
ASSUME(frac >= 0);
ASSUME(increment > 0);
- ASSUME(dstlen > 0);
InitiatePositionArrays(frac, increment, frac_, pos_, 4);
frac4 = vld1q_s32(frac_);
pos4 = vld1q_s32(pos_);
- todo = dstlen & ~3;
- for(i = 0;i < todo;i += 4)
+ auto dst_iter = dst.begin();
+ const auto aligned_end = (dst.size()&~3) + dst_iter;
+ while(dst_iter != aligned_end)
{
const int pos0 = vgetq_lane_s32(pos4, 0);
const int pos1 = vgetq_lane_s32(pos4, 1);
@@ -48,7 +47,8 @@ const ALfloat *Resample_<LerpTag,NEONTag>(const InterpState*, const ALfloat *RES
const float32x4_t mu = vmulq_f32(vcvtq_f32_s32(frac4), fracOne4);
const float32x4_t out = vmlaq_f32(val1, mu, r0);
- vst1q_f32(&dst[i], out);
+ vst1q_f32(dst_iter, out);
+ dst_iter += 4;
frac4 = vaddq_s32(frac4, increment4);
pos4 = vaddq_s32(pos4, vshrq_n_s32(frac4, FRACTIONBITS));
@@ -58,39 +58,38 @@ const ALfloat *Resample_<LerpTag,NEONTag>(const InterpState*, const ALfloat *RES
/* NOTE: These four elements represent the position *after* the last four
* samples, so the lowest element is the next position to resample.
*/
- pos = vgetq_lane_s32(pos4, 0);
+ ALsizei pos{vgetq_lane_s32(pos4, 0)};
frac = vgetq_lane_s32(frac4, 0);
- for(;i < dstlen;++i)
+ while(dst_iter != dst.end())
{
- dst[i] = lerp(src[pos], src[pos+1], frac * (1.0f/FRACTIONONE));
+ *(dst_iter++) = lerp(src[pos], src[pos+1], frac * (1.0f/FRACTIONONE));
frac += increment;
pos += frac>>FRACTIONBITS;
frac &= FRACTIONMASK;
}
- return dst;
+ return dst.begin();
}
template<>
const ALfloat *Resample_<BSincTag,NEONTag>(const InterpState *state, const ALfloat *RESTRICT src,
- ALsizei frac, ALint increment, ALfloat *RESTRICT dst, ALsizei dstlen)
+ ALsizei frac, ALint increment, const al::span<float> dst)
{
const ALfloat *const filter = state->bsinc.filter;
const float32x4_t sf4 = vdupq_n_f32(state->bsinc.sf);
const ALsizei m = state->bsinc.m;
const float32x4_t *fil, *scd, *phd, *spd;
- ALsizei pi, i, j, offset;
+ ALsizei pi, j, offset;
float32x4_t r4;
ALfloat pf;
ASSUME(m > 0);
- ASSUME(dstlen > 0);
ASSUME(increment > 0);
ASSUME(frac >= 0);
src -= state->bsinc.l;
- for(i = 0;i < dstlen;i++)
+ for(float &out_sample : dst)
{
// Calculate the phase index and factor.
#define FRAC_PHASE_BITDIFF (FRACTIONBITS-BSINC_PHASE_BITS)
@@ -125,13 +124,13 @@ const ALfloat *Resample_<BSincTag,NEONTag>(const InterpState *state, const ALflo
}
r4 = vaddq_f32(r4, vcombine_f32(vrev64_f32(vget_high_f32(r4)),
vrev64_f32(vget_low_f32(r4))));
- dst[i] = vget_lane_f32(vadd_f32(vget_low_f32(r4), vget_high_f32(r4)), 0);
+ out_sample = vget_lane_f32(vadd_f32(vget_low_f32(r4), vget_high_f32(r4)), 0);
frac += increment;
src += frac>>FRACTIONBITS;
frac &= FRACTIONMASK;
}
- return dst;
+ return dst.begin();
}
diff --git a/alc/mixer/mixer_sse.cpp b/alc/mixer/mixer_sse.cpp
index 3c8204d2..c154eeef 100644
--- a/alc/mixer/mixer_sse.cpp
+++ b/alc/mixer/mixer_sse.cpp
@@ -15,19 +15,18 @@
template<>
const ALfloat *Resample_<BSincTag,SSETag>(const InterpState *state, const ALfloat *RESTRICT src,
- ALsizei frac, ALint increment, ALfloat *RESTRICT dst, ALsizei dstlen)
+ ALsizei frac, ALint increment, const al::span<float> dst)
{
const ALfloat *const filter{state->bsinc.filter};
const __m128 sf4{_mm_set1_ps(state->bsinc.sf)};
const ALsizei m{state->bsinc.m};
ASSUME(m > 0);
- ASSUME(dstlen > 0);
ASSUME(increment > 0);
ASSUME(frac >= 0);
src -= state->bsinc.l;
- for(ALsizei i{0};i < dstlen;i++)
+ for(float &out_sample : dst)
{
// Calculate the phase index and factor.
#define FRAC_PHASE_BITDIFF (FRACTIONBITS-BSINC_PHASE_BITS)
@@ -64,13 +63,13 @@ const ALfloat *Resample_<BSincTag,SSETag>(const InterpState *state, const ALfloa
}
r4 = _mm_add_ps(r4, _mm_shuffle_ps(r4, r4, _MM_SHUFFLE(0, 1, 2, 3)));
r4 = _mm_add_ps(r4, _mm_movehl_ps(r4, r4));
- dst[i] = _mm_cvtss_f32(r4);
+ out_sample = _mm_cvtss_f32(r4);
frac += increment;
src += frac>>FRACTIONBITS;
frac &= FRACTIONMASK;
}
- return dst;
+ return dst.begin();
}
diff --git a/alc/mixer/mixer_sse2.cpp b/alc/mixer/mixer_sse2.cpp
index b1c67f09..e3443f4e 100644
--- a/alc/mixer/mixer_sse2.cpp
+++ b/alc/mixer/mixer_sse2.cpp
@@ -29,7 +29,7 @@
template<>
const ALfloat *Resample_<LerpTag,SSE2Tag>(const InterpState*, const ALfloat *RESTRICT src,
- ALsizei frac, ALint increment, ALfloat *RESTRICT dst, ALsizei dstlen)
+ ALsizei frac, ALint increment, const al::span<float> dst)
{
const __m128i increment4{_mm_set1_epi32(increment*4)};
const __m128 fracOne4{_mm_set1_ps(1.0f/FRACTIONONE)};
@@ -37,15 +37,15 @@ const ALfloat *Resample_<LerpTag,SSE2Tag>(const InterpState*, const ALfloat *RES
ASSUME(frac >= 0);
ASSUME(increment > 0);
- ASSUME(dstlen >= 0);
alignas(16) ALsizei pos_[4], frac_[4];
InitiatePositionArrays(frac, increment, frac_, pos_, 4);
__m128i frac4{_mm_setr_epi32(frac_[0], frac_[1], frac_[2], frac_[3])};
__m128i pos4{_mm_setr_epi32(pos_[0], pos_[1], pos_[2], pos_[3])};
- const ALsizei todo{dstlen & ~3};
- for(ALsizei i{0};i < todo;i += 4)
+ auto dst_iter = dst.begin();
+ const auto aligned_end = (dst.size()&~3) + dst_iter;
+ while(dst_iter != aligned_end)
{
const int pos0{_mm_cvtsi128_si32(_mm_shuffle_epi32(pos4, _MM_SHUFFLE(0, 0, 0, 0)))};
const int pos1{_mm_cvtsi128_si32(_mm_shuffle_epi32(pos4, _MM_SHUFFLE(1, 1, 1, 1)))};
@@ -59,7 +59,8 @@ const ALfloat *Resample_<LerpTag,SSE2Tag>(const InterpState*, const ALfloat *RES
const __m128 mu{_mm_mul_ps(_mm_cvtepi32_ps(frac4), fracOne4)};
const __m128 out{_mm_add_ps(val1, _mm_mul_ps(mu, r0))};
- _mm_store_ps(&dst[i], out);
+ _mm_store_ps(dst_iter, out);
+ dst_iter += 4;
frac4 = _mm_add_epi32(frac4, increment4);
pos4 = _mm_add_epi32(pos4, _mm_srli_epi32(frac4, FRACTIONBITS));
@@ -72,13 +73,13 @@ const ALfloat *Resample_<LerpTag,SSE2Tag>(const InterpState*, const ALfloat *RES
ALsizei pos{_mm_cvtsi128_si32(pos4)};
frac = _mm_cvtsi128_si32(frac4);
- for(ALsizei i{todo};i < dstlen;++i)
+ while(dst_iter != dst.end())
{
- dst[i] = lerp(src[pos], src[pos+1], frac * (1.0f/FRACTIONONE));
+ *(dst_iter++) = lerp(src[pos], src[pos+1], frac * (1.0f/FRACTIONONE));
frac += increment;
pos += frac>>FRACTIONBITS;
frac &= FRACTIONMASK;
}
- return dst;
+ return dst.begin();
}
diff --git a/alc/mixer/mixer_sse41.cpp b/alc/mixer/mixer_sse41.cpp
index 077be44c..424b9b5f 100644
--- a/alc/mixer/mixer_sse41.cpp
+++ b/alc/mixer/mixer_sse41.cpp
@@ -30,7 +30,7 @@
template<>
const ALfloat *Resample_<LerpTag,SSE4Tag>(const InterpState*, const ALfloat *RESTRICT src,
- ALsizei frac, ALint increment, ALfloat *RESTRICT dst, ALsizei dstlen)
+ ALsizei frac, ALint increment, const al::span<float> dst)
{
const __m128i increment4{_mm_set1_epi32(increment*4)};
const __m128 fracOne4{_mm_set1_ps(1.0f/FRACTIONONE)};
@@ -38,15 +38,15 @@ const ALfloat *Resample_<LerpTag,SSE4Tag>(const InterpState*, const ALfloat *RES
ASSUME(frac >= 0);
ASSUME(increment > 0);
- ASSUME(dstlen >= 0);
alignas(16) ALsizei pos_[4], frac_[4];
InitiatePositionArrays(frac, increment, frac_, pos_, 4);
__m128i frac4{_mm_setr_epi32(frac_[0], frac_[1], frac_[2], frac_[3])};
__m128i pos4{_mm_setr_epi32(pos_[0], pos_[1], pos_[2], pos_[3])};
- const ALsizei todo{dstlen & ~3};
- for(ALsizei i{0};i < todo;i += 4)
+ auto dst_iter = dst.begin();
+ const auto aligned_end = (dst.size()&~3) + dst_iter;
+ while(dst_iter != aligned_end)
{
const int pos0{_mm_extract_epi32(pos4, 0)};
const int pos1{_mm_extract_epi32(pos4, 1)};
@@ -60,7 +60,8 @@ const ALfloat *Resample_<LerpTag,SSE4Tag>(const InterpState*, const ALfloat *RES
const __m128 mu{_mm_mul_ps(_mm_cvtepi32_ps(frac4), fracOne4)};
const __m128 out{_mm_add_ps(val1, _mm_mul_ps(mu, r0))};
- _mm_store_ps(&dst[i], out);
+ _mm_store_ps(dst_iter, out);
+ dst_iter += 4;
frac4 = _mm_add_epi32(frac4, increment4);
pos4 = _mm_add_epi32(pos4, _mm_srli_epi32(frac4, FRACTIONBITS));
@@ -73,13 +74,13 @@ const ALfloat *Resample_<LerpTag,SSE4Tag>(const InterpState*, const ALfloat *RES
ALsizei pos{_mm_cvtsi128_si32(pos4)};
frac = _mm_cvtsi128_si32(frac4);
- for(ALsizei i{todo};i < dstlen;++i)
+ while(dst_iter != dst.end())
{
- dst[i] = lerp(src[pos], src[pos+1], frac * (1.0f/FRACTIONONE));
+ *(dst_iter++) = lerp(src[pos], src[pos+1], frac * (1.0f/FRACTIONONE));
frac += increment;
pos += frac>>FRACTIONBITS;
frac &= FRACTIONMASK;
}
- return dst;
+ return dst.begin();
}
diff --git a/alc/mixvoice.cpp b/alc/mixvoice.cpp
index c13245eb..6bdbdec1 100644
--- a/alc/mixvoice.cpp
+++ b/alc/mixvoice.cpp
@@ -621,7 +621,7 @@ void MixVoice(ALvoice *voice, ALvoice::State vstate, const ALuint SourceID, ALCc
/* Resample, then apply ambisonic upsampling as needed. */
const ALfloat *ResampledData{Resample(&voice->mResampleState,
&SrcData[MAX_RESAMPLE_PADDING], DataPosFrac, increment,
- Device->ResampledData, DstBufferSize)};
+ {Device->ResampledData, DstBufferSize})};
if((voice->mFlags&VOICE_IS_AMBISONIC))
{
const ALfloat hfscale{chandata.mAmbiScale};