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.
12 #include "./vpx_config.h"
13 #include "./vp8_rtcd.h"
15 #include "test/clear_system_state.h"
16 #include "test/register_state_check.h"
17 #include "third_party/googletest/src/include/gtest/gtest.h"
19 #include "vpx/vpx_integer.h"
21 typedef void (*idct_fn_t)(int16_t *input, unsigned char *pred_ptr,
22 int pred_stride, unsigned char *dst_ptr,
25 class IDCTTest : public ::testing::TestWithParam<idct_fn_t> {
27 virtual void SetUp() {
31 memset(input, 0, sizeof(input));
32 /* Set up guard blocks */
33 for (i = 0; i < 256; i++) output[i] = ((i & 0xF) < 4 && (i < 64)) ? 0 : -1;
36 virtual void TearDown() { libvpx_test::ClearSystemState(); }
40 unsigned char output[256];
41 unsigned char predict[256];
44 TEST_P(IDCTTest, TestGuardBlocks) {
47 for (i = 0; i < 256; i++)
48 if ((i & 0xF) < 4 && i < 64)
49 EXPECT_EQ(0, output[i]) << i;
51 EXPECT_EQ(255, output[i]);
54 TEST_P(IDCTTest, TestAllZeros) {
57 REGISTER_STATE_CHECK(UUT(input, output, 16, output, 16));
59 for (i = 0; i < 256; i++)
60 if ((i & 0xF) < 4 && i < 64)
61 EXPECT_EQ(0, output[i]) << "i==" << i;
63 EXPECT_EQ(255, output[i]) << "i==" << i;
66 TEST_P(IDCTTest, TestAllOnes) {
70 REGISTER_STATE_CHECK(UUT(input, output, 16, output, 16));
72 for (i = 0; i < 256; i++)
73 if ((i & 0xF) < 4 && i < 64)
74 EXPECT_EQ(1, output[i]) << "i==" << i;
76 EXPECT_EQ(255, output[i]) << "i==" << i;
79 TEST_P(IDCTTest, TestAddOne) {
82 for (i = 0; i < 256; i++) predict[i] = i;
84 REGISTER_STATE_CHECK(UUT(input, predict, 16, output, 16));
86 for (i = 0; i < 256; i++)
87 if ((i & 0xF) < 4 && i < 64)
88 EXPECT_EQ(i + 1, output[i]) << "i==" << i;
90 EXPECT_EQ(255, output[i]) << "i==" << i;
93 TEST_P(IDCTTest, TestWithData) {
96 for (i = 0; i < 16; i++) input[i] = i;
98 REGISTER_STATE_CHECK(UUT(input, output, 16, output, 16));
100 for (i = 0; i < 256; i++)
101 if ((i & 0xF) > 3 || i > 63)
102 EXPECT_EQ(255, output[i]) << "i==" << i;
104 EXPECT_EQ(11, output[i]) << "i==" << i;
106 EXPECT_EQ(1, output[i]) << "i==" << i;
107 else if (i == 2 || i == 17 || i == 32)
108 EXPECT_EQ(3, output[i]) << "i==" << i;
110 EXPECT_EQ(0, output[i]) << "i==" << i;
113 INSTANTIATE_TEST_CASE_P(C, IDCTTest, ::testing::Values(vp8_short_idct4x4llm_c));
115 INSTANTIATE_TEST_CASE_P(MMX, IDCTTest,
116 ::testing::Values(vp8_short_idct4x4llm_mmx));