Audio: Cleanup buffer wrap code.

This is a bit more straight-forward.
This commit is contained in:
Unknown W. Brackets 2021-10-09 08:17:55 -07:00
parent 14bf5de83c
commit 01b99eff98

View file

@ -118,7 +118,8 @@ inline void ClampBufferToS16(s16 *out, const s32 *in, size_t size, s8 volShift)
size -= 8;
}
#elif PPSSPP_ARCH(ARM_NEON)
int16x4_t signedVolShift = vdup_n_s16 (-volShift); // Can only dynamic-shift right, but by a signed integer
// Dynamic shifts can only be left, but it's signed - negate to shift right.
int16x4_t signedVolShift = vdup_n_s16(-volShift);
while (size >= 8) {
int32x4_t in1 = vld1q_s32(in);
int32x4_t in2 = vld1q_s32(in + 4);
@ -281,10 +282,11 @@ void StereoResampler::PushSamples(const s32 *samples, unsigned int numSamples) {
return;
}
int over_bytes = numSamples * 4 - (m_maxBufsize * 2 - (indexW & INDEX_MASK)) * sizeof(short);
if (over_bytes > 0) {
ClampBufferToS16WithVolume(&m_buffer[indexW & INDEX_MASK], samples, (numSamples * 4 - over_bytes) / 2);
ClampBufferToS16WithVolume(&m_buffer[0], samples + (numSamples * 4 - over_bytes) / sizeof(short), over_bytes / 2);
// Check if we need to roll over to the start of the buffer during the copy.
int indexW_left_samples = m_maxBufsize * 2 - (indexW & INDEX_MASK);
if (numSamples * 2 > indexW_left_samples) {
ClampBufferToS16WithVolume(&m_buffer[indexW & INDEX_MASK], samples, indexW_left_samples);
ClampBufferToS16WithVolume(&m_buffer[0], samples + indexW_left_samples, numSamples * 2 - indexW_left_samples);
} else {
ClampBufferToS16WithVolume(&m_buffer[indexW & INDEX_MASK], samples, numSamples * 2);
}