common_audio/signal_processing: Removed macro WEBRTC_SPL_MAX_SEED_USED
* Moved the macro to randomization_functions and made it static const.
* Made WebRtc_IncreaseSeed() static, since it is not used outside this function.
* Style guide changes.
BUG=3348,3353
TESTED=trybots, common_audio_unittests, modules_unittests, modules_tests
R=tina.legrand@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/21459004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@6179 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/webrtc/common_audio/signal_processing/randomization_functions.c b/webrtc/common_audio/signal_processing/randomization_functions.c
index e2711fd..73f2409 100644
--- a/webrtc/common_audio/signal_processing/randomization_functions.c
+++ b/webrtc/common_audio/signal_processing/randomization_functions.c
@@ -11,7 +11,6 @@
/*
* This file contains implementations of the randomization functions
- * WebRtcSpl_IncreaseSeed()
* WebRtcSpl_RandU()
* WebRtcSpl_RandN()
* WebRtcSpl_RandUArray()
@@ -22,6 +21,8 @@
#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"
+static const uint32_t kMaxSeedUsed = 0x80000000;
+
static const int16_t kRandNTable[] = {
9178, -7260, 40, 10189, 4894, -3531, -13779, 14764,
-4008, -8884, -8990, 1008, 7368, 5184, 3251, -5817,
@@ -89,31 +90,26 @@
2374, -5797, 11839, 8940, -11874, 18213, 2855, 10492
};
-uint32_t WebRtcSpl_IncreaseSeed(uint32_t *seed)
-{
- seed[0] = (seed[0] * ((int32_t)69069) + 1) & (WEBRTC_SPL_MAX_SEED_USED - 1);
- return seed[0];
+static uint32_t IncreaseSeed(uint32_t* seed) {
+ seed[0] = (seed[0] * ((int32_t)69069) + 1) & (kMaxSeedUsed - 1);
+ return seed[0];
}
-int16_t WebRtcSpl_RandU(uint32_t *seed)
-{
- return (int16_t)(WebRtcSpl_IncreaseSeed(seed) >> 16);
+int16_t WebRtcSpl_RandU(uint32_t* seed) {
+ return (int16_t)(IncreaseSeed(seed) >> 16);
}
-int16_t WebRtcSpl_RandN(uint32_t *seed)
-{
- return kRandNTable[WebRtcSpl_IncreaseSeed(seed) >> 23];
+int16_t WebRtcSpl_RandN(uint32_t* seed) {
+ return kRandNTable[IncreaseSeed(seed) >> 23];
}
-// Creates an array of uniformly distributed variables
+// Creates an array of uniformly distributed variables.
int16_t WebRtcSpl_RandUArray(int16_t* vector,
int16_t vector_length,
- uint32_t* seed)
-{
- int i;
- for (i = 0; i < vector_length; i++)
- {
- vector[i] = WebRtcSpl_RandU(seed);
- }
- return vector_length;
+ uint32_t* seed) {
+ int i;
+ for (i = 0; i < vector_length; i++) {
+ vector[i] = WebRtcSpl_RandU(seed);
+ }
+ return vector_length;
}