blob: 39db3e4c6115f66fb1c4b553abdd5390b3a32e1b [file] [log] [blame]
James Berry0c1cec22012-02-21 11:57:14 -05001/*
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
Yaowu Xu00555262013-03-12 11:24:04 -070011#include "./vpx_config.h"
12#include "./vp8_rtcd.h"
Jingning Han097d59c2015-07-29 14:51:36 -070013
John Koleszare82d2612012-05-16 16:25:51 -070014#include "third_party/googletest/src/include/gtest/gtest.h"
15
Jingning Han097d59c2015-07-29 14:51:36 -070016#include "test/clear_system_state.h"
17#include "test/register_state_check.h"
James Zern563c2732013-09-09 22:20:41 -070018#include "vpx/vpx_integer.h"
19
James Zern75d56b32014-07-16 18:57:11 -070020typedef void (*IdctFunc)(int16_t *input, unsigned char *pred_ptr,
21 int pred_stride, unsigned char *dst_ptr,
22 int dst_stride);
John Koleszare82d2612012-05-16 16:25:51 -070023namespace {
James Zern75d56b32014-07-16 18:57:11 -070024class IDCTTest : public ::testing::TestWithParam<IdctFunc> {
James Zern36b882e2013-07-18 15:42:06 -070025 protected:
26 virtual void SetUp() {
27 int i;
John Koleszare82d2612012-05-16 16:25:51 -070028
James Zern36b882e2013-07-18 15:42:06 -070029 UUT = GetParam();
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;
33 }
John Koleszare82d2612012-05-16 16:25:51 -070034
James Zern36b882e2013-07-18 15:42:06 -070035 virtual void TearDown() { libvpx_test::ClearSystemState(); }
James Zern5b756742013-06-17 22:58:40 -070036
James Zern75d56b32014-07-16 18:57:11 -070037 IdctFunc UUT;
Yaowu Xuafffa3d2013-09-05 08:45:56 -070038 int16_t input[16];
James Zern36b882e2013-07-18 15:42:06 -070039 unsigned char output[256];
40 unsigned char predict[256];
John Koleszare82d2612012-05-16 16:25:51 -070041};
42
Yaowu Xu00555262013-03-12 11:24:04 -070043TEST_P(IDCTTest, TestGuardBlocks) {
James Zern36b882e2013-07-18 15:42:06 -070044 int i;
John Koleszare82d2612012-05-16 16:25:51 -070045
James Zern36b882e2013-07-18 15:42:06 -070046 for (i = 0; i < 256; i++)
47 if ((i & 0xF) < 4 && i < 64)
48 EXPECT_EQ(0, output[i]) << i;
49 else
50 EXPECT_EQ(255, output[i]);
James Berry0c1cec22012-02-21 11:57:14 -050051}
52
Yaowu Xu00555262013-03-12 11:24:04 -070053TEST_P(IDCTTest, TestAllZeros) {
James Zern36b882e2013-07-18 15:42:06 -070054 int i;
John Koleszare82d2612012-05-16 16:25:51 -070055
James Zern29e1b1a2014-07-09 21:02:02 -070056 ASM_REGISTER_STATE_CHECK(UUT(input, output, 16, output, 16));
John Koleszare82d2612012-05-16 16:25:51 -070057
James Zern36b882e2013-07-18 15:42:06 -070058 for (i = 0; i < 256; i++)
59 if ((i & 0xF) < 4 && i < 64)
60 EXPECT_EQ(0, output[i]) << "i==" << i;
61 else
62 EXPECT_EQ(255, output[i]) << "i==" << i;
John Koleszare82d2612012-05-16 16:25:51 -070063}
64
Yaowu Xu00555262013-03-12 11:24:04 -070065TEST_P(IDCTTest, TestAllOnes) {
James Zern36b882e2013-07-18 15:42:06 -070066 int i;
John Koleszare82d2612012-05-16 16:25:51 -070067
James Zern36b882e2013-07-18 15:42:06 -070068 input[0] = 4;
James Zern29e1b1a2014-07-09 21:02:02 -070069 ASM_REGISTER_STATE_CHECK(UUT(input, output, 16, output, 16));
John Koleszare82d2612012-05-16 16:25:51 -070070
James Zern36b882e2013-07-18 15:42:06 -070071 for (i = 0; i < 256; i++)
72 if ((i & 0xF) < 4 && i < 64)
73 EXPECT_EQ(1, output[i]) << "i==" << i;
74 else
75 EXPECT_EQ(255, output[i]) << "i==" << i;
John Koleszare82d2612012-05-16 16:25:51 -070076}
77
Yaowu Xu00555262013-03-12 11:24:04 -070078TEST_P(IDCTTest, TestAddOne) {
James Zern36b882e2013-07-18 15:42:06 -070079 int i;
John Koleszare82d2612012-05-16 16:25:51 -070080
James Zern36b882e2013-07-18 15:42:06 -070081 for (i = 0; i < 256; i++) predict[i] = i;
82 input[0] = 4;
James Zern29e1b1a2014-07-09 21:02:02 -070083 ASM_REGISTER_STATE_CHECK(UUT(input, predict, 16, output, 16));
John Koleszare82d2612012-05-16 16:25:51 -070084
James Zern36b882e2013-07-18 15:42:06 -070085 for (i = 0; i < 256; i++)
86 if ((i & 0xF) < 4 && i < 64)
87 EXPECT_EQ(i + 1, output[i]) << "i==" << i;
88 else
89 EXPECT_EQ(255, output[i]) << "i==" << i;
John Koleszare82d2612012-05-16 16:25:51 -070090}
91
Yaowu Xu00555262013-03-12 11:24:04 -070092TEST_P(IDCTTest, TestWithData) {
James Zern36b882e2013-07-18 15:42:06 -070093 int i;
John Koleszare82d2612012-05-16 16:25:51 -070094
James Zern36b882e2013-07-18 15:42:06 -070095 for (i = 0; i < 16; i++) input[i] = i;
John Koleszare82d2612012-05-16 16:25:51 -070096
James Zern29e1b1a2014-07-09 21:02:02 -070097 ASM_REGISTER_STATE_CHECK(UUT(input, output, 16, output, 16));
John Koleszare82d2612012-05-16 16:25:51 -070098
James Zern36b882e2013-07-18 15:42:06 -070099 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;
John Koleszare82d2612012-05-16 16:25:51 -0700110}
James Berry0c1cec22012-02-21 11:57:14 -0500111
James Zern36b882e2013-07-18 15:42:06 -0700112INSTANTIATE_TEST_CASE_P(C, IDCTTest, ::testing::Values(vp8_short_idct4x4llm_c));
John Koleszare82d2612012-05-16 16:25:51 -0700113#if HAVE_MMX
114INSTANTIATE_TEST_CASE_P(MMX, IDCTTest,
115 ::testing::Values(vp8_short_idct4x4llm_mmx));
116#endif
Parag Salasakar3d938d72015-07-02 18:08:06 +0530117#if HAVE_MSA
118INSTANTIATE_TEST_CASE_P(MSA, IDCTTest,
119 ::testing::Values(vp8_short_idct4x4llm_msa));
120#endif
James Berry0c1cec22012-02-21 11:57:14 -0500121}