2013-06-21 20:35:37 +04:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "third_party/googletest/src/include/gtest/gtest.h"
|
|
|
|
#include "test/acm_random.h"
|
|
|
|
#include "test/clear_system_state.h"
|
|
|
|
#include "test/register_state_check.h"
|
|
|
|
#include "./vpx_config.h"
|
|
|
|
#include "./vp9_rtcd.h"
|
|
|
|
#include "vp9/common/vp9_blockd.h"
|
2013-06-22 04:03:57 +04:00
|
|
|
#include "vpx_mem/vpx_mem.h"
|
2013-06-21 20:35:37 +04:00
|
|
|
|
|
|
|
typedef void (*subtract_fn_t)(int rows, int cols,
|
|
|
|
int16_t *diff_ptr, ptrdiff_t diff_stride,
|
|
|
|
const uint8_t *src_ptr, ptrdiff_t src_stride,
|
|
|
|
const uint8_t *pred_ptr, ptrdiff_t pred_stride);
|
|
|
|
|
|
|
|
namespace vp9 {
|
|
|
|
|
|
|
|
class VP9SubtractBlockTest : public ::testing::TestWithParam<subtract_fn_t> {
|
|
|
|
public:
|
|
|
|
virtual void TearDown() {
|
|
|
|
libvpx_test::ClearSystemState();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
using libvpx_test::ACMRandom;
|
|
|
|
|
|
|
|
TEST_P(VP9SubtractBlockTest, SimpleSubtract) {
|
|
|
|
ACMRandom rnd(ACMRandom::DeterministicSeed());
|
|
|
|
|
|
|
|
// FIXME(rbultje) split in its own file
|
2013-08-26 22:33:16 +04:00
|
|
|
for (BLOCK_SIZE bsize = BLOCK_4X4; bsize < BLOCK_SIZES;
|
|
|
|
bsize = static_cast<BLOCK_SIZE>(static_cast<int>(bsize) + 1)) {
|
2013-11-22 03:53:06 +04:00
|
|
|
const int block_width = 4 * num_4x4_blocks_wide_lookup[bsize];
|
|
|
|
const int block_height = 4 * num_4x4_blocks_high_lookup[bsize];
|
2013-06-22 04:03:57 +04:00
|
|
|
int16_t *diff = reinterpret_cast<int16_t *>(
|
|
|
|
vpx_memalign(16, sizeof(*diff) * block_width * block_height * 2));
|
|
|
|
uint8_t *pred = reinterpret_cast<uint8_t *>(
|
|
|
|
vpx_memalign(16, block_width * block_height * 2));
|
|
|
|
uint8_t *src = reinterpret_cast<uint8_t *>(
|
|
|
|
vpx_memalign(16, block_width * block_height * 2));
|
2013-06-21 20:35:37 +04:00
|
|
|
|
|
|
|
for (int n = 0; n < 100; n++) {
|
|
|
|
for (int r = 0; r < block_height; ++r) {
|
|
|
|
for (int c = 0; c < block_width * 2; ++c) {
|
|
|
|
src[r * block_width * 2 + c] = rnd.Rand8();
|
|
|
|
pred[r * block_width * 2 + c] = rnd.Rand8();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GetParam()(block_height, block_width, diff, block_width,
|
|
|
|
src, block_width, pred, block_width);
|
|
|
|
|
|
|
|
for (int r = 0; r < block_height; ++r) {
|
|
|
|
for (int c = 0; c < block_width; ++c) {
|
|
|
|
EXPECT_EQ(diff[r * block_width + c],
|
|
|
|
(src[r * block_width + c] -
|
|
|
|
pred[r * block_width + c])) << "r = " << r
|
|
|
|
<< ", c = " << c
|
|
|
|
<< ", bs = " << bsize;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GetParam()(block_height, block_width, diff, block_width * 2,
|
|
|
|
src, block_width * 2, pred, block_width * 2);
|
|
|
|
|
|
|
|
for (int r = 0; r < block_height; ++r) {
|
|
|
|
for (int c = 0; c < block_width; ++c) {
|
|
|
|
EXPECT_EQ(diff[r * block_width * 2 + c],
|
|
|
|
(src[r * block_width * 2 + c] -
|
|
|
|
pred[r * block_width * 2 + c])) << "r = " << r
|
|
|
|
<< ", c = " << c
|
|
|
|
<< ", bs = " << bsize;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-06-22 04:03:57 +04:00
|
|
|
vpx_free(diff);
|
|
|
|
vpx_free(pred);
|
|
|
|
vpx_free(src);
|
2013-06-21 20:35:37 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
INSTANTIATE_TEST_CASE_P(C, VP9SubtractBlockTest,
|
|
|
|
::testing::Values(vp9_subtract_block_c));
|
|
|
|
|
2013-08-06 04:28:52 +04:00
|
|
|
#if HAVE_SSE2 && CONFIG_USE_X86INC
|
2013-06-21 20:35:37 +04:00
|
|
|
INSTANTIATE_TEST_CASE_P(SSE2, VP9SubtractBlockTest,
|
|
|
|
::testing::Values(vp9_subtract_block_sse2));
|
|
|
|
#endif
|
|
|
|
} // namespace vp9
|