diff options
author | Chris Robinson <[email protected]> | 2020-10-21 17:16:27 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2020-10-21 17:16:27 -0700 |
commit | 7bb37deb51c6c1d0faa4f2fbe92f8051e64d6401 (patch) | |
tree | e1a8cf7da46d8816ee0e1a3ff6151206735bc981 | |
parent | 3e62600ecc3c2f1be4da0d3e8166f5c67cc25fed (diff) |
Replace the mixer fraction macros with constexpr variables
-rw-r--r-- | al/source.cpp | 17 | ||||
-rw-r--r-- | alc/alu.cpp | 14 | ||||
-rw-r--r-- | alc/alu.h | 7 | ||||
-rw-r--r-- | alc/converter.cpp | 18 | ||||
-rw-r--r-- | alc/effects/chorus.cpp | 14 | ||||
-rw-r--r-- | alc/effects/fshifter.cpp | 6 | ||||
-rw-r--r-- | alc/effects/pshifter.cpp | 8 | ||||
-rw-r--r-- | alc/mixer/defs.h | 5 | ||||
-rw-r--r-- | alc/mixer/mixer_c.cpp | 10 | ||||
-rw-r--r-- | alc/mixer/mixer_neon.cpp | 22 | ||||
-rw-r--r-- | alc/mixer/mixer_sse.cpp | 10 | ||||
-rw-r--r-- | alc/mixer/mixer_sse2.cpp | 12 | ||||
-rw-r--r-- | alc/mixer/mixer_sse41.cpp | 12 | ||||
-rw-r--r-- | alc/voice.cpp | 20 |
14 files changed, 88 insertions, 87 deletions
diff --git a/al/source.cpp b/al/source.cpp index d3227c95..64a7afc1 100644 --- a/al/source.cpp +++ b/al/source.cpp @@ -195,7 +195,7 @@ int64_t GetSourceSampleOffset(ALsource *Source, ALCcontext *context, nanoseconds readPos = uint64_t{voice->mPosition.load(std::memory_order_relaxed)} << 32; readPos |= uint64_t{voice->mPositionFrac.load(std::memory_order_relaxed)} << - (32-FRACTIONBITS); + (32-MixerFracBits); } std::atomic_thread_fence(std::memory_order_acquire); } while(refcount != device->MixCount.load(std::memory_order_relaxed)); @@ -233,7 +233,7 @@ double GetSourceSecOffset(ALsource *Source, ALCcontext *context, nanoseconds *cl { Current = voice->mCurrentBuffer.load(std::memory_order_relaxed); - readPos = uint64_t{voice->mPosition.load(std::memory_order_relaxed)} << FRACTIONBITS; + readPos = uint64_t{voice->mPosition.load(std::memory_order_relaxed)} << MixerFracBits; readPos |= voice->mPositionFrac.load(std::memory_order_relaxed); } std::atomic_thread_fence(std::memory_order_acquire); @@ -247,7 +247,7 @@ double GetSourceSecOffset(ALsource *Source, ALCcontext *context, nanoseconds *cl while(BufferList && BufferList != Current) { if(!BufferFmt) BufferFmt = BufferList->mBuffer; - readPos += uint64_t{BufferList->mSampleLen} << FRACTIONBITS; + readPos += uint64_t{BufferList->mSampleLen} << MixerFracBits; BufferList = BufferList->mNext.load(std::memory_order_relaxed); } while(BufferList && !BufferFmt) @@ -257,7 +257,7 @@ double GetSourceSecOffset(ALsource *Source, ALCcontext *context, nanoseconds *cl } assert(BufferFmt != nullptr); - return static_cast<double>(readPos) / double{FRACTIONONE} / BufferFmt->mBuffer.mSampleRate; + return static_cast<double>(readPos) / double{MixerFracOne} / BufferFmt->mBuffer.mSampleRate; } /* GetSourceOffset @@ -313,12 +313,11 @@ double GetSourceOffset(ALsource *Source, ALenum name, ALCcontext *context) switch(name) { case AL_SEC_OFFSET: - offset = (readPos + static_cast<double>(readPosFrac)/FRACTIONONE) / - BufferFmt->mBuffer.mSampleRate; + offset = (readPos + readPosFrac/double{MixerFracOne}) / BufferFmt->mBuffer.mSampleRate; break; case AL_SAMPLE_OFFSET: - offset = readPos + static_cast<double>(readPosFrac)/FRACTIONONE; + offset = readPos + readPosFrac/double{MixerFracOne}; break; case AL_BYTE_OFFSET: @@ -406,13 +405,13 @@ al::optional<VoicePos> GetSampleOffset(ALbufferlistitem *BufferList, ALenum Offs case AL_SAMPLE_OFFSET: dblfrac = std::modf(Offset, &dbloff); offset = static_cast<ALuint>(mind(dbloff, std::numeric_limits<ALuint>::max())); - frac = static_cast<ALuint>(mind(dblfrac*FRACTIONONE, FRACTIONONE-1.0)); + frac = static_cast<ALuint>(mind(dblfrac*MixerFracOne, MixerFracOne-1.0)); break; case AL_SEC_OFFSET: dblfrac = std::modf(Offset*BufferFmt->mBuffer.mSampleRate, &dbloff); offset = static_cast<ALuint>(mind(dbloff, std::numeric_limits<ALuint>::max())); - frac = static_cast<ALuint>(mind(dblfrac*FRACTIONONE, FRACTIONONE-1.0)); + frac = static_cast<ALuint>(mind(dblfrac*MixerFracOne, MixerFracOne-1.0)); break; } diff --git a/alc/alu.cpp b/alc/alu.cpp index c4d8e8f4..5bc1f6bf 100644 --- a/alc/alu.cpp +++ b/alc/alu.cpp @@ -177,9 +177,9 @@ inline void BsincPrepare(const ALuint increment, BsincState *state, const BSincT size_t si{BSincScaleCount - 1}; float sf{0.0f}; - if(increment > FRACTIONONE) + if(increment > MixerFracOne) { - sf = FRACTIONONE / static_cast<float>(increment); + sf = MixerFracOne / static_cast<float>(increment); sf = maxf(0.0f, (BSincScaleCount-1) * (sf-table->scaleBase) * table->scaleRange); si = float2uint(sf); /* The interpolation factor is fit to this diagonally-symmetric curve @@ -219,7 +219,7 @@ inline ResamplerFunc SelectResampler(Resampler resampler, ALuint increment) return Resample_<CubicTag,CTag>; case Resampler::BSinc12: case Resampler::BSinc24: - if(increment <= FRACTIONONE) + if(increment <= MixerFracOne) { /* fall-through */ case Resampler::FastBSinc12: @@ -1244,9 +1244,9 @@ void CalcNonAttnSourceParams(Voice *voice, const VoiceProps *props, const ALCcon const auto Pitch = static_cast<float>(voice->mFrequency) / static_cast<float>(Device->Frequency) * props->Pitch; if(Pitch > float{MAX_PITCH}) - voice->mStep = MAX_PITCH<<FRACTIONBITS; + voice->mStep = MAX_PITCH<<MixerFracBits; else - voice->mStep = maxu(fastf2u(Pitch * FRACTIONONE), 1); + voice->mStep = maxu(fastf2u(Pitch * MixerFracOne), 1); voice->mResampler = PrepareResampler(props->mResampler, voice->mStep, &voice->mResampleState); /* Calculate gains */ @@ -1557,9 +1557,9 @@ void CalcAttnSourceParams(Voice *voice, const VoiceProps *props, const ALCcontex */ Pitch *= static_cast<float>(voice->mFrequency) / static_cast<float>(Device->Frequency); if(Pitch > float{MAX_PITCH}) - voice->mStep = MAX_PITCH<<FRACTIONBITS; + voice->mStep = MAX_PITCH<<MixerFracBits; else - voice->mStep = maxu(fastf2u(Pitch * FRACTIONONE), 1); + voice->mStep = maxu(fastf2u(Pitch * MixerFracOne), 1); voice->mResampler = PrepareResampler(props->mResampler, voice->mStep, &voice->mResampleState); float spread{0.0f}; @@ -36,9 +36,10 @@ constexpr float AirAbsorbGainHF{0.99426f}; /* -0.05dB */ /** Target gain for the reverb decay feedback reaching the decay time. */ constexpr float ReverbDecayGain{0.001f}; /* -60 dB */ -#define FRACTIONBITS 12 -#define FRACTIONONE (1<<FRACTIONBITS) -#define FRACTIONMASK (FRACTIONONE-1) + +constexpr int MixerFracBits{12}; +constexpr int MixerFracOne{1 << MixerFracBits}; +constexpr int MixerFracMask{MixerFracOne - 1}; inline float lerp(float val1, float val2, float mu) noexcept diff --git a/alc/converter.cpp b/alc/converter.cpp index 6e5b2207..5d8c59ea 100644 --- a/alc/converter.cpp +++ b/alc/converter.cpp @@ -175,9 +175,9 @@ SampleConverterPtr CreateSampleConverter(DevFmtType srcType, DevFmtType dstType, /* Have to set the mixer FPU mode since that's what the resampler code expects. */ FPUCtl mixer_mode{}; auto step = static_cast<ALuint>( - mind(srcRate*double{FRACTIONONE}/dstRate + 0.5, MAX_PITCH*FRACTIONONE)); + mind(srcRate*double{MixerFracOne}/dstRate + 0.5, MAX_PITCH*MixerFracOne)); converter->mIncrement = maxu(step, 1); - if(converter->mIncrement == FRACTIONONE) + if(converter->mIncrement == MixerFracOne) converter->mResample = Resample_<CopyTag,CTag>; else converter->mResample = PrepareResampler(resampler, converter->mIncrement, @@ -214,7 +214,7 @@ ALuint SampleConverter::availableOut(ALuint srcframes) const auto DataSize64 = static_cast<uint64_t>(prepcount); DataSize64 += srcframes; DataSize64 -= MAX_RESAMPLER_PADDING; - DataSize64 <<= FRACTIONBITS; + DataSize64 <<= MixerFracBits; DataSize64 -= mFracOffset; /* If we have a full prep, we can generate at least one sample. */ @@ -271,7 +271,7 @@ ALuint SampleConverter::convert(const void **src, ALuint *srcframes, void *dst, auto DataSize64 = static_cast<uint64_t>(prepcount); DataSize64 += toread; DataSize64 -= MAX_RESAMPLER_PADDING; - DataSize64 <<= FRACTIONBITS; + DataSize64 <<= MixerFracBits; DataSize64 -= DataPosFrac; /* If we have a full prep, we can generate at least one sample. */ @@ -293,7 +293,7 @@ ALuint SampleConverter::convert(const void **src, ALuint *srcframes, void *dst, /* Store as many prep samples for next time as possible, given the * number of output samples being generated. */ - ALuint SrcDataEnd{(DstSize*increment + DataPosFrac)>>FRACTIONBITS}; + ALuint SrcDataEnd{(DstSize*increment + DataPosFrac)>>MixerFracBits}; if(SrcDataEnd >= static_cast<ALuint>(prepcount)+toread) std::fill(std::begin(mChan[chan].PrevSamples), std::end(mChan[chan].PrevSamples), 0.0f); @@ -317,13 +317,13 @@ ALuint SampleConverter::convert(const void **src, ALuint *srcframes, void *dst, * fractional offset. */ DataPosFrac += increment*DstSize; - mSrcPrepCount = mini(prepcount + static_cast<int>(toread - (DataPosFrac>>FRACTIONBITS)), + mSrcPrepCount = mini(prepcount + static_cast<int>(toread - (DataPosFrac>>MixerFracBits)), MAX_RESAMPLER_PADDING); - mFracOffset = DataPosFrac & FRACTIONMASK; + mFracOffset = DataPosFrac & MixerFracMask; /* Update the src and dst pointers in case there's still more to do. */ - SamplesIn += SrcFrameSize*(DataPosFrac>>FRACTIONBITS); - NumSrcSamples -= minu(NumSrcSamples, (DataPosFrac>>FRACTIONBITS)); + SamplesIn += SrcFrameSize*(DataPosFrac>>MixerFracBits); + NumSrcSamples -= minu(NumSrcSamples, (DataPosFrac>>MixerFracBits)); dst = static_cast<al::byte*>(dst) + DstFrameSize*DstSize; pos += DstSize; diff --git a/alc/effects/chorus.cpp b/alc/effects/chorus.cpp index 418c5d2d..7e68508d 100644 --- a/alc/effects/chorus.cpp +++ b/alc/effects/chorus.cpp @@ -106,7 +106,7 @@ void ChorusState::deviceUpdate(const ALCdevice *Device) void ChorusState::update(const ALCcontext *Context, const ALeffectslot *Slot, const EffectProps *props, const EffectTarget target) { - constexpr ALsizei mindelay{(MAX_RESAMPLER_PADDING>>1) << FRACTIONBITS}; + constexpr ALsizei mindelay{(MAX_RESAMPLER_PADDING>>1) << MixerFracBits}; switch(props->Chorus.Waveform) { @@ -124,7 +124,7 @@ void ChorusState::update(const ALCcontext *Context, const ALeffectslot *Slot, co const ALCdevice *device{Context->mDevice.get()}; const auto frequency = static_cast<float>(device->Frequency); - mDelay = maxi(float2int(props->Chorus.Delay*frequency*FRACTIONONE + 0.5f), mindelay); + mDelay = maxi(float2int(props->Chorus.Delay*frequency*MixerFracOne + 0.5f), mindelay); mDepth = minf(props->Chorus.Depth * static_cast<float>(mDelay), static_cast<float>(mDelay - mindelay)); @@ -227,7 +227,7 @@ void ChorusState::process(const size_t samplesToDo, const al::span<const FloatBu { const size_t bufmask{mSampleBuffer.size()-1}; const float feedback{mFeedback}; - const ALuint avgdelay{(static_cast<ALuint>(mDelay) + (FRACTIONONE>>1)) >> FRACTIONBITS}; + const ALuint avgdelay{(static_cast<ALuint>(mDelay) + (MixerFracOne>>1)) >> MixerFracBits}; float *RESTRICT delaybuf{mSampleBuffer.data()}; ALuint offset{mOffset}; @@ -248,14 +248,14 @@ void ChorusState::process(const size_t samplesToDo, const al::span<const FloatBu delaybuf[offset&bufmask] = samplesIn[0][base+i]; // Tap for the left output. - ALuint delay{offset - (moddelays[0][i]>>FRACTIONBITS)}; - float mu{static_cast<float>(moddelays[0][i]&FRACTIONMASK) * (1.0f/FRACTIONONE)}; + ALuint delay{offset - (moddelays[0][i]>>MixerFracBits)}; + float mu{static_cast<float>(moddelays[0][i]&MixerFracMask) * (1.0f/MixerFracOne)}; temps[0][i] = cubic(delaybuf[(delay+1) & bufmask], delaybuf[(delay ) & bufmask], delaybuf[(delay-1) & bufmask], delaybuf[(delay-2) & bufmask], mu); // Tap for the right output. - delay = offset - (moddelays[1][i]>>FRACTIONBITS); - mu = static_cast<float>(moddelays[1][i]&FRACTIONMASK) * (1.0f/FRACTIONONE); + delay = offset - (moddelays[1][i]>>MixerFracBits); + mu = static_cast<float>(moddelays[1][i]&MixerFracMask) * (1.0f/MixerFracOne); temps[1][i] = cubic(delaybuf[(delay+1) & bufmask], delaybuf[(delay ) & bufmask], delaybuf[(delay-1) & bufmask], delaybuf[(delay-2) & bufmask], mu); diff --git a/alc/effects/fshifter.cpp b/alc/effects/fshifter.cpp index 2ad98231..f3f409e0 100644 --- a/alc/effects/fshifter.cpp +++ b/alc/effects/fshifter.cpp @@ -114,7 +114,7 @@ void FshifterState::update(const ALCcontext *context, const ALeffectslot *slot, const ALCdevice *device{context->mDevice.get()}; const float step{props->Fshifter.Frequency / static_cast<float>(device->Frequency)}; - mPhaseStep[0] = mPhaseStep[1] = fastf2u(minf(step, 1.0f) * FRACTIONONE); + mPhaseStep[0] = mPhaseStep[1] = fastf2u(minf(step, 1.0f) * MixerFracOne); switch(props->Fshifter.LeftDirection) { @@ -202,12 +202,12 @@ void FshifterState::process(const size_t samplesToDo, const al::span<const Float ALuint phase_idx{mPhase[c]}; for(size_t k{0};k < samplesToDo;++k) { - const double phase{phase_idx * ((1.0 / FRACTIONONE) * al::MathDefs<double>::Tau())}; + const double phase{phase_idx * ((1.0/MixerFracOne) * al::MathDefs<double>::Tau())}; BufferOut[k] = static_cast<float>(mOutdata[k].real()*std::cos(phase) + mOutdata[k].imag()*std::sin(phase)*mSign[c]); phase_idx += phase_step; - phase_idx &= FRACTIONMASK; + phase_idx &= MixerFracMask; } mPhase[c] = phase_idx; diff --git a/alc/effects/pshifter.cpp b/alc/effects/pshifter.cpp index d923e376..44ddc694 100644 --- a/alc/effects/pshifter.cpp +++ b/alc/effects/pshifter.cpp @@ -107,7 +107,7 @@ void PshifterState::deviceUpdate(const ALCdevice *device) { /* (Re-)initializing parameters and clear the buffers. */ mCount = FIFO_LATENCY; - mPitchShiftI = FRACTIONONE; + mPitchShiftI = MixerFracOne; mPitchShift = 1.0; mFreqPerBin = device->Frequency / double{STFT_SIZE}; @@ -127,8 +127,8 @@ void PshifterState::update(const ALCcontext*, const ALeffectslot *slot, const Ef { const int tune{props->Pshifter.CoarseTune*100 + props->Pshifter.FineTune}; const float pitch{std::pow(2.0f, static_cast<float>(tune) / 1200.0f)}; - mPitchShiftI = fastf2u(pitch*FRACTIONONE); - mPitchShift = mPitchShiftI * double{1.0/FRACTIONONE}; + mPitchShiftI = fastf2u(pitch*MixerFracOne); + mPitchShift = mPitchShiftI * double{1.0/MixerFracOne}; const auto coeffs = CalcDirectionCoeffs({0.0f, 0.0f, -1.0f}, 0.0f); @@ -206,7 +206,7 @@ void PshifterState::process(const size_t samplesToDo, const al::span<const Float std::fill(mSynthesisBuffer.begin(), mSynthesisBuffer.end(), FrequencyBin{}); for(size_t k{0u};k < STFT_HALF_SIZE+1;k++) { - const size_t j{(k*mPitchShiftI + (FRACTIONONE>>1)) >> FRACTIONBITS}; + const size_t j{(k*mPitchShiftI + (MixerFracOne>>1)) >> MixerFracBits}; if(j >= STFT_HALF_SIZE+1) break; mSynthesisBuffer[j].Amplitude += mAnalysisBuffer[k].Amplitude; diff --git a/alc/mixer/defs.h b/alc/mixer/defs.h index 0f3a0f3d..762355d2 100644 --- a/alc/mixer/defs.h +++ b/alc/mixer/defs.h @@ -5,6 +5,7 @@ #include "alcmain.h" #include "alspan.h" +#include "alu.h" #include "hrtf.h" union InterpState; @@ -39,8 +40,8 @@ inline void InitPosArrays(ALuint frac, ALuint increment, ALuint *frac_arr, ALuin for(size_t i{1};i < size;i++) { const ALuint frac_tmp{frac_arr[i-1] + increment}; - pos_arr[i] = pos_arr[i-1] + (frac_tmp>>FRACTIONBITS); - frac_arr[i] = frac_tmp&FRACTIONMASK; + pos_arr[i] = pos_arr[i-1] + (frac_tmp>>MixerFracBits); + frac_arr[i] = frac_tmp&MixerFracMask; } } diff --git a/alc/mixer/mixer_c.cpp b/alc/mixer/mixer_c.cpp index 5d71e0a4..2be60892 100644 --- a/alc/mixer/mixer_c.cpp +++ b/alc/mixer/mixer_c.cpp @@ -21,15 +21,15 @@ struct FastBSincTag; namespace { -constexpr ALuint FracPhaseBitDiff{FRACTIONBITS - BSincPhaseBits}; +constexpr ALuint FracPhaseBitDiff{MixerFracBits - BSincPhaseBits}; constexpr ALuint FracPhaseDiffOne{1 << FracPhaseBitDiff}; inline float do_point(const InterpState&, const float *RESTRICT vals, const ALuint) { return vals[0]; } inline float do_lerp(const InterpState&, const float *RESTRICT vals, const ALuint frac) -{ return lerp(vals[0], vals[1], static_cast<float>(frac)*(1.0f/FRACTIONONE)); } +{ return lerp(vals[0], vals[1], static_cast<float>(frac)*(1.0f/MixerFracOne)); } inline float do_cubic(const InterpState&, const float *RESTRICT vals, const ALuint frac) -{ return cubic(vals[0], vals[1], vals[2], vals[3], static_cast<float>(frac)*(1.0f/FRACTIONONE)); } +{ return cubic(vals[0], vals[1], vals[2], vals[3], static_cast<float>(frac)*(1.0f/MixerFracOne)); } inline float do_bsinc(const InterpState &istate, const float *RESTRICT vals, const ALuint frac) { const size_t m{istate.bsinc.m}; @@ -78,8 +78,8 @@ const float *DoResample(const InterpState *state, const float *RESTRICT src, ALu out = Sampler(istate, src, frac); frac += increment; - src += frac>>FRACTIONBITS; - frac &= FRACTIONMASK; + src += frac>>MixerFracBits; + frac &= MixerFracMask; } return dst.data(); } diff --git a/alc/mixer/mixer_neon.cpp b/alc/mixer/mixer_neon.cpp index cfa541c7..1b6e7b54 100644 --- a/alc/mixer/mixer_neon.cpp +++ b/alc/mixer/mixer_neon.cpp @@ -21,7 +21,7 @@ struct FastBSincTag; namespace { -constexpr ALuint FracPhaseBitDiff{FRACTIONBITS - BSincPhaseBits}; +constexpr ALuint FracPhaseBitDiff{MixerFracBits - BSincPhaseBits}; constexpr ALuint FracPhaseDiffOne{1 << FracPhaseBitDiff}; inline void ApplyCoeffs(float2 *RESTRICT Values, const uint_fast32_t IrSize, @@ -54,8 +54,8 @@ const float *Resample_<LerpTag,NEONTag>(const InterpState*, const float *RESTRIC ALuint increment, const al::span<float> dst) { const int32x4_t increment4 = vdupq_n_s32(static_cast<int>(increment*4)); - const float32x4_t fracOne4 = vdupq_n_f32(1.0f/FRACTIONONE); - const int32x4_t fracMask4 = vdupq_n_s32(FRACTIONMASK); + const float32x4_t fracOne4 = vdupq_n_f32(1.0f/MixerFracOne); + const int32x4_t fracMask4 = vdupq_n_s32(MixerFracMask); alignas(16) ALuint pos_[4], frac_[4]; int32x4_t pos4, frac4; @@ -82,7 +82,7 @@ const float *Resample_<LerpTag,NEONTag>(const InterpState*, const float *RESTRIC dst_iter += 4; frac4 = vaddq_s32(frac4, increment4); - pos4 = vaddq_s32(pos4, vshrq_n_s32(frac4, FRACTIONBITS)); + pos4 = vaddq_s32(pos4, vshrq_n_s32(frac4, MixerFracBits)); frac4 = vandq_s32(frac4, fracMask4); } @@ -92,11 +92,11 @@ const float *Resample_<LerpTag,NEONTag>(const InterpState*, const float *RESTRIC frac = static_cast<ALuint>(vgetq_lane_s32(frac4, 0)); do { - *(dst_iter++) = lerp(src[0], src[1], static_cast<float>(frac) * (1.0f/FRACTIONONE)); + *(dst_iter++) = lerp(src[0], src[1], static_cast<float>(frac) * (1.0f/MixerFracOne)); frac += increment; - src += frac>>FRACTIONBITS; - frac &= FRACTIONMASK; + src += frac>>MixerFracBits; + frac &= MixerFracMask; } while(--todo); } return dst.data(); @@ -142,8 +142,8 @@ const float *Resample_<BSincTag,NEONTag>(const InterpState *state, const float * out_sample = vget_lane_f32(vadd_f32(vget_low_f32(r4), vget_high_f32(r4)), 0); frac += increment; - src += frac>>FRACTIONBITS; - frac &= FRACTIONMASK; + src += frac>>MixerFracBits; + frac &= MixerFracMask; } return dst.data(); } @@ -183,8 +183,8 @@ const float *Resample_<FastBSincTag,NEONTag>(const InterpState *state, out_sample = vget_lane_f32(vadd_f32(vget_low_f32(r4), vget_high_f32(r4)), 0); frac += increment; - src += frac>>FRACTIONBITS; - frac &= FRACTIONMASK; + src += frac>>MixerFracBits; + frac &= MixerFracMask; } return dst.data(); } diff --git a/alc/mixer/mixer_sse.cpp b/alc/mixer/mixer_sse.cpp index e1aa479c..6c0e5762 100644 --- a/alc/mixer/mixer_sse.cpp +++ b/alc/mixer/mixer_sse.cpp @@ -20,7 +20,7 @@ struct FastBSincTag; namespace { -constexpr ALuint FracPhaseBitDiff{FRACTIONBITS - BSincPhaseBits}; +constexpr ALuint FracPhaseBitDiff{MixerFracBits - BSincPhaseBits}; constexpr ALuint FracPhaseDiffOne{1 << FracPhaseBitDiff}; #define MLA4(x, y, z) _mm_add_ps(x, _mm_mul_ps(y, z)) @@ -115,8 +115,8 @@ const float *Resample_<BSincTag,SSETag>(const InterpState *state, const float *R out_sample = _mm_cvtss_f32(r4); frac += increment; - src += frac>>FRACTIONBITS; - frac &= FRACTIONMASK; + src += frac>>MixerFracBits; + frac &= MixerFracMask; } return dst.data(); } @@ -157,8 +157,8 @@ const float *Resample_<FastBSincTag,SSETag>(const InterpState *state, const floa out_sample = _mm_cvtss_f32(r4); frac += increment; - src += frac>>FRACTIONBITS; - frac &= FRACTIONMASK; + src += frac>>MixerFracBits; + frac &= MixerFracMask; } return dst.data(); } diff --git a/alc/mixer/mixer_sse2.cpp b/alc/mixer/mixer_sse2.cpp index 088284a7..892e0758 100644 --- a/alc/mixer/mixer_sse2.cpp +++ b/alc/mixer/mixer_sse2.cpp @@ -35,8 +35,8 @@ const float *Resample_<LerpTag,SSE2Tag>(const InterpState*, const float *RESTRIC ALuint increment, const al::span<float> dst) { const __m128i increment4{_mm_set1_epi32(static_cast<int>(increment*4))}; - const __m128 fracOne4{_mm_set1_ps(1.0f/FRACTIONONE)}; - const __m128i fracMask4{_mm_set1_epi32(FRACTIONMASK)}; + const __m128 fracOne4{_mm_set1_ps(1.0f/MixerFracOne)}; + const __m128i fracMask4{_mm_set1_epi32(MixerFracMask)}; alignas(16) ALuint pos_[4], frac_[4]; InitPosArrays(frac, increment, frac_, pos_, 4); @@ -64,7 +64,7 @@ const float *Resample_<LerpTag,SSE2Tag>(const InterpState*, const float *RESTRIC dst_iter += 4; frac4 = _mm_add_epi32(frac4, increment4); - pos4 = _mm_add_epi32(pos4, _mm_srli_epi32(frac4, FRACTIONBITS)); + pos4 = _mm_add_epi32(pos4, _mm_srli_epi32(frac4, MixerFracBits)); frac4 = _mm_and_si128(frac4, fracMask4); } @@ -74,11 +74,11 @@ const float *Resample_<LerpTag,SSE2Tag>(const InterpState*, const float *RESTRIC frac = static_cast<ALuint>(_mm_cvtsi128_si32(frac4)); do { - *(dst_iter++) = lerp(src[0], src[1], static_cast<float>(frac) * (1.0f/FRACTIONONE)); + *(dst_iter++) = lerp(src[0], src[1], static_cast<float>(frac) * (1.0f/MixerFracOne)); frac += increment; - src += frac>>FRACTIONBITS; - frac &= FRACTIONMASK; + src += frac>>MixerFracBits; + frac &= MixerFracMask; } while(--todo); } return dst.data(); diff --git a/alc/mixer/mixer_sse41.cpp b/alc/mixer/mixer_sse41.cpp index f18cd6b4..19391ea3 100644 --- a/alc/mixer/mixer_sse41.cpp +++ b/alc/mixer/mixer_sse41.cpp @@ -36,8 +36,8 @@ const float *Resample_<LerpTag,SSE4Tag>(const InterpState*, const float *RESTRIC ALuint increment, const al::span<float> dst) { const __m128i increment4{_mm_set1_epi32(static_cast<int>(increment*4))}; - const __m128 fracOne4{_mm_set1_ps(1.0f/FRACTIONONE)}; - const __m128i fracMask4{_mm_set1_epi32(FRACTIONMASK)}; + const __m128 fracOne4{_mm_set1_ps(1.0f/MixerFracOne)}; + const __m128i fracMask4{_mm_set1_epi32(MixerFracMask)}; alignas(16) ALuint pos_[4], frac_[4]; InitPosArrays(frac, increment, frac_, pos_, 4); @@ -65,7 +65,7 @@ const float *Resample_<LerpTag,SSE4Tag>(const InterpState*, const float *RESTRIC dst_iter += 4; frac4 = _mm_add_epi32(frac4, increment4); - pos4 = _mm_add_epi32(pos4, _mm_srli_epi32(frac4, FRACTIONBITS)); + pos4 = _mm_add_epi32(pos4, _mm_srli_epi32(frac4, MixerFracBits)); frac4 = _mm_and_si128(frac4, fracMask4); } @@ -79,11 +79,11 @@ const float *Resample_<LerpTag,SSE4Tag>(const InterpState*, const float *RESTRIC frac = static_cast<ALuint>(_mm_cvtsi128_si32(frac4)); do { - *(dst_iter++) = lerp(src[0], src[1], static_cast<float>(frac) * (1.0f/FRACTIONONE)); + *(dst_iter++) = lerp(src[0], src[1], static_cast<float>(frac) * (1.0f/MixerFracOne)); frac += increment; - src += frac>>FRACTIONBITS; - frac &= FRACTIONMASK; + src += frac>>MixerFracBits; + frac &= MixerFracMask; } while(--todo); } return dst.data(); diff --git a/alc/voice.cpp b/alc/voice.cpp index cf726bef..44c6b7fa 100644 --- a/alc/voice.cpp +++ b/alc/voice.cpp @@ -75,8 +75,8 @@ struct CopyTag; static_assert((BUFFERSIZE-1)/MAX_PITCH > 0, "MAX_PITCH is too large for BUFFERSIZE!"); -static_assert((INT_MAX>>FRACTIONBITS)/MAX_PITCH > BUFFERSIZE, - "MAX_PITCH and/or BUFFERSIZE are too large for FRACTIONBITS!"); +static_assert((INT_MAX>>MixerFracBits)/MAX_PITCH > BUFFERSIZE, + "MAX_PITCH and/or BUFFERSIZE are too large for MixerFracBits!"); Resampler ResamplerDefault{Resampler::Linear}; @@ -477,7 +477,7 @@ void Voice::mix(const State vstate, ALCcontext *Context, const ALuint SamplesToD const ALuint NumSends{Device->NumAuxSends}; const ALuint IrSize{Device->mHrtf ? Device->mHrtf->irSize : 0}; - ResamplerFunc Resample{(increment == FRACTIONONE && DataPosFrac == 0) ? + ResamplerFunc Resample{(increment == MixerFracOne && DataPosFrac == 0) ? Resample_<CopyTag,CTag> : mResampler}; ALuint Counter{(mFlags&VoiceIsFading) ? SamplesToDo : 0}; @@ -511,12 +511,12 @@ void Voice::mix(const State vstate, ALCcontext *Context, const ALuint SamplesToD ALuint DstBufferSize{SamplesToDo - OutPos}; ALuint SrcBufferSize; - if(increment <= FRACTIONONE) + if(increment <= MixerFracOne) { /* Calculate the last written dst sample pos. */ uint64_t DataSize64{DstBufferSize - 1}; /* Calculate the last read src sample pos. */ - DataSize64 = (DataSize64*increment + DataPosFrac) >> FRACTIONBITS; + DataSize64 = (DataSize64*increment + DataPosFrac) >> MixerFracBits; /* +1 to get the src sample count, include padding. */ DataSize64 += 1 + MAX_RESAMPLER_PADDING; @@ -529,7 +529,7 @@ void Voice::mix(const State vstate, ALCcontext *Context, const ALuint SamplesToD { uint64_t DataSize64{DstBufferSize}; /* Calculate the end src sample pos, include padding. */ - DataSize64 = (DataSize64*increment + DataPosFrac) >> FRACTIONBITS; + DataSize64 = (DataSize64*increment + DataPosFrac) >> MixerFracBits; DataSize64 += MAX_RESAMPLER_PADDING; if(DataSize64 <= BUFFERSIZE + MAX_RESAMPLER_PADDING) @@ -542,7 +542,7 @@ void Voice::mix(const State vstate, ALCcontext *Context, const ALuint SamplesToD SrcBufferSize = BUFFERSIZE + MAX_RESAMPLER_PADDING; DataSize64 = SrcBufferSize - MAX_RESAMPLER_PADDING; - DataSize64 = ((DataSize64<<FRACTIONBITS) - DataPosFrac) / increment; + DataSize64 = ((DataSize64<<MixerFracBits) - DataPosFrac) / increment; if(DataSize64 < DstBufferSize) { /* Some mixers require being 16-byte aligned, so also limit @@ -618,7 +618,7 @@ void Voice::mix(const State vstate, ALCcontext *Context, const ALuint SamplesToD } /* Store the last source samples used for next time. */ - std::copy_n(&SrcData[(increment*DstBufferSize + DataPosFrac)>>FRACTIONBITS], + std::copy_n(&SrcData[(increment*DstBufferSize + DataPosFrac)>>MixerFracBits], chandata.mPrevSamples.size(), chandata.mPrevSamples.begin()); /* Resample, then apply ambisonic upsampling as needed. */ @@ -685,9 +685,9 @@ void Voice::mix(const State vstate, ALCcontext *Context, const ALuint SamplesToD } /* Update positions */ DataPosFrac += increment*DstBufferSize; - const ALuint SrcSamplesDone{DataPosFrac>>FRACTIONBITS}; + const ALuint SrcSamplesDone{DataPosFrac>>MixerFracBits}; DataPosInt += SrcSamplesDone; - DataPosFrac &= FRACTIONMASK; + DataPosFrac &= MixerFracMask; OutPos += DstBufferSize; Counter = maxu(DstBufferSize, Counter) - DstBufferSize; |