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/buffer.h"
17 #include "test/clear_system_state.h"
18 #include "test/register_state_check.h"
19 #include "vpx/vpx_integer.h"
21 typedef void (*IdctFunc)(int16_t *input, unsigned char *pred_ptr,
22 int pred_stride, unsigned char *dst_ptr,
26 using libvpx_test::Buffer;
28 class IDCTTest : public ::testing::TestWithParam<IdctFunc> {
30 virtual void SetUp() {
33 input = new Buffer<int16_t>(4, 4, 0);
34 ASSERT_NE(input, nullptr);
35 ASSERT_TRUE(input->Init());
36 predict = new Buffer<uint8_t>(4, 4, 3);
37 ASSERT_NE(predict, nullptr);
38 ASSERT_TRUE(predict->Init());
39 output = new Buffer<uint8_t>(4, 4, 3);
40 ASSERT_NE(output, nullptr);
41 ASSERT_TRUE(output->Init());
44 virtual void TearDown() {
48 libvpx_test::ClearSystemState();
52 Buffer<int16_t> *input;
53 Buffer<uint8_t> *predict;
54 Buffer<uint8_t> *output;
57 TEST_P(IDCTTest, TestAllZeros) {
58 // When the input is '0' the output will be '0'.
63 ASM_REGISTER_STATE_CHECK(UUT(input->TopLeftPixel(), predict->TopLeftPixel(),
64 predict->stride(), output->TopLeftPixel(),
67 ASSERT_TRUE(input->CheckValues(0));
68 ASSERT_TRUE(input->CheckPadding());
69 ASSERT_TRUE(output->CheckValues(0));
70 ASSERT_TRUE(output->CheckPadding());
73 TEST_P(IDCTTest, TestAllOnes) {
75 ASSERT_NE(input->TopLeftPixel(), nullptr);
76 // When the first element is '4' it will fill the output buffer with '1'.
77 input->TopLeftPixel()[0] = 4;
81 ASM_REGISTER_STATE_CHECK(UUT(input->TopLeftPixel(), predict->TopLeftPixel(),
82 predict->stride(), output->TopLeftPixel(),
85 ASSERT_TRUE(output->CheckValues(1));
86 ASSERT_TRUE(output->CheckPadding());
89 TEST_P(IDCTTest, TestAddOne) {
90 // Set the transform output to '1' and make sure it gets added to the
93 ASSERT_NE(input->TopLeftPixel(), nullptr);
94 input->TopLeftPixel()[0] = 4;
97 uint8_t *pred = predict->TopLeftPixel();
98 for (int y = 0; y < 4; ++y) {
99 for (int x = 0; x < 4; ++x) {
100 pred[y * predict->stride() + x] = y * 4 + x;
104 ASM_REGISTER_STATE_CHECK(UUT(input->TopLeftPixel(), predict->TopLeftPixel(),
105 predict->stride(), output->TopLeftPixel(),
108 uint8_t const *out = output->TopLeftPixel();
109 for (int y = 0; y < 4; ++y) {
110 for (int x = 0; x < 4; ++x) {
111 EXPECT_EQ(1 + y * 4 + x, out[y * output->stride() + x]);
116 output->DumpBuffer();
119 ASSERT_TRUE(output->CheckPadding());
122 TEST_P(IDCTTest, TestWithData) {
123 // Test a single known input.
126 int16_t *in = input->TopLeftPixel();
127 for (int y = 0; y < 4; ++y) {
128 for (int x = 0; x < 4; ++x) {
129 in[y * input->stride() + x] = y * 4 + x;
133 ASM_REGISTER_STATE_CHECK(UUT(input->TopLeftPixel(), predict->TopLeftPixel(),
134 predict->stride(), output->TopLeftPixel(),
137 uint8_t *out = output->TopLeftPixel();
138 for (int y = 0; y < 4; ++y) {
139 for (int x = 0; x < 4; ++x) {
141 case 0: EXPECT_EQ(11, out[y * output->stride() + x]); break;
144 case 8: EXPECT_EQ(3, out[y * output->stride() + x]); break;
145 case 10: EXPECT_EQ(1, out[y * output->stride() + x]); break;
146 default: EXPECT_EQ(0, out[y * output->stride() + x]);
152 output->DumpBuffer();
155 ASSERT_TRUE(output->CheckPadding());
158 INSTANTIATE_TEST_SUITE_P(C, IDCTTest,
159 ::testing::Values(vp8_short_idct4x4llm_c));
162 INSTANTIATE_TEST_SUITE_P(NEON, IDCTTest,
163 ::testing::Values(vp8_short_idct4x4llm_neon));
167 INSTANTIATE_TEST_SUITE_P(MMX, IDCTTest,
168 ::testing::Values(vp8_short_idct4x4llm_mmx));
172 INSTANTIATE_TEST_SUITE_P(MSA, IDCTTest,
173 ::testing::Values(vp8_short_idct4x4llm_msa));
177 INSTANTIATE_TEST_SUITE_P(MMI, IDCTTest,
178 ::testing::Values(vp8_short_idct4x4llm_mmi));