Make some more channel counts unsigned

This commit is contained in:
Chris Robinson 2019-06-05 19:26:54 -07:00
parent 410a5ca621
commit 1ce310c6d1
13 changed files with 42 additions and 44 deletions

View File

@ -1927,7 +1927,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
device->Frequency, device->UpdateSize, device->BufferSize);
aluInitRenderer(device, hrtf_id, hrtf_appreq, hrtf_userreq);
TRACE("Channel config, Main: %d, Real: %d\n", device->Dry.NumChannels,
TRACE("Channel config, Main: %u, Real: %u\n", device->Dry.NumChannels,
device->RealOut.NumChannels);
/* Allocate extra channels for any post-filter output. */

View File

@ -134,8 +134,7 @@ void ProcessHrtf(ALCdevice *device, const ALsizei SamplesToDo)
DirectHrtfState *state{device->mHrtfState.get()};
MixDirectHrtf(device->RealOut.Buffer[lidx], device->RealOut.Buffer[ridx],
{device->Dry.Buffer,device->Dry.Buffer+device->Dry.NumChannels}, device->HrtfAccumData,
state, SamplesToDo);
{device->Dry.Buffer, device->Dry.NumChannels}, device->HrtfAccumData, state, SamplesToDo);
}
void ProcessAmbiDec(ALCdevice *device, const ALsizei SamplesToDo)
@ -982,8 +981,7 @@ void CalcNonAttnSourceParams(ALvoice *voice, const ALvoicePropsBase *props, cons
}
else
{
voice->mSend[i].Buffer = {SendSlots[i]->Wet.Buffer,
static_cast<size_t>(SendSlots[i]->Wet.NumChannels)};
voice->mSend[i].Buffer = {SendSlots[i]->Wet.Buffer, SendSlots[i]->Wet.NumChannels};
}
}
@ -1028,7 +1026,7 @@ void CalcAttnSourceParams(ALvoice *voice, const ALvoicePropsBase *props, const A
const ALlistener &Listener = ALContext->Listener;
/* Set mixing buffers and get send parameters. */
voice->mDirect.Buffer = {Device->Dry.Buffer, static_cast<size_t>(Device->Dry.NumChannels)};
voice->mDirect.Buffer = {Device->Dry.Buffer, Device->Dry.NumChannels};
ALeffectslot *SendSlots[MAX_SENDS];
ALfloat RoomRolloff[MAX_SENDS];
ALfloat DecayDistance[MAX_SENDS];
@ -1085,10 +1083,7 @@ void CalcAttnSourceParams(ALvoice *voice, const ALvoicePropsBase *props, const A
if(!SendSlots[i])
voice->mSend[i].Buffer = {};
else
{
voice->mSend[i].Buffer = {SendSlots[i]->Wet.Buffer,
static_cast<size_t>(SendSlots[i]->Wet.NumChannels)};
}
voice->mSend[i].Buffer = {SendSlots[i]->Wet.Buffer, SendSlots[i]->Wet.NumChannels};
}
/* Transform source to listener space (convert to head relative) */
@ -1459,9 +1454,8 @@ void ProcessContext(ALCcontext *ctx, const ALsizei SamplesToDo)
[SamplesToDo](const ALeffectslot *slot) -> void
{
EffectState *state{slot->Params.mEffectState};
const auto outchans = static_cast<size_t>(state->mOutChannels);
state->process(SamplesToDo, slot->Wet.Buffer, slot->Wet.NumChannels,
{state->mOutBuffer, outchans});
{state->mOutBuffer, state->mOutChannels});
}
);
}

View File

@ -49,7 +49,7 @@ inline auto GetAmbiScales(AmbDecScale scaletype) noexcept -> const std::array<fl
} // namespace
BFormatDec::BFormatDec(const AmbDecConf *conf, const bool allow_2band, const ALsizei inchans,
BFormatDec::BFormatDec(const AmbDecConf *conf, const bool allow_2band, const ALuint inchans,
const ALuint srate, const ALsizei (&chanmap)[MAX_OUTPUT_CHANNELS])
{
mDualBand = allow_2band && (conf->FreqBands == 2);
@ -119,7 +119,7 @@ BFormatDec::BFormatDec(const AmbDecConf *conf, const bool allow_2band, const ALs
}
}
BFormatDec::BFormatDec(const ALsizei inchans, const ALsizei chancount,
BFormatDec::BFormatDec(const ALuint inchans, const ALsizei chancount,
const ChannelDec (&chancoeffs)[MAX_OUTPUT_CHANNELS],
const ALsizei (&chanmap)[MAX_OUTPUT_CHANNELS])
{
@ -154,12 +154,12 @@ void BFormatDec::process(FloatBufferLine *OutBuffer, const ALuint OutChannels,
if(mDualBand)
{
for(ALsizei i{0};i < mNumChannels;i++)
for(ALuint i{0};i < mNumChannels;i++)
mXOver[i].process(mSamplesHF[i].data(), mSamplesLF[i].data(), InSamples[i].data(),
SamplesToDo);
const al::span<const FloatBufferLine> hfsamples{mSamplesHF, mSamplesHF+mNumChannels};
const al::span<const FloatBufferLine> lfsamples{mSamplesLF, mSamplesLF+mNumChannels};
const al::span<const FloatBufferLine> hfsamples{mSamplesHF, mNumChannels};
const al::span<const FloatBufferLine> lfsamples{mSamplesLF, mNumChannels};
for(ALuint chan{0};chan < OutChannels;chan++)
{
if(UNLIKELY(!(mEnabled&(1<<chan))))
@ -171,7 +171,7 @@ void BFormatDec::process(FloatBufferLine *OutBuffer, const ALuint OutChannels,
}
else
{
const al::span<const FloatBufferLine> insamples{InSamples, InSamples+mNumChannels};
const al::span<const FloatBufferLine> insamples{InSamples, mNumChannels};
for(ALuint chan{0};chan < OutChannels;chan++)
{
if(UNLIKELY(!(mEnabled&(1<<chan))))

View File

@ -32,13 +32,13 @@ class BFormatDec {
std::array<ALfloat,BUFFERSIZE> *mSamplesHF{nullptr};
std::array<ALfloat,BUFFERSIZE> *mSamplesLF{nullptr};
ALsizei mNumChannels{0};
ALuint mNumChannels{0u};
bool mDualBand{false};
public:
BFormatDec(const AmbDecConf *conf, const bool allow_2band, const ALsizei inchans,
BFormatDec(const AmbDecConf *conf, const bool allow_2band, const ALuint inchans,
const ALuint srate, const ALsizei (&chanmap)[MAX_OUTPUT_CHANNELS]);
BFormatDec(const ALsizei inchans, const ALsizei chancount,
BFormatDec(const ALuint inchans, const ALsizei chancount,
const ChannelDec (&chancoeffs)[MAX_OUTPUT_CHANNELS],
const ALsizei (&chanmap)[MAX_OUTPUT_CHANNELS]);

View File

@ -121,7 +121,7 @@ void ALautowahState::update(const ALCcontext *context, const ALeffectslot *slot,
mOutBuffer = target.Main->Buffer;
mOutChannels = target.Main->NumChannels;
for(ALsizei i{0};i < slot->Wet.NumChannels;++i)
for(ALuint i{0u};i < slot->Wet.NumChannels;++i)
{
auto coeffs = GetAmbiIdentityRow(i);
ComputePanGains(target.Main, coeffs.data(), slot->Params.Gain, mChans[i].TargetGains);

View File

@ -145,7 +145,7 @@ struct EffectState {
RefCount mRef{1u};
FloatBufferLine *mOutBuffer{nullptr};
ALsizei mOutChannels{0};
ALuint mOutChannels{0u};
virtual ~EffectState() = default;

View File

@ -80,7 +80,7 @@ void CompressorState::update(const ALCcontext* UNUSED(context), const ALeffectsl
mOutBuffer = target.Main->Buffer;
mOutChannels = target.Main->NumChannels;
for(ALsizei i{0};i < slot->Wet.NumChannels;++i)
for(ALuint i{0u};i < slot->Wet.NumChannels;++i)
{
auto coeffs = GetAmbiIdentityRow(i);
ComputePanGains(target.Main, coeffs.data(), slot->Params.Gain, mGain[i]);

View File

@ -141,7 +141,7 @@ void EqualizerState::update(const ALCcontext *context, const ALeffectslot *slot,
BiquadFilter::rcpQFromSlope(gain, 0.75f));
/* Copy the filter coefficients for the other input channels. */
for(ALsizei i{1};i < slot->Wet.NumChannels;++i)
for(ALuint i{1u};i < slot->Wet.NumChannels;++i)
{
mChans[i].filter[0].copyParamsFrom(mChans[0].filter[0]);
mChans[i].filter[1].copyParamsFrom(mChans[0].filter[1]);
@ -151,7 +151,7 @@ void EqualizerState::update(const ALCcontext *context, const ALeffectslot *slot,
mOutBuffer = target.Main->Buffer;
mOutChannels = target.Main->NumChannels;
for(ALsizei i{0};i < slot->Wet.NumChannels;++i)
for(ALuint i{0u};i < slot->Wet.NumChannels;++i)
{
auto coeffs = GetAmbiIdentityRow(i);
ComputePanGains(target.Main, coeffs.data(), slot->Params.Gain, mChans[i].TargetGains);

View File

@ -129,12 +129,12 @@ void ModulatorState::update(const ALCcontext *context, const ALeffectslot *slot,
/* Bandwidth value is constant in octaves. */
mChans[0].Filter.setParams(BiquadType::HighPass, 1.0f, f0norm,
BiquadFilter::rcpQFromBandwidth(f0norm, 0.75f));
for(ALsizei i{1};i < slot->Wet.NumChannels;++i)
for(ALuint i{1u};i < slot->Wet.NumChannels;++i)
mChans[i].Filter.copyParamsFrom(mChans[0].Filter);
mOutBuffer = target.Main->Buffer;
mOutChannels = target.Main->NumChannels;
for(ALsizei i{0};i < slot->Wet.NumChannels;++i)
for(ALuint i{0u};i < slot->Wet.NumChannels;++i)
{
auto coeffs = GetAmbiIdentityRow(i);
ComputePanGains(target.Main, coeffs.data(), slot->Params.Gain, mChans[i].TargetGains);

View File

@ -291,7 +291,9 @@ std::unique_ptr<DirectHrtfState> DirectHrtfState::Create(size_t num_chans)
return std::unique_ptr<DirectHrtfState>{new (ptr) DirectHrtfState{num_chans}};
}
void BuildBFormatHrtf(const HrtfEntry *Hrtf, DirectHrtfState *state, const ALsizei NumChannels, const AngularPoint *AmbiPoints, const ALfloat (*RESTRICT AmbiMatrix)[MAX_AMBI_CHANNELS], const size_t AmbiCount, const ALfloat *RESTRICT AmbiOrderHFGain)
void BuildBFormatHrtf(const HrtfEntry *Hrtf, DirectHrtfState *state, const ALuint NumChannels,
const AngularPoint *AmbiPoints, const ALfloat (*RESTRICT AmbiMatrix)[MAX_AMBI_CHANNELS],
const size_t AmbiCount, const ALfloat *RESTRICT AmbiOrderHFGain)
{
static constexpr int OrderFromChan[MAX_AMBI_CHANNELS]{
0, 1,1,1, 2,2,2,2,2, 3,3,3,3,3,3,3,
@ -350,7 +352,7 @@ void BuildBFormatHrtf(const HrtfEntry *Hrtf, DirectHrtfState *state, const ALsiz
if(!DualBand)
{
/* For single-band decoding, apply the HF scale to the response. */
for(ALsizei i{0};i < NumChannels;++i)
for(ALuint i{0u};i < NumChannels;++i)
{
const ALdouble mult{ALdouble{AmbiOrderHFGain[OrderFromChan[i]]} *
AmbiMatrix[c][i]};
@ -392,7 +394,7 @@ void BuildBFormatHrtf(const HrtfEntry *Hrtf, DirectHrtfState *state, const ALsiz
static_cast<int>(tmpfilt[2].size()));
/* Apply left ear response with delay and HF scale. */
for(ALsizei i{0};i < NumChannels;++i)
for(ALuint i{0u};i < NumChannels;++i)
{
const ALdouble mult{AmbiMatrix[c][i]};
const ALdouble hfgain{AmbiOrderHFGain[OrderFromChan[i]]};
@ -413,7 +415,7 @@ void BuildBFormatHrtf(const HrtfEntry *Hrtf, DirectHrtfState *state, const ALsiz
splitter.process(tmpfilt[0].data(), tmpfilt[1].data(), tmpfilt[2].data(),
static_cast<int>(tmpfilt[2].size()));
for(ALsizei i{0};i < NumChannels;++i)
for(ALuint i{0u};i < NumChannels;++i)
{
const ALdouble mult{AmbiMatrix[c][i]};
const ALdouble hfgain{AmbiOrderHFGain[OrderFromChan[i]]};
@ -425,7 +427,7 @@ void BuildBFormatHrtf(const HrtfEntry *Hrtf, DirectHrtfState *state, const ALsiz
tmpfilt.clear();
idx.clear();
for(ALsizei i{0};i < NumChannels;++i)
for(ALuint i{0u};i < NumChannels;++i)
{
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])}}; };

View File

@ -115,6 +115,8 @@ void GetHrtfCoeffs(const HrtfEntry *Hrtf, ALfloat elevation, ALfloat azimuth, AL
* ordered and scaled according to the matrix input. Note the specified virtual
* positions should be in degrees, not radians!
*/
void BuildBFormatHrtf(const HrtfEntry *Hrtf, DirectHrtfState *state, const ALsizei NumChannels, const AngularPoint *AmbiPoints, const ALfloat (*RESTRICT AmbiMatrix)[MAX_AMBI_CHANNELS], const size_t AmbiCount, const ALfloat *RESTRICT AmbiOrderHFGain);
void BuildBFormatHrtf(const HrtfEntry *Hrtf, DirectHrtfState *state, const ALuint NumChannels,
const AngularPoint *AmbiPoints, const ALfloat (*RESTRICT AmbiMatrix)[MAX_AMBI_CHANNELS],
const size_t AmbiCount, const ALfloat *RESTRICT AmbiOrderHFGain);
#endif /* ALC_HRTF_H */

View File

@ -328,7 +328,7 @@ auto GetAmbiLayout(AmbiLayout layouttype) noexcept -> const std::array<int,MAX_A
void InitPanning(ALCdevice *device)
{
al::span<const ChannelMap> chanmap;
ALsizei coeffcount{};
ALuint coeffcount{};
switch(device->FmtChans)
{
@ -383,7 +383,7 @@ void InitPanning(ALCdevice *device)
[&n3dscale](const ALsizei &acn) noexcept -> BFChannelConfig
{ return BFChannelConfig{1.0f/n3dscale[acn], acn}; }
);
device->Dry.NumChannels = static_cast<ALsizei>(count);
device->Dry.NumChannels = static_cast<ALuint>(count);
ALfloat nfc_delay{0.0f};
if(ConfigValueFloat(devname, "decoder", "nfc-ref-delay", &nfc_delay) && nfc_delay > 0.0f)
@ -417,7 +417,7 @@ void InitPanning(ALCdevice *device)
* channel count. Built-in speaker decoders are always 2D, so just
* reverse that calculation.
*/
device->mAmbiOrder = (coeffcount-1) / 2;
device->mAmbiOrder = static_cast<ALsizei>((coeffcount-1) / 2);
std::transform(AmbiIndex::From2D.begin(), AmbiIndex::From2D.begin()+coeffcount,
std::begin(device->Dry.AmbiMap),
@ -450,10 +450,10 @@ void InitCustomPanning(ALCdevice *device, bool hqdec, const AmbDecConf *conf, co
(conf->ChanMask > AMBI_1ORDER_MASK) ? 2 : 1};
device->mAmbiOrder = order;
ALsizei count;
ALuint count;
if((conf->ChanMask&AMBI_PERIPHONIC_MASK))
{
count = static_cast<ALsizei>(AmbiChannelsFromOrder(order));
count = static_cast<ALuint>(AmbiChannelsFromOrder(order));
std::transform(AmbiIndex::From3D.begin(), AmbiIndex::From3D.begin()+count,
std::begin(device->Dry.AmbiMap),
[](const ALsizei &index) noexcept { return BFChannelConfig{1.0f, index}; }
@ -461,7 +461,7 @@ void InitCustomPanning(ALCdevice *device, bool hqdec, const AmbDecConf *conf, co
}
else
{
count = static_cast<ALsizei>(Ambi2DChannelsFromOrder(order));
count = static_cast<ALuint>(Ambi2DChannelsFromOrder(order));
std::transform(AmbiIndex::From2D.begin(), AmbiIndex::From2D.begin()+count,
std::begin(device->Dry.AmbiMap),
[](const ALsizei &index) noexcept { return BFChannelConfig{1.0f, index}; }
@ -607,7 +607,7 @@ void InitHrtfPanning(ALCdevice *device)
std::begin(device->Dry.AmbiMap),
[](const ALsizei &index) noexcept { return BFChannelConfig{1.0f, index}; }
);
device->Dry.NumChannels = static_cast<ALsizei>(count);
device->Dry.NumChannels = static_cast<ALuint>(count);
device->RealOut.NumChannels = device->channelsFromFmt();
@ -733,7 +733,7 @@ void CalcAmbiCoeffs(const ALfloat y, const ALfloat z, const ALfloat x, const ALf
void ComputePanGains(const MixParams *mix, const ALfloat *RESTRICT coeffs, ALfloat ingain, ALfloat (&gains)[MAX_OUTPUT_CHANNELS])
{
auto ambimap = mix->AmbiMap.cbegin();
const ALsizei numchans{mix->NumChannels};
const ALuint numchans{mix->NumChannels};
ASSUME(numchans > 0);
auto iter = std::transform(ambimap, ambimap+numchans, std::begin(gains),
@ -998,5 +998,5 @@ void aluInitEffectPanning(ALeffectslot *slot, ALCdevice *device)
);
std::fill(iter, slot->Wet.AmbiMap.end(), BFChannelConfig{});
slot->Wet.Buffer = slot->MixBuffer.data();
slot->Wet.NumChannels = static_cast<ALsizei>(count);
slot->Wet.NumChannels = static_cast<ALuint>(count);
}

View File

@ -318,7 +318,7 @@ struct MixParams {
std::array<BFChannelConfig,MAX_OUTPUT_CHANNELS> AmbiMap;
FloatBufferLine *Buffer{nullptr};
ALsizei NumChannels{0};
ALuint NumChannels{0u};
};
struct RealMixParams {