• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2018, 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_TOOLS_TXFM_ANALYZER_TXFM_GRAPH_H_
13 #define AOM_TOOLS_TXFM_ANALYZER_TXFM_GRAPH_H_
14 
15 struct Node {
16   Node *inNode[2];
17   int inNodeNum;
18   int inNodeIdx[2];
19   double inWeight[2];
20   double value;
21   int nodeIdx;
22   int stageIdx;
23   int visited;
24 };
25 
26 #define STAGENUM (10)
27 #define NODENUM (32)
28 #define COS_MOD (128)
29 
30 typedef enum {
31   TYPE_DCT = 0,
32   TYPE_ADST,
33   TYPE_IDCT,
34   TYPE_IADST,
35   TYPE_LAST
36 } TYPE_TXFM;
37 
38 TYPE_TXFM get_inv_type(TYPE_TXFM type);
39 void get_fun_name(char *str_fun_name, int str_buf_size, const TYPE_TXFM type,
40                   const int txfm_size);
41 
42 void get_txfm_type_name(char *str_fun_name, int str_buf_size,
43                         const TYPE_TXFM type, const int txfm_size);
44 void get_hybrid_2d_type_name(char *buf, int buf_size, const TYPE_TXFM type0,
45                              const TYPE_TXFM type1, const int txfm_size0,
46                              const int txfm_size1);
47 unsigned int get_max_bit(unsigned int x);
48 unsigned int bitwise_reverse(unsigned int x, int max_bit);
49 int get_idx(int ri, int ci, int cSize);
50 
51 int get_dct_stage_num(int size);
52 void reference_dct_1d(double *in, double *out, int size);
53 void reference_dct_2d(double *in, double *out, int size);
54 void connect_node(Node *node, int stage_num, int node_num, int stage_idx,
55                   int node_idx, int in0, double w0, int in1, double w1);
56 void propagate(Node *node, int stage_num, int node_num, int stage);
57 void init_graph(Node *node, int stage_num, int node_num);
58 void graph_reset_visited(Node *node, int stage_num, int node_num);
59 void gen_B_graph(Node *node, int stage_num, int node_num, int stage_idx,
60                  int node_idx, int N, int star);
61 void gen_P_graph(Node *node, int stage_num, int node_num, int stage_idx,
62                  int node_idx, int N);
63 
64 void gen_type1_graph(Node *node, int stage_num, int node_num, int stage_idx,
65                      int node_idx, int N);
66 void gen_type2_graph(Node *node, int stage_num, int node_num, int stage_idx,
67                      int node_idx, int N);
68 void gen_type3_graph(Node *node, int stage_num, int node_num, int stage_idx,
69                      int node_idx, int idx, int N);
70 void gen_type4_graph(Node *node, int stage_num, int node_num, int stage_idx,
71                      int node_idx, int idx, int N);
72 
73 void gen_R_graph(Node *node, int stage_num, int node_num, int stage_idx,
74                  int node_idx, int N);
75 
76 void gen_DCT_graph(Node *node, int stage_num, int node_num, int stage_idx,
77                    int node_idx, int N);
78 
79 void gen_DCT_graph_1d(Node *node, int stage_num, int node_num, int stage_idx,
80                       int node_idx, int dct_node_num);
81 void connect_layer_2d(Node *node, int stage_num, int node_num, int stage_idx,
82                       int node_idx, int dct_node_num);
83 
84 void gen_DCT_graph_2d(Node *node, int stage_num, int node_num, int stage_idx,
85                       int node_idx, int dct_node_num);
86 
87 void gen_adst_B_graph(Node *node, int stage_num, int node_num, int stage_idx,
88                       int node_idx, int adst_idx);
89 
90 void gen_adst_U_graph(Node *node, int stage_num, int node_num, int stage_idx,
91                       int node_idx, int adst_idx, int adst_node_num);
92 void gen_adst_T_graph(Node *node, int stage_num, int node_num, int stage_idx,
93                       int node_idx, double freq);
94 
95 void gen_adst_E_graph(Node *node, int stage_num, int node_num, int stage_idx,
96                       int node_idx, int adst_idx);
97 
98 void gen_adst_V_graph(Node *node, int stage_num, int node_num, int stage_idx,
99                       int node_idx, int adst_idx, int adst_node_num);
100 
101 void gen_adst_VJ_graph(Node *node, int stage_num, int node_num, int stage_idx,
102                        int node_idx, int adst_node_num);
103 void gen_adst_Q_graph(Node *node, int stage_num, int node_num, int stage_idx,
104                       int node_idx, int adst_node_num);
105 void gen_adst_Ibar_graph(Node *node, int stage_num, int node_num, int stage_idx,
106                          int node_idx, int adst_node_num);
107 
108 void gen_adst_D_graph(Node *node, int stage_num, int node_num, int stage_idx,
109                       int node_idx, int adst_node_num);
110 
111 int get_hadamard_idx(int x, int adst_node_num);
112 void gen_adst_Ht_graph(Node *node, int stage_num, int node_num, int stage_idx,
113                        int node_idx, int adst_node_num);
114 
115 int gen_adst_graph(Node *node, int stage_num, int node_num, int stage_idx,
116                    int node_idx, int adst_node_num);
117 int gen_iadst_graph(Node *node, int stage_num, int node_num, int stage_idx,
118                     int node_idx, int adst_node_num);
119 void reference_adst_1d(double *in, double *out, int size);
120 
121 int get_adst_stage_num(int adst_node_num);
122 int get_hybrid_stage_num(int type, int hybrid_node_num);
123 int get_hybrid_2d_stage_num(int type0, int type1, int hybrid_node_num);
124 int get_hybrid_2d_stage_num_new(int type0, int type1, int hybrid_node_num0,
125                                 int hybrid_node_num1);
126 int get_hybrid_amplify_factor(int type, int hybrid_node_num);
127 void gen_hybrid_graph_1d(Node *node, int stage_num, int node_num, int stage_idx,
128                          int node_idx, int hybrid_node_num, int type);
129 void gen_hybrid_graph_2d(Node *node, int stage_num, int node_num, int stage_idx,
130                          int node_idx, int hybrid_node_num, int type0,
131                          int type1);
132 void gen_hybrid_graph_2d_new(Node *node, int stage_num, int node_num,
133                              int stage_idx, int node_idx, int hybrid_node_num0,
134                              int hybrid_node_num1, int type0, int type1);
135 
136 void reference_hybrid_2d(double *in, double *out, int size, int type0,
137                          int type1);
138 
139 void reference_hybrid_2d_new(double *in, double *out, int size0, int size1,
140                              int type0, int type1);
141 void reference_adst_dct_2d(double *in, double *out, int size);
142 
143 void gen_code(Node *node, int stage_num, int node_num, TYPE_TXFM type);
144 
145 void gen_inv_graph(Node *node, int stage_num, int node_num, Node *invNode,
146                    int inv_stage_num, int inv_node_num, int inv_stage_idx,
147                    int inv_node_idx);
148 
149 TYPE_TXFM hybrid_char_to_int(char ctype);
150 
151 int64_t round_shift(int64_t value, int bit);
152 void round_shift_array(int32_t *arr, int size, int bit);
153 void estimate_value(Node *node, int stage_num, int node_num, int stage_idx,
154                     int node_idx, int estimate_bit);
155 void amplify_value(Node *node, int stage_num, int node_num, int stage_idx,
156                    int node_idx, int estimate_bit);
157 void propagate_estimate_amlify(Node *node, int stage_num, int node_num,
158                                int stage_idx, int amplify_bit,
159                                int estimate_bit);
160 #endif  // AOM_TOOLS_TXFM_ANALYZER_TXFM_GRAPH_H_
161