2 * Copyright (c) 2010 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 "./vpx_config.h"
12 #include "./vp8_rtcd.h"
13 #include "test/clear_system_state.h"
14 #include "test/register_state_check.h"
15 #include "third_party/googletest/src/include/gtest/gtest.h"
17 #include "vpx/vpx_integer.h"
19 typedef void (*IdctFunc)(int16_t *input, unsigned char *pred_ptr,
20 int pred_stride, unsigned char *dst_ptr,
23 class IDCTTest : public ::testing::TestWithParam<IdctFunc> {
25 virtual void SetUp() {
29 memset(input, 0, sizeof(input));
30 /* Set up guard blocks */
31 for (i = 0; i < 256; i++) output[i] = ((i & 0xF) < 4 && (i < 64)) ? 0 : -1;
34 virtual void TearDown() { libvpx_test::ClearSystemState(); }
38 unsigned char output[256];
39 unsigned char predict[256];
42 TEST_P(IDCTTest, TestGuardBlocks) {
45 for (i = 0; i < 256; i++)
46 if ((i & 0xF) < 4 && i < 64)
47 EXPECT_EQ(0, output[i]) << i;
49 EXPECT_EQ(255, output[i]);
52 TEST_P(IDCTTest, TestAllZeros) {
55 ASM_REGISTER_STATE_CHECK(UUT(input, output, 16, output, 16));
57 for (i = 0; i < 256; i++)
58 if ((i & 0xF) < 4 && i < 64)
59 EXPECT_EQ(0, output[i]) << "i==" << i;
61 EXPECT_EQ(255, output[i]) << "i==" << i;
64 TEST_P(IDCTTest, TestAllOnes) {
68 ASM_REGISTER_STATE_CHECK(UUT(input, output, 16, output, 16));
70 for (i = 0; i < 256; i++)
71 if ((i & 0xF) < 4 && i < 64)
72 EXPECT_EQ(1, output[i]) << "i==" << i;
74 EXPECT_EQ(255, output[i]) << "i==" << i;
77 TEST_P(IDCTTest, TestAddOne) {
80 for (i = 0; i < 256; i++) predict[i] = i;
82 ASM_REGISTER_STATE_CHECK(UUT(input, predict, 16, output, 16));
84 for (i = 0; i < 256; i++)
85 if ((i & 0xF) < 4 && i < 64)
86 EXPECT_EQ(i + 1, output[i]) << "i==" << i;
88 EXPECT_EQ(255, output[i]) << "i==" << i;
91 TEST_P(IDCTTest, TestWithData) {
94 for (i = 0; i < 16; i++) input[i] = i;
96 ASM_REGISTER_STATE_CHECK(UUT(input, output, 16, output, 16));
98 for (i = 0; i < 256; i++)
99 if ((i & 0xF) > 3 || i > 63)
100 EXPECT_EQ(255, output[i]) << "i==" << i;
102 EXPECT_EQ(11, output[i]) << "i==" << i;
104 EXPECT_EQ(1, output[i]) << "i==" << i;
105 else if (i == 2 || i == 17 || i == 32)
106 EXPECT_EQ(3, output[i]) << "i==" << i;
108 EXPECT_EQ(0, output[i]) << "i==" << i;
111 INSTANTIATE_TEST_CASE_P(C, IDCTTest, ::testing::Values(vp8_short_idct4x4llm_c));
113 INSTANTIATE_TEST_CASE_P(MMX, IDCTTest,
114 ::testing::Values(vp8_short_idct4x4llm_mmx));