Move ACMRandom to acm_random.h
Change-Id: I1d99c56d1e1f521507978737fc661ca90af72507
This commit is contained in:
48
test/acm_random.h
Normal file
48
test/acm_random.h
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* 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 <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
namespace libvpx_test {
|
||||||
|
|
||||||
|
class ACMRandom {
|
||||||
|
public:
|
||||||
|
explicit ACMRandom(int seed) {
|
||||||
|
Reset(seed);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Reset(int seed) {
|
||||||
|
srand(seed);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t Rand8(void) {
|
||||||
|
return (rand() >> 8) & 0xff;
|
||||||
|
}
|
||||||
|
|
||||||
|
int PseudoUniform(int range) {
|
||||||
|
return (rand() >> 8) % range;
|
||||||
|
}
|
||||||
|
|
||||||
|
int operator()(int n) {
|
||||||
|
return PseudoUniform(n);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DeterministicSeed(void) {
|
||||||
|
return 0xbaba;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace libvpx_test
|
||||||
|
|
||||||
|
#endif // LIBVPX_TEST_ACM_RANDOM_H_
|
@@ -20,28 +20,16 @@ extern "C" {
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include "test/acm_random.h"
|
||||||
#include "third_party/googletest/src/include/gtest/gtest.h"
|
#include "third_party/googletest/src/include/gtest/gtest.h"
|
||||||
#include "vpx/vpx_integer.h"
|
#include "vpx/vpx_integer.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
const int num_tests = 10;
|
const int num_tests = 10;
|
||||||
|
|
||||||
class ACMRandom {
|
|
||||||
public:
|
|
||||||
explicit ACMRandom(int seed) { Reset(seed); }
|
|
||||||
|
|
||||||
void Reset(int seed) { srand(seed); }
|
|
||||||
|
|
||||||
uint8_t Rand8(void) { return (rand() >> 8) & 0xff; }
|
|
||||||
|
|
||||||
int PseudoUniform(int range) { return (rand() >> 8) % range; }
|
|
||||||
|
|
||||||
int operator()(int n) { return PseudoUniform(n); }
|
|
||||||
|
|
||||||
static int DeterministicSeed(void) { return 0xbaba; }
|
|
||||||
};
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
using libvpx_test::ACMRandom;
|
||||||
|
|
||||||
TEST(VP8, TestBitIO) {
|
TEST(VP8, TestBitIO) {
|
||||||
ACMRandom rnd(ACMRandom::DeterministicSeed());
|
ACMRandom rnd(ACMRandom::DeterministicSeed());
|
||||||
for (int n = 0; n < num_tests; ++n) {
|
for (int n = 0; n < num_tests; ++n) {
|
||||||
|
@@ -21,6 +21,7 @@ extern "C" {
|
|||||||
#include "vpx_rtcd.h"
|
#include "vpx_rtcd.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include "test/acm_random.h"
|
||||||
#include "third_party/googletest/src/include/gtest/gtest.h"
|
#include "third_party/googletest/src/include/gtest/gtest.h"
|
||||||
#include "vpx/vpx_integer.h"
|
#include "vpx/vpx_integer.h"
|
||||||
|
|
||||||
@@ -70,22 +71,7 @@ void reference_idct4x4(const int16_t *input, int16_t *output) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is a class that generate random numbers for test input.
|
using libvpx_test::ACMRandom;
|
||||||
class ACMRandom {
|
|
||||||
public:
|
|
||||||
explicit ACMRandom(int seed) { Reset(seed); }
|
|
||||||
|
|
||||||
void Reset(int seed) { srand(seed); }
|
|
||||||
|
|
||||||
uint8_t Rand8(void) { return (rand() >> 8) & 0xff; }
|
|
||||||
|
|
||||||
int PseudoUniform(int range) { return (rand() >> 8) % range; }
|
|
||||||
|
|
||||||
int operator()(int n) { return PseudoUniform(n); }
|
|
||||||
|
|
||||||
static int DeterministicSeed(void) { return 0xbaba; }
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
TEST(Vp8FdctTest, SignBiasCheck) {
|
TEST(Vp8FdctTest, SignBiasCheck) {
|
||||||
ACMRandom rnd(ACMRandom::DeterministicSeed());
|
ACMRandom rnd(ACMRandom::DeterministicSeed());
|
||||||
|
@@ -11,6 +11,7 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include "test/acm_random.h"
|
||||||
#include "test/util.h"
|
#include "test/util.h"
|
||||||
#include "third_party/googletest/src/include/gtest/gtest.h"
|
#include "third_party/googletest/src/include/gtest/gtest.h"
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@@ -22,21 +23,6 @@ extern "C" {
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class ACMRandom {
|
|
||||||
public:
|
|
||||||
explicit ACMRandom(int seed) { Reset(seed); }
|
|
||||||
|
|
||||||
void Reset(int seed) { srand(seed); }
|
|
||||||
|
|
||||||
uint8_t Rand8(void) { return (rand() >> 8) & 0xff; }
|
|
||||||
|
|
||||||
int PseudoUniform(int range) { return (rand() >> 8) % range; }
|
|
||||||
|
|
||||||
int operator()(int n) { return PseudoUniform(n); }
|
|
||||||
|
|
||||||
static int DeterministicSeed(void) { return 0xbaba; }
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef void (*sixtap_predict_fn_t)(uint8_t *src_ptr,
|
typedef void (*sixtap_predict_fn_t)(uint8_t *src_ptr,
|
||||||
int src_pixels_per_line,
|
int src_pixels_per_line,
|
||||||
int xoffset,
|
int xoffset,
|
||||||
@@ -139,6 +125,8 @@ TEST_P(SixtapPredictTest, TestWithPresetData) {
|
|||||||
<< "i==" << (i * width_ + j);
|
<< "i==" << (i * width_ + j);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
using libvpx_test::ACMRandom;
|
||||||
|
|
||||||
TEST_P(SixtapPredictTest, TestWithRandomData) {
|
TEST_P(SixtapPredictTest, TestWithRandomData) {
|
||||||
const size_t src_size = sizeof(src_) / sizeof(uint8_t);
|
const size_t src_size = sizeof(src_) / sizeof(uint8_t);
|
||||||
|
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
LIBVPX_TEST_SRCS-yes += acm_random.h
|
||||||
LIBVPX_TEST_SRCS-yes += test.mk
|
LIBVPX_TEST_SRCS-yes += test.mk
|
||||||
LIBVPX_TEST_SRCS-yes += test_libvpx.cc
|
LIBVPX_TEST_SRCS-yes += test_libvpx.cc
|
||||||
LIBVPX_TEST_SRCS-yes += util.h
|
LIBVPX_TEST_SRCS-yes += util.h
|
||||||
|
Reference in New Issue
Block a user