2012-02-21 17:57:14 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2012-05-17 01:25:51 +02:00
|
|
|
extern "C" {
|
2013-03-12 19:24:04 +01:00
|
|
|
#include "./vpx_config.h"
|
|
|
|
#include "./vp8_rtcd.h"
|
2012-02-21 17:57:14 +01:00
|
|
|
}
|
2012-11-27 22:08:05 +01:00
|
|
|
#include "test/register_state_check.h"
|
2012-05-17 01:25:51 +02:00
|
|
|
#include "third_party/googletest/src/include/gtest/gtest.h"
|
2012-02-21 17:57:14 +01:00
|
|
|
|
2012-05-17 01:25:51 +02:00
|
|
|
typedef void (*idct_fn_t)(short *input, unsigned char *pred_ptr,
|
|
|
|
int pred_stride, unsigned char *dst_ptr,
|
|
|
|
int dst_stride);
|
|
|
|
namespace {
|
2013-03-12 19:24:04 +01:00
|
|
|
class IDCTTest : public ::testing::TestWithParam<idct_fn_t> {
|
2012-05-17 01:25:51 +02:00
|
|
|
protected:
|
2013-03-12 19:24:04 +01:00
|
|
|
virtual void SetUp() {
|
2012-05-17 01:25:51 +02:00
|
|
|
int i;
|
2012-02-21 17:57:14 +01:00
|
|
|
|
2012-05-17 01:25:51 +02:00
|
|
|
UUT = GetParam();
|
|
|
|
memset(input, 0, sizeof(input));
|
|
|
|
/* Set up guard blocks */
|
2013-03-12 19:24:04 +01:00
|
|
|
for (i = 0; i < 256; i++)
|
|
|
|
output[i] = ((i & 0xF) < 4 && (i < 64)) ? 0 : -1;
|
2012-05-17 01:25:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
idct_fn_t UUT;
|
|
|
|
short input[16];
|
|
|
|
unsigned char output[256];
|
|
|
|
unsigned char predict[256];
|
|
|
|
};
|
|
|
|
|
2013-03-12 19:24:04 +01:00
|
|
|
TEST_P(IDCTTest, TestGuardBlocks) {
|
2012-05-17 01:25:51 +02:00
|
|
|
int i;
|
|
|
|
|
2013-03-12 19:24:04 +01:00
|
|
|
for (i = 0; i < 256; i++)
|
|
|
|
if ((i & 0xF) < 4 && i < 64)
|
2012-05-17 01:25:51 +02:00
|
|
|
EXPECT_EQ(0, output[i]) << i;
|
|
|
|
else
|
|
|
|
EXPECT_EQ(255, output[i]);
|
|
|
|
}
|
|
|
|
|
2013-03-12 19:24:04 +01:00
|
|
|
TEST_P(IDCTTest, TestAllZeros) {
|
2012-05-17 01:25:51 +02:00
|
|
|
int i;
|
|
|
|
|
2012-11-27 22:08:05 +01:00
|
|
|
REGISTER_STATE_CHECK(UUT(input, output, 16, output, 16));
|
2012-05-17 01:25:51 +02:00
|
|
|
|
2013-03-12 19:24:04 +01:00
|
|
|
for (i = 0; i < 256; i++)
|
|
|
|
if ((i & 0xF) < 4 && i < 64)
|
2012-05-17 01:25:51 +02:00
|
|
|
EXPECT_EQ(0, output[i]) << "i==" << i;
|
|
|
|
else
|
|
|
|
EXPECT_EQ(255, output[i]) << "i==" << i;
|
|
|
|
}
|
|
|
|
|
2013-03-12 19:24:04 +01:00
|
|
|
TEST_P(IDCTTest, TestAllOnes) {
|
2012-05-17 01:25:51 +02:00
|
|
|
int i;
|
2012-02-21 17:57:14 +01:00
|
|
|
|
2012-05-17 01:25:51 +02:00
|
|
|
input[0] = 4;
|
2012-11-27 22:08:05 +01:00
|
|
|
REGISTER_STATE_CHECK(UUT(input, output, 16, output, 16));
|
2012-02-21 17:57:14 +01:00
|
|
|
|
2013-03-12 19:24:04 +01:00
|
|
|
for (i = 0; i < 256; i++)
|
|
|
|
if ((i & 0xF) < 4 && i < 64)
|
2012-05-17 01:25:51 +02:00
|
|
|
EXPECT_EQ(1, output[i]) << "i==" << i;
|
|
|
|
else
|
|
|
|
EXPECT_EQ(255, output[i]) << "i==" << i;
|
|
|
|
}
|
|
|
|
|
2013-03-12 19:24:04 +01:00
|
|
|
TEST_P(IDCTTest, TestAddOne) {
|
2012-05-17 01:25:51 +02:00
|
|
|
int i;
|
|
|
|
|
2013-03-12 19:24:04 +01:00
|
|
|
for (i = 0; i < 256; i++)
|
2012-05-17 01:25:51 +02:00
|
|
|
predict[i] = i;
|
|
|
|
input[0] = 4;
|
2012-11-27 22:08:05 +01:00
|
|
|
REGISTER_STATE_CHECK(UUT(input, predict, 16, output, 16));
|
2012-05-17 01:25:51 +02:00
|
|
|
|
2013-03-12 19:24:04 +01:00
|
|
|
for (i = 0; i < 256; i++)
|
|
|
|
if ((i & 0xF) < 4 && i < 64)
|
2012-05-17 01:25:51 +02:00
|
|
|
EXPECT_EQ(i+1, output[i]) << "i==" << i;
|
|
|
|
else
|
|
|
|
EXPECT_EQ(255, output[i]) << "i==" << i;
|
|
|
|
}
|
|
|
|
|
2013-03-12 19:24:04 +01:00
|
|
|
TEST_P(IDCTTest, TestWithData) {
|
2012-05-17 01:25:51 +02:00
|
|
|
int i;
|
|
|
|
|
2013-03-12 19:24:04 +01:00
|
|
|
for (i = 0; i < 16; i++)
|
2012-05-17 01:25:51 +02:00
|
|
|
input[i] = i;
|
|
|
|
|
2012-11-27 22:08:05 +01:00
|
|
|
REGISTER_STATE_CHECK(UUT(input, output, 16, output, 16));
|
2012-05-17 01:25:51 +02:00
|
|
|
|
2013-03-12 19:24:04 +01:00
|
|
|
for (i = 0; i < 256; i++)
|
|
|
|
if ((i & 0xF) > 3 || i > 63)
|
2012-05-17 01:25:51 +02:00
|
|
|
EXPECT_EQ(255, output[i]) << "i==" << i;
|
2013-03-12 19:24:04 +01:00
|
|
|
else if (i == 0)
|
2012-05-17 01:25:51 +02:00
|
|
|
EXPECT_EQ(11, output[i]) << "i==" << i;
|
2013-03-12 19:24:04 +01:00
|
|
|
else if (i == 34)
|
2012-05-17 01:25:51 +02:00
|
|
|
EXPECT_EQ(1, output[i]) << "i==" << i;
|
2013-03-12 19:24:04 +01:00
|
|
|
else if (i == 2 || i == 17 || i == 32)
|
2012-05-17 01:25:51 +02:00
|
|
|
EXPECT_EQ(3, output[i]) << "i==" << i;
|
|
|
|
else
|
|
|
|
EXPECT_EQ(0, output[i]) << "i==" << i;
|
|
|
|
}
|
|
|
|
|
|
|
|
INSTANTIATE_TEST_CASE_P(C, IDCTTest,
|
|
|
|
::testing::Values(vp8_short_idct4x4llm_c));
|
|
|
|
#if HAVE_MMX
|
|
|
|
INSTANTIATE_TEST_CASE_P(MMX, IDCTTest,
|
|
|
|
::testing::Values(vp8_short_idct4x4llm_mmx));
|
|
|
|
#endif
|
2012-02-21 17:57:14 +01:00
|
|
|
}
|