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"
14 #include "third_party/googletest/src/include/gtest/gtest.h"
16 #include "test/clear_system_state.h"
17 #include "test/register_state_check.h"
18 #include "vpx/vpx_integer.h"
20 typedef void (*IdctFunc)(int16_t *input, unsigned char *pred_ptr,
21 int pred_stride, unsigned char *dst_ptr,
24 class IDCTTest : public ::testing::TestWithParam<IdctFunc> {
26 virtual void SetUp() {
30 memset(input, 0, sizeof(input));
31 /* Set up guard blocks */
32 for (i = 0; i < 256; i++) output[i] = ((i & 0xF) < 4 && (i < 64)) ? 0 : -1;
35 virtual void TearDown() { libvpx_test::ClearSystemState(); }
39 unsigned char output[256];
40 unsigned char predict[256];
43 TEST_P(IDCTTest, TestGuardBlocks) {
46 for (i = 0; i < 256; i++) {
47 if ((i & 0xF) < 4 && i < 64)
48 EXPECT_EQ(0, output[i]) << i;
50 EXPECT_EQ(255, output[i]);
54 TEST_P(IDCTTest, TestAllZeros) {
57 ASM_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;
67 TEST_P(IDCTTest, TestAllOnes) {
71 ASM_REGISTER_STATE_CHECK(UUT(input, output, 16, output, 16));
73 for (i = 0; i < 256; i++) {
74 if ((i & 0xF) < 4 && i < 64)
75 EXPECT_EQ(1, output[i]) << "i==" << i;
77 EXPECT_EQ(255, output[i]) << "i==" << i;
81 TEST_P(IDCTTest, TestAddOne) {
84 for (i = 0; i < 256; i++) predict[i] = i;
86 ASM_REGISTER_STATE_CHECK(UUT(input, predict, 16, output, 16));
88 for (i = 0; i < 256; i++) {
89 if ((i & 0xF) < 4 && i < 64)
90 EXPECT_EQ(i + 1, output[i]) << "i==" << i;
92 EXPECT_EQ(255, output[i]) << "i==" << i;
96 TEST_P(IDCTTest, TestWithData) {
99 for (i = 0; i < 16; i++) input[i] = i;
101 ASM_REGISTER_STATE_CHECK(UUT(input, output, 16, output, 16));
103 for (i = 0; i < 256; i++) {
104 if ((i & 0xF) > 3 || i > 63)
105 EXPECT_EQ(255, output[i]) << "i==" << i;
107 EXPECT_EQ(11, output[i]) << "i==" << i;
109 EXPECT_EQ(1, output[i]) << "i==" << i;
110 else if (i == 2 || i == 17 || i == 32)
111 EXPECT_EQ(3, output[i]) << "i==" << i;
113 EXPECT_EQ(0, output[i]) << "i==" << i;
117 INSTANTIATE_TEST_CASE_P(C, IDCTTest, ::testing::Values(vp8_short_idct4x4llm_c));
119 INSTANTIATE_TEST_CASE_P(MMX, IDCTTest,
120 ::testing::Values(vp8_short_idct4x4llm_mmx));
123 INSTANTIATE_TEST_CASE_P(MSA, IDCTTest,
124 ::testing::Values(vp8_short_idct4x4llm_msa));