diff options
author | Chris Robinson <[email protected]> | 2019-09-13 20:04:22 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2019-09-13 20:04:22 -0700 |
commit | 2646f509ee686f21458c32a990346be6e2a806d1 (patch) | |
tree | 3ff687847b038b43a3ad94bf5778b605d5b86b48 | |
parent | 42ae95b8fafb0ea1fa676b1e0f67b23fd375a817 (diff) |
Store the ambisonic order as unsigned
-rw-r--r-- | alc/alc.cpp | 14 | ||||
-rw-r--r-- | alc/alcmain.h | 4 | ||||
-rw-r--r-- | alc/backends/wave.cpp | 2 | ||||
-rw-r--r-- | alc/bformatdec.cpp | 7 | ||||
-rw-r--r-- | alc/bformatdec.h | 4 | ||||
-rw-r--r-- | alc/devformat.h | 4 | ||||
-rw-r--r-- | alc/panning.cpp | 8 |
7 files changed, 21 insertions, 22 deletions
diff --git a/alc/alc.cpp b/alc/alc.cpp index 9bb604a4..408b3ca3 100644 --- a/alc/alc.cpp +++ b/alc/alc.cpp @@ -1286,7 +1286,7 @@ ALuint BytesFromDevFmt(DevFmtType type) noexcept } return 0; } -ALuint ChannelsFromDevFmt(DevFmtChannels chans, ALsizei ambiorder) noexcept +ALuint ChannelsFromDevFmt(DevFmtChannels chans, ALuint ambiorder) noexcept { switch(chans) { @@ -1297,7 +1297,7 @@ ALuint ChannelsFromDevFmt(DevFmtChannels chans, ALsizei ambiorder) noexcept case DevFmtX51Rear: return 6; case DevFmtX61: return 7; case DevFmtX71: return 8; - case DevFmtAmbi3D: return static_cast<ALuint>((ambiorder+1) * (ambiorder+1)); + case DevFmtAmbi3D: return (ambiorder+1) * (ambiorder+1); } return 0; } @@ -1639,7 +1639,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) ALCenum schans{AL_NONE}; ALCenum stype{AL_NONE}; ALCsizei attrIdx{0}; - ALCsizei aorder{0}; + ALCuint aorder{0}; ALCuint freq{0u}; ALuint numMono{device->NumMonoSources}; @@ -1677,7 +1677,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) break; case ALC_AMBISONIC_ORDER_SOFT: - aorder = attrList[attrIdx + 1]; + aorder = static_cast<ALuint>(attrList[attrIdx + 1]); TRACE_ATTR(ALC_AMBISONIC_ORDER_SOFT, aorder); break; @@ -2855,7 +2855,7 @@ static size_t GetIntegerv(ALCdevice *device, ALCenum param, const al::span<ALCin values[i++] = static_cast<ALCint>(device->mAmbiScale); values[i++] = ALC_AMBISONIC_ORDER_SOFT; - values[i++] = device->mAmbiOrder; + values[i++] = static_cast<ALCint>(device->mAmbiOrder); } values[i++] = ALC_FORMAT_CHANNELS_SOFT; @@ -2973,7 +2973,7 @@ static size_t GetIntegerv(ALCdevice *device, ALCenum param, const al::span<ALCin alcSetError(device, ALC_INVALID_DEVICE); return 0; } - values[0] = device->mAmbiOrder; + values[0] = static_cast<int>(device->mAmbiOrder); return 1; case ALC_MONO_SOURCES: @@ -3558,7 +3558,7 @@ START_API_FUNC static constexpr struct ChannelMap { const char name[16]; DevFmtChannels chans; - ALsizei order; + ALuint order; } chanlist[] = { { "mono", DevFmtMono, 0 }, { "stereo", DevFmtStereo, 0 }, diff --git a/alc/alcmain.h b/alc/alcmain.h index f7842d96..933ee779 100644 --- a/alc/alcmain.h +++ b/alc/alcmain.h @@ -213,9 +213,9 @@ struct ALCdevice : public al::intrusive_ref<ALCdevice> { ALuint BufferSize{}; DevFmtChannels FmtChans{}; - DevFmtType FmtType{}; + DevFmtType FmtType{}; ALboolean IsHeadphones{AL_FALSE}; - ALsizei mAmbiOrder{0}; + ALuint mAmbiOrder{0}; /* For DevFmtAmbi* output only, specifies the channel order and * normalization. */ diff --git a/alc/backends/wave.cpp b/alc/backends/wave.cpp index f1171747..41d0a880 100644 --- a/alc/backends/wave.cpp +++ b/alc/backends/wave.cpp @@ -274,7 +274,7 @@ ALCboolean WaveBackend::reset() case DevFmtX71: chanmask = 0x01 | 0x02 | 0x04 | 0x08 | 0x010 | 0x020 | 0x200 | 0x400; break; case DevFmtAmbi3D: /* .amb output requires FuMa */ - mDevice->mAmbiOrder = mini(mDevice->mAmbiOrder, 3); + mDevice->mAmbiOrder = minu(mDevice->mAmbiOrder, 3); mDevice->mAmbiLayout = AmbiLayout::FuMa; mDevice->mAmbiScale = AmbiNorm::FuMa; isbformat = 1; diff --git a/alc/bformatdec.cpp b/alc/bformatdec.cpp index 17b0d3d9..9fbe32b8 100644 --- a/alc/bformatdec.cpp +++ b/alc/bformatdec.cpp @@ -31,7 +31,7 @@ constexpr ALfloat Ambi3DDecoderHFScale3O[MAX_AMBI_ORDER+1] = { 5.89792205e-01f, 8.79693856e-01f }; -inline auto GetDecoderHFScales(ALsizei order) noexcept -> const ALfloat(&)[MAX_AMBI_ORDER+1] +inline auto GetDecoderHFScales(ALuint order) noexcept -> const ALfloat(&)[MAX_AMBI_ORDER+1] { if(order >= 3) return Ambi3DDecoderHFScale3O; if(order == 2) return Ambi3DDecoderHFScale2O; @@ -187,17 +187,16 @@ void BFormatDec::process(const al::span<FloatBufferLine> OutBuffer, } -std::array<ALfloat,MAX_AMBI_ORDER+1> BFormatDec::GetHFOrderScales(const ALsizei in_order, const ALsizei out_order) noexcept +std::array<ALfloat,MAX_AMBI_ORDER+1> BFormatDec::GetHFOrderScales(const ALuint in_order, const ALuint out_order) noexcept { std::array<ALfloat,MAX_AMBI_ORDER+1> ret{}; assert(out_order >= in_order); - ASSUME(out_order >= in_order); const ALfloat (&target)[MAX_AMBI_ORDER+1] = GetDecoderHFScales(out_order); const ALfloat (&input)[MAX_AMBI_ORDER+1] = GetDecoderHFScales(in_order); - for(ALsizei i{0};i < in_order+1;++i) + for(ALuint i{0};i < in_order+1;++i) ret[i] = input[i] / target[i]; return ret; diff --git a/alc/bformatdec.h b/alc/bformatdec.h index dc8059b0..edbb6d50 100644 --- a/alc/bformatdec.h +++ b/alc/bformatdec.h @@ -53,8 +53,8 @@ public: const size_t SamplesToDo); /* Retrieves per-order HF scaling factors for "upsampling" ambisonic data. */ - static std::array<ALfloat,MAX_AMBI_ORDER+1> GetHFOrderScales(const ALsizei in_order, - const ALsizei out_order) noexcept; + static std::array<ALfloat,MAX_AMBI_ORDER+1> GetHFOrderScales(const ALuint in_order, + const ALuint out_order) noexcept; DEF_NEWDEL(BFormatDec) }; diff --git a/alc/devformat.h b/alc/devformat.h index 674dd848..e7ff2ec4 100644 --- a/alc/devformat.h +++ b/alc/devformat.h @@ -98,8 +98,8 @@ struct DevFmtTypeTraits<DevFmtFloat> { using Type = ALfloat; }; ALuint BytesFromDevFmt(DevFmtType type) noexcept; -ALuint ChannelsFromDevFmt(DevFmtChannels chans, ALsizei ambiorder) noexcept; -inline ALuint FrameSizeFromDevFmt(DevFmtChannels chans, DevFmtType type, ALsizei ambiorder) noexcept +ALuint ChannelsFromDevFmt(DevFmtChannels chans, ALuint ambiorder) noexcept; +inline ALuint FrameSizeFromDevFmt(DevFmtChannels chans, DevFmtType type, ALuint ambiorder) noexcept { return ChannelsFromDevFmt(chans, ambiorder) * BytesFromDevFmt(type); } enum class AmbiLayout { diff --git a/alc/panning.cpp b/alc/panning.cpp index b5394cbc..8feff9a9 100644 --- a/alc/panning.cpp +++ b/alc/panning.cpp @@ -269,7 +269,7 @@ constexpr ChannelMap MonoCfg[1] = { { BackRight, { 2.04124145e-1f, -1.08880247e-1f, -1.88586120e-1f, 1.29099444e-1f, 7.45355993e-2f, -3.73460789e-2f, 0.00000000e+0f } }, }; -void InitNearFieldCtrl(ALCdevice *device, ALfloat ctrl_dist, ALsizei order, +void InitNearFieldCtrl(ALCdevice *device, ALfloat ctrl_dist, ALuint order, const al::span<const ALuint,MAX_AMBI_ORDER+1> chans_per_order) { /* NFC is only used when AvgSpeakerDist is greater than 0. */ @@ -448,7 +448,7 @@ void InitPanning(ALCdevice *device) * channel count. Built-in speaker decoders are always 2D, so just * reverse that calculation. */ - device->mAmbiOrder = static_cast<ALsizei>((coeffcount-1) / 2); + device->mAmbiOrder = (coeffcount-1) / 2; std::transform(AmbiIndex::From2D.begin(), AmbiIndex::From2D.begin()+coeffcount, std::begin(device->Dry.AmbiMap), @@ -478,7 +478,7 @@ void InitCustomPanning(ALCdevice *device, bool hqdec, const AmbDecConf *conf, const ALuint order{(conf->ChanMask > AMBI_2ORDER_MASK) ? 3u : (conf->ChanMask > AMBI_1ORDER_MASK) ? 2u : 1u}; - device->mAmbiOrder = static_cast<ALsizei>(order); + device->mAmbiOrder = order; ALuint count; if((conf->ChanMask&AMBI_PERIPHONIC_MASK)) @@ -582,7 +582,7 @@ void InitHrtfPanning(ALCdevice *device) * and it eases the CPU/memory load. */ device->mRenderMode = HrtfRender; - ALsizei ambi_order{1}; + ALuint ambi_order{1}; if(auto modeopt = ConfigValueStr(device->DeviceName.c_str(), nullptr, "hrtf-mode")) { const char *mode{modeopt->c_str()}; |