2015-10-28 02:41:38 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2015 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.
|
|
|
|
*/
|
|
|
|
|
2016-08-31 00:01:10 +03:00
|
|
|
#include "av1/common/av1_fwd_txfm1d.h"
|
|
|
|
#include "test/av1_txfm_test.h"
|
2015-10-28 02:41:38 +03:00
|
|
|
|
2016-08-23 02:08:15 +03:00
|
|
|
using libaom_test::ACMRandom;
|
|
|
|
using libaom_test::input_base;
|
|
|
|
using libaom_test::reference_hybrid_1d;
|
|
|
|
using libaom_test::TYPE_TXFM;
|
|
|
|
using libaom_test::TYPE_DCT;
|
|
|
|
using libaom_test::TYPE_ADST;
|
2015-10-28 02:41:38 +03:00
|
|
|
|
|
|
|
namespace {
|
2016-03-30 00:27:50 +03:00
|
|
|
const int txfm_type_num = 2;
|
2016-08-12 03:46:05 +03:00
|
|
|
const TYPE_TXFM txfm_type_ls[2] = { TYPE_DCT, TYPE_ADST };
|
2015-10-28 02:41:38 +03:00
|
|
|
|
2016-03-30 00:27:50 +03:00
|
|
|
const int txfm_size_num = 5;
|
2016-10-18 22:24:20 +03:00
|
|
|
const int txfm_size_ls[5] = { 4, 8, 16, 32, 64 };
|
2015-10-28 02:41:38 +03:00
|
|
|
|
2016-03-30 00:27:50 +03:00
|
|
|
const TxfmFunc fwd_txfm_func_ls[2][5] = {
|
2016-10-18 22:24:20 +03:00
|
|
|
#if CONFIG_TX64X64
|
|
|
|
{ av1_fdct4_new, av1_fdct8_new, av1_fdct16_new, av1_fdct32_new,
|
|
|
|
av1_fdct64_new },
|
|
|
|
#else
|
2016-08-31 00:01:10 +03:00
|
|
|
{ av1_fdct4_new, av1_fdct8_new, av1_fdct16_new, av1_fdct32_new, NULL },
|
2016-10-18 22:24:20 +03:00
|
|
|
#endif
|
2016-08-31 00:01:10 +03:00
|
|
|
{ av1_fadst4_new, av1_fadst8_new, av1_fadst16_new, av1_fadst32_new, NULL }
|
2016-08-12 03:46:05 +03:00
|
|
|
};
|
2015-10-28 02:41:38 +03:00
|
|
|
|
|
|
|
// the maximum stage number of fwd/inv 1d dct/adst txfm is 12
|
2016-08-12 03:46:05 +03:00
|
|
|
const int8_t cos_bit[12] = { 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14 };
|
|
|
|
const int8_t range_bit[12] = { 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32 };
|
2015-10-28 02:41:38 +03:00
|
|
|
|
2016-08-31 00:01:10 +03:00
|
|
|
TEST(av1_fwd_txfm1d, round_shift) {
|
2016-03-23 20:59:32 +03:00
|
|
|
EXPECT_EQ(round_shift(7, 1), 4);
|
2015-10-28 02:41:38 +03:00
|
|
|
EXPECT_EQ(round_shift(-7, 1), -3);
|
|
|
|
|
|
|
|
EXPECT_EQ(round_shift(7, 2), 2);
|
|
|
|
EXPECT_EQ(round_shift(-7, 2), -2);
|
|
|
|
|
|
|
|
EXPECT_EQ(round_shift(8, 2), 2);
|
|
|
|
EXPECT_EQ(round_shift(-8, 2), -2);
|
|
|
|
}
|
|
|
|
|
2016-08-31 00:01:10 +03:00
|
|
|
TEST(av1_fwd_txfm1d, get_max_bit) {
|
2015-10-28 02:41:38 +03:00
|
|
|
int max_bit = get_max_bit(8);
|
|
|
|
EXPECT_EQ(max_bit, 3);
|
|
|
|
}
|
|
|
|
|
2016-08-31 00:01:10 +03:00
|
|
|
TEST(av1_fwd_txfm1d, cospi_arr) {
|
2015-10-28 02:41:38 +03:00
|
|
|
for (int i = 0; i < 7; i++) {
|
|
|
|
for (int j = 0; j < 64; j++) {
|
|
|
|
EXPECT_EQ(cospi_arr[i][j],
|
|
|
|
(int32_t)round(cos(M_PI * j / 128) * (1 << (cos_bit_min + i))));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-31 00:01:10 +03:00
|
|
|
TEST(av1_fwd_txfm1d, clamp_block) {
|
2016-08-12 03:46:05 +03:00
|
|
|
int16_t block[5][5] = { { 7, -5, 6, -3, 9 },
|
|
|
|
{ 7, -5, 6, -3, 9 },
|
|
|
|
{ 7, -5, 6, -3, 9 },
|
|
|
|
{ 7, -5, 6, -3, 9 },
|
|
|
|
{ 7, -5, 6, -3, 9 } };
|
2015-10-28 02:41:38 +03:00
|
|
|
|
2016-08-12 03:46:05 +03:00
|
|
|
int16_t ref_block[5][5] = { { 7, -5, 6, -3, 9 },
|
|
|
|
{ 7, -5, 6, -3, 9 },
|
|
|
|
{ 7, -4, 2, -3, 9 },
|
|
|
|
{ 7, -4, 2, -3, 9 },
|
|
|
|
{ 7, -4, 2, -3, 9 } };
|
2015-10-28 02:41:38 +03:00
|
|
|
|
|
|
|
int row = 2;
|
|
|
|
int col = 1;
|
|
|
|
int block_size = 3;
|
|
|
|
int stride = 5;
|
|
|
|
clamp_block(block[row] + col, block_size, stride, -4, 2);
|
|
|
|
for (int r = 0; r < stride; r++) {
|
|
|
|
for (int c = 0; c < stride; c++) {
|
|
|
|
EXPECT_EQ(block[r][c], ref_block[r][c]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-31 00:01:10 +03:00
|
|
|
TEST(av1_fwd_txfm1d, accuracy) {
|
2015-10-28 02:41:38 +03:00
|
|
|
ACMRandom rnd(ACMRandom::DeterministicSeed());
|
|
|
|
for (int si = 0; si < txfm_size_num; ++si) {
|
|
|
|
int txfm_size = txfm_size_ls[si];
|
|
|
|
int32_t *input = new int32_t[txfm_size];
|
|
|
|
int32_t *output = new int32_t[txfm_size];
|
|
|
|
double *ref_input = new double[txfm_size];
|
|
|
|
double *ref_output = new double[txfm_size];
|
|
|
|
|
|
|
|
for (int ti = 0; ti < txfm_type_num; ++ti) {
|
|
|
|
TYPE_TXFM txfm_type = txfm_type_ls[ti];
|
|
|
|
TxfmFunc fwd_txfm_func = fwd_txfm_func_ls[ti][si];
|
|
|
|
int max_error = 7;
|
|
|
|
|
|
|
|
const int count_test_block = 5000;
|
2016-03-14 22:02:27 +03:00
|
|
|
if (fwd_txfm_func != NULL) {
|
|
|
|
for (int ti = 0; ti < count_test_block; ++ti) {
|
|
|
|
for (int ni = 0; ni < txfm_size; ++ni) {
|
2016-04-19 21:59:00 +03:00
|
|
|
input[ni] = rnd.Rand16() % input_base - rnd.Rand16() % input_base;
|
2016-03-14 22:02:27 +03:00
|
|
|
ref_input[ni] = static_cast<double>(input[ni]);
|
|
|
|
}
|
|
|
|
|
|
|
|
fwd_txfm_func(input, output, cos_bit, range_bit);
|
|
|
|
reference_hybrid_1d(ref_input, ref_output, txfm_size, txfm_type);
|
|
|
|
|
|
|
|
for (int ni = 0; ni < txfm_size; ++ni) {
|
|
|
|
EXPECT_LE(
|
|
|
|
abs(output[ni] - static_cast<int32_t>(round(ref_output[ni]))),
|
|
|
|
max_error);
|
|
|
|
}
|
2015-10-28 02:41:38 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
delete[] input;
|
|
|
|
delete[] output;
|
|
|
|
delete[] ref_input;
|
|
|
|
delete[] ref_output;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} // namespace
|