Avoid an underflow in the SSE mixers if BufferSize is less than 4
authorChris Robinson <chris.kcat@gmail.com>
Mon, 24 Dec 2012 13:49:44 +0000 (24 05:49 -0800)
committerChris Robinson <chris.kcat@gmail.com>
Mon, 24 Dec 2012 13:49:44 +0000 (24 05:49 -0800)
Alc/mixer_sse.c

index 540a0d7..3c45fd2 100644 (file)
@@ -155,7 +155,7 @@ void MixDirect_SSE(const DirectParams *params, const ALfloat *RESTRICT data, ALu
             ClickRemoval[c] -= data[0]*DrySend;
 
         gain = _mm_set1_ps(DrySend);
-        for(pos = 0;pos < BufferSize-3;pos += 4)
+        for(pos = 0;BufferSize-pos > 3;pos += 4)
         {
             const __m128 val4 = _mm_load_ps(&data[pos]);
             __m128 dry4 = _mm_load_ps(&DryBuffer[c][OutPos+pos]);
@@ -189,7 +189,7 @@ void MixSend_SSE(const SendParams *params, const ALfloat *RESTRICT data,
         WetClickRemoval[0] -= data[0] * WetGain;
 
     gain = _mm_set1_ps(WetGain);
-    for(pos = 0;pos < BufferSize-3;pos+=4)
+    for(pos = 0;BufferSize-pos > 3;pos += 4)
     {
         const __m128 val4 = _mm_load_ps(&data[pos]);
         __m128 wet4 = _mm_load_ps(&WetBuffer[0][OutPos+pos]);