Commit 31780e66 authored by JackyChen's avatar JackyChen

Code style change in unit test for VP8/VP9 denoiser.

Change-Id: If4b0aca18c8474dd2456900ae9681e74222e645f
parent a62acf3c
...@@ -28,19 +28,18 @@ using libvpx_test::ACMRandom; ...@@ -28,19 +28,18 @@ using libvpx_test::ACMRandom;
namespace { namespace {
const int kNumPixels = 16 * 16; const int kNumPixels = 16 * 16;
class VP8DenoiserTest class VP8DenoiserTest : public ::testing::TestWithParam<int> {
: public ::testing::TestWithParam<int> {
public: public:
virtual ~VP8DenoiserTest() {} virtual ~VP8DenoiserTest() {}
virtual void SetUp() { virtual void SetUp() {
increase_denoising = GetParam(); increase_denoising_ = GetParam();
} }
virtual void TearDown() { libvpx_test::ClearSystemState(); } virtual void TearDown() { libvpx_test::ClearSystemState(); }
protected: protected:
int increase_denoising; int increase_denoising_;
}; };
TEST_P(VP8DenoiserTest, BitexactCheck) { TEST_P(VP8DenoiserTest, BitexactCheck) {
...@@ -63,8 +62,8 @@ TEST_P(VP8DenoiserTest, BitexactCheck) { ...@@ -63,8 +62,8 @@ TEST_P(VP8DenoiserTest, BitexactCheck) {
for (int i = 0; i < count_test_block; ++i) { for (int i = 0; i < count_test_block; ++i) {
// Generate random motion magnitude, 20% of which exceed the threshold. // Generate random motion magnitude, 20% of which exceed the threshold.
uint8_t motion_magnitude_random const int motion_magnitude_ran =
= rnd.Rand8() % (uint8_t)(MOTION_MAGNITUDE_THRESHOLD * 1.2); rnd.Rand8() % static_cast<int>(MOTION_MAGNITUDE_THRESHOLD * 1.2);
// Initialize a test block with random number in range [0, 255]. // Initialize a test block with random number in range [0, 255].
for (int j = 0; j < kNumPixels; ++j) { for (int j = 0; j < kNumPixels; ++j) {
...@@ -72,20 +71,20 @@ TEST_P(VP8DenoiserTest, BitexactCheck) { ...@@ -72,20 +71,20 @@ TEST_P(VP8DenoiserTest, BitexactCheck) {
sig_block_sse2[j] = sig_block_c[j] = rnd.Rand8(); sig_block_sse2[j] = sig_block_c[j] = rnd.Rand8();
// The pixels in mc_avg_block are generated by adding a random // The pixels in mc_avg_block are generated by adding a random
// number in range [-19, 19] to corresponding pixels in sig_block. // number in range [-19, 19] to corresponding pixels in sig_block.
temp = sig_block_c[j] + (rnd.Rand8() % 2 == 0? -1 : 1) * temp = sig_block_c[j] + (rnd.Rand8() % 2 == 0 ? -1 : 1) *
(rnd.Rand8()%20); (rnd.Rand8() % 20);
// Clip. // Clip.
mc_avg_block[j] = (temp < 0? 0 : (temp > 255? 255 : temp)); mc_avg_block[j] = (temp < 0) ? 0 : ((temp > 255) ? 255 : temp);
} }
// Test denosiser on Y component. // Test denosiser on Y component.
ASM_REGISTER_STATE_CHECK(vp8_denoiser_filter_c(mc_avg_block, stride, ASM_REGISTER_STATE_CHECK(vp8_denoiser_filter_c(
avg_block_c, stride, sig_block_c, stride, mc_avg_block, stride, avg_block_c, stride, sig_block_c, stride,
motion_magnitude_random, increase_denoising)); motion_magnitude_ran, increase_denoising_));
ASM_REGISTER_STATE_CHECK(vp8_denoiser_filter_sse2(mc_avg_block, stride, ASM_REGISTER_STATE_CHECK(vp8_denoiser_filter_sse2(
avg_block_sse2, stride, sig_block_sse2, stride, mc_avg_block, stride, avg_block_sse2, stride, sig_block_sse2, stride,
motion_magnitude_random, increase_denoising)); motion_magnitude_ran, increase_denoising_));
// Check bitexactness. // Check bitexactness.
for (int h = 0; h < 16; ++h) { for (int h = 0; h < 16; ++h) {
...@@ -94,14 +93,14 @@ TEST_P(VP8DenoiserTest, BitexactCheck) { ...@@ -94,14 +93,14 @@ TEST_P(VP8DenoiserTest, BitexactCheck) {
} }
} }
// Test denosiser on UV component. // Test denoiser on UV component.
ASM_REGISTER_STATE_CHECK(vp8_denoiser_filter_uv_c(mc_avg_block, stride, ASM_REGISTER_STATE_CHECK(vp8_denoiser_filter_uv_c(
avg_block_c, stride, sig_block_c, stride, mc_avg_block, stride, avg_block_c, stride, sig_block_c, stride,
motion_magnitude_random, increase_denoising)); motion_magnitude_ran, increase_denoising_));
ASM_REGISTER_STATE_CHECK(vp8_denoiser_filter_uv_sse2(mc_avg_block, stride, ASM_REGISTER_STATE_CHECK(vp8_denoiser_filter_uv_sse2(
avg_block_sse2, stride, sig_block_sse2, stride, mc_avg_block, stride, avg_block_sse2, stride, sig_block_sse2, stride,
motion_magnitude_random, increase_denoising)); motion_magnitude_ran, increase_denoising_));
// Check bitexactness. // Check bitexactness.
for (int h = 0; h < 16; ++h) { for (int h = 0; h < 16; ++h) {
...@@ -113,7 +112,5 @@ TEST_P(VP8DenoiserTest, BitexactCheck) { ...@@ -113,7 +112,5 @@ TEST_P(VP8DenoiserTest, BitexactCheck) {
} }
// Test for all block size. // Test for all block size.
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P(SSE2, VP8DenoiserTest, ::testing::Values(0, 1));
SSE2, VP8DenoiserTest,
::testing::Values(0, 1));
} // namespace } // namespace
...@@ -29,19 +29,18 @@ using libvpx_test::ACMRandom; ...@@ -29,19 +29,18 @@ using libvpx_test::ACMRandom;
namespace { namespace {
const int kNumPixels = 64 * 64; const int kNumPixels = 64 * 64;
class VP9DenoiserTest class VP9DenoiserTest : public ::testing::TestWithParam<BLOCK_SIZE> {
: public ::testing::TestWithParam<int> {
public: public:
virtual ~VP9DenoiserTest() {} virtual ~VP9DenoiserTest() {}
virtual void SetUp() { virtual void SetUp() {
bs = (BLOCK_SIZE)GetParam(); bs_ = GetParam();
} }
virtual void TearDown() { libvpx_test::ClearSystemState(); } virtual void TearDown() { libvpx_test::ClearSystemState(); }
protected: protected:
BLOCK_SIZE bs; BLOCK_SIZE bs_;
}; };
TEST_P(VP9DenoiserTest, BitexactCheck) { TEST_P(VP9DenoiserTest, BitexactCheck) {
...@@ -60,8 +59,8 @@ TEST_P(VP9DenoiserTest, BitexactCheck) { ...@@ -60,8 +59,8 @@ TEST_P(VP9DenoiserTest, BitexactCheck) {
for (int i = 0; i < count_test_block; ++i) { for (int i = 0; i < count_test_block; ++i) {
// Generate random motion magnitude, 20% of which exceed the threshold. // Generate random motion magnitude, 20% of which exceed the threshold.
uint8_t motion_magnitude_random const int motion_magnitude_random =
= rnd.Rand8() % (uint8_t)(MOTION_MAGNITUDE_THRESHOLD * 1.2); rnd.Rand8() % static_cast<int>(MOTION_MAGNITUDE_THRESHOLD * 1.2);
// Initialize a test block with random number in range [0, 255]. // Initialize a test block with random number in range [0, 255].
for (int j = 0; j < kNumPixels; ++j) { for (int j = 0; j < kNumPixels; ++j) {
...@@ -69,23 +68,23 @@ TEST_P(VP9DenoiserTest, BitexactCheck) { ...@@ -69,23 +68,23 @@ TEST_P(VP9DenoiserTest, BitexactCheck) {
sig_block[j] = rnd.Rand8(); sig_block[j] = rnd.Rand8();
// The pixels in mc_avg_block are generated by adding a random // The pixels in mc_avg_block are generated by adding a random
// number in range [-19, 19] to corresponding pixels in sig_block. // number in range [-19, 19] to corresponding pixels in sig_block.
temp = sig_block[j] + (rnd.Rand8() % 2 == 0? -1 : 1) * temp = sig_block[j] + ((rnd.Rand8() % 2 == 0) ? -1 : 1) *
(rnd.Rand8()%20); (rnd.Rand8() % 20);
// Clip. // Clip.
mc_avg_block[j] = (temp < 0? 0 : (temp > 255? 255 : temp)); mc_avg_block[j] = (temp < 0) ? 0 : ((temp > 255) ? 255 : temp);
} }
ASM_REGISTER_STATE_CHECK(vp9_denoiser_filter_c(sig_block, 64, ASM_REGISTER_STATE_CHECK(vp9_denoiser_filter_c(
mc_avg_block, 64, avg_block_c, 64, sig_block, 64, mc_avg_block, 64, avg_block_c,
0, bs, motion_magnitude_random)); 64, 0, bs_, motion_magnitude_random));
ASM_REGISTER_STATE_CHECK(vp9_denoiser_filter_sse2(sig_block, 64, ASM_REGISTER_STATE_CHECK(vp9_denoiser_filter_sse2(
mc_avg_block, 64, avg_block_sse2, 64, sig_block, 64, mc_avg_block, 64, avg_block_sse2,
0, bs, motion_magnitude_random)); 64, 0, bs_, motion_magnitude_random));
// Test bitexactness. // Test bitexactness.
for (int h = 0; h < (4 << b_height_log2_lookup[bs]); ++h) { for (int h = 0; h < (4 << b_height_log2_lookup[bs_]); ++h) {
for (int w = 0; w < (4 << b_width_log2_lookup[bs]); ++w) { for (int w = 0; w < (4 << b_width_log2_lookup[bs_]); ++w) {
EXPECT_EQ(avg_block_c[h * 64 + w], avg_block_sse2[h * 64 + w]); EXPECT_EQ(avg_block_c[h * 64 + w], avg_block_sse2[h * 64 + w]);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment