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_
14 #include "third_party/googletest/src/include/gtest/gtest.h"
16 #include "vpx/vpx_integer.h"
18 namespace libvpx_test {
22 ACMRandom() : random_(DeterministicSeed()) {}
24 explicit ACMRandom(int seed) : random_(seed) {}
26 void Reset(int seed) {
31 const uint32_t value =
32 random_.Generate(testing::internal::Random::kMaxRange);
33 // There's a bit more entropy in the upper bits of this implementation.
34 return (value >> 24) & 0xff;
37 int PseudoUniform(int range) {
38 return random_.Generate(range);
41 int operator()(int n) {
42 return PseudoUniform(n);
45 static int DeterministicSeed(void) {
50 testing::internal::Random random_;
53 } // namespace libvpx_test
55 #endif // LIBVPX_TEST_ACM_RANDOM_H_