[pulseaudio-discuss] [PATCH] core: svolume tests should generate realistic random volume data

Peter Meerwald pmeerw at pmeerw.net
Thu Jan 12 08:20:05 PST 2012


From: Peter Meerwald <p.meerwald at bct-electronic.com>

assuming RAND_MAX is around 1<<31, rand() >> 1 generates large numbers as
random volume data; these likely causes saturated sample values after
applying the volume function -- not a good test
---
 src/pulsecore/svolume_arm.c |    2 +-
 src/pulsecore/svolume_mmx.c |    2 +-
 src/pulsecore/svolume_orc.c |    2 +-
 src/pulsecore/svolume_sse.c |    2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/pulsecore/svolume_arm.c b/src/pulsecore/svolume_arm.c
index 455d746..f938e57 100644
--- a/src/pulsecore/svolume_arm.c
+++ b/src/pulsecore/svolume_arm.c
@@ -151,7 +151,7 @@ static void run_test(void) {
     memcpy(samples_orig, samples, sizeof(samples));
 
     for (i = 0; i < CHANNELS; i++)
-        volumes[i] = PA_CLAMP_VOLUME(rand() >> 1);
+        volumes[i] = PA_CLAMP_VOLUME(rand() >> 15);
     for (padding = 0; padding < PADDING; padding++, i++)
         volumes[i] = volumes[padding];
 
diff --git a/src/pulsecore/svolume_mmx.c b/src/pulsecore/svolume_mmx.c
index 43c1058..f9fc175 100644
--- a/src/pulsecore/svolume_mmx.c
+++ b/src/pulsecore/svolume_mmx.c
@@ -272,7 +272,7 @@ static void run_test(void) {
     memcpy(samples_orig, samples, sizeof(samples));
 
     for (i = 0; i < CHANNELS; i++)
-        volumes[i] = PA_CLAMP_VOLUME(rand() >> 1);
+        volumes[i] = PA_CLAMP_VOLUME(rand() >> 15);
         /* volumes[i] = 0x0000ffff; */
     for (padding = 0; padding < PADDING; padding++, i++)
         volumes[i] = volumes[padding];
diff --git a/src/pulsecore/svolume_orc.c b/src/pulsecore/svolume_orc.c
index 86f843e..b178bbf 100644
--- a/src/pulsecore/svolume_orc.c
+++ b/src/pulsecore/svolume_orc.c
@@ -75,7 +75,7 @@ static void run_test(void) {
     memcpy(samples_orig, samples, sizeof(samples));
 
     for (i = 0; i < CHANNELS; i++)
-        volumes[i] = PA_CLAMP_VOLUME(rand() >> 1);
+        volumes[i] = PA_CLAMP_VOLUME(rand() >> 15);
     for (padding = 0; padding < PADDING; padding++, i++)
         volumes[i] = volumes[padding];
 
diff --git a/src/pulsecore/svolume_sse.c b/src/pulsecore/svolume_sse.c
index 89414c6..fe08de4 100644
--- a/src/pulsecore/svolume_sse.c
+++ b/src/pulsecore/svolume_sse.c
@@ -282,7 +282,7 @@ static void run_test(void) {
     memcpy(samples_orig, samples, sizeof(samples));
 
     for (i = 0; i < CHANNELS; i++)
-        volumes[i] = PA_CLAMP_VOLUME(rand() >> 1);
+        volumes[i] = PA_CLAMP_VOLUME(rand() >> 15);
     for (padding = 0; padding < PADDING; padding++, i++)
         volumes[i] = volumes[padding];
 
-- 
1.7.4.1



More information about the pulseaudio-discuss mailing list