mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-26 19:58:36 +01:00
Merge pull request #7159 from unknownbrackets/sse-audio
Use SSE shifts for high-vol channels
This commit is contained in:
commit
2de705a9e7
1 file changed
+14
-1
+14
-1
@@ -89,7 +89,6 @@ static inline s16 adjustvolume(s16 sample, int vol) {
|
||||
|
||||
inline void AdjustVolumeBlock(s16 *out, s16 *in, size_t size, int leftVol, int rightVol) {
|
||||
#ifdef _M_SSE
|
||||
// TODO: This can be done in SSE with some extra shifting (might not even affect speed.)
|
||||
if (leftVol <= 0x7fff && rightVol <= 0x7fff) {
|
||||
__m128i volume = _mm_set_epi16(leftVol, rightVol, leftVol, rightVol, leftVol, rightVol, leftVol, rightVol);
|
||||
while (size >= 16) {
|
||||
@@ -101,6 +100,20 @@ inline void AdjustVolumeBlock(s16 *out, s16 *in, size_t size, int leftVol, int r
|
||||
out += 16;
|
||||
size -= 16;
|
||||
}
|
||||
} else {
|
||||
// We have to shift inside the loop to avoid the signed multiply issue.
|
||||
leftVol >>= 1;
|
||||
rightVol >>= 1;
|
||||
__m128i volume = _mm_set_epi16(leftVol, rightVol, leftVol, rightVol, leftVol, rightVol, leftVol, rightVol);
|
||||
while (size >= 16) {
|
||||
__m128i indata1 = _mm_loadu_si128((__m128i *)in);
|
||||
__m128i indata2 = _mm_loadu_si128((__m128i *)(in + 8));
|
||||
_mm_storeu_si128((__m128i *)out, _mm_slli_epi16(_mm_mulhi_epi16(indata1, volume), 1));
|
||||
_mm_storeu_si128((__m128i *)(out + 8), _mm_slli_epi16(_mm_mulhi_epi16(indata2, volume), 1));
|
||||
in += 16;
|
||||
out += 16;
|
||||
size -= 16;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
for (size_t i = 0; i < size; i += 2) {
|
||||
|
||||
Reference in new issue
Block a user