diff options
author | Chris Robinson <[email protected]> | 2017-01-16 07:45:07 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2017-01-16 08:06:25 -0800 |
commit | cbb796bf31cd3acfba0ce35e71a51d03e7e26021 (patch) | |
tree | 0264bcb03f58e8dee89ee383d61da0bf4e7469d1 /Alc | |
parent | 9f23d17333c8faaa0a2b7a86df33c41874a929a5 (diff) |
Use ALsizei for sizes and offsets with the mixer
Unsigned 32-bit offsets actually have some potential overhead on 64-bit targets
for pointer/array accesses due to rules on integer wrapping. No idea how much
impact it has in practice, but it's nice to be correct about it.
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/ALu.c | 2 | ||||
-rw-r--r-- | Alc/hrtf.c | 52 | ||||
-rw-r--r-- | Alc/hrtf.h | 6 | ||||
-rw-r--r-- | Alc/mixer.c | 6 | ||||
-rw-r--r-- | Alc/mixer_c.c | 32 | ||||
-rw-r--r-- | Alc/mixer_defs.h | 72 | ||||
-rw-r--r-- | Alc/mixer_inc.c | 36 | ||||
-rw-r--r-- | Alc/mixer_neon.c | 40 | ||||
-rw-r--r-- | Alc/mixer_sse.c | 48 | ||||
-rw-r--r-- | Alc/panning.c | 48 |
10 files changed, 171 insertions, 171 deletions
@@ -1498,7 +1498,7 @@ ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size) if(lidx != -1 && ridx != -1) { HrtfDirectMixerFunc HrtfMix = SelectHrtfMixer(); - ALuint irsize = device->Hrtf.IrSize; + ALsizei irsize = device->Hrtf.IrSize; for(c = 0;c < device->Dry.NumChannels;c++) { HrtfMix(device->RealOut.Buffer, lidx, ridx, @@ -60,32 +60,32 @@ static struct Hrtf *LoadedHrtfs = NULL; * will return an index between 0 and (evcount - 1). Assumes the FPU is in * round-to-zero mode. */ -static ALuint CalcEvIndex(ALuint evcount, ALfloat ev) +static ALsizei CalcEvIndex(ALsizei evcount, ALfloat ev) { ev = (F_PI_2 + ev) * (evcount-1) / F_PI; - return minu(fastf2u(ev + 0.5f), evcount-1); + return mini(fastf2i(ev + 0.5f), evcount-1); } /* Calculate the azimuth index given the polar azimuth in radians. This will * return an index between 0 and (azcount - 1). Assumes the FPU is in round-to- * zero mode. */ -static ALuint CalcAzIndex(ALuint azcount, ALfloat az) +static ALsizei CalcAzIndex(ALsizei azcount, ALfloat az) { az = (F_TAU + az) * azcount / F_TAU; - return fastf2u(az + 0.5f) % azcount; + return fastf2i(az + 0.5f) % azcount; } /* Calculates static HRIR coefficients and delays for the given polar elevation * and azimuth in radians. The coefficients are normalized and attenuated by * the specified gain. */ -void GetHrtfCoeffs(const struct Hrtf *Hrtf, ALfloat elevation, ALfloat azimuth, ALfloat spread, ALfloat gain, ALfloat (*coeffs)[2], ALuint *delays) +void GetHrtfCoeffs(const struct Hrtf *Hrtf, ALfloat elevation, ALfloat azimuth, ALfloat spread, ALfloat gain, ALfloat (*coeffs)[2], ALsizei *delays) { - ALuint evidx, azidx, lidx, ridx; - ALuint azcount, evoffset; + ALsizei evidx, azidx, lidx, ridx; + ALsizei azcount, evoffset; ALfloat dirfact; - ALuint i; + ALsizei i; dirfact = 1.0f - (spread / F_TAU); @@ -102,8 +102,8 @@ void GetHrtfCoeffs(const struct Hrtf *Hrtf, ALfloat elevation, ALfloat azimuth, ridx = evoffset + ((azcount-azidx) % azcount); /* Calculate the HRIR delays. */ - delays[0] = fastf2u(Hrtf->delays[lidx]*dirfact + 0.5f) << HRTFDELAY_BITS; - delays[1] = fastf2u(Hrtf->delays[ridx]*dirfact + 0.5f) << HRTFDELAY_BITS; + delays[0] = fastf2i(Hrtf->delays[lidx]*dirfact + 0.5f) << HRTFDELAY_BITS; + delays[1] = fastf2i(Hrtf->delays[ridx]*dirfact + 0.5f) << HRTFDELAY_BITS; /* Calculate the sample offsets for the HRIR indices. */ lidx *= Hrtf->irSize; @@ -136,7 +136,7 @@ void GetHrtfCoeffs(const struct Hrtf *Hrtf, ALfloat elevation, ALfloat azimuth, } -ALuint BuildBFormatHrtf(const struct Hrtf *Hrtf, ALfloat (*coeffs)[HRIR_LENGTH][2], ALuint NumChannels, const ALuint *AmbiMap) +ALsizei BuildBFormatHrtf(const struct Hrtf *Hrtf, ALfloat (*coeffs)[HRIR_LENGTH][2], ALsizei NumChannels, const ALsizei *AmbiMap) { #define HRTF_AMBI_CHAN_COUNT 14 /* NOTE: azimuth goes clockwise. */ @@ -199,10 +199,10 @@ ALuint BuildBFormatHrtf(const struct Hrtf *Hrtf, ALfloat (*coeffs)[HRIR_LENGTH][ #define NUM_BANDS 2 BandSplitter splitter; ALfloat temps[3][HRIR_LENGTH]; - ALuint lidx[14], ridx[14]; - ALuint min_delay = HRTF_HISTORY_LENGTH; - ALuint max_length = 0; - ALuint i, j, c, b; + ALsizei lidx[14], ridx[14]; + ALsizei min_delay = HRTF_HISTORY_LENGTH; + ALsizei max_length = 0; + ALsizei i, j, c, b; for(c = 0;c < HRTF_AMBI_CHAN_COUNT;c++) { @@ -211,22 +211,22 @@ ALuint BuildBFormatHrtf(const struct Hrtf *Hrtf, ALfloat (*coeffs)[HRIR_LENGTH][ ALuint azcount; /* Calculate elevation index. */ - evidx = (ALuint)floorf((F_PI_2 + Ambi3DPoints[c].elevation) * - (Hrtf->evCount-1)/F_PI + 0.5f); - evidx = minu(evidx, Hrtf->evCount-1); + evidx = (ALsizei)floorf((F_PI_2 + Ambi3DPoints[c].elevation) * + (Hrtf->evCount-1)/F_PI + 0.5f); + evidx = mini(evidx, Hrtf->evCount-1); azcount = Hrtf->azCount[evidx]; evoffset = Hrtf->evOffset[evidx]; /* Calculate azimuth index for this elevation. */ - azidx = (ALuint)floorf((F_TAU+Ambi3DPoints[c].azimuth) * - azcount/F_TAU + 0.5f) % azcount; + azidx = (ALsizei)floorf((F_TAU+Ambi3DPoints[c].azimuth) * + azcount/F_TAU + 0.5f) % azcount; /* Calculate indices for left and right channels. */ lidx[c] = evoffset + azidx; ridx[c] = evoffset + ((azcount-azidx) % azcount); - min_delay = minu(min_delay, minu(Hrtf->delays[lidx[c]], Hrtf->delays[ridx[c]])); + min_delay = mini(min_delay, mini(Hrtf->delays[lidx[c]], Hrtf->delays[ridx[c]])); } memset(temps, 0, sizeof(temps)); @@ -234,7 +234,7 @@ ALuint BuildBFormatHrtf(const struct Hrtf *Hrtf, ALfloat (*coeffs)[HRIR_LENGTH][ for(c = 0;c < HRTF_AMBI_CHAN_COUNT;c++) { const ALshort *fir; - ALuint delay; + ALsizei delay; /* Convert the left FIR from shorts to float */ fir = &Hrtf->coeffs[lidx[c] * Hrtf->irSize]; @@ -259,12 +259,12 @@ ALuint BuildBFormatHrtf(const struct Hrtf *Hrtf, ALfloat (*coeffs)[HRIR_LENGTH][ const ALsizei a = AmbiMap ? AmbiMap[i] : i; for(b = 0;b < NUM_BANDS;b++) { - ALuint k = 0; + ALsizei k = 0; for(j = delay;j < HRIR_LENGTH;++j) coeffs[i][j][0] += temps[b][k++] * Ambi3DMatrix[c][b][a]; } } - max_length = maxu(max_length, minu(delay + Hrtf->irSize, HRIR_LENGTH)); + max_length = maxi(max_length, mini(delay + Hrtf->irSize, HRIR_LENGTH)); /* Convert the right FIR from shorts to float */ fir = &Hrtf->coeffs[ridx[c] * Hrtf->irSize]; @@ -294,9 +294,9 @@ ALuint BuildBFormatHrtf(const struct Hrtf *Hrtf, ALfloat (*coeffs)[HRIR_LENGTH][ coeffs[i][j][1] += temps[b][k++] * Ambi3DMatrix[c][b][a]; } } - max_length = maxu(max_length, minu(delay + Hrtf->irSize, HRIR_LENGTH)); + max_length = maxi(max_length, mini(delay + Hrtf->irSize, HRIR_LENGTH)); } - TRACE("Skipped min delay: %u, new combined length: %u\n", min_delay, max_length); + TRACE("Skipped min delay: %d, new combined length: %d\n", min_delay, max_length); #undef NUM_BANDS return max_length; @@ -9,7 +9,7 @@ struct Hrtf { ALuint sampleRate; - ALuint irSize; + ALsizei irSize; ALubyte evCount; const ALubyte *azCount; @@ -40,13 +40,13 @@ void FreeHrtfs(void); vector_HrtfEntry EnumerateHrtf(const_al_string devname); void FreeHrtfList(vector_HrtfEntry *list); -void GetHrtfCoeffs(const struct Hrtf *Hrtf, ALfloat elevation, ALfloat azimuth, ALfloat spread, ALfloat gain, ALfloat (*coeffs)[2], ALuint *delays); +void GetHrtfCoeffs(const struct Hrtf *Hrtf, ALfloat elevation, ALfloat azimuth, ALfloat spread, ALfloat gain, ALfloat (*coeffs)[2], ALsizei *delays); /* Produces HRTF filter coefficients for decoding B-Format. The result will * have ACN ordering with N3D normalization. NumChannels must currently be 4, * for first-order. Returns the maximum impulse-response length of the * generated coefficients. */ -ALuint BuildBFormatHrtf(const struct Hrtf *Hrtf, ALfloat (*coeffs)[HRIR_LENGTH][2], ALuint NumChannels, const ALuint *AmbiMap); +ALsizei BuildBFormatHrtf(const struct Hrtf *Hrtf, ALfloat (*coeffs)[HRIR_LENGTH][2], ALsizei NumChannels, const ALsizei *AmbiMap); #endif /* ALC_HRTF_H */ diff --git a/Alc/mixer.c b/Alc/mixer.c index be6a137c..cfb975f4 100644 --- a/Alc/mixer.c +++ b/Alc/mixer.c @@ -589,7 +589,7 @@ ALvoid MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALuint Sam { ALfloat delta = 1.0f / (ALfloat)Counter; ALfloat coeffdiff; - ALint delaydiff; + ALsizei delaydiff; for(j = 0;j < IrSize;j++) { coeffdiff = parms->Hrtf.Target.Coeffs[j][0] - parms->Hrtf.Current.Coeffs[j][0]; @@ -597,9 +597,9 @@ ALvoid MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALuint Sam coeffdiff = parms->Hrtf.Target.Coeffs[j][1] - parms->Hrtf.Current.Coeffs[j][1]; hrtfparams.Steps.Coeffs[j][1] = coeffdiff * delta; } - delaydiff = (ALint)(parms->Hrtf.Target.Delay[0] - parms->Hrtf.Current.Delay[0]); + delaydiff = parms->Hrtf.Target.Delay[0] - parms->Hrtf.Current.Delay[0]; hrtfparams.Steps.Delay[0] = fastf2i((ALfloat)delaydiff * delta); - delaydiff = (ALint)(parms->Hrtf.Target.Delay[1] - parms->Hrtf.Current.Delay[1]); + delaydiff = parms->Hrtf.Target.Delay[1] - parms->Hrtf.Current.Delay[1]; hrtfparams.Steps.Delay[1] = fastf2i((ALfloat)delaydiff * delta); } hrtfparams.Target = &parms->Hrtf.Target; diff --git a/Alc/mixer_c.c b/Alc/mixer_c.c index 6ef818c7..8ddd07f3 100644 --- a/Alc/mixer_c.c +++ b/Alc/mixer_c.c @@ -135,16 +135,16 @@ void ALfilterState_processC(ALfilterState *filter, ALfloat *restrict dst, const } -static inline void ApplyCoeffsStep(ALuint Offset, ALfloat (*restrict Values)[2], - const ALuint IrSize, +static inline void ApplyCoeffsStep(ALsizei Offset, ALfloat (*restrict Values)[2], + const ALsizei IrSize, ALfloat (*restrict Coeffs)[2], const ALfloat (*restrict CoeffStep)[2], ALfloat left, ALfloat right) { - ALuint c; + ALsizei c; for(c = 0;c < IrSize;c++) { - const ALuint off = (Offset+c)&HRIR_MASK; + const ALsizei off = (Offset+c)&HRIR_MASK; Values[off][0] += Coeffs[c][0] * left; Values[off][1] += Coeffs[c][1] * right; Coeffs[c][0] += CoeffStep[c][0]; @@ -152,15 +152,15 @@ static inline void ApplyCoeffsStep(ALuint Offset, ALfloat (*restrict Values)[2], } } -static inline void ApplyCoeffs(ALuint Offset, ALfloat (*restrict Values)[2], - const ALuint IrSize, +static inline void ApplyCoeffs(ALsizei Offset, ALfloat (*restrict Values)[2], + const ALsizei IrSize, ALfloat (*restrict Coeffs)[2], ALfloat left, ALfloat right) { - ALuint c; + ALsizei c; for(c = 0;c < IrSize;c++) { - const ALuint off = (Offset+c)&HRIR_MASK; + const ALsizei off = (Offset+c)&HRIR_MASK; Values[off][0] += Coeffs[c][0] * left; Values[off][1] += Coeffs[c][1] * right; } @@ -172,23 +172,23 @@ static inline void ApplyCoeffs(ALuint Offset, ALfloat (*restrict Values)[2], #undef MixHrtf -void Mix_C(const ALfloat *data, ALuint OutChans, ALfloat (*restrict OutBuffer)[BUFFERSIZE], - ALfloat *CurrentGains, const ALfloat *TargetGains, ALuint Counter, ALuint OutPos, - ALuint BufferSize) +void Mix_C(const ALfloat *data, ALsizei OutChans, ALfloat (*restrict OutBuffer)[BUFFERSIZE], + ALfloat *CurrentGains, const ALfloat *TargetGains, ALsizei Counter, ALsizei OutPos, + ALsizei BufferSize) { ALfloat gain, delta, step; - ALuint c; + ALsizei c; delta = (Counter > 0) ? 1.0f/(ALfloat)Counter : 0.0f; for(c = 0;c < OutChans;c++) { - ALuint pos = 0; + ALsizei pos = 0; gain = CurrentGains[c]; step = (TargetGains[c] - gain) * delta; if(fabsf(step) > FLT_EPSILON) { - ALuint minsize = minu(BufferSize, Counter); + ALsizei minsize = mini(BufferSize, Counter); for(;pos < minsize;pos++) { OutBuffer[c][OutPos+pos] += data[pos]*gain; @@ -212,9 +212,9 @@ void Mix_C(const ALfloat *data, ALuint OutChans, ALfloat (*restrict OutBuffer)[B * transform. And as the matrices are more or less static once set up, no * stepping is necessary. */ -void MixRow_C(ALfloat *OutBuffer, const ALfloat *Gains, const ALfloat (*restrict data)[BUFFERSIZE], ALuint InChans, ALuint InPos, ALuint BufferSize) +void MixRow_C(ALfloat *OutBuffer, const ALfloat *Gains, const ALfloat (*restrict data)[BUFFERSIZE], ALsizei InChans, ALsizei InPos, ALsizei BufferSize) { - ALuint c, i; + ALsizei c, i; for(c = 0;c < InChans;c++) { diff --git a/Alc/mixer_defs.h b/Alc/mixer_defs.h index 24916002..318df626 100644 --- a/Alc/mixer_defs.h +++ b/Alc/mixer_defs.h @@ -21,36 +21,36 @@ const ALfloat *Resample_bsinc32_C(const BsincState *state, const ALfloat *restri /* C mixers */ -void MixHrtf_C(ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALuint lidx, ALuint ridx, - const ALfloat *data, ALuint Counter, ALuint Offset, ALuint OutPos, - const ALuint IrSize, const struct MixHrtfParams *hrtfparams, - struct HrtfState *hrtfstate, ALuint BufferSize); -void MixDirectHrtf_C(ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALuint lidx, ALuint ridx, - const ALfloat *data, ALuint Offset, const ALuint IrSize, +void MixHrtf_C(ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALsizei lidx, ALsizei ridx, + const ALfloat *data, ALsizei Counter, ALsizei Offset, ALsizei OutPos, + const ALsizei IrSize, const struct MixHrtfParams *hrtfparams, + struct HrtfState *hrtfstate, ALsizei BufferSize); +void MixDirectHrtf_C(ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALsizei lidx, ALsizei ridx, + const ALfloat *data, ALsizei Offset, const ALsizei IrSize, ALfloat (*restrict Coeffs)[2], ALfloat (*restrict Values)[2], - ALuint BufferSize); -void Mix_C(const ALfloat *data, ALuint OutChans, ALfloat (*restrict OutBuffer)[BUFFERSIZE], - ALfloat *CurrentGains, const ALfloat *TargetGains, ALuint Counter, ALuint OutPos, - ALuint BufferSize); + ALsizei BufferSize); +void Mix_C(const ALfloat *data, ALsizei OutChans, ALfloat (*restrict OutBuffer)[BUFFERSIZE], + ALfloat *CurrentGains, const ALfloat *TargetGains, ALsizei Counter, ALsizei OutPos, + ALsizei BufferSize); void MixRow_C(ALfloat *OutBuffer, const ALfloat *Gains, - const ALfloat (*restrict data)[BUFFERSIZE], ALuint InChans, - ALuint InPos, ALuint BufferSize); + const ALfloat (*restrict data)[BUFFERSIZE], ALsizei InChans, + ALsizei InPos, ALsizei BufferSize); /* SSE mixers */ -void MixHrtf_SSE(ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALuint lidx, ALuint ridx, - const ALfloat *data, ALuint Counter, ALuint Offset, ALuint OutPos, - const ALuint IrSize, const struct MixHrtfParams *hrtfparams, - struct HrtfState *hrtfstate, ALuint BufferSize); -void MixDirectHrtf_SSE(ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALuint lidx, ALuint ridx, - const ALfloat *data, ALuint Offset, const ALuint IrSize, +void MixHrtf_SSE(ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALsizei lidx, ALsizei ridx, + const ALfloat *data, ALsizei Counter, ALsizei Offset, ALsizei OutPos, + const ALsizei IrSize, const struct MixHrtfParams *hrtfparams, + struct HrtfState *hrtfstate, ALsizei BufferSize); +void MixDirectHrtf_SSE(ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALsizei lidx, ALsizei ridx, + const ALfloat *data, ALsizei Offset, const ALsizei IrSize, ALfloat (*restrict Coeffs)[2], ALfloat (*restrict Values)[2], - ALuint BufferSize); -void Mix_SSE(const ALfloat *data, ALuint OutChans, ALfloat (*restrict OutBuffer)[BUFFERSIZE], - ALfloat *CurrentGains, const ALfloat *TargetGains, ALuint Counter, ALuint OutPos, - ALuint BufferSize); + ALsizei BufferSize); +void Mix_SSE(const ALfloat *data, ALsizei OutChans, ALfloat (*restrict OutBuffer)[BUFFERSIZE], + ALfloat *CurrentGains, const ALfloat *TargetGains, ALsizei Counter, ALsizei OutPos, + ALsizei BufferSize); void MixRow_SSE(ALfloat *OutBuffer, const ALfloat *Gains, - const ALfloat (*restrict data)[BUFFERSIZE], ALuint InChans, - ALuint InPos, ALuint BufferSize); + const ALfloat (*restrict data)[BUFFERSIZE], ALsizei InChans, + ALsizei InPos, ALsizei BufferSize); /* SSE resamplers */ inline void InitiatePositionArrays(ALuint frac, ALuint increment, ALuint *restrict frac_arr, ALuint *restrict pos_arr, ALuint size) @@ -92,19 +92,19 @@ const ALfloat *Resample_fir8_32_SSE41(const BsincState *state, const ALfloat *re ALuint numsamples); /* Neon mixers */ -void MixHrtf_Neon(ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALuint lidx, ALuint ridx, - const ALfloat *data, ALuint Counter, ALuint Offset, ALuint OutPos, - const ALuint IrSize, const struct MixHrtfParams *hrtfparams, - struct HrtfState *hrtfstate, ALuint BufferSize); -void MixDirectHrtf_Neon(ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALuint lidx, ALuint ridx, - const ALfloat *data, ALuint Offset, const ALuint IrSize, +void MixHrtf_Neon(ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALsizei lidx, ALsizei ridx, + const ALfloat *data, ALsizei Counter, ALsizei Offset, ALsizei OutPos, + const ALsizei IrSize, const struct MixHrtfParams *hrtfparams, + struct HrtfState *hrtfstate, ALsizei BufferSize); +void MixDirectHrtf_Neon(ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALsizei lidx, ALsizei ridx, + const ALfloat *data, ALsizei Offset, const ALsizei IrSize, ALfloat (*restrict Coeffs)[2], ALfloat (*restrict Values)[2], - ALuint BufferSize); -void Mix_Neon(const ALfloat *data, ALuint OutChans, ALfloat (*restrict OutBuffer)[BUFFERSIZE], - ALfloat *CurrentGains, const ALfloat *TargetGains, ALuint Counter, ALuint OutPos, - ALuint BufferSize); + ALsizei BufferSize); +void Mix_Neon(const ALfloat *data, ALsizei OutChans, ALfloat (*restrict OutBuffer)[BUFFERSIZE], + ALfloat *CurrentGains, const ALfloat *TargetGains, ALsizei Counter, ALsizei OutPos, + ALsizei BufferSize); void MixRow_Neon(ALfloat *OutBuffer, const ALfloat *Gains, - const ALfloat (*restrict data)[BUFFERSIZE], ALuint InChans, - ALuint InPos, ALuint BufferSize); + const ALfloat (*restrict data)[BUFFERSIZE], ALsizei InChans, + ALsizei InPos, ALsizei BufferSize); #endif /* MIXER_DEFS_H */ diff --git a/Alc/mixer_inc.c b/Alc/mixer_inc.c index 25dc2b58..38b0242e 100644 --- a/Alc/mixer_inc.c +++ b/Alc/mixer_inc.c @@ -12,28 +12,28 @@ #define MAX_UPDATE_SAMPLES 128 -static inline void ApplyCoeffsStep(ALuint Offset, ALfloat (*restrict Values)[2], - const ALuint irSize, +static inline void ApplyCoeffsStep(ALsizei Offset, ALfloat (*restrict Values)[2], + const ALsizei irSize, ALfloat (*restrict Coeffs)[2], const ALfloat (*restrict CoeffStep)[2], ALfloat left, ALfloat right); -static inline void ApplyCoeffs(ALuint Offset, ALfloat (*restrict Values)[2], - const ALuint irSize, +static inline void ApplyCoeffs(ALsizei Offset, ALfloat (*restrict Values)[2], + const ALsizei irSize, ALfloat (*restrict Coeffs)[2], ALfloat left, ALfloat right); -void MixHrtf(ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALuint lidx, ALuint ridx, - const ALfloat *data, ALuint Counter, ALuint Offset, ALuint OutPos, - const ALuint IrSize, const MixHrtfParams *hrtfparams, HrtfState *hrtfstate, - ALuint BufferSize) +void MixHrtf(ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALsizei lidx, ALsizei ridx, + const ALfloat *data, ALsizei Counter, ALsizei Offset, ALsizei OutPos, + const ALsizei IrSize, const MixHrtfParams *hrtfparams, HrtfState *hrtfstate, + ALsizei BufferSize) { ALfloat (*Coeffs)[2] = hrtfparams->Current->Coeffs; - ALuint Delay[2] = { hrtfparams->Current->Delay[0], hrtfparams->Current->Delay[1] }; + ALsizei Delay[2] = { hrtfparams->Current->Delay[0], hrtfparams->Current->Delay[1] }; ALfloat out[MAX_UPDATE_SAMPLES][2]; ALfloat left, right; - ALuint minsize; - ALuint pos, i; + ALsizei minsize; + ALsizei pos, i; pos = 0; if(Counter == 0) @@ -42,7 +42,7 @@ void MixHrtf(ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALuint lidx, ALuint ridx minsize = minu(BufferSize, Counter); while(pos < minsize) { - ALuint todo = minu(minsize-pos, MAX_UPDATE_SAMPLES); + ALsizei todo = mini(minsize-pos, MAX_UPDATE_SAMPLES); for(i = 0;i < todo;i++) { @@ -90,7 +90,7 @@ skip_stepping: Delay[1] >>= HRTFDELAY_BITS; while(pos < BufferSize) { - ALuint todo = minu(BufferSize-pos, MAX_UPDATE_SAMPLES); + ALsizei todo = mini(BufferSize-pos, MAX_UPDATE_SAMPLES); for(i = 0;i < todo;i++) { @@ -115,18 +115,18 @@ skip_stepping: } } -void MixDirectHrtf(ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALuint lidx, ALuint ridx, - const ALfloat *data, ALuint Offset, const ALuint IrSize, +void MixDirectHrtf(ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALsizei lidx, ALsizei ridx, + const ALfloat *data, ALsizei Offset, const ALsizei IrSize, ALfloat (*restrict Coeffs)[2], ALfloat (*restrict Values)[2], - ALuint BufferSize) + ALsizei BufferSize) { ALfloat out[MAX_UPDATE_SAMPLES][2]; ALfloat insample; - ALuint pos, i; + ALsizei pos, i; for(pos = 0;pos < BufferSize;) { - ALuint todo = minu(BufferSize-pos, MAX_UPDATE_SAMPLES); + ALsizei todo = mini(BufferSize-pos, MAX_UPDATE_SAMPLES); for(i = 0;i < todo;i++) { diff --git a/Alc/mixer_neon.c b/Alc/mixer_neon.c index 6b506357..0fbcea67 100644 --- a/Alc/mixer_neon.c +++ b/Alc/mixer_neon.c @@ -9,13 +9,13 @@ #include "hrtf.h" -static inline void ApplyCoeffsStep(ALuint Offset, ALfloat (*restrict Values)[2], - const ALuint IrSize, +static inline void ApplyCoeffsStep(ALsizei Offset, ALfloat (*restrict Values)[2], + const ALsizei IrSize, ALfloat (*restrict Coeffs)[2], const ALfloat (*restrict CoeffStep)[2], ALfloat left, ALfloat right) { - ALuint c; + ALsizei c; float32x4_t leftright4; { float32x2_t leftright2 = vdup_n_f32(0.0); @@ -25,8 +25,8 @@ static inline void ApplyCoeffsStep(ALuint Offset, ALfloat (*restrict Values)[2], } for(c = 0;c < IrSize;c += 2) { - const ALuint o0 = (Offset+c)&HRIR_MASK; - const ALuint o1 = (o0+1)&HRIR_MASK; + const ALsizei o0 = (Offset+c)&HRIR_MASK; + const ALsizei o1 = (o0+1)&HRIR_MASK; float32x4_t vals = vcombine_f32(vld1_f32((float32_t*)&Values[o0][0]), vld1_f32((float32_t*)&Values[o1][0])); float32x4_t coefs = vld1q_f32((float32_t*)&Coeffs[c][0]); @@ -41,12 +41,12 @@ static inline void ApplyCoeffsStep(ALuint Offset, ALfloat (*restrict Values)[2], } } -static inline void ApplyCoeffs(ALuint Offset, ALfloat (*restrict Values)[2], - const ALuint IrSize, +static inline void ApplyCoeffs(ALsizei Offset, ALfloat (*restrict Values)[2], + const ALsizei IrSize, ALfloat (*restrict Coeffs)[2], ALfloat left, ALfloat right) { - ALuint c; + ALsizei c; float32x4_t leftright4; { float32x2_t leftright2 = vdup_n_f32(0.0); @@ -56,8 +56,8 @@ static inline void ApplyCoeffs(ALuint Offset, ALfloat (*restrict Values)[2], } for(c = 0;c < IrSize;c += 2) { - const ALuint o0 = (Offset+c)&HRIR_MASK; - const ALuint o1 = (o0+1)&HRIR_MASK; + const ALsizei o0 = (Offset+c)&HRIR_MASK; + const ALsizei o1 = (o0+1)&HRIR_MASK; float32x4_t vals = vcombine_f32(vld1_f32((float32_t*)&Values[o0][0]), vld1_f32((float32_t*)&Values[o1][0])); float32x4_t coefs = vld1q_f32((float32_t*)&Coeffs[c][0]); @@ -75,24 +75,24 @@ static inline void ApplyCoeffs(ALuint Offset, ALfloat (*restrict Values)[2], #undef MixHrtf -void Mix_Neon(const ALfloat *data, ALuint OutChans, ALfloat (*restrict OutBuffer)[BUFFERSIZE], - ALfloat *CurrentGains, const ALfloat *TargetGains, ALuint Counter, ALuint OutPos, - ALuint BufferSize) +void Mix_Neon(const ALfloat *data, ALsizei OutChans, ALfloat (*restrict OutBuffer)[BUFFERSIZE], + ALfloat *CurrentGains, const ALfloat *TargetGains, ALsizei Counter, ALsizei OutPos, + ALsizei BufferSize) { ALfloat gain, delta, step; float32x4_t gain4; - ALuint c; + ALsizei c; delta = (Counter > 0) ? 1.0f/(ALfloat)Counter : 0.0f; for(c = 0;c < OutChans;c++) { - ALuint pos = 0; + ALsizei pos = 0; gain = CurrentGains[c]; step = (TargetGains[c] - gain) * delta; if(fabsf(step) > FLT_EPSILON) { - ALuint minsize = minu(BufferSize, Counter); + ALsizei minsize = mini(BufferSize, Counter); /* Mix with applying gain steps in aligned multiples of 4. */ if(minsize-pos > 3) { @@ -127,7 +127,7 @@ void Mix_Neon(const ALfloat *data, ALuint OutChans, ALfloat (*restrict OutBuffer CurrentGains[c] = gain; /* Mix until pos is aligned with 4 or the mix is done. */ - minsize = minu(BufferSize, (pos+3)&~3); + minsize = mini(BufferSize, (pos+3)&~3); for(;pos < minsize;pos++) OutBuffer[c][OutPos+pos] += data[pos]*gain; } @@ -147,14 +147,14 @@ void Mix_Neon(const ALfloat *data, ALuint OutChans, ALfloat (*restrict OutBuffer } } -void MixRow_Neon(ALfloat *OutBuffer, const ALfloat *Gains, const ALfloat (*restrict data)[BUFFERSIZE], ALuint InChans, ALuint InPos, ALuint BufferSize) +void MixRow_Neon(ALfloat *OutBuffer, const ALfloat *Gains, const ALfloat (*restrict data)[BUFFERSIZE], ALsizei InChans, ALsizei InPos, ALsizei BufferSize) { float32x4_t gain4; - ALuint c; + ALsizei c; for(c = 0;c < InChans;c++) { - ALuint pos = 0; + ALsizei pos = 0; ALfloat gain = Gains[c]; if(!(fabsf(gain) > GAIN_SILENCE_THRESHOLD)) continue; diff --git a/Alc/mixer_sse.c b/Alc/mixer_sse.c index f5e21e23..bad08e2d 100644 --- a/Alc/mixer_sse.c +++ b/Alc/mixer_sse.c @@ -72,8 +72,8 @@ const ALfloat *Resample_bsinc32_SSE(const BsincState *state, const ALfloat *rest } -static inline void ApplyCoeffsStep(ALuint Offset, ALfloat (*restrict Values)[2], - const ALuint IrSize, +static inline void ApplyCoeffsStep(ALsizei Offset, ALfloat (*restrict Values)[2], + const ALsizei IrSize, ALfloat (*restrict Coeffs)[2], const ALfloat (*restrict CoeffStep)[2], ALfloat left, ALfloat right) @@ -81,12 +81,12 @@ static inline void ApplyCoeffsStep(ALuint Offset, ALfloat (*restrict Values)[2], const __m128 lrlr = _mm_setr_ps(left, right, left, right); __m128 coeffs, deltas, imp0, imp1; __m128 vals = _mm_setzero_ps(); - ALuint i; + ALsizei i; if((Offset&1)) { - const ALuint o0 = Offset&HRIR_MASK; - const ALuint o1 = (Offset+IrSize-1)&HRIR_MASK; + const ALsizei o0 = Offset&HRIR_MASK; + const ALsizei o1 = (Offset+IrSize-1)&HRIR_MASK; coeffs = _mm_load_ps(&Coeffs[0][0]); deltas = _mm_load_ps(&CoeffStep[0][0]); @@ -98,7 +98,7 @@ static inline void ApplyCoeffsStep(ALuint Offset, ALfloat (*restrict Values)[2], _mm_storel_pi((__m64*)&Values[o0][0], vals); for(i = 1;i < IrSize-1;i += 2) { - const ALuint o2 = (Offset+i)&HRIR_MASK; + const ALsizei o2 = (Offset+i)&HRIR_MASK; coeffs = _mm_load_ps(&Coeffs[i+1][0]); deltas = _mm_load_ps(&CoeffStep[i+1][0]); @@ -120,7 +120,7 @@ static inline void ApplyCoeffsStep(ALuint Offset, ALfloat (*restrict Values)[2], { for(i = 0;i < IrSize;i += 2) { - const ALuint o = (Offset + i)&HRIR_MASK; + const ALsizei o = (Offset + i)&HRIR_MASK; coeffs = _mm_load_ps(&Coeffs[i][0]); deltas = _mm_load_ps(&CoeffStep[i][0]); @@ -134,20 +134,20 @@ static inline void ApplyCoeffsStep(ALuint Offset, ALfloat (*restrict Values)[2], } } -static inline void ApplyCoeffs(ALuint Offset, ALfloat (*restrict Values)[2], - const ALuint IrSize, +static inline void ApplyCoeffs(ALsizei Offset, ALfloat (*restrict Values)[2], + const ALsizei IrSize, ALfloat (*restrict Coeffs)[2], ALfloat left, ALfloat right) { const __m128 lrlr = _mm_setr_ps(left, right, left, right); __m128 vals = _mm_setzero_ps(); __m128 coeffs; - ALuint i; + ALsizei i; if((Offset&1)) { - const ALuint o0 = Offset&HRIR_MASK; - const ALuint o1 = (Offset+IrSize-1)&HRIR_MASK; + const ALsizei o0 = Offset&HRIR_MASK; + const ALsizei o1 = (Offset+IrSize-1)&HRIR_MASK; __m128 imp0, imp1; coeffs = _mm_load_ps(&Coeffs[0][0]); @@ -157,7 +157,7 @@ static inline void ApplyCoeffs(ALuint Offset, ALfloat (*restrict Values)[2], _mm_storel_pi((__m64*)&Values[o0][0], vals); for(i = 1;i < IrSize-1;i += 2) { - const ALuint o2 = (Offset+i)&HRIR_MASK; + const ALsizei o2 = (Offset+i)&HRIR_MASK; coeffs = _mm_load_ps(&Coeffs[i+1][0]); vals = _mm_load_ps(&Values[o2][0]); @@ -176,7 +176,7 @@ static inline void ApplyCoeffs(ALuint Offset, ALfloat (*restrict Values)[2], { for(i = 0;i < IrSize;i += 2) { - const ALuint o = (Offset + i)&HRIR_MASK; + const ALsizei o = (Offset + i)&HRIR_MASK; coeffs = _mm_load_ps(&Coeffs[i][0]); vals = _mm_load_ps(&Values[o][0]); @@ -192,24 +192,24 @@ static inline void ApplyCoeffs(ALuint Offset, ALfloat (*restrict Values)[2], #undef MixHrtf -void Mix_SSE(const ALfloat *data, ALuint OutChans, ALfloat (*restrict OutBuffer)[BUFFERSIZE], - ALfloat *CurrentGains, const ALfloat *TargetGains, ALuint Counter, ALuint OutPos, - ALuint BufferSize) +void Mix_SSE(const ALfloat *data, ALsizei OutChans, ALfloat (*restrict OutBuffer)[BUFFERSIZE], + ALfloat *CurrentGains, const ALfloat *TargetGains, ALsizei Counter, ALsizei OutPos, + ALsizei BufferSize) { ALfloat gain, delta, step; __m128 gain4; - ALuint c; + ALsizei c; delta = (Counter > 0) ? 1.0f/(ALfloat)Counter : 0.0f; for(c = 0;c < OutChans;c++) { - ALuint pos = 0; + ALsizei pos = 0; gain = CurrentGains[c]; step = (TargetGains[c] - gain) * delta; if(fabsf(step) > FLT_EPSILON) { - ALuint minsize = minu(BufferSize, Counter); + ALsizei minsize = mini(BufferSize, Counter); /* Mix with applying gain steps in aligned multiples of 4. */ if(minsize-pos > 3) { @@ -246,7 +246,7 @@ void Mix_SSE(const ALfloat *data, ALuint OutChans, ALfloat (*restrict OutBuffer) CurrentGains[c] = gain; /* Mix until pos is aligned with 4 or the mix is done. */ - minsize = minu(BufferSize, (pos+3)&~3); + minsize = mini(BufferSize, (pos+3)&~3); for(;pos < minsize;pos++) OutBuffer[c][OutPos+pos] += data[pos]*gain; } @@ -266,14 +266,14 @@ void Mix_SSE(const ALfloat *data, ALuint OutChans, ALfloat (*restrict OutBuffer) } } -void MixRow_SSE(ALfloat *OutBuffer, const ALfloat *Gains, const ALfloat (*restrict data)[BUFFERSIZE], ALuint InChans, ALuint InPos, ALuint BufferSize) +void MixRow_SSE(ALfloat *OutBuffer, const ALfloat *Gains, const ALfloat (*restrict data)[BUFFERSIZE], ALsizei InChans, ALsizei InPos, ALsizei BufferSize) { __m128 gain4; - ALuint c; + ALsizei c; for(c = 0;c < InChans;c++) { - ALuint pos = 0; + ALsizei pos = 0; ALfloat gain = Gains[c]; if(!(fabsf(gain) > GAIN_SILENCE_THRESHOLD)) continue; diff --git a/Alc/panning.c b/Alc/panning.c index de9b8cb1..06c0d9cc 100644 --- a/Alc/panning.c +++ b/Alc/panning.c @@ -45,7 +45,7 @@ extern inline void CalcXYZCoeffs(ALfloat x, ALfloat y, ALfloat z, ALfloat spread #define THIRD_ORDER_SCALE (1.0f / 1.30657f) -static const ALuint FuMa2ACN[MAX_AMBI_COEFFS] = { +static const ALsizei FuMa2ACN[MAX_AMBI_COEFFS] = { 0, /* W */ 3, /* X */ 1, /* Y */ @@ -63,7 +63,7 @@ static const ALuint FuMa2ACN[MAX_AMBI_COEFFS] = { 15, /* P */ 9, /* Q */ }; -static const ALuint ACN2ACN[MAX_AMBI_COEFFS] = { +static const ALsizei ACN2ACN[MAX_AMBI_COEFFS] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; @@ -345,7 +345,7 @@ static void SetChannelMap(const enum Channel *devchans, ChannelConfig *ambicoeff const ChannelMap *chanmap, size_t count, ALuint *outcount, ALboolean isfuma) { - const ALuint *acnmap = isfuma ? FuMa2ACN : ACN2ACN; + const ALsizei *acnmap = isfuma ? FuMa2ACN : ACN2ACN; const ALfloat *n3dscale = isfuma ? FuMa2N3DScale : UnitScale; size_t j, k; ALuint i; @@ -366,7 +366,7 @@ static void SetChannelMap(const enum Channel *devchans, ChannelConfig *ambicoeff for(k = 0;k < MAX_AMBI_COEFFS;++k) { - ALuint acn = acnmap[k]; + ALsizei acn = acnmap[k]; ambicoeffs[i][acn] = chanmap[j].Config[k] / n3dscale[acn]; } break; @@ -514,10 +514,10 @@ static const ChannelMap MonoCfg[1] = { static void InitPanning(ALCdevice *device) { const ChannelMap *chanmap = NULL; - ALuint coeffcount = 0; + ALsizei coeffcount = 0; ALfloat ambiscale; - size_t count = 0; - ALuint i, j; + ALsizei count = 0; + ALsizei i, j; ambiscale = 1.0f; switch(device->FmtChans) @@ -579,7 +579,7 @@ static void InitPanning(ALCdevice *device) if(device->FmtChans >= DevFmtAmbi1 && device->FmtChans <= DevFmtAmbi3) { - const ALuint *acnmap = (device->AmbiFmt == AmbiFormat_FuMa) ? FuMa2ACN : ACN2ACN; + const ALsizei *acnmap = (device->AmbiFmt == AmbiFormat_FuMa) ? FuMa2ACN : ACN2ACN; const ALfloat *n3dscale = (device->AmbiFmt == AmbiFormat_FuMa) ? FuMa2N3DScale : (device->AmbiFmt == AmbiFormat_ACN_SN3D) ? SN3D2N3DScale : /*(device->AmbiFmt == AmbiFormat_ACN_N3D) ?*/ UnitScale; @@ -589,7 +589,7 @@ static void InitPanning(ALCdevice *device) (device->FmtChans == DevFmtAmbi1) ? 4 : 1; for(i = 0;i < count;i++) { - ALuint acn = acnmap[i]; + ALsizei acn = acnmap[i]; device->Dry.Ambi.Map[i].Scale = 1.0f/n3dscale[acn]; device->Dry.Ambi.Map[i].Index = acn; } @@ -624,7 +624,7 @@ static void InitPanning(ALCdevice *device) device->Dry.CoeffCount = coeffcount; memset(&device->FOAOut.Ambi, 0, sizeof(device->FOAOut.Ambi)); - for(i = 0;i < device->Dry.NumChannels;i++) + for(i = 0;i < (ALsizei)device->Dry.NumChannels;i++) { device->FOAOut.Ambi.Coeffs[i][0] = device->Dry.Ambi.Coeffs[i][0]; for(j = 1;j < 4;j++) @@ -639,7 +639,7 @@ static void InitCustomPanning(ALCdevice *device, const AmbDecConf *conf, const A ChannelMap chanmap[MAX_OUTPUT_CHANNELS]; const ALfloat *coeff_scale = UnitScale; ALfloat ambiscale = 1.0f; - ALuint i, j; + ALsizei i, j; if(conf->FreqBands != 1) ERR("Basic renderer uses the high-frequency matrix as single-band (xover_freq = %.0fhz)\n", @@ -659,11 +659,11 @@ static void InitCustomPanning(ALCdevice *device, const AmbDecConf *conf, const A else if(conf->CoeffScale == ADS_FuMa) coeff_scale = FuMa2N3DScale; - for(i = 0;i < conf->NumSpeakers;i++) + for(i = 0;i < (ALsizei)conf->NumSpeakers;i++) { - ALuint chan = speakermap[i]; + ALsizei chan = speakermap[i]; ALfloat gain; - ALuint k = 0; + ALsizei k = 0; for(j = 0;j < MAX_AMBI_COEFFS;j++) chanmap[i].Config[j] = 0.0f; @@ -686,7 +686,7 @@ static void InitCustomPanning(ALCdevice *device, const AmbDecConf *conf, const A (conf->ChanMask > 0xf) ? 9 : 4; memset(&device->FOAOut.Ambi, 0, sizeof(device->FOAOut.Ambi)); - for(i = 0;i < device->Dry.NumChannels;i++) + for(i = 0;i < (ALsizei)device->Dry.NumChannels;i++) { device->FOAOut.Ambi.Coeffs[i][0] = device->Dry.Ambi.Coeffs[i][0]; for(j = 1;j < 4;j++) @@ -700,7 +700,7 @@ static void InitHQPanning(ALCdevice *device, const AmbDecConf *conf, const ALuin const char *devname; int decflags = 0; size_t count; - ALuint i; + size_t i; devname = al_string_get_cstr(device->DeviceName); if(GetConfigValueBool(devname, "decoder", "distance-comp", 1)) @@ -758,11 +758,11 @@ static void InitHQPanning(ALCdevice *device, const AmbDecConf *conf, const ALuin static void InitHrtfPanning(ALCdevice *device, bool hoa_mode) { - static const ALuint map_foa[] = { 0, 1, 2, 3 }; - static const ALuint map_hoa[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8 }; - const ALuint *ambi_map = hoa_mode ? map_hoa : map_foa; + static const ALsizei map_foa[] = { 0, 1, 2, 3 }; + static const ALsizei map_hoa[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8 }; + const ALsizei *ambi_map = hoa_mode ? map_hoa : map_foa; size_t count = hoa_mode ? COUNTOF(map_hoa) : COUNTOF(map_foa); - ALuint i; + size_t i; static_assert(COUNTOF(map_hoa) <= COUNTOF(device->Hrtf.Coeffs), "ALCdevice::Hrtf.Values/Coeffs size is too small"); @@ -803,12 +803,12 @@ static void InitHrtfPanning(ALCdevice *device, bool hoa_mode) static void InitUhjPanning(ALCdevice *device) { - size_t count = 3; - ALuint i; + ALsizei count = 3; + ALsizei i; for(i = 0;i < count;i++) { - ALuint acn = FuMa2ACN[i]; + ALsizei acn = FuMa2ACN[i]; device->Dry.Ambi.Map[i].Scale = 1.0f/FuMa2N3DScale[acn]; device->Dry.Ambi.Map[i].Index = acn; } @@ -1065,7 +1065,7 @@ no_hrtf: void aluInitEffectPanning(ALeffectslot *slot) { - ALuint i; + ALsizei i; memset(slot->ChanMap, 0, sizeof(slot->ChanMap)); slot->NumChannels = 0; |