aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Alc/hrtf.cpp37
-rw-r--r--Alc/hrtf.h17
-rw-r--r--Alc/mixer/hrtfbase.h15
-rw-r--r--Alc/mixer/mixer_c.cpp5
-rw-r--r--Alc/mixer/mixer_neon.cpp5
-rw-r--r--Alc/mixer/mixer_sse.cpp5
-rw-r--r--OpenAL32/Include/alu.h2
7 files changed, 41 insertions, 45 deletions
diff --git a/Alc/hrtf.cpp b/Alc/hrtf.cpp
index 44cf3d74..96d5ec43 100644
--- a/Alc/hrtf.cpp
+++ b/Alc/hrtf.cpp
@@ -206,7 +206,7 @@ IdxBlend CalcAzIndex(ALsizei azcount, ALfloat az)
* and azimuth in radians. The coefficients are normalized.
*/
void GetHrtfCoeffs(const HrtfEntry *Hrtf, ALfloat elevation, ALfloat azimuth, ALfloat distance,
- ALfloat spread, ALfloat (*RESTRICT coeffs)[2], ALsizei *delays)
+ ALfloat spread, HrirArray<ALfloat> &coeffs, ALsizei *delays)
{
const ALfloat dirfact{1.0f - (spread / al::MathDefs<float>::Tau())};
@@ -273,7 +273,7 @@ void GetHrtfCoeffs(const HrtfEntry *Hrtf, ALfloat elevation, ALfloat azimuth, AL
idx[3] *= irSize;
/* Calculate the blended HRIR coefficients. */
- ALfloat *coeffout{al::assume_aligned<16>(coeffs[0])};
+ ALfloat *coeffout{al::assume_aligned<16>(&coeffs[0][0])};
coeffout[0] = PassthruCoeff * (1.0f-dirfact);
coeffout[1] = PassthruCoeff * (1.0f-dirfact);
std::fill(coeffout+2, coeffout + irSize*2, 0.0f);
@@ -343,8 +343,8 @@ void BuildBFormatHrtf(const HrtfEntry *Hrtf, DirectHrtfState *state, const ALsiz
BandSplitterR<double> splitter;
splitter.init(xover_norm);
- al::vector<std::array<std::array<ALdouble,2>,HRIR_LENGTH>> tmpres(NumChannels);
- al::vector<std::array<ALdouble,HRIR_LENGTH>> tmpfilt(3);
+ auto tmpres = al::vector<HrirArray<ALdouble>>(NumChannels);
+ auto tmpfilt = al::vector<std::array<ALdouble,HRIR_LENGTH>>(3);
for(ALsizei c{0};c < AmbiCount;++c)
{
const ALfloat (*fir)[2]{&Hrtf->coeffs[idx[c] * Hrtf->irSize]};
@@ -402,29 +402,24 @@ void BuildBFormatHrtf(const HrtfEntry *Hrtf, DirectHrtfState *state, const ALsiz
}
}
tmpfilt.clear();
+ idx.clear();
for(ALsizei i{0};i < NumChannels;++i)
{
- for(ALsizei idx{0};idx < HRIR_LENGTH;idx++)
- {
- state->Chan[i].Coeffs[idx][0] = static_cast<ALfloat>(tmpres[i][idx][0]);
- state->Chan[i].Coeffs[idx][1] = static_cast<ALfloat>(tmpres[i][idx][1]);
- }
+ auto copy_arr = [](const std::array<double,2> &in) noexcept -> std::array<float,2>
+ { return std::array<float,2>{{static_cast<float>(in[0]), static_cast<float>(in[1])}}; };
+ std::transform(tmpres[i].begin(), tmpres[i].end(), state->Chan[i].Coeffs.begin(),
+ copy_arr);
}
tmpres.clear();
- idx.clear();
- ALsizei max_length;
- if(!DualBand)
- max_length = mini(max_delay-min_delay + Hrtf->irSize, HRIR_LENGTH);
- else
- {
- /* Increase the IR size by 2/3rds to account for the tail generated by
- * the filter.
- */
- const ALsizei irsize = mini(Hrtf->irSize*5/3, HRIR_LENGTH);
- max_length = mini(max_delay-min_delay + irsize, HRIR_LENGTH);
- }
+ ALsizei max_length{HRIR_LENGTH};
+ /* Increase the IR size by 2/3rds with dual-band processing to account for
+ * the tail generated by the filter.
+ */
+ const ALsizei irsize{DualBand ? mini(Hrtf->irSize*5/3, max_length) : Hrtf->irSize};
+ max_length = mini(max_delay-min_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;
diff --git a/Alc/hrtf.h b/Alc/hrtf.h
index eda04850..0f1270f0 100644
--- a/Alc/hrtf.h
+++ b/Alc/hrtf.h
@@ -1,6 +1,7 @@
#ifndef ALC_HRTF_H
#define ALC_HRTF_H
+#include <array>
#include <memory>
#include <string>
@@ -54,13 +55,16 @@ struct EnumeratedHrtf {
};
+template<typename T>
+using HrirArray = std::array<std::array<T,2>,HRIR_LENGTH>;
+
struct HrtfState {
- alignas(16) ALfloat History[HRTF_HISTORY_LENGTH];
- alignas(16) ALfloat Values[HRIR_LENGTH][2];
+ alignas(16) std::array<ALfloat,HRTF_HISTORY_LENGTH> History;
+ alignas(16) HrirArray<ALfloat> Values;
};
struct HrtfParams {
- alignas(16) ALfloat Coeffs[HRIR_LENGTH][2];
+ alignas(16) HrirArray<ALfloat> Coeffs;
ALsizei Delay[2];
ALfloat Gain;
};
@@ -70,8 +74,8 @@ struct DirectHrtfState {
ALsizei Offset{0};
ALsizei IrSize{0};
struct ChanData {
- alignas(16) ALfloat Values[HRIR_LENGTH][2];
- alignas(16) ALfloat Coeffs[HRIR_LENGTH][2];
+ alignas(16) HrirArray<ALfloat> Values;
+ alignas(16) HrirArray<ALfloat> Coeffs;
};
al::FlexArray<ChanData> Chan;
@@ -95,7 +99,8 @@ struct AngularPoint {
al::vector<EnumeratedHrtf> EnumerateHrtf(const char *devname);
HrtfEntry *GetLoadedHrtf(HrtfHandle *handle);
-void GetHrtfCoeffs(const HrtfEntry *Hrtf, ALfloat elevation, ALfloat azimuth, ALfloat distance, ALfloat spread, ALfloat (*RESTRICT coeffs)[2], ALsizei *delays);
+void GetHrtfCoeffs(const HrtfEntry *Hrtf, ALfloat elevation, ALfloat azimuth, ALfloat distance,
+ ALfloat spread, HrirArray<ALfloat> &coeffs, ALsizei *delays);
/**
* Produces HRTF filter coefficients for decoding B-Format, given a set of
diff --git a/Alc/mixer/hrtfbase.h b/Alc/mixer/hrtfbase.h
index facb577f..388d9ba1 100644
--- a/Alc/mixer/hrtfbase.h
+++ b/Alc/mixer/hrtfbase.h
@@ -6,9 +6,8 @@
#include "opthelpers.h"
-using ApplyCoeffsT = void(ALsizei Offset, ALfloat (&Values)[HRIR_LENGTH][2],
- const ALsizei irSize, const ALfloat (&Coeffs)[HRIR_LENGTH][2],
- const ALfloat left, const ALfloat right);
+using ApplyCoeffsT = void(ALsizei Offset, HrirArray<ALfloat> &Values, const ALsizei irSize,
+ const HrirArray<ALfloat> &Coeffs, const ALfloat left, const ALfloat right);
template<ApplyCoeffsT ApplyCoeffs>
inline void MixHrtfBase(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut, const ALfloat *data,
@@ -19,7 +18,7 @@ inline void MixHrtfBase(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut, c
ASSUME(IrSize >= 4);
ASSUME(BufferSize > 0);
- const ALfloat (&Coeffs)[HRIR_LENGTH][2] = *hrtfparams->Coeffs;
+ const auto &Coeffs = *hrtfparams->Coeffs;
const ALfloat gainstep{hrtfparams->GainStep};
const ALfloat gain{hrtfparams->Gain};
ALfloat stepcount{0.0f};
@@ -79,10 +78,10 @@ inline void MixHrtfBlendBase(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightO
const HrtfParams *oldparams, MixHrtfParams *newparams, HrtfState *hrtfstate,
const ALsizei BufferSize)
{
- const ALfloat (&OldCoeffs)[HRIR_LENGTH][2] = oldparams->Coeffs;
+ const auto OldCoeffs = oldparams->Coeffs;
const ALfloat oldGain{oldparams->Gain};
const ALfloat oldGainStep{-oldGain / (ALfloat)BufferSize};
- const ALfloat (&NewCoeffs)[HRIR_LENGTH][2] = *newparams->Coeffs;
+ const auto &NewCoeffs = *newparams->Coeffs;
const ALfloat newGainStep{newparams->GainStep};
ALfloat stepcount{0.0f};
@@ -162,8 +161,8 @@ inline void MixDirectHrtfBase(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT Right
for(ALsizei c{0};c < NumChans;++c)
{
const ALfloat (&input)[BUFFERSIZE] = data[c];
- const ALfloat (&Coeffs)[HRIR_LENGTH][2] = State->Chan[c].Coeffs;
- ALfloat (&Values)[HRIR_LENGTH][2] = State->Chan[c].Values;
+ const auto &Coeffs = State->Chan[c].Coeffs;
+ auto &Values = State->Chan[c].Values;
ALsizei Offset{State->Offset&HRIR_MASK};
ALsizei HeadOffset{(Offset+IrSize-1)&HRIR_MASK};
diff --git a/Alc/mixer/mixer_c.cpp b/Alc/mixer/mixer_c.cpp
index 4ca7c84d..6ee22cfe 100644
--- a/Alc/mixer/mixer_c.cpp
+++ b/Alc/mixer/mixer_c.cpp
@@ -101,9 +101,8 @@ const ALfloat *Resample_<BSincTag,CTag>(const InterpState *state, const ALfloat
{ return DoResample<do_bsinc>(state, src-state->bsinc.l, frac, increment, dst, dstlen); }
-static inline void ApplyCoeffs(ALsizei Offset, ALfloat (&Values)[HRIR_LENGTH][2],
- const ALsizei IrSize, const ALfloat (&Coeffs)[HRIR_LENGTH][2],
- const ALfloat left, const ALfloat right)
+static inline void ApplyCoeffs(ALsizei Offset, HrirArray<ALfloat> &Values, const ALsizei IrSize,
+ const HrirArray<ALfloat> &Coeffs, const ALfloat left, const ALfloat right)
{
ASSUME(Offset >= 0 && Offset < HRIR_LENGTH);
ASSUME(IrSize >= 2);
diff --git a/Alc/mixer/mixer_neon.cpp b/Alc/mixer/mixer_neon.cpp
index 649ff8d3..9e8324aa 100644
--- a/Alc/mixer/mixer_neon.cpp
+++ b/Alc/mixer/mixer_neon.cpp
@@ -136,9 +136,8 @@ const ALfloat *Resample_<BSincTag,NEONTag>(const InterpState *state, const ALflo
}
-static inline void ApplyCoeffs(ALsizei Offset, ALfloat (&Values)[HRIR_LENGTH][2],
- const ALsizei IrSize, const ALfloat (&Coeffs)[HRIR_LENGTH][2],
- const ALfloat left, const ALfloat right)
+static inline void ApplyCoeffs(ALsizei Offset, HrirArray<ALfloat> &Values, const ALsizei IrSize,
+ const HrirArray<ALfloat> &Coeffs, const ALfloat left, const ALfloat right)
{
ASSUME(IrSize >= 2);
ASSUME(&Values != &Coeffs);
diff --git a/Alc/mixer/mixer_sse.cpp b/Alc/mixer/mixer_sse.cpp
index 8d5660ed..69aeaa62 100644
--- a/Alc/mixer/mixer_sse.cpp
+++ b/Alc/mixer/mixer_sse.cpp
@@ -76,9 +76,8 @@ const ALfloat *Resample_<BSincTag,SSETag>(const InterpState *state, const ALfloa
}
-static inline void ApplyCoeffs(ALsizei Offset, ALfloat (&Values)[HRIR_LENGTH][2],
- const ALsizei IrSize, const ALfloat (&Coeffs)[HRIR_LENGTH][2],
- const ALfloat left, const ALfloat right)
+static inline void ApplyCoeffs(ALsizei Offset, HrirArray<ALfloat> &Values, const ALsizei IrSize,
+ const HrirArray<ALfloat> &Coeffs, const ALfloat left, const ALfloat right)
{
const __m128 lrlr{_mm_setr_ps(left, right, left, right)};
diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h
index b24dbca0..819743b6 100644
--- a/OpenAL32/Include/alu.h
+++ b/OpenAL32/Include/alu.h
@@ -158,7 +158,7 @@ enum {
struct MixHrtfParams {
- const ALfloat (*Coeffs)[HRIR_LENGTH][2];
+ const HrirArray<ALfloat> *Coeffs;
ALsizei Delay[2];
ALfloat Gain;
ALfloat GainStep;