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
]);
53 TEST_P(IDCTTest
, TestAllZeros
) {
56 ASM_REGISTER_STATE_CHECK(UUT(input
, output
, 16, output
, 16));
58 for (i
= 0; i
< 256; i
++)
59 if ((i
& 0xF) < 4 && i
< 64)
60 EXPECT_EQ(0, output
[i
]) << "i==" << i
;
62 EXPECT_EQ(255, output
[i
]) << "i==" << i
;
65 TEST_P(IDCTTest
, TestAllOnes
) {
69 ASM_REGISTER_STATE_CHECK(UUT(input
, output
, 16, output
, 16));
71 for (i
= 0; i
< 256; i
++)
72 if ((i
& 0xF) < 4 && i
< 64)
73 EXPECT_EQ(1, output
[i
]) << "i==" << i
;
75 EXPECT_EQ(255, output
[i
]) << "i==" << i
;
78 TEST_P(IDCTTest
, TestAddOne
) {
81 for (i
= 0; i
< 256; i
++) predict
[i
] = i
;
83 ASM_REGISTER_STATE_CHECK(UUT(input
, predict
, 16, output
, 16));
85 for (i
= 0; i
< 256; i
++)
86 if ((i
& 0xF) < 4 && i
< 64)
87 EXPECT_EQ(i
+ 1, output
[i
]) << "i==" << i
;
89 EXPECT_EQ(255, output
[i
]) << "i==" << i
;
92 TEST_P(IDCTTest
, TestWithData
) {
95 for (i
= 0; i
< 16; i
++) input
[i
] = i
;
97 ASM_REGISTER_STATE_CHECK(UUT(input
, output
, 16, output
, 16));
99 for (i
= 0; i
< 256; i
++)
100 if ((i
& 0xF) > 3 || i
> 63)
101 EXPECT_EQ(255, output
[i
]) << "i==" << i
;
103 EXPECT_EQ(11, output
[i
]) << "i==" << i
;
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
;
109 EXPECT_EQ(0, output
[i
]) << "i==" << i
;
112 INSTANTIATE_TEST_CASE_P(C
, IDCTTest
, ::testing::Values(vp8_short_idct4x4llm_c
));
114 INSTANTIATE_TEST_CASE_P(MMX
, IDCTTest
,
115 ::testing::Values(vp8_short_idct4x4llm_mmx
));
118 INSTANTIATE_TEST_CASE_P(MSA
, IDCTTest
,
119 ::testing::Values(vp8_short_idct4x4llm_msa
));