]> granicus.if.org Git - libvpx/blob - test/idct_test.cc
Merge "Removed shadow warnings : postproc.c decodframe.c threading.c"
[libvpx] / test / idct_test.cc
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
12 extern "C" {
13 #include "./vpx_config.h"
14 #include "./vp8_rtcd.h"
15 }
16 #include "test/register_state_check.h"
17 #include "third_party/googletest/src/include/gtest/gtest.h"
18
19 typedef void (*idct_fn_t)(short *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:
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++)
32             output[i] = ((i & 0xF) < 4 && (i < 64)) ? 0 : -1;
33     }
34
35     idct_fn_t UUT;
36     short input[16];
37     unsigned char output[256];
38     unsigned char predict[256];
39 };
40
41 TEST_P(IDCTTest, TestGuardBlocks) {
42     int i;
43
44     for (i = 0; i < 256; i++)
45         if ((i & 0xF) < 4 && i < 64)
46             EXPECT_EQ(0, output[i]) << i;
47         else
48             EXPECT_EQ(255, output[i]);
49 }
50
51 TEST_P(IDCTTest, TestAllZeros) {
52     int i;
53
54     REGISTER_STATE_CHECK(UUT(input, output, 16, output, 16));
55
56     for (i = 0; i < 256; i++)
57         if ((i & 0xF) < 4 && i < 64)
58             EXPECT_EQ(0, output[i]) << "i==" << i;
59         else
60             EXPECT_EQ(255, output[i]) << "i==" << i;
61 }
62
63 TEST_P(IDCTTest, TestAllOnes) {
64     int i;
65
66     input[0] = 4;
67     REGISTER_STATE_CHECK(UUT(input, output, 16, output, 16));
68
69     for (i = 0; i < 256; i++)
70         if ((i & 0xF) < 4 && i < 64)
71             EXPECT_EQ(1, output[i]) << "i==" << i;
72         else
73             EXPECT_EQ(255, output[i]) << "i==" << i;
74 }
75
76 TEST_P(IDCTTest, TestAddOne) {
77     int i;
78
79     for (i = 0; i < 256; i++)
80         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
91 TEST_P(IDCTTest, TestWithData) {
92     int i;
93
94     for (i = 0; i < 16; i++)
95         input[i] = i;
96
97     REGISTER_STATE_CHECK(UUT(input, output, 16, output, 16));
98
99     for (i = 0; i < 256; i++)
100         if ((i & 0xF) > 3 || i > 63)
101             EXPECT_EQ(255, output[i]) << "i==" << i;
102         else if (i == 0)
103             EXPECT_EQ(11, output[i]) << "i==" << i;
104         else if (i == 34)
105             EXPECT_EQ(1, output[i]) << "i==" << i;
106         else if (i == 2 || i == 17 || i == 32)
107             EXPECT_EQ(3, output[i]) << "i==" << i;
108         else
109             EXPECT_EQ(0, output[i]) << "i==" << i;
110 }
111
112 INSTANTIATE_TEST_CASE_P(C, IDCTTest,
113                         ::testing::Values(vp8_short_idct4x4llm_c));
114 #if HAVE_MMX
115 INSTANTIATE_TEST_CASE_P(MMX, IDCTTest,
116                         ::testing::Values(vp8_short_idct4x4llm_mmx));
117 #endif
118 }