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 #include "third_party/googletest/src/include/gtest/gtest.h"
13 #include "./vp9_rtcd.h"
14 #include "./vpx_config.h"
15 #include "./vpx_dsp_rtcd.h"
16 #include "test/acm_random.h"
17 #include "test/bench.h"
18 #include "test/clear_system_state.h"
19 #include "test/register_state_check.h"
20 #include "vp9/common/vp9_blockd.h"
21 #include "vpx_ports/msvc.h"
22 #include "vpx_mem/vpx_mem.h"
24 typedef void (*SubtractFunc)(int rows, int cols, int16_t *diff_ptr,
25 ptrdiff_t diff_stride, const uint8_t *src_ptr,
26 ptrdiff_t src_stride, const uint8_t *pred_ptr,
27 ptrdiff_t pred_stride);
31 class VP9SubtractBlockTest : public AbstractBench,
32 public ::testing::TestWithParam<SubtractFunc> {
34 virtual void TearDown() { libvpx_test::ClearSystemState(); }
38 GetParam()(block_height_, block_width_, diff_, block_width_, src_,
39 block_width_, pred_, block_width_);
42 void SetupBlocks(BLOCK_SIZE bsize) {
43 block_width_ = 4 * num_4x4_blocks_wide_lookup[bsize];
44 block_height_ = 4 * num_4x4_blocks_high_lookup[bsize];
45 diff_ = reinterpret_cast<int16_t *>(
46 vpx_memalign(16, sizeof(*diff_) * block_width_ * block_height_ * 2));
47 pred_ = reinterpret_cast<uint8_t *>(
48 vpx_memalign(16, block_width_ * block_height_ * 2));
49 src_ = reinterpret_cast<uint8_t *>(
50 vpx_memalign(16, block_width_ * block_height_ * 2));
60 using libvpx_test::ACMRandom;
62 TEST_P(VP9SubtractBlockTest, DISABLED_Speed) {
63 ACMRandom rnd(ACMRandom::DeterministicSeed());
65 for (BLOCK_SIZE bsize = BLOCK_4X4; bsize < BLOCK_SIZES;
66 bsize = static_cast<BLOCK_SIZE>(static_cast<int>(bsize) + 1)) {
69 RunNTimes(100000000 / (block_height_ * block_width_));
71 snprintf(block_size, sizeof(block_size), "%dx%d", block_height_,
74 snprintf(title, sizeof(title), "%8s ", block_size);
83 TEST_P(VP9SubtractBlockTest, SimpleSubtract) {
84 ACMRandom rnd(ACMRandom::DeterministicSeed());
86 for (BLOCK_SIZE bsize = BLOCK_4X4; bsize < BLOCK_SIZES;
87 bsize = static_cast<BLOCK_SIZE>(static_cast<int>(bsize) + 1)) {
90 for (int n = 0; n < 100; n++) {
91 for (int r = 0; r < block_height_; ++r) {
92 for (int c = 0; c < block_width_ * 2; ++c) {
93 src_[r * block_width_ * 2 + c] = rnd.Rand8();
94 pred_[r * block_width_ * 2 + c] = rnd.Rand8();
98 GetParam()(block_height_, block_width_, diff_, block_width_, src_,
99 block_width_, pred_, block_width_);
101 for (int r = 0; r < block_height_; ++r) {
102 for (int c = 0; c < block_width_; ++c) {
103 EXPECT_EQ(diff_[r * block_width_ + c],
104 (src_[r * block_width_ + c] - pred_[r * block_width_ + c]))
105 << "r = " << r << ", c = " << c
106 << ", bs = " << static_cast<int>(bsize);
110 GetParam()(block_height_, block_width_, diff_, block_width_ * 2, src_,
111 block_width_ * 2, pred_, block_width_ * 2);
113 for (int r = 0; r < block_height_; ++r) {
114 for (int c = 0; c < block_width_; ++c) {
115 EXPECT_EQ(diff_[r * block_width_ * 2 + c],
116 (src_[r * block_width_ * 2 + c] -
117 pred_[r * block_width_ * 2 + c]))
118 << "r = " << r << ", c = " << c
119 << ", bs = " << static_cast<int>(bsize);
129 INSTANTIATE_TEST_SUITE_P(C, VP9SubtractBlockTest,
130 ::testing::Values(vpx_subtract_block_c));
133 INSTANTIATE_TEST_SUITE_P(SSE2, VP9SubtractBlockTest,
134 ::testing::Values(vpx_subtract_block_sse2));
137 INSTANTIATE_TEST_SUITE_P(NEON, VP9SubtractBlockTest,
138 ::testing::Values(vpx_subtract_block_neon));
141 INSTANTIATE_TEST_SUITE_P(MSA, VP9SubtractBlockTest,
142 ::testing::Values(vpx_subtract_block_msa));
146 INSTANTIATE_TEST_SUITE_P(MMI, VP9SubtractBlockTest,
147 ::testing::Values(vpx_subtract_block_mmi));
151 INSTANTIATE_TEST_SUITE_P(VSX, VP9SubtractBlockTest,
152 ::testing::Values(vpx_subtract_block_vsx));