Allow using a variable channel stride for MixRowSamples
This commit is contained in:
@@ -317,9 +317,8 @@ struct ALvoice {
|
||||
using MixerFunc = void(*)(const ALfloat *data, const al::span<FloatBufferLine> OutBuffer,
|
||||
ALfloat *CurrentGains, const ALfloat *TargetGains, const ALsizei Counter, const ALsizei OutPos,
|
||||
const ALsizei BufferSize);
|
||||
using RowMixerFunc = void(*)(ALfloat *OutBuffer, const ALfloat *gains,
|
||||
const al::span<const FloatBufferLine> InSamples, const ALsizei InPos,
|
||||
const ALsizei BufferSize);
|
||||
using RowMixerFunc = void(*)(ALfloat *OutBuffer, const al::span<const ALfloat> Gains,
|
||||
const ALfloat *InSamples, const ALsizei InStride, const ALsizei BufferSize);
|
||||
using HrtfMixerFunc = void(*)(FloatBufferLine &LeftOut, FloatBufferLine &RightOut,
|
||||
const ALfloat *InSamples, float2 *AccumSamples, const ALsizei OutPos, const ALsizei IrSize,
|
||||
MixHrtfFilter *hrtfparams, const ALsizei BufferSize);
|
||||
|
||||
+6
-6
@@ -156,16 +156,16 @@ void BFormatDec::process(const al::span<FloatBufferLine> OutBuffer,
|
||||
mXOver[i].process(mSamplesHF[i].data(), mSamplesLF[i].data(), InSamples[i].data(),
|
||||
SamplesToDo);
|
||||
|
||||
const al::span<const FloatBufferLine> hfsamples{mSamplesHF, mNumChannels};
|
||||
const al::span<const FloatBufferLine> lfsamples{mSamplesLF, mNumChannels};
|
||||
ALfloat (*mixmtx)[sNumBands][MAX_AMBI_CHANNELS]{mMatrix.Dual};
|
||||
ALuint enabled{mEnabled};
|
||||
for(FloatBufferLine &outbuf : OutBuffer)
|
||||
{
|
||||
if LIKELY(enabled&1)
|
||||
{
|
||||
MixRowSamples(outbuf.data(), (*mixmtx)[sHFBand], hfsamples, 0, SamplesToDo);
|
||||
MixRowSamples(outbuf.data(), (*mixmtx)[sLFBand], lfsamples, 0, SamplesToDo);
|
||||
MixRowSamples(outbuf.data(), {(*mixmtx)[sHFBand], mNumChannels},
|
||||
mSamplesHF->data(), mSamplesHF->size(), SamplesToDo);
|
||||
MixRowSamples(outbuf.data(), {(*mixmtx)[sLFBand], mNumChannels},
|
||||
mSamplesLF->data(), mSamplesLF->size(), SamplesToDo);
|
||||
}
|
||||
++mixmtx;
|
||||
enabled >>= 1;
|
||||
@@ -173,13 +173,13 @@ void BFormatDec::process(const al::span<FloatBufferLine> OutBuffer,
|
||||
}
|
||||
else
|
||||
{
|
||||
const al::span<const FloatBufferLine> insamples{InSamples, mNumChannels};
|
||||
ALfloat (*mixmtx)[MAX_AMBI_CHANNELS]{mMatrix.Single};
|
||||
ALuint enabled{mEnabled};
|
||||
for(FloatBufferLine &outbuf : OutBuffer)
|
||||
{
|
||||
if LIKELY(enabled&1)
|
||||
MixRowSamples(outbuf.data(), *mixmtx, insamples, 0, SamplesToDo);
|
||||
MixRowSamples(outbuf.data(), {*mixmtx, mNumChannels}, InSamples->data(),
|
||||
InSamples->size(), SamplesToDo);
|
||||
++mixmtx;
|
||||
enabled >>= 1;
|
||||
}
|
||||
|
||||
+2
-3
@@ -24,8 +24,10 @@ class BFormatDec {
|
||||
static constexpr size_t sLFBand{1};
|
||||
static constexpr size_t sNumBands{2};
|
||||
|
||||
bool mDualBand{false};
|
||||
ALuint mEnabled{0u}; /* Bitfield of enabled channels. */
|
||||
|
||||
ALuint mNumChannels{0u};
|
||||
union MatrixU {
|
||||
ALfloat Dual[MAX_OUTPUT_CHANNELS][sNumBands][MAX_AMBI_CHANNELS];
|
||||
ALfloat Single[MAX_OUTPUT_CHANNELS][MAX_AMBI_CHANNELS];
|
||||
@@ -39,9 +41,6 @@ class BFormatDec {
|
||||
FloatBufferLine *mSamplesHF{nullptr};
|
||||
FloatBufferLine *mSamplesLF{nullptr};
|
||||
|
||||
ALuint mNumChannels{0u};
|
||||
bool mDualBand{false};
|
||||
|
||||
public:
|
||||
BFormatDec(const AmbDecConf *conf, const bool allow_2band, const ALuint inchans,
|
||||
const ALuint srate, const ALsizei (&chanmap)[MAX_OUTPUT_CHANNELS]);
|
||||
|
||||
+10
-5
@@ -424,14 +424,16 @@ struct ReverbState final : public EffectState {
|
||||
for(ALsizei c{0};c < NUM_LINES;c++)
|
||||
{
|
||||
std::fill_n(mTempLine.begin(), todo, 0.0f);
|
||||
MixRowSamples(mTempLine.data(), A2B[c], mTempSamples, sEarlyOffset, todo);
|
||||
MixRowSamples(mTempLine.data(), A2B[c], mTempSamples[0].data()+sEarlyOffset,
|
||||
mTempSamples[0].size(), todo);
|
||||
MixSamples(mTempLine.data(), samplesOut, mEarly.CurrentGain[c],
|
||||
mEarly.PanGain[c], counter, offset, todo);
|
||||
}
|
||||
for(ALsizei c{0};c < NUM_LINES;c++)
|
||||
{
|
||||
std::fill_n(mTempLine.begin(), todo, 0.0f);
|
||||
MixRowSamples(mTempLine.data(), A2B[c], mTempSamples, sLateOffset, todo);
|
||||
MixRowSamples(mTempLine.data(), A2B[c], mTempSamples[0].data()+sLateOffset,
|
||||
mTempSamples[0].size(), todo);
|
||||
MixSamples(mTempLine.data(), samplesOut, mLate.CurrentGain[c], mLate.PanGain[c],
|
||||
counter, offset, todo);
|
||||
}
|
||||
@@ -445,7 +447,8 @@ struct ReverbState final : public EffectState {
|
||||
for(ALsizei c{0};c < NUM_LINES;c++)
|
||||
{
|
||||
std::fill_n(mTempLine.begin(), todo, 0.0f);
|
||||
MixRowSamples(mTempLine.data(), A2B[c], mTempSamples, sEarlyOffset, todo);
|
||||
MixRowSamples(mTempLine.data(), A2B[c], mTempSamples[0].data()+sEarlyOffset,
|
||||
mTempSamples[0].size(), todo);
|
||||
|
||||
/* Apply scaling to the B-Format's HF response to "upsample" it to
|
||||
* higher-order output.
|
||||
@@ -459,7 +462,8 @@ struct ReverbState final : public EffectState {
|
||||
for(ALsizei c{0};c < NUM_LINES;c++)
|
||||
{
|
||||
std::fill_n(mTempLine.begin(), todo, 0.0f);
|
||||
MixRowSamples(mTempLine.data(), A2B[c], mTempSamples, sLateOffset, todo);
|
||||
MixRowSamples(mTempLine.data(), A2B[c], mTempSamples[0].data()+sLateOffset,
|
||||
mTempSamples[0].size(), todo);
|
||||
|
||||
const ALfloat hfscale{(c==0) ? mOrderScales[0] : mOrderScales[1]};
|
||||
mAmbiSplitter[1][c].applyHfScale(mTempLine.data(), hfscale, todo);
|
||||
@@ -1457,7 +1461,8 @@ void ReverbState::process(const ALsizei samplesToDo, const FloatBufferLine *REST
|
||||
for(ALsizei c{0};c < NUM_LINES;c++)
|
||||
{
|
||||
std::fill_n(mTempLine.begin(), samplesToDo, 0.0f);
|
||||
MixRowSamples(mTempLine.data(), B2A[c], {samplesIn, samplesIn+numInput}, 0, samplesToDo);
|
||||
MixRowSamples(mTempLine.data(), {B2A[c], B2A[c]+numInput}, samplesIn->data(),
|
||||
samplesIn->size(), samplesToDo);
|
||||
|
||||
/* Band-pass the incoming samples and feed the initial delay line. */
|
||||
mFilter[c].Lp.process(mTempLine.data(), mTempLine.data(), samplesToDo);
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ const ALfloat *Resample_(const InterpState *state, const ALfloat *RESTRICT src,
|
||||
template<InstSetType InstTag>
|
||||
void Mix_(const ALfloat *data, const al::span<FloatBufferLine> OutBuffer, ALfloat *CurrentGains, const ALfloat *TargetGains, const ALsizei Counter, const ALsizei OutPos, const ALsizei BufferSize);
|
||||
template<InstSetType InstTag>
|
||||
void MixRow_(ALfloat *OutBuffer, const ALfloat *Gains, const al::span<const FloatBufferLine> InSamples, const ALsizei InPos, const ALsizei BufferSize);
|
||||
void MixRow_(ALfloat *OutBuffer, const al::span<const ALfloat> Gains, const ALfloat *InSamples, const ALsizei InStride, const ALsizei BufferSize);
|
||||
|
||||
template<InstSetType InstTag>
|
||||
void MixHrtf_(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, const ALfloat *InSamples, float2 *AccumSamples, const ALsizei OutPos, const ALsizei IrSize, MixHrtfFilter *hrtfparams, const ALsizei BufferSize);
|
||||
|
||||
@@ -189,15 +189,16 @@ void Mix_<CTag>(const ALfloat *data, const al::span<FloatBufferLine> OutBuffer,
|
||||
* stepping is necessary.
|
||||
*/
|
||||
template<>
|
||||
void MixRow_<CTag>(ALfloat *OutBuffer, const ALfloat *Gains,
|
||||
const al::span<const FloatBufferLine> InSamples, const ALsizei InPos, const ALsizei BufferSize)
|
||||
void MixRow_<CTag>(ALfloat *OutBuffer, const al::span<const ALfloat> Gains,
|
||||
const ALfloat *InSamples, const ALsizei InStride, const ALsizei BufferSize)
|
||||
{
|
||||
ASSUME(BufferSize > 0);
|
||||
|
||||
for(const FloatBufferLine &input : InSamples)
|
||||
for(const ALfloat gain : Gains)
|
||||
{
|
||||
const ALfloat *RESTRICT src{input.data()+InPos};
|
||||
const ALfloat gain{*(Gains++)};
|
||||
const ALfloat *RESTRICT src{InSamples};
|
||||
InSamples += InStride;
|
||||
|
||||
if(!(std::fabs(gain) > GAIN_SILENCE_THRESHOLD))
|
||||
continue;
|
||||
|
||||
|
||||
@@ -276,15 +276,16 @@ void Mix_<NEONTag>(const ALfloat *data, const al::span<FloatBufferLine> OutBuffe
|
||||
}
|
||||
|
||||
template<>
|
||||
void MixRow_<NEONTag>(ALfloat *OutBuffer, const ALfloat *Gains,
|
||||
const al::span<const FloatBufferLine> InSamples, const ALsizei InPos, const ALsizei BufferSize)
|
||||
void MixRow_<NEONTag>(ALfloat *OutBuffer, const al::span<const ALfloat> Gains,
|
||||
const ALfloat *InSamples, const ALsizei InStride, const ALsizei BufferSize)
|
||||
{
|
||||
ASSUME(BufferSize > 0);
|
||||
|
||||
for(const FloatBufferLine &input : InSamples)
|
||||
for(const ALfloat gain : Gains)
|
||||
{
|
||||
const ALfloat *RESTRICT src{al::assume_aligned<16>(input.data()+InPos)};
|
||||
const ALfloat gain{*(Gains++)};
|
||||
const ALfloat *RESTRICT src{InSamples};
|
||||
InSamples += InStride;
|
||||
|
||||
if(!(std::fabs(gain) > GAIN_SILENCE_THRESHOLD))
|
||||
continue;
|
||||
|
||||
|
||||
@@ -229,15 +229,16 @@ void Mix_<SSETag>(const ALfloat *data, const al::span<FloatBufferLine> OutBuffer
|
||||
}
|
||||
|
||||
template<>
|
||||
void MixRow_<SSETag>(ALfloat *OutBuffer, const ALfloat *Gains,
|
||||
const al::span<const FloatBufferLine> InSamples, const ALsizei InPos, const ALsizei BufferSize)
|
||||
void MixRow_<SSETag>(ALfloat *OutBuffer, const al::span<const ALfloat> Gains,
|
||||
const ALfloat *InSamples, const ALsizei InStride, const ALsizei BufferSize)
|
||||
{
|
||||
ASSUME(BufferSize > 0);
|
||||
|
||||
for(const FloatBufferLine &input : InSamples)
|
||||
for(const ALfloat gain : Gains)
|
||||
{
|
||||
const ALfloat *RESTRICT src{al::assume_aligned<16>(input.data()+InPos)};
|
||||
const ALfloat gain{*(Gains++)};
|
||||
const ALfloat *RESTRICT src{InSamples};
|
||||
InSamples += InStride;
|
||||
|
||||
if(!(std::fabs(gain) > GAIN_SILENCE_THRESHOLD))
|
||||
continue;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user