tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

av1_txfm_test.h (5089B)


      1 /*
      2 * Copyright (c) 2016, Alliance for Open Media. All rights reserved.
      3 *
      4 * 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.
     10 */
     11 
     12 #ifndef AOM_TEST_AV1_TXFM_TEST_H_
     13 #define AOM_TEST_AV1_TXFM_TEST_H_
     14 
     15 #include <stdio.h>
     16 #include <stdlib.h>
     17 #ifdef _MSC_VER
     18 #define _USE_MATH_DEFINES
     19 #endif
     20 #include <math.h>
     21 
     22 #include "config/av1_rtcd.h"
     23 
     24 #include "gtest/gtest.h"
     25 
     26 #include "test/acm_random.h"
     27 #include "av1/common/av1_txfm.h"
     28 #include "av1/common/blockd.h"
     29 #include "av1/common/enums.h"
     30 
     31 namespace libaom_test {
     32 
     33 extern const char *tx_type_name[];
     34 
     35 enum {
     36  TYPE_DCT = 0,
     37  TYPE_ADST,
     38  TYPE_IDTX,
     39  TYPE_IDCT,
     40  TYPE_IADST,
     41  TYPE_LAST
     42 } UENUM1BYTE(TYPE_TXFM);
     43 
     44 int get_txfm1d_size(TX_SIZE tx_size);
     45 
     46 void get_txfm1d_type(TX_TYPE txfm2d_type, TYPE_TXFM *type0, TYPE_TXFM *type1);
     47 
     48 void reference_dct_1d(const double *in, double *out, int size);
     49 void reference_idct_1d(const double *in, double *out, int size);
     50 
     51 void reference_adst_1d(const double *in, double *out, int size);
     52 
     53 void reference_hybrid_1d(double *in, double *out, int size, int type);
     54 
     55 double get_amplification_factor(TX_TYPE tx_type, TX_SIZE tx_size);
     56 
     57 void reference_hybrid_2d(double *in, double *out, TX_TYPE tx_type,
     58                         TX_SIZE tx_size);
     59 template <typename Type1, typename Type2>
     60 static double compute_avg_abs_error(const Type1 *a, const Type2 *b,
     61                                    const int size) {
     62  double error = 0;
     63  for (int i = 0; i < size; i++) {
     64    error += fabs(static_cast<double>(a[i]) - static_cast<double>(b[i]));
     65  }
     66  error = error / size;
     67  return error;
     68 }
     69 
     70 template <typename Type>
     71 void fliplr(Type *dest, int width, int height, int stride);
     72 
     73 template <typename Type>
     74 void flipud(Type *dest, int width, int height, int stride);
     75 
     76 template <typename Type>
     77 void fliplrud(Type *dest, int width, int height, int stride);
     78 
     79 using TxfmFunc = void (*)(const int32_t *in, int32_t *out, const int8_t cos_bit,
     80                          const int8_t *range_bit);
     81 
     82 using InvTxfm2dFunc = void (*)(const int32_t *, uint16_t *, int, TX_TYPE, int);
     83 using LbdInvTxfm2dFunc = void (*)(const int32_t *, uint8_t *, int, TX_TYPE,
     84                                  TX_SIZE, int);
     85 
     86 static const int bd = 10;
     87 static const int input_base = (1 << bd);
     88 
     89 static inline bool IsTxSizeTypeValid(TX_SIZE tx_size, TX_TYPE tx_type) {
     90  const TX_SIZE tx_size_sqr_up = txsize_sqr_up_map[tx_size];
     91  TxSetType tx_set_type;
     92  if (tx_size_sqr_up > TX_32X32) {
     93    tx_set_type = EXT_TX_SET_DCTONLY;
     94  } else if (tx_size_sqr_up == TX_32X32) {
     95    tx_set_type = EXT_TX_SET_DCT_IDTX;
     96  } else {
     97    tx_set_type = EXT_TX_SET_ALL16;
     98  }
     99  return av1_ext_tx_used[tx_set_type][tx_type] != 0;
    100 }
    101 
    102 #if CONFIG_AV1_ENCODER
    103 #if !CONFIG_REALTIME_ONLY
    104 static const FwdTxfm2dFunc fwd_txfm_func_ls[TX_SIZES_ALL] = {
    105  av1_fwd_txfm2d_4x4_c,   av1_fwd_txfm2d_8x8_c,   av1_fwd_txfm2d_16x16_c,
    106  av1_fwd_txfm2d_32x32_c, av1_fwd_txfm2d_64x64_c, av1_fwd_txfm2d_4x8_c,
    107  av1_fwd_txfm2d_8x4_c,   av1_fwd_txfm2d_8x16_c,  av1_fwd_txfm2d_16x8_c,
    108  av1_fwd_txfm2d_16x32_c, av1_fwd_txfm2d_32x16_c, av1_fwd_txfm2d_32x64_c,
    109  av1_fwd_txfm2d_64x32_c, av1_fwd_txfm2d_4x16_c,  av1_fwd_txfm2d_16x4_c,
    110  av1_fwd_txfm2d_8x32_c,  av1_fwd_txfm2d_32x8_c,  av1_fwd_txfm2d_16x64_c,
    111  av1_fwd_txfm2d_64x16_c,
    112 };
    113 #else
    114 static const FwdTxfm2dFunc fwd_txfm_func_ls[TX_SIZES_ALL] = {
    115  av1_fwd_txfm2d_4x4_c,
    116  av1_fwd_txfm2d_8x8_c,
    117  av1_fwd_txfm2d_16x16_c,
    118  av1_fwd_txfm2d_32x32_c,
    119  av1_fwd_txfm2d_64x64_c,
    120  av1_fwd_txfm2d_4x8_c,
    121  av1_fwd_txfm2d_8x4_c,
    122  av1_fwd_txfm2d_8x16_c,
    123  av1_fwd_txfm2d_16x8_c,
    124  av1_fwd_txfm2d_16x32_c,
    125  av1_fwd_txfm2d_32x16_c,
    126  av1_fwd_txfm2d_32x64_c,
    127  av1_fwd_txfm2d_64x32_c,
    128  nullptr,
    129  av1_fwd_txfm2d_16x4_c,
    130  nullptr,
    131  nullptr,
    132  nullptr,
    133  nullptr,
    134 };
    135 #endif
    136 #endif
    137 
    138 static const InvTxfm2dFunc inv_txfm_func_ls[TX_SIZES_ALL] = {
    139  av1_inv_txfm2d_add_4x4_c,   av1_inv_txfm2d_add_8x8_c,
    140  av1_inv_txfm2d_add_16x16_c, av1_inv_txfm2d_add_32x32_c,
    141  av1_inv_txfm2d_add_64x64_c, av1_inv_txfm2d_add_4x8_c,
    142  av1_inv_txfm2d_add_8x4_c,   av1_inv_txfm2d_add_8x16_c,
    143  av1_inv_txfm2d_add_16x8_c,  av1_inv_txfm2d_add_16x32_c,
    144  av1_inv_txfm2d_add_32x16_c, av1_inv_txfm2d_add_32x64_c,
    145  av1_inv_txfm2d_add_64x32_c, av1_inv_txfm2d_add_4x16_c,
    146  av1_inv_txfm2d_add_16x4_c,  av1_inv_txfm2d_add_8x32_c,
    147  av1_inv_txfm2d_add_32x8_c,  av1_inv_txfm2d_add_16x64_c,
    148  av1_inv_txfm2d_add_64x16_c,
    149 };
    150 
    151 #define BD_NUM 3
    152 
    153 extern int bd_arr[];
    154 extern int8_t low_range_arr[];
    155 extern int8_t high_range_arr[];
    156 
    157 void txfm_stage_range_check(const int8_t *stage_range, int stage_num,
    158                            const int8_t cos_bit, int low_range,
    159                            int high_range);
    160 }  // namespace libaom_test
    161 #endif  // AOM_TEST_AV1_TXFM_TEST_H_