diff options
-rw-r--r-- | utils/makemhr/loaddef.cpp | 10 | ||||
-rw-r--r-- | utils/makemhr/loadsofa.cpp | 10 | ||||
-rw-r--r-- | utils/makemhr/makemhr.cpp | 6 | ||||
-rw-r--r-- | utils/makemhr/makemhr.h | 2 |
4 files changed, 16 insertions, 12 deletions
diff --git a/utils/makemhr/loaddef.cpp b/utils/makemhr/loaddef.cpp index 6b33d6c4..bb9799c6 100644 --- a/utils/makemhr/loaddef.cpp +++ b/utils/makemhr/loaddef.cpp @@ -1239,7 +1239,8 @@ static int ProcessMetrics(TokenReaderT *tr, const uint fftSize, const uint trunc double distances[MAX_FD_COUNT]; uint fdCount = 0; uint evCounts[MAX_FD_COUNT]; - auto azCounts = std::vector<uint>(MAX_FD_COUNT * MAX_EV_COUNT); + auto azCounts = std::vector<std::array<uint,MAX_EV_COUNT>>(MAX_FD_COUNT); + for(auto &azs : azCounts) azs.fill(0u); TrIndication(tr, &line, &col); while(TrIsIdent(tr)) @@ -1388,7 +1389,7 @@ static int ProcessMetrics(TokenReaderT *tr, const uint fftSize, const uint trunc { if(!TrReadInt(tr, MIN_AZ_COUNT, MAX_AZ_COUNT, &intVal)) return 0; - azCounts[(count * MAX_EV_COUNT) + evCounts[count]++] = static_cast<uint>(intVal); + azCounts[count][evCounts[count]++] = static_cast<uint>(intVal); if(TrIsOperator(tr, ",")) { if(evCounts[count] >= MAX_EV_COUNT) @@ -1405,7 +1406,7 @@ static int ProcessMetrics(TokenReaderT *tr, const uint fftSize, const uint trunc TrErrorAt(tr, line, col, "Did not reach the minimum of %d azimuth counts.\n", MIN_EV_COUNT); return 0; } - if(azCounts[count * MAX_EV_COUNT] != 1 || azCounts[(count * MAX_EV_COUNT) + evCounts[count] - 1] != 1) + if(azCounts[count][0] != 1 || azCounts[count][evCounts[count] - 1] != 1) { TrError(tr, "Poles are not singular for field %d.\n", count - 1); return 0; @@ -1450,7 +1451,8 @@ static int ProcessMetrics(TokenReaderT *tr, const uint fftSize, const uint trunc } if(hData->mChannelType == CT_NONE) hData->mChannelType = CT_MONO; - if(!PrepareHrirData({distances, fdCount}, evCounts, azCounts.data(), hData)) + const auto azs = al::as_span(azCounts).first<MAX_FD_COUNT>(); + if(!PrepareHrirData({distances, fdCount}, evCounts, azs, hData)) { fprintf(stderr, "Error: Out of memory.\n"); exit(-1); diff --git a/utils/makemhr/loadsofa.cpp b/utils/makemhr/loadsofa.cpp index f175ecc4..2c445dac 100644 --- a/utils/makemhr/loadsofa.cpp +++ b/utils/makemhr/loadsofa.cpp @@ -67,7 +67,8 @@ static bool PrepareLayout(const uint m, const float *xyzs, HrirDataT *hData) double distances[MAX_FD_COUNT]{}; uint evCounts[MAX_FD_COUNT]{}; - auto azCounts = std::vector<uint>(MAX_FD_COUNT*MAX_EV_COUNT, 0u); + auto azCounts = std::vector<std::array<uint,MAX_EV_COUNT>>(MAX_FD_COUNT); + for(auto &azs : azCounts) azs.fill(0u); uint fi{0u}, ir_total{0u}; for(const auto &field : fds) @@ -76,17 +77,18 @@ static bool PrepareLayout(const uint m, const float *xyzs, HrirDataT *hData) evCounts[fi] = field.mEvCount; for(uint ei{0u};ei < field.mEvStart;ei++) - azCounts[fi*MAX_EV_COUNT + ei] = field.mAzCounts[field.mEvCount-ei-1]; + azCounts[fi][ei] = field.mAzCounts[field.mEvCount-ei-1]; for(uint ei{field.mEvStart};ei < field.mEvCount;ei++) { - azCounts[fi*MAX_EV_COUNT + ei] = field.mAzCounts[ei]; + azCounts[fi][ei] = field.mAzCounts[ei]; ir_total += field.mAzCounts[ei]; } ++fi; } fprintf(stdout, "Using %u of %u IRs.\n", ir_total, m); - return PrepareHrirData({distances, fi}, evCounts, azCounts.data(), hData); + const auto azs = al::as_span(azCounts).first<MAX_FD_COUNT>(); + return PrepareHrirData({distances, fi}, evCounts, azs, hData); } diff --git a/utils/makemhr/makemhr.cpp b/utils/makemhr/makemhr.cpp index 1de69bb2..04581f88 100644 --- a/utils/makemhr/makemhr.cpp +++ b/utils/makemhr/makemhr.cpp @@ -1144,7 +1144,7 @@ static void CalculateHrtds(const HeadModelT model, const double radius, HrirData // Allocate and configure dynamic HRIR structures. bool PrepareHrirData(const al::span<const double> distances, const al::span<const uint,MAX_FD_COUNT> evCounts, - const uint azCounts[MAX_FD_COUNT * MAX_EV_COUNT], HrirDataT *hData) + const al::span<const std::array<uint,MAX_EV_COUNT>,MAX_FD_COUNT> azCounts, HrirDataT *hData) { uint evTotal{0}, azTotal{0}; @@ -1152,7 +1152,7 @@ bool PrepareHrirData(const al::span<const double> distances, { evTotal += evCounts[fi]; for(size_t ei{0};ei < evCounts[fi];++ei) - azTotal += azCounts[(fi * MAX_EV_COUNT) + ei]; + azTotal += azCounts[fi][ei]; } if(!evTotal || !azTotal) return false; @@ -1172,7 +1172,7 @@ bool PrepareHrirData(const al::span<const double> distances, evTotal += evCounts[fi]; for(uint ei{0};ei < evCounts[fi];++ei) { - uint azCount = azCounts[(fi * MAX_EV_COUNT) + ei]; + uint azCount = azCounts[fi][ei]; hData->mFds[fi].mEvs[ei].mElevation = -M_PI / 2.0 + M_PI * ei / (evCounts[fi] - 1); hData->mFds[fi].mEvs[ei].mAzCount = azCount; diff --git a/utils/makemhr/makemhr.h b/utils/makemhr/makemhr.h index 0ac581be..3554f9a7 100644 --- a/utils/makemhr/makemhr.h +++ b/utils/makemhr/makemhr.h @@ -110,7 +110,7 @@ struct HrirDataT { bool PrepareHrirData(const al::span<const double> distances, const al::span<const uint,MAX_FD_COUNT> evCounts, - const uint azCounts[MAX_FD_COUNT * MAX_EV_COUNT], HrirDataT *hData); + const al::span<const std::array<uint,MAX_EV_COUNT>,MAX_FD_COUNT> azCounts, HrirDataT *hData); void MagnitudeResponse(const uint n, const complex_d *in, double *out); // Performs a forward FFT. |