av1_txfm_test.h 2.61 KB
Newer Older
Angie Chiang's avatar
Angie Chiang committed
1 2 3 4 5 6 7 8 9 10
/*
 *  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.
 */

11 12
#ifndef AV1_TXFM_TEST_H_
#define AV1_TXFM_TEST_H_
Angie Chiang's avatar
Angie Chiang committed
13 14 15

#include <stdio.h>
#include <stdlib.h>
Yaowu Xu's avatar
Yaowu Xu committed
16 17 18
#ifdef _MSC_VER
#define _USE_MATH_DEFINES
#endif
Angie Chiang's avatar
Angie Chiang committed
19 20 21 22 23
#include <math.h>

#include "third_party/googletest/src/include/gtest/gtest.h"

#include "test/acm_random.h"
24
#include "av1/common/enums.h"
25 26
#include "av1/common/av1_txfm.h"
#include "./av1_rtcd.h"
Angie Chiang's avatar
Angie Chiang committed
27

28
namespace libaom_test {
Angie Chiang's avatar
Angie Chiang committed
29 30 31 32 33 34 35 36
typedef enum {
  TYPE_DCT = 0,
  TYPE_ADST,
  TYPE_IDCT,
  TYPE_IADST,
  TYPE_LAST
} TYPE_TXFM;

37
int get_txfm1d_size(TX_SIZE tx_size);
Angie Chiang's avatar
Angie Chiang committed
38

clang-format's avatar
clang-format committed
39
void get_txfm1d_type(TX_TYPE txfm2d_type, TYPE_TXFM *type0, TYPE_TXFM *type1);
Angie Chiang's avatar
Angie Chiang committed
40

clang-format's avatar
clang-format committed
41
void reference_dct_1d(const double *in, double *out, int size);
Angie Chiang's avatar
Angie Chiang committed
42

clang-format's avatar
clang-format committed
43
void reference_adst_1d(const double *in, double *out, int size);
Angie Chiang's avatar
Angie Chiang committed
44

clang-format's avatar
clang-format committed
45
void reference_hybrid_1d(double *in, double *out, int size, int type);
Angie Chiang's avatar
Angie Chiang committed
46

clang-format's avatar
clang-format committed
47 48
void reference_hybrid_2d(double *in, double *out, int size, int type0,
                         int type1);
Angie Chiang's avatar
Angie Chiang committed
49
template <typename Type1, typename Type2>
clang-format's avatar
clang-format committed
50
static double compute_avg_abs_error(const Type1 *a, const Type2 *b,
Angie Chiang's avatar
Angie Chiang committed
51 52 53 54 55 56 57 58 59
                                    const int size) {
  double error = 0;
  for (int i = 0; i < size; i++) {
    error += fabs(static_cast<double>(a[i]) - static_cast<double>(b[i]));
  }
  error = error / size;
  return error;
}

clang-format's avatar
clang-format committed
60
template <typename Type>
61 62
void fliplr(Type *dest, int stride, int length);

clang-format's avatar
clang-format committed
63
template <typename Type>
64 65
void flipud(Type *dest, int stride, int length);

clang-format's avatar
clang-format committed
66
template <typename Type>
67 68
void fliplrud(Type *dest, int stride, int length);

clang-format's avatar
clang-format committed
69 70
typedef void (*TxfmFunc)(const int32_t *in, int32_t *out, const int8_t *cos_bit,
                         const int8_t *range_bit);
Angie Chiang's avatar
Angie Chiang committed
71

clang-format's avatar
clang-format committed
72 73
typedef void (*Fwd_Txfm2d_Func)(const int16_t *, int32_t *, int, int, int);
typedef void (*Inv_Txfm2d_Func)(const int32_t *, uint16_t *, int, int, int);
Angie Chiang's avatar
Angie Chiang committed
74 75

static const int bd = 10;
76
static const int input_base = (1 << bd);
77

78
#if CONFIG_AOM_HIGHBITDEPTH
79
static const Fwd_Txfm2d_Func fwd_txfm_func_ls[TX_SIZES] = {
80 81
  av1_fwd_txfm2d_4x4_c, av1_fwd_txfm2d_8x8_c, av1_fwd_txfm2d_16x16_c,
  av1_fwd_txfm2d_32x32_c
clang-format's avatar
clang-format committed
82
};
83 84

static const Inv_Txfm2d_Func inv_txfm_func_ls[TX_SIZES] = {
85 86
  av1_inv_txfm2d_add_4x4_c, av1_inv_txfm2d_add_8x8_c,
  av1_inv_txfm2d_add_16x16_c, av1_inv_txfm2d_add_32x32_c
clang-format's avatar
clang-format committed
87
};
88
#endif  // CONFIG_AOM_HIGHBITDEPTH
89

90
}  // namespace libaom_test
91
#endif  // AV1_TXFM_TEST_H_