]> code.delx.au - pulseaudio/blobdiff - src/pulsecore/svolume_sse.c
SSE/MMX/ARM: Fix high frequency noise with unusual number of channels
[pulseaudio] / src / pulsecore / svolume_sse.c
index 620524fa6cb166c3e73b9063b958d73bbd57b061..200482ec502246af4e788b0ebfe7fd9d0cbcba60 100644 (file)
       " por %%xmm4, "#s1"            \n\t" /* .. |  l  h |  */ \
       " por %%xmm5, "#s2"            \n\t"
 
+
+static int channel_overread_table[8] = {8,8,8,12,8,10,12,14};
+
 static void
 pa_volume_s16ne_sse2 (int16_t *samples, int32_t *volumes, unsigned channels, unsigned length)
 {
     pa_reg_x86 channel, temp;
 
-    /* the max number of samples we process at a time, this is also the max amount
-     * we overread the volume array, which should have enough padding. */
-    channels = PA_MAX (8U, channels);
+    /* Channels must be at least 8 and always a multiple of the original number.
+     * This is also the max amount we overread the volume array, which should
+     * have enough padding. */
+    if (channels < 8)
+        channels = channel_overread_table[channels];
 
     __asm__ __volatile__ (
         " xor %3, %3                    \n\t"
@@ -161,9 +166,11 @@ pa_volume_s16re_sse2 (int16_t *samples, int32_t *volumes, unsigned channels, uns
 {
     pa_reg_x86 channel, temp;
 
-    /* the max number of samples we process at a time, this is also the max amount
-     * we overread the volume array, which should have enough padding. */
-    channels = PA_MAX (8U, channels);
+    /* Channels must be at least 8 and always a multiple of the original number.
+     * This is also the max amount we overread the volume array, which should
+     * have enough padding. */
+    if (channels < 8)
+        channels = channel_overread_table[channels];
 
     __asm__ __volatile__ (
         " xor %3, %3                    \n\t"