aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2014-05-21 15:24:40 -0700
committerChris Robinson <[email protected]>2014-05-21 15:24:40 -0700
commit4b433c900ebec9f0bcdc8a4238291d572f89f1c3 (patch)
tree98eb52047762bd3acf58fcf2614d17d2e012ec2c /Alc
parentdd2e6b7902ebe40865a9700b492697b70926198d (diff)
Copy samples if needed in the 'copy' resampler
Diffstat (limited to 'Alc')
-rw-r--r--Alc/mixer_c.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/Alc/mixer_c.c b/Alc/mixer_c.c
index 389971e0..6dd01e7d 100644
--- a/Alc/mixer_c.c
+++ b/Alc/mixer_c.c
@@ -15,27 +15,33 @@ static inline ALfloat lerp32(const ALfloat *vals, ALuint frac)
static inline ALfloat cubic32(const ALfloat *vals, ALuint frac)
{ return cubic(vals[-1], vals[0], vals[1], vals[2], frac * (1.0f/FRACTIONONE)); }
-const ALfloat *Resample_copy32_C(const ALfloat *data, ALuint UNUSED(frac),
- ALuint increment, ALfloat *restrict UNUSED(OutBuffer), ALuint UNUSED(BufferSize))
+const ALfloat *Resample_copy32_C(const ALfloat *src, ALuint UNUSED(frac),
+ ALuint increment, ALfloat *restrict dst, ALuint numsamples)
{
assert(increment==FRACTIONONE);
- return data;
+#if defined(HAVE_SSE) || defined(HAVE_NEON)
+ /* Avoid copying the source data if it's aligned like the destination. */
+ if((((intptr_t)src)&15) == (((intptr_t)dst)&15))
+ return src;
+#endif
+ memcpy(dst, src, numsamples*sizeof(ALfloat));
+ return dst;
}
#define DECL_TEMPLATE(Sampler) \
-const ALfloat *Resample_##Sampler##_C(const ALfloat *data, ALuint frac, \
- ALuint increment, ALfloat *restrict OutBuffer, ALuint BufferSize) \
+const ALfloat *Resample_##Sampler##_C(const ALfloat *src, ALuint frac, \
+ ALuint increment, ALfloat *restrict dst, ALuint numsamples) \
{ \
ALuint i; \
- for(i = 0;i < BufferSize;i++) \
+ for(i = 0;i < numsamples;i++) \
{ \
- OutBuffer[i] = Sampler(data, frac); \
+ dst[i] = Sampler(src, frac); \
\
frac += increment; \
- data += frac>>FRACTIONBITS; \
+ src += frac>>FRACTIONBITS; \
frac &= FRACTIONMASK; \
} \
- return OutBuffer; \
+ return dst; \
}
DECL_TEMPLATE(point32)