2012-06-29 01:26:31 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2012 The WebM project authors. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef LIBVPX_TEST_ACM_RANDOM_H_
|
|
|
|
#define LIBVPX_TEST_ACM_RANDOM_H_
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "vpx/vpx_integer.h"
|
|
|
|
|
|
|
|
namespace libvpx_test {
|
|
|
|
|
|
|
|
class ACMRandom {
|
|
|
|
public:
|
2012-07-14 00:21:29 +02:00
|
|
|
explicit ACMRandom(int seed) {
|
|
|
|
Reset(seed);
|
|
|
|
}
|
2012-06-29 01:26:31 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
void Reset(int seed) {
|
|
|
|
srand(seed);
|
|
|
|
}
|
2012-06-29 01:26:31 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
uint8_t Rand8(void) {
|
|
|
|
return (rand() >> 8) & 0xff;
|
|
|
|
}
|
2012-06-29 01:26:31 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
int PseudoUniform(int range) {
|
|
|
|
return (rand() >> 8) % range;
|
|
|
|
}
|
2012-06-29 01:26:31 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
int operator()(int n) {
|
|
|
|
return PseudoUniform(n);
|
|
|
|
}
|
2012-06-29 01:26:31 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
static int DeterministicSeed(void) {
|
|
|
|
return 0xbaba;
|
|
|
|
}
|
2012-06-29 01:26:31 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace libvpx_test
|
|
|
|
|
|
|
|
#endif // LIBVPX_TEST_ACM_RANDOM_H_
|