diff options
Diffstat (limited to 'alc')
-rw-r--r-- | alc/hrtf.cpp | 31 | ||||
-rw-r--r-- | alc/hrtf.h | 8 | ||||
-rw-r--r-- | alc/mixer/mixer_c.cpp | 2 | ||||
-rw-r--r-- | alc/mixer/mixer_neon.cpp | 2 | ||||
-rw-r--r-- | alc/mixer/mixer_sse.cpp | 2 |
5 files changed, 18 insertions, 27 deletions
diff --git a/alc/hrtf.cpp b/alc/hrtf.cpp index d773b47c..83df4b37 100644 --- a/alc/hrtf.cpp +++ b/alc/hrtf.cpp @@ -72,9 +72,6 @@ struct LoadedHrtf { /* Data set limits must be the same as or more flexible than those defined in * the makemhr utility. */ -#define MIN_IR_SIZE (8) -#define MOD_IR_SIZE (2) - #define MIN_FD_COUNT (1) #define MAX_FD_COUNT (16) @@ -262,7 +259,7 @@ void GetHrtfCoeffs(const HrtfStore *Hrtf, float elevation, float azimuth, float delays[1] = fastf2u(d * float{1.0f/HRIR_DELAY_FRACONE}); const ALuint irSize{Hrtf->irSize}; - ASSUME(irSize >= MIN_IR_SIZE); + ASSUME(irSize >= MIN_IR_LENGTH); /* Calculate the blended HRIR coefficients. */ float *coeffout{al::assume_aligned<16>(&coeffs[0][0])}; @@ -473,10 +470,6 @@ void BuildBFormatHrtf(const HrtfStore *Hrtf, DirectHrtfState *state, const ALuint irsize{minu(Hrtf->irSize + base_delay*2, max_length)}; max_length = minu(hrir_delay_round(max_delay) + irsize, max_length); - /* Round up to the next IR size multiple. */ - max_length += MOD_IR_SIZE-1; - max_length -= max_length%MOD_IR_SIZE; - TRACE("Skipped delay: %.2f, max delay: %.2f, new FIR length: %u\n", min_delay/double{HRIR_DELAY_FRACONE}, max_delay/double{HRIR_DELAY_FRACONE}, max_length); @@ -621,9 +614,9 @@ std::unique_ptr<HrtfStore> LoadHrtf00(std::istream &data, const char *filename) } ALboolean failed{AL_FALSE}; - if(irSize < MIN_IR_SIZE || irSize > HRIR_LENGTH) + if(irSize < MIN_IR_LENGTH || irSize > HRIR_LENGTH) { - ERR("Unsupported HRIR size, irSize=%d (%d to %d)\n", irSize, MIN_IR_SIZE, HRIR_LENGTH); + ERR("Unsupported HRIR size, irSize=%d (%d to %d)\n", irSize, MIN_IR_LENGTH, HRIR_LENGTH); failed = AL_TRUE; } if(evCount < MIN_EV_COUNT || evCount > MAX_EV_COUNT) @@ -737,9 +730,9 @@ std::unique_ptr<HrtfStore> LoadHrtf01(std::istream &data, const char *filename) } ALboolean failed{AL_FALSE}; - if(irSize < MIN_IR_SIZE || irSize > HRIR_LENGTH) + if(irSize < MIN_IR_LENGTH || irSize > HRIR_LENGTH) { - ERR("Unsupported HRIR size, irSize=%d (%d to %d)\n", irSize, MIN_IR_SIZE, HRIR_LENGTH); + ERR("Unsupported HRIR size, irSize=%d (%d to %d)\n", irSize, MIN_IR_LENGTH, HRIR_LENGTH); failed = AL_TRUE; } if(evCount < MIN_EV_COUNT || evCount > MAX_EV_COUNT) @@ -853,9 +846,9 @@ std::unique_ptr<HrtfStore> LoadHrtf02(std::istream &data, const char *filename) failed = AL_TRUE; } - if(irSize < MIN_IR_SIZE || irSize > HRIR_LENGTH) + if(irSize < MIN_IR_LENGTH || irSize > HRIR_LENGTH) { - ERR("Unsupported HRIR size, irSize=%d (%d to %d)\n", irSize, MIN_IR_SIZE, HRIR_LENGTH); + ERR("Unsupported HRIR size, irSize=%d (%d to %d)\n", irSize, MIN_IR_LENGTH, HRIR_LENGTH); failed = AL_TRUE; } if(fdCount < 1 || fdCount > MAX_FD_COUNT) @@ -1382,19 +1375,15 @@ HrtfStore *GetLoadedHrtf(const std::string &name, const char *devname, const ALu /* Scale the IR size for the new sample rate and update the stored * sample rate. */ - uint64_t newIrSize{(uint64_t{hrtf->irSize}*devrate + srate-1) / srate}; - newIrSize = minu64(HRIR_LENGTH, newIrSize) + (MOD_IR_SIZE-1); - hrtf->irSize = static_cast<ALuint>(newIrSize - (newIrSize%MOD_IR_SIZE)); + const uint64_t newIrSize{(uint64_t{hrtf->irSize}*devrate + srate-1) / srate}; + hrtf->irSize = static_cast<ALuint>(minu64(HRIR_LENGTH, newIrSize)); hrtf->sampleRate = devrate; } if(auto hrtfsizeopt = ConfigValueUInt(devname, nullptr, "hrtf-size")) { if(*hrtfsizeopt > 0 && *hrtfsizeopt < hrtf->irSize) - { - hrtf->irSize = maxu(*hrtfsizeopt, MIN_IR_SIZE); - hrtf->irSize -= hrtf->irSize % MOD_IR_SIZE; - } + hrtf->irSize = maxu(*hrtfsizeopt, MIN_IR_LENGTH); } TRACE("Loaded HRTF %s for sample rate %uhz, %u-sample filter\n", name.c_str(), @@ -19,9 +19,11 @@ #define HRTF_HISTORY_LENGTH (1<<HRTF_HISTORY_BITS) #define HRTF_HISTORY_MASK (HRTF_HISTORY_LENGTH-1) -#define HRIR_BITS (7) -#define HRIR_LENGTH (1<<HRIR_BITS) -#define HRIR_MASK (HRIR_LENGTH-1) +#define HRIR_BITS (7) +#define HRIR_LENGTH (1<<HRIR_BITS) +#define HRIR_MASK (HRIR_LENGTH-1) + +#define MIN_IR_LENGTH (8) using float2 = std::array<float,2>; using HrirArray = std::array<float2,HRIR_LENGTH>; diff --git a/alc/mixer/mixer_c.cpp b/alc/mixer/mixer_c.cpp index fad33746..64d12ef7 100644 --- a/alc/mixer/mixer_c.cpp +++ b/alc/mixer/mixer_c.cpp @@ -86,7 +86,7 @@ const float *DoResample(const InterpState *state, const float *RESTRICT src, ALu inline void ApplyCoeffs(float2 *RESTRICT Values, const ALuint IrSize, const HrirArray &Coeffs, const float left, const float right) { - ASSUME(IrSize >= 4); + ASSUME(IrSize >= MIN_IR_LENGTH); for(ALuint c{0};c < IrSize;++c) { Values[c][0] += Coeffs[c][0] * left; diff --git a/alc/mixer/mixer_neon.cpp b/alc/mixer/mixer_neon.cpp index 67bf9c71..ccfc5761 100644 --- a/alc/mixer/mixer_neon.cpp +++ b/alc/mixer/mixer_neon.cpp @@ -26,7 +26,7 @@ inline void ApplyCoeffs(float2 *RESTRICT Values, const ALuint IrSize, const Hrir leftright4 = vcombine_f32(leftright2, leftright2); } - ASSUME(IrSize >= 4); + ASSUME(IrSize >= MIN_IR_LENGTH); for(ALuint c{0};c < IrSize;c += 2) { float32x4_t vals = vld1q_f32(&Values[c][0]); diff --git a/alc/mixer/mixer_sse.cpp b/alc/mixer/mixer_sse.cpp index aaf37df6..4458f9a0 100644 --- a/alc/mixer/mixer_sse.cpp +++ b/alc/mixer/mixer_sse.cpp @@ -20,7 +20,7 @@ inline void ApplyCoeffs(float2 *RESTRICT Values, const ALuint IrSize, const Hrir { const __m128 lrlr{_mm_setr_ps(left, right, left, right)}; - ASSUME(IrSize >= 4); + ASSUME(IrSize >= MIN_IR_LENGTH); /* This isn't technically correct to test alignment, but it's true for * systems that support SSE, which is the only one that needs to know the * alignment of Values (which alternates between 8- and 16-byte aligned). |