Avoid tracing wide-char strings
[openal-soft.git] / Alc / mixer_c.c
blobcd7499f08ab91da8bd4c76d61ba8885273513438
1 #include "config.h"
3 #include <assert.h>
5 #include "alMain.h"
6 #include "alu.h"
7 #include "alSource.h"
8 #include "alAuxEffectSlot.h"
11 static inline ALfloat point32(const ALfloat *vals, ALuint UNUSED(frac))
12 { return vals[0]; }
13 static inline ALfloat lerp32(const ALfloat *vals, ALuint frac)
14 { return lerp(vals[0], vals[1], frac * (1.0f/FRACTIONONE)); }
15 static inline ALfloat cubic32(const ALfloat *vals, ALuint frac)
16 { return cubic(vals[-1], vals[0], vals[1], vals[2], frac); }
18 const ALfloat *Resample_copy32_C(const ALfloat *src, ALuint UNUSED(frac),
19 ALuint increment, ALfloat *restrict dst, ALuint numsamples)
21 assert(increment==FRACTIONONE);
22 #if defined(HAVE_SSE) || defined(HAVE_NEON)
23 /* Avoid copying the source data if it's aligned like the destination. */
24 if((((intptr_t)src)&15) == (((intptr_t)dst)&15))
25 return src;
26 #endif
27 memcpy(dst, src, numsamples*sizeof(ALfloat));
28 return dst;
31 #define DECL_TEMPLATE(Sampler) \
32 const ALfloat *Resample_##Sampler##_C(const ALfloat *src, ALuint frac, \
33 ALuint increment, ALfloat *restrict dst, ALuint numsamples) \
34 { \
35 ALuint i; \
36 for(i = 0;i < numsamples;i++) \
37 { \
38 dst[i] = Sampler(src, frac); \
40 frac += increment; \
41 src += frac>>FRACTIONBITS; \
42 frac &= FRACTIONMASK; \
43 } \
44 return dst; \
47 DECL_TEMPLATE(point32)
48 DECL_TEMPLATE(lerp32)
49 DECL_TEMPLATE(cubic32)
51 #undef DECL_TEMPLATE
54 void ALfilterState_processC(ALfilterState *filter, ALfloat *restrict dst, const ALfloat *src, ALuint numsamples)
56 ALuint i;
57 for(i = 0;i < numsamples;i++)
58 *(dst++) = ALfilterState_processSingle(filter, *(src++));
62 static inline void SetupCoeffs(ALfloat (*restrict OutCoeffs)[2],
63 const HrtfParams *hrtfparams,
64 ALuint IrSize, ALuint Counter)
66 ALuint c;
67 for(c = 0;c < IrSize;c++)
69 OutCoeffs[c][0] = hrtfparams->Coeffs[c][0] - (hrtfparams->CoeffStep[c][0]*Counter);
70 OutCoeffs[c][1] = hrtfparams->Coeffs[c][1] - (hrtfparams->CoeffStep[c][1]*Counter);
74 static inline void ApplyCoeffsStep(ALuint Offset, ALfloat (*restrict Values)[2],
75 const ALuint IrSize,
76 ALfloat (*restrict Coeffs)[2],
77 const ALfloat (*restrict CoeffStep)[2],
78 ALfloat left, ALfloat right)
80 ALuint c;
81 for(c = 0;c < IrSize;c++)
83 const ALuint off = (Offset+c)&HRIR_MASK;
84 Values[off][0] += Coeffs[c][0] * left;
85 Values[off][1] += Coeffs[c][1] * right;
86 Coeffs[c][0] += CoeffStep[c][0];
87 Coeffs[c][1] += CoeffStep[c][1];
91 static inline void ApplyCoeffs(ALuint Offset, ALfloat (*restrict Values)[2],
92 const ALuint IrSize,
93 ALfloat (*restrict Coeffs)[2],
94 ALfloat left, ALfloat right)
96 ALuint c;
97 for(c = 0;c < IrSize;c++)
99 const ALuint off = (Offset+c)&HRIR_MASK;
100 Values[off][0] += Coeffs[c][0] * left;
101 Values[off][1] += Coeffs[c][1] * right;
105 #define SUFFIX C
106 #include "mixer_inc.c"
107 #undef SUFFIX
110 void Mix_C(const ALfloat *data, ALuint OutChans, ALfloat (*restrict OutBuffer)[BUFFERSIZE],
111 MixGains *Gains, ALuint Counter, ALuint OutPos, ALuint BufferSize)
113 ALfloat gain, step;
114 ALuint c;
116 for(c = 0;c < OutChans;c++)
118 ALuint pos = 0;
119 gain = Gains[c].Current;
120 step = Gains[c].Step;
121 if(step != 0.0f && Counter > 0)
123 for(;pos < BufferSize && pos < Counter;pos++)
125 OutBuffer[c][OutPos+pos] += data[pos]*gain;
126 gain += step;
128 if(pos == Counter)
129 gain = Gains[c].Target;
130 Gains[c].Current = gain;
133 if(!(fabsf(gain) > GAIN_SILENCE_THRESHOLD))
134 continue;
135 for(;pos < BufferSize;pos++)
136 OutBuffer[c][OutPos+pos] += data[pos]*gain;