• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
3  *
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.
9  */
10 
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"
16 
17 #include "vpx/vpx_integer.h"
18 
19 typedef void (*idct_fn_t)(int16_t *input, unsigned char *pred_ptr,
20                           int pred_stride, unsigned char *dst_ptr,
21                           int dst_stride);
22 namespace {
23 class IDCTTest : public ::testing::TestWithParam<idct_fn_t> {
24  protected:
SetUp()25   virtual void SetUp() {
26     int i;
27 
28     UUT = GetParam();
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;
32   }
33 
TearDown()34   virtual void TearDown() { libvpx_test::ClearSystemState(); }
35 
36   idct_fn_t UUT;
37   int16_t input[16];
38   unsigned char output[256];
39   unsigned char predict[256];
40 };
41 
TEST_P(IDCTTest,TestGuardBlocks)42 TEST_P(IDCTTest, TestGuardBlocks) {
43   int i;
44 
45   for (i = 0; i < 256; i++)
46     if ((i & 0xF) < 4 && i < 64)
47       EXPECT_EQ(0, output[i]) << i;
48     else
49       EXPECT_EQ(255, output[i]);
50 }
51 
TEST_P(IDCTTest,TestAllZeros)52 TEST_P(IDCTTest, TestAllZeros) {
53   int i;
54 
55   REGISTER_STATE_CHECK(UUT(input, output, 16, output, 16));
56 
57   for (i = 0; i < 256; i++)
58     if ((i & 0xF) < 4 && i < 64)
59       EXPECT_EQ(0, output[i]) << "i==" << i;
60     else
61       EXPECT_EQ(255, output[i]) << "i==" << i;
62 }
63 
TEST_P(IDCTTest,TestAllOnes)64 TEST_P(IDCTTest, TestAllOnes) {
65   int i;
66 
67   input[0] = 4;
68   REGISTER_STATE_CHECK(UUT(input, output, 16, output, 16));
69 
70   for (i = 0; i < 256; i++)
71     if ((i & 0xF) < 4 && i < 64)
72       EXPECT_EQ(1, output[i]) << "i==" << i;
73     else
74       EXPECT_EQ(255, output[i]) << "i==" << i;
75 }
76 
TEST_P(IDCTTest,TestAddOne)77 TEST_P(IDCTTest, TestAddOne) {
78   int i;
79 
80   for (i = 0; i < 256; i++) predict[i] = i;
81   input[0] = 4;
82   REGISTER_STATE_CHECK(UUT(input, predict, 16, output, 16));
83 
84   for (i = 0; i < 256; i++)
85     if ((i & 0xF) < 4 && i < 64)
86       EXPECT_EQ(i + 1, output[i]) << "i==" << i;
87     else
88       EXPECT_EQ(255, output[i]) << "i==" << i;
89 }
90 
TEST_P(IDCTTest,TestWithData)91 TEST_P(IDCTTest, TestWithData) {
92   int i;
93 
94   for (i = 0; i < 16; i++) input[i] = i;
95 
96   REGISTER_STATE_CHECK(UUT(input, output, 16, output, 16));
97 
98   for (i = 0; i < 256; i++)
99     if ((i & 0xF) > 3 || i > 63)
100       EXPECT_EQ(255, output[i]) << "i==" << i;
101     else if (i == 0)
102       EXPECT_EQ(11, output[i]) << "i==" << i;
103     else if (i == 34)
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;
107     else
108       EXPECT_EQ(0, output[i]) << "i==" << i;
109 }
110 
111 INSTANTIATE_TEST_CASE_P(C, IDCTTest, ::testing::Values(vp8_short_idct4x4llm_c));
112 #if HAVE_MMX
113 INSTANTIATE_TEST_CASE_P(MMX, IDCTTest,
114                         ::testing::Values(vp8_short_idct4x4llm_mmx));
115 #endif
116 }
117