blob: b786665c2fba767bc744306f6e091f4c3b5102b8 [file] [log] [blame]
Angie Chiangb9341482015-10-27 16:41:38 -07001/*
Yaowu Xubde4ac82016-11-28 15:26:06 -08002 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
Angie Chiangb9341482015-10-27 16:41:38 -07003 *
Yaowu Xubde4ac82016-11-28 15:26:06 -08004 * This source code is subject to the terms of the BSD 2 Clause License and
5 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6 * was not distributed with this source code in the LICENSE file, you can
7 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8 * Media Patent License 1.0 was not distributed with this source code in the
9 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
Angie Chiangb9341482015-10-27 16:41:38 -070010 */
11
Yaowu Xuf883b422016-08-30 14:01:10 -070012#ifndef AV1_TXFM_TEST_H_
13#define AV1_TXFM_TEST_H_
Angie Chiangb9341482015-10-27 16:41:38 -070014
15#include <stdio.h>
16#include <stdlib.h>
Yaowu Xu4bc259d2015-11-09 12:07:25 -080017#ifdef _MSC_VER
18#define _USE_MATH_DEFINES
19#endif
Angie Chiangb9341482015-10-27 16:41:38 -070020#include <math.h>
21
22#include "third_party/googletest/src/include/gtest/gtest.h"
23
24#include "test/acm_random.h"
Yaowu Xuc27fc142016-08-22 16:08:15 -070025#include "av1/common/enums.h"
Yaowu Xuf883b422016-08-30 14:01:10 -070026#include "av1/common/av1_txfm.h"
27#include "./av1_rtcd.h"
Angie Chiangb9341482015-10-27 16:41:38 -070028
Yaowu Xuc27fc142016-08-22 16:08:15 -070029namespace libaom_test {
Angie Chiangb9341482015-10-27 16:41:38 -070030typedef enum {
31 TYPE_DCT = 0,
32 TYPE_ADST,
33 TYPE_IDCT,
34 TYPE_IADST,
35 TYPE_LAST
36} TYPE_TXFM;
37
Angie Chiang716f1bd2016-05-11 16:41:36 -070038int get_txfm1d_size(TX_SIZE tx_size);
Angie Chiangb9341482015-10-27 16:41:38 -070039
clang-format3a826f12016-08-11 17:46:05 -070040void get_txfm1d_type(TX_TYPE txfm2d_type, TYPE_TXFM *type0, TYPE_TXFM *type1);
Angie Chiangb9341482015-10-27 16:41:38 -070041
clang-format3a826f12016-08-11 17:46:05 -070042void reference_dct_1d(const double *in, double *out, int size);
Angie Chiangb9341482015-10-27 16:41:38 -070043
clang-format3a826f12016-08-11 17:46:05 -070044void reference_adst_1d(const double *in, double *out, int size);
Angie Chiangb9341482015-10-27 16:41:38 -070045
clang-format3a826f12016-08-11 17:46:05 -070046void reference_hybrid_1d(double *in, double *out, int size, int type);
Angie Chiangb9341482015-10-27 16:41:38 -070047
clang-format3a826f12016-08-11 17:46:05 -070048void reference_hybrid_2d(double *in, double *out, int size, int type0,
49 int type1);
Angie Chiangb9341482015-10-27 16:41:38 -070050template <typename Type1, typename Type2>
clang-format3a826f12016-08-11 17:46:05 -070051static double compute_avg_abs_error(const Type1 *a, const Type2 *b,
Angie Chiangb9341482015-10-27 16:41:38 -070052 const int size) {
53 double error = 0;
54 for (int i = 0; i < size; i++) {
55 error += fabs(static_cast<double>(a[i]) - static_cast<double>(b[i]));
56 }
57 error = error / size;
58 return error;
59}
60
clang-format3a826f12016-08-11 17:46:05 -070061template <typename Type>
Angie Chiang6a752532016-05-11 18:50:47 -070062void fliplr(Type *dest, int stride, int length);
63
clang-format3a826f12016-08-11 17:46:05 -070064template <typename Type>
Angie Chiang6a752532016-05-11 18:50:47 -070065void flipud(Type *dest, int stride, int length);
66
clang-format3a826f12016-08-11 17:46:05 -070067template <typename Type>
Angie Chiang6a752532016-05-11 18:50:47 -070068void fliplrud(Type *dest, int stride, int length);
69
clang-format3a826f12016-08-11 17:46:05 -070070typedef void (*TxfmFunc)(const int32_t *in, int32_t *out, const int8_t *cos_bit,
71 const int8_t *range_bit);
Angie Chiangb9341482015-10-27 16:41:38 -070072
clang-format3a826f12016-08-11 17:46:05 -070073typedef void (*Fwd_Txfm2d_Func)(const int16_t *, int32_t *, int, int, int);
74typedef void (*Inv_Txfm2d_Func)(const int32_t *, uint16_t *, int, int, int);
Angie Chiangb9341482015-10-27 16:41:38 -070075
76static const int bd = 10;
Angie Chiang218dfbd2016-04-19 11:59:00 -070077static const int input_base = (1 << bd);
Angie Chiangfdaad9f2016-05-12 17:11:27 -070078
Yaowu Xuf883b422016-08-30 14:01:10 -070079#if CONFIG_AOM_HIGHBITDEPTH
Angie Chiangfdaad9f2016-05-12 17:11:27 -070080static const Fwd_Txfm2d_Func fwd_txfm_func_ls[TX_SIZES] = {
Yaowu Xuf883b422016-08-30 14:01:10 -070081 av1_fwd_txfm2d_4x4_c, av1_fwd_txfm2d_8x8_c, av1_fwd_txfm2d_16x16_c,
82 av1_fwd_txfm2d_32x32_c
clang-format3a826f12016-08-11 17:46:05 -070083};
Angie Chiangfdaad9f2016-05-12 17:11:27 -070084
85static const Inv_Txfm2d_Func inv_txfm_func_ls[TX_SIZES] = {
Yaowu Xuf883b422016-08-30 14:01:10 -070086 av1_inv_txfm2d_add_4x4_c, av1_inv_txfm2d_add_8x8_c,
87 av1_inv_txfm2d_add_16x16_c, av1_inv_txfm2d_add_32x32_c
clang-format3a826f12016-08-11 17:46:05 -070088};
Yaowu Xuf883b422016-08-30 14:01:10 -070089#endif // CONFIG_AOM_HIGHBITDEPTH
Angie Chiangfdaad9f2016-05-12 17:11:27 -070090
Yaowu Xuc27fc142016-08-22 16:08:15 -070091} // namespace libaom_test
Yaowu Xuf883b422016-08-30 14:01:10 -070092#endif // AV1_TXFM_TEST_H_