blob: 8f0022d54b453a01fc2b28a2604471aeea8171de [file] [log] [blame]
Angie Chiangb9341482015-10-27 16:41:38 -07001/*
2 * Copyright (c) 2015 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 Xuf883b422016-08-30 14:01:10 -070011#ifndef AV1_TXFM_TEST_H_
12#define AV1_TXFM_TEST_H_
Angie Chiangb9341482015-10-27 16:41:38 -070013
14#include <stdio.h>
15#include <stdlib.h>
Yaowu Xu4bc259d2015-11-09 12:07:25 -080016#ifdef _MSC_VER
17#define _USE_MATH_DEFINES
18#endif
Angie Chiangb9341482015-10-27 16:41:38 -070019#include <math.h>
20
21#include "third_party/googletest/src/include/gtest/gtest.h"
22
23#include "test/acm_random.h"
Yaowu Xuc27fc142016-08-22 16:08:15 -070024#include "av1/common/enums.h"
Yaowu Xuf883b422016-08-30 14:01:10 -070025#include "av1/common/av1_txfm.h"
26#include "./av1_rtcd.h"
Angie Chiangb9341482015-10-27 16:41:38 -070027
Yaowu Xuc27fc142016-08-22 16:08:15 -070028namespace libaom_test {
Angie Chiangb9341482015-10-27 16:41:38 -070029typedef enum {
30 TYPE_DCT = 0,
31 TYPE_ADST,
32 TYPE_IDCT,
33 TYPE_IADST,
34 TYPE_LAST
35} TYPE_TXFM;
36
Angie Chiang716f1bd2016-05-11 16:41:36 -070037int get_txfm1d_size(TX_SIZE tx_size);
Angie Chiangb9341482015-10-27 16:41:38 -070038
clang-format3a826f12016-08-11 17:46:05 -070039void get_txfm1d_type(TX_TYPE txfm2d_type, TYPE_TXFM *type0, TYPE_TXFM *type1);
Angie Chiangb9341482015-10-27 16:41:38 -070040
clang-format3a826f12016-08-11 17:46:05 -070041void reference_dct_1d(const double *in, double *out, int size);
Angie Chiangb9341482015-10-27 16:41:38 -070042
clang-format3a826f12016-08-11 17:46:05 -070043void reference_adst_1d(const double *in, double *out, int size);
Angie Chiangb9341482015-10-27 16:41:38 -070044
clang-format3a826f12016-08-11 17:46:05 -070045void reference_hybrid_1d(double *in, double *out, int size, int type);
Angie Chiangb9341482015-10-27 16:41:38 -070046
clang-format3a826f12016-08-11 17:46:05 -070047void reference_hybrid_2d(double *in, double *out, int size, int type0,
48 int type1);
Angie Chiangb9341482015-10-27 16:41:38 -070049template <typename Type1, typename Type2>
clang-format3a826f12016-08-11 17:46:05 -070050static double compute_avg_abs_error(const Type1 *a, const Type2 *b,
Angie Chiangb9341482015-10-27 16:41:38 -070051 const int size) {
52 double error = 0;
53 for (int i = 0; i < size; i++) {
54 error += fabs(static_cast<double>(a[i]) - static_cast<double>(b[i]));
55 }
56 error = error / size;
57 return error;
58}
59
clang-format3a826f12016-08-11 17:46:05 -070060template <typename Type>
Angie Chiang6a752532016-05-11 18:50:47 -070061void fliplr(Type *dest, int stride, int length);
62
clang-format3a826f12016-08-11 17:46:05 -070063template <typename Type>
Angie Chiang6a752532016-05-11 18:50:47 -070064void flipud(Type *dest, int stride, int length);
65
clang-format3a826f12016-08-11 17:46:05 -070066template <typename Type>
Angie Chiang6a752532016-05-11 18:50:47 -070067void fliplrud(Type *dest, int stride, int length);
68
clang-format3a826f12016-08-11 17:46:05 -070069typedef void (*TxfmFunc)(const int32_t *in, int32_t *out, const int8_t *cos_bit,
70 const int8_t *range_bit);
Angie Chiangb9341482015-10-27 16:41:38 -070071
clang-format3a826f12016-08-11 17:46:05 -070072typedef void (*Fwd_Txfm2d_Func)(const int16_t *, int32_t *, int, int, int);
73typedef void (*Inv_Txfm2d_Func)(const int32_t *, uint16_t *, int, int, int);
Angie Chiangb9341482015-10-27 16:41:38 -070074
75static const int bd = 10;
Angie Chiang218dfbd2016-04-19 11:59:00 -070076static const int input_base = (1 << bd);
Angie Chiangfdaad9f2016-05-12 17:11:27 -070077
Yaowu Xuf883b422016-08-30 14:01:10 -070078#if CONFIG_AOM_HIGHBITDEPTH
Angie Chiangfdaad9f2016-05-12 17:11:27 -070079static const Fwd_Txfm2d_Func fwd_txfm_func_ls[TX_SIZES] = {
Yaowu Xuf883b422016-08-30 14:01:10 -070080 av1_fwd_txfm2d_4x4_c, av1_fwd_txfm2d_8x8_c, av1_fwd_txfm2d_16x16_c,
81 av1_fwd_txfm2d_32x32_c
clang-format3a826f12016-08-11 17:46:05 -070082};
Angie Chiangfdaad9f2016-05-12 17:11:27 -070083
84static const Inv_Txfm2d_Func inv_txfm_func_ls[TX_SIZES] = {
Yaowu Xuf883b422016-08-30 14:01:10 -070085 av1_inv_txfm2d_add_4x4_c, av1_inv_txfm2d_add_8x8_c,
86 av1_inv_txfm2d_add_16x16_c, av1_inv_txfm2d_add_32x32_c
clang-format3a826f12016-08-11 17:46:05 -070087};
Yaowu Xuf883b422016-08-30 14:01:10 -070088#endif // CONFIG_AOM_HIGHBITDEPTH
Angie Chiangfdaad9f2016-05-12 17:11:27 -070089
Yaowu Xuc27fc142016-08-22 16:08:15 -070090} // namespace libaom_test
Yaowu Xuf883b422016-08-30 14:01:10 -070091#endif // AV1_TXFM_TEST_H_