2 * Copyright (c) 2012 The WebM project authors. All Rights Reserved.
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
11 #ifndef LIBVPX_TEST_ACM_RANDOM_H_
12 #define LIBVPX_TEST_ACM_RANDOM_H_
16 #include "vpx/vpx_integer.h"
18 namespace libvpx_test {
23 Reset(DeterministicSeed());
26 explicit ACMRandom(int seed) {
30 void Reset(int seed) {
35 return (rand() >> 8) & 0xff;
38 uint8_t Rand8Extremes(void) {
39 // Returns a random value near 0 or near 255, to better exercise
40 // saturation behavior.
41 const uint8_t r = Rand8();
42 return r < 128 ? r << 4 : r >> 4;
45 int PseudoUniform(int range) {
46 return (rand() >> 8) % range;
49 int operator()(int n) {
50 return PseudoUniform(n);
53 static int DeterministicSeed(void) {
58 } // namespace libvpx_test
60 #endif // LIBVPX_TEST_ACM_RANDOM_H_