aboutsummaryrefslogtreecommitdiffstats
path: root/alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2020-01-04 00:59:49 -0800
committerChris Robinson <[email protected]>2020-01-04 00:59:49 -0800
commitcdd24c7d010a18de26b8c1d20a71a12a7db7aafe (patch)
treea034ae7ff02127789004ff96070de3278d3f8187 /alc
parent462bcd4ab7ba1603bef159ec48dc995045ced036 (diff)
Combine identical arrays
Diffstat (limited to 'alc')
-rw-r--r--alc/alc.cpp16
-rw-r--r--alc/alu.cpp5
-rw-r--r--alc/ambidefs.h7
-rw-r--r--alc/bformatdec.cpp26
-rw-r--r--alc/hrtf.cpp10
-rw-r--r--alc/panning.cpp2
6 files changed, 27 insertions, 39 deletions
diff --git a/alc/alc.cpp b/alc/alc.cpp
index 199934f9..31b57e35 100644
--- a/alc/alc.cpp
+++ b/alc/alc.cpp
@@ -2267,19 +2267,9 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
if((voice.mFmtChannels == FmtBFormat2D || voice.mFmtChannels == FmtBFormat3D)
&& device->mAmbiOrder > voice.mAmbiOrder)
{
- const ALuint *OrderFromChan;
- if(voice.mFmtChannels == FmtBFormat2D)
- {
- static const ALuint Order2DFromChan[MAX_AMBI2D_CHANNELS]{
- 0, 1,1, 2,2, 3,3,};
- OrderFromChan = Order2DFromChan;
- }
- else
- {
- static const ALuint Order3DFromChan[MAX_AMBI_CHANNELS]{
- 0, 1,1,1, 2,2,2,2,2, 3,3,3,3,3,3,3,};
- OrderFromChan = Order3DFromChan;
- }
+ const uint8_t *OrderFromChan{(voice.mFmtChannels == FmtBFormat2D) ?
+ AmbiIndex::OrderFrom2DChannel.data() :
+ AmbiIndex::OrderFromChannel.data()};
const BandSplitter splitter{400.0f / static_cast<float>(device->Frequency)};
diff --git a/alc/alu.cpp b/alc/alu.cpp
index 4b2a5c26..77a37593 100644
--- a/alc/alu.cpp
+++ b/alc/alu.cpp
@@ -904,15 +904,12 @@ void CalcPanningAndFilters(ALvoice *voice, const ALfloat xpos, const ALfloat ypo
GetAmbiLayout(voice->mAmbiLayout).data()};
const float *scales{GetAmbiScales(voice->mAmbiScaling).data()};
- static const uint8_t OrderFromChan[MAX_AMBI_CHANNELS]{
- 0, 1,1,1, 2,2,2,2,2, 3,3,3,3,3,3,3,
- };
static const uint8_t ChansPerOrder[MAX_AMBI_ORDER+1]{1, 3, 5, 7,};
static const uint8_t OrderOffset[MAX_AMBI_ORDER+1]{0, 1, 4, 9,};
for(ALuint c{0};c < num_channels;c++)
{
const size_t acn{index_map[c]};
- const size_t order{OrderFromChan[acn]};
+ const size_t order{AmbiIndex::OrderFromChannel[acn]};
const size_t tocopy{ChansPerOrder[order]};
const size_t offset{OrderOffset[order]};
const float scale{scales[acn]};
diff --git a/alc/ambidefs.h b/alc/ambidefs.h
index a38c4900..5a34804d 100644
--- a/alc/ambidefs.h
+++ b/alc/ambidefs.h
@@ -120,6 +120,13 @@ struct AmbiIndex {
static constexpr std::array<uint8_t,MAX_AMBI2D_CHANNELS> From2D{{
0, 1,3, 4,8, 9,15
}};
+
+ static constexpr std::array<uint8_t,MAX_AMBI_CHANNELS> OrderFromChannel{{
+ 0, 1,1,1, 2,2,2,2,2, 3,3,3,3,3,3,3,
+ }};
+ static constexpr std::array<uint8_t,MAX_AMBI2D_CHANNELS> OrderFrom2DChannel{{
+ 0, 1,1, 2,2, 3,3,
+ }};
};
#endif /* AMBIDEFS_H */
diff --git a/alc/bformatdec.cpp b/alc/bformatdec.cpp
index bef5ae20..d8f59ddc 100644
--- a/alc/bformatdec.cpp
+++ b/alc/bformatdec.cpp
@@ -78,12 +78,10 @@ BFormatDec::BFormatDec(const AmbDecConf *conf, const bool allow_2band, const ALu
ALfloat (&mtx)[MAX_AMBI_CHANNELS] = mMatrix.Single[chanmap[i]];
for(size_t j{0},k{0};j < coeff_count;j++)
{
- const size_t l{periphonic ? j : AmbiIndex::From2D[j]};
- if(!(conf->ChanMask&(1u<<l))) continue;
- mtx[j] = conf->HFMatrix[i][k] / coeff_scale[l] *
- ((l>=9) ? conf->HFOrderGain[3] :
- (l>=4) ? conf->HFOrderGain[2] :
- (l>=1) ? conf->HFOrderGain[1] : conf->HFOrderGain[0]);
+ const size_t acn{periphonic ? j : AmbiIndex::From2D[j]};
+ if(!(conf->ChanMask&(1u<<acn))) continue;
+ mtx[j] = conf->HFMatrix[i][k] / coeff_scale[acn] *
+ conf->HFOrderGain[AmbiIndex::OrderFromChannel[acn]];
++k;
}
}
@@ -99,16 +97,12 @@ BFormatDec::BFormatDec(const AmbDecConf *conf, const bool allow_2band, const ALu
ALfloat (&mtx)[sNumBands][MAX_AMBI_CHANNELS] = mMatrix.Dual[chanmap[i]];
for(size_t j{0},k{0};j < coeff_count;j++)
{
- const size_t l{periphonic ? j : AmbiIndex::From2D[j]};
- if(!(conf->ChanMask&(1u<<l))) continue;
- mtx[sHFBand][j] = conf->HFMatrix[i][k] / coeff_scale[l] *
- ((l>=9) ? conf->HFOrderGain[3] :
- (l>=4) ? conf->HFOrderGain[2] :
- (l>=1) ? conf->HFOrderGain[1] : conf->HFOrderGain[0]) * ratio;
- mtx[sLFBand][j] = conf->LFMatrix[i][k] / coeff_scale[l] *
- ((l>=9) ? conf->LFOrderGain[3] :
- (l>=4) ? conf->LFOrderGain[2] :
- (l>=1) ? conf->LFOrderGain[1] : conf->LFOrderGain[0]) / ratio;
+ const size_t acn{periphonic ? j : AmbiIndex::From2D[j]};
+ if(!(conf->ChanMask&(1u<<acn))) continue;
+ mtx[sHFBand][j] = conf->HFMatrix[i][k] / coeff_scale[acn] *
+ conf->HFOrderGain[AmbiIndex::OrderFromChannel[acn]] * ratio;
+ mtx[sLFBand][j] = conf->LFMatrix[i][k] / coeff_scale[acn] *
+ conf->LFOrderGain[AmbiIndex::OrderFromChannel[acn]] / ratio;
++k;
}
}
diff --git a/alc/hrtf.cpp b/alc/hrtf.cpp
index 0d4bf393..e8128cfe 100644
--- a/alc/hrtf.cpp
+++ b/alc/hrtf.cpp
@@ -292,9 +292,6 @@ void BuildBFormatHrtf(const HrtfStore *Hrtf, DirectHrtfState *state,
ALuint ldelay, rdelay;
};
- static const int OrderFromChan[MAX_AMBI_CHANNELS]{
- 0, 1,1,1, 2,2,2,2,2, 3,3,3,3,3,3,3,
- };
/* Set this to true for dual-band HRTF processing. May require better
* calculation of the new IR length to deal with the head and tail
* generated by the HF scaling.
@@ -384,7 +381,8 @@ void BuildBFormatHrtf(const HrtfStore *Hrtf, DirectHrtfState *state,
/* For single-band decoding, apply the HF scale to the response. */
for(size_t i{0u};i < state->Coeffs.size();++i)
{
- const double mult{double{AmbiOrderHFGain[OrderFromChan[i]]} * AmbiMatrix[c][i]};
+ const size_t order{AmbiIndex::OrderFromChannel[i]};
+ const double mult{double{AmbiOrderHFGain[order]} * AmbiMatrix[c][i]};
const ALuint numirs{HRIR_LENGTH - maxu(ldelay, rdelay)};
ALuint lidx{ldelay}, ridx{rdelay};
for(ALuint j{0};j < numirs;++j)
@@ -425,7 +423,7 @@ void BuildBFormatHrtf(const HrtfStore *Hrtf, DirectHrtfState *state,
for(size_t i{0u};i < state->Coeffs.size();++i)
{
const ALdouble mult{AmbiMatrix[c][i]};
- const ALdouble hfgain{AmbiOrderHFGain[OrderFromChan[i]]};
+ const ALdouble hfgain{AmbiOrderHFGain[AmbiIndex::OrderFromChannel[i]]};
ALuint j{HRIR_LENGTH*3 - ldelay};
for(ALuint lidx{0};lidx < HRIR_LENGTH;++lidx,++j)
tmpres[i][lidx][0] += (tmpflt[0][j]*hfgain + tmpflt[1][j]) * mult;
@@ -445,7 +443,7 @@ void BuildBFormatHrtf(const HrtfStore *Hrtf, DirectHrtfState *state,
for(size_t i{0u};i < state->Coeffs.size();++i)
{
const ALdouble mult{AmbiMatrix[c][i]};
- const ALdouble hfgain{AmbiOrderHFGain[OrderFromChan[i]]};
+ const ALdouble hfgain{AmbiOrderHFGain[AmbiIndex::OrderFromChannel[i]]};
ALuint j{HRIR_LENGTH*3 - rdelay};
for(ALuint ridx{0};ridx < HRIR_LENGTH;++ridx,++j)
tmpres[i][ridx][1] += (tmpflt[0][j]*hfgain + tmpflt[1][j]) * mult;
diff --git a/alc/panning.cpp b/alc/panning.cpp
index cbe6d58f..1f1dda4e 100644
--- a/alc/panning.cpp
+++ b/alc/panning.cpp
@@ -65,6 +65,8 @@ constexpr std::array<uint8_t,MAX_AMBI_CHANNELS> AmbiIndex::FromFuMa;
constexpr std::array<uint8_t,MAX_AMBI2D_CHANNELS> AmbiIndex::FromFuMa2D;
constexpr std::array<uint8_t,MAX_AMBI_CHANNELS> AmbiIndex::FromACN;
constexpr std::array<uint8_t,MAX_AMBI2D_CHANNELS> AmbiIndex::From2D;
+constexpr std::array<uint8_t,MAX_AMBI_CHANNELS> AmbiIndex::OrderFromChannel;
+constexpr std::array<uint8_t,MAX_AMBI2D_CHANNELS> AmbiIndex::OrderFrom2DChannel;
namespace {