/src/aom/av1/encoder/av1_fwd_txfm2d.c
Line | Count | Source (jump to first uncovered line) |
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 | | #include <assert.h> |
13 | | |
14 | | #include "config/aom_dsp_rtcd.h" |
15 | | #include "config/av1_rtcd.h" |
16 | | |
17 | | #include "aom_dsp/txfm_common.h" |
18 | | #include "av1/common/enums.h" |
19 | | #include "av1/common/av1_txfm.h" |
20 | | #include "av1/encoder/av1_fwd_txfm1d.h" |
21 | | #include "av1/encoder/av1_fwd_txfm1d_cfg.h" |
22 | | |
23 | 10.4M | static INLINE TxfmFunc fwd_txfm_type_to_func(TXFM_TYPE txfm_type) { |
24 | 10.4M | switch (txfm_type) { |
25 | 1.71M | case TXFM_TYPE_DCT4: return av1_fdct4; |
26 | 2.46M | case TXFM_TYPE_DCT8: return av1_fdct8; |
27 | 1.67M | case TXFM_TYPE_DCT16: return av1_fdct16; |
28 | 1.12M | case TXFM_TYPE_DCT32: return av1_fdct32; |
29 | 587k | case TXFM_TYPE_DCT64: return av1_fdct64; |
30 | 702k | case TXFM_TYPE_ADST4: return av1_fadst4; |
31 | 1.30M | case TXFM_TYPE_ADST8: return av1_fadst8; |
32 | 607k | case TXFM_TYPE_ADST16: return av1_fadst16; |
33 | 116k | case TXFM_TYPE_IDENTITY4: return av1_fidentity4_c; |
34 | 103k | case TXFM_TYPE_IDENTITY8: return av1_fidentity8_c; |
35 | 123k | case TXFM_TYPE_IDENTITY16: return av1_fidentity16_c; |
36 | 0 | case TXFM_TYPE_IDENTITY32: return av1_fidentity32_c; |
37 | 0 | default: assert(0); return NULL; |
38 | 10.4M | } |
39 | 10.4M | } |
40 | | |
41 | | void av1_gen_fwd_stage_range(int8_t *stage_range_col, int8_t *stage_range_row, |
42 | 5.24M | const TXFM_2D_FLIP_CFG *cfg, int bd) { |
43 | | // Take the shift from the larger dimension in the rectangular case. |
44 | 5.24M | const int8_t *shift = cfg->shift; |
45 | | // i < MAX_TXFM_STAGE_NUM will mute above array bounds warning |
46 | 42.2M | for (int i = 0; i < cfg->stage_num_col && i < MAX_TXFM_STAGE_NUM; ++i) { |
47 | 36.9M | stage_range_col[i] = cfg->stage_range_col[i] + shift[0] + bd + 1; |
48 | 36.9M | } |
49 | | |
50 | | // i < MAX_TXFM_STAGE_NUM will mute above array bounds warning |
51 | 43.1M | for (int i = 0; i < cfg->stage_num_row && i < MAX_TXFM_STAGE_NUM; ++i) { |
52 | 37.9M | stage_range_row[i] = cfg->stage_range_row[i] + shift[0] + shift[1] + bd + 1; |
53 | 37.9M | } |
54 | 5.24M | } |
55 | | |
56 | | static INLINE void fwd_txfm2d_c(const int16_t *input, int32_t *output, |
57 | | const int stride, const TXFM_2D_FLIP_CFG *cfg, |
58 | 5.24M | int32_t *buf, int bd) { |
59 | 5.24M | int c, r; |
60 | | // Note when assigning txfm_size_col, we use the txfm_size from the |
61 | | // row configuration and vice versa. This is intentionally done to |
62 | | // accurately perform rectangular transforms. When the transform is |
63 | | // rectangular, the number of columns will be the same as the |
64 | | // txfm_size stored in the row cfg struct. It will make no difference |
65 | | // for square transforms. |
66 | 5.24M | const int txfm_size_col = tx_size_wide[cfg->tx_size]; |
67 | 5.24M | const int txfm_size_row = tx_size_high[cfg->tx_size]; |
68 | | // Take the shift from the larger dimension in the rectangular case. |
69 | 5.24M | const int8_t *shift = cfg->shift; |
70 | 5.24M | const int rect_type = get_rect_tx_log_ratio(txfm_size_col, txfm_size_row); |
71 | 5.24M | int8_t stage_range_col[MAX_TXFM_STAGE_NUM]; |
72 | 5.24M | int8_t stage_range_row[MAX_TXFM_STAGE_NUM]; |
73 | 5.24M | assert(cfg->stage_num_col <= MAX_TXFM_STAGE_NUM); |
74 | 5.24M | assert(cfg->stage_num_row <= MAX_TXFM_STAGE_NUM); |
75 | 5.24M | av1_gen_fwd_stage_range(stage_range_col, stage_range_row, cfg, bd); |
76 | | |
77 | 5.24M | const int8_t cos_bit_col = cfg->cos_bit_col; |
78 | 5.24M | const int8_t cos_bit_row = cfg->cos_bit_row; |
79 | 5.24M | const TxfmFunc txfm_func_col = fwd_txfm_type_to_func(cfg->txfm_type_col); |
80 | 5.24M | const TxfmFunc txfm_func_row = fwd_txfm_type_to_func(cfg->txfm_type_row); |
81 | | |
82 | | // use output buffer as temp buffer |
83 | 5.24M | int32_t *temp_in = output; |
84 | 5.24M | int32_t *temp_out = output + txfm_size_row; |
85 | | |
86 | | // Columns |
87 | 80.8M | for (c = 0; c < txfm_size_col; ++c) { |
88 | 75.6M | if (cfg->ud_flip == 0) { |
89 | 2.11G | for (r = 0; r < txfm_size_row; ++r) temp_in[r] = input[r * stride + c]; |
90 | 18.4E | } else { |
91 | 18.4E | for (r = 0; r < txfm_size_row; ++r) |
92 | | // flip upside down |
93 | 0 | temp_in[r] = input[(txfm_size_row - r - 1) * stride + c]; |
94 | 18.4E | } |
95 | 75.5M | av1_round_shift_array(temp_in, txfm_size_row, -shift[0]); |
96 | 75.5M | txfm_func_col(temp_in, temp_out, cos_bit_col, stage_range_col); |
97 | 75.5M | av1_round_shift_array(temp_out, txfm_size_row, -shift[1]); |
98 | 75.5M | if (cfg->lr_flip == 0) { |
99 | 2.08G | for (r = 0; r < txfm_size_row; ++r) |
100 | 2.00G | buf[r * txfm_size_col + c] = temp_out[r]; |
101 | 74.2M | } else { |
102 | 1.38M | for (r = 0; r < txfm_size_row; ++r) |
103 | | // flip from left to right |
104 | 0 | buf[r * txfm_size_col + (txfm_size_col - c - 1)] = temp_out[r]; |
105 | 1.38M | } |
106 | 75.5M | } |
107 | | |
108 | | // Rows |
109 | 80.4M | for (r = 0; r < txfm_size_row; ++r) { |
110 | 75.1M | txfm_func_row(buf + r * txfm_size_col, output + r * txfm_size_col, |
111 | 75.1M | cos_bit_row, stage_range_row); |
112 | 75.1M | av1_round_shift_array(output + r * txfm_size_col, txfm_size_col, -shift[2]); |
113 | 75.1M | if (abs(rect_type) == 1) { |
114 | | // Multiply everything by Sqrt2 if the transform is rectangular and the |
115 | | // size difference is a factor of 2. |
116 | 597M | for (c = 0; c < txfm_size_col; ++c) { |
117 | 573M | output[r * txfm_size_col + c] = round_shift( |
118 | 573M | (int64_t)output[r * txfm_size_col + c] * NewSqrt2, NewSqrt2Bits); |
119 | 573M | } |
120 | 24.9M | } |
121 | 75.1M | } |
122 | 5.24M | } |
123 | | |
124 | | void av1_fwd_txfm2d_4x8_c(const int16_t *input, int32_t *output, int stride, |
125 | 119k | TX_TYPE tx_type, int bd) { |
126 | 119k | DECLARE_ALIGNED(32, int32_t, txfm_buf[4 * 8]); |
127 | 119k | TXFM_2D_FLIP_CFG cfg; |
128 | 119k | av1_get_fwd_txfm_cfg(tx_type, TX_4X8, &cfg); |
129 | 119k | fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf, bd); |
130 | 119k | } |
131 | | |
132 | | void av1_fwd_txfm2d_8x4_c(const int16_t *input, int32_t *output, int stride, |
133 | 141k | TX_TYPE tx_type, int bd) { |
134 | 141k | int32_t txfm_buf[8 * 4]; |
135 | 141k | TXFM_2D_FLIP_CFG cfg; |
136 | 141k | av1_get_fwd_txfm_cfg(tx_type, TX_8X4, &cfg); |
137 | 141k | fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf, bd); |
138 | 141k | } |
139 | | |
140 | | void av1_fwd_txfm2d_8x16_c(const int16_t *input, int32_t *output, int stride, |
141 | 307k | TX_TYPE tx_type, int bd) { |
142 | 307k | DECLARE_ALIGNED(32, int32_t, txfm_buf[8 * 16]); |
143 | 307k | TXFM_2D_FLIP_CFG cfg; |
144 | 307k | av1_get_fwd_txfm_cfg(tx_type, TX_8X16, &cfg); |
145 | 307k | fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf, bd); |
146 | 307k | } |
147 | | |
148 | | void av1_fwd_txfm2d_16x8_c(const int16_t *input, int32_t *output, int stride, |
149 | 311k | TX_TYPE tx_type, int bd) { |
150 | 311k | int32_t txfm_buf[16 * 8]; |
151 | 311k | TXFM_2D_FLIP_CFG cfg; |
152 | 311k | av1_get_fwd_txfm_cfg(tx_type, TX_16X8, &cfg); |
153 | 311k | fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf, bd); |
154 | 311k | } |
155 | | |
156 | | void av1_fwd_txfm2d_16x32_c(const int16_t *input, int32_t *output, int stride, |
157 | 192k | TX_TYPE tx_type, int bd) { |
158 | 192k | DECLARE_ALIGNED(32, int32_t, txfm_buf[16 * 32]); |
159 | 192k | TXFM_2D_FLIP_CFG cfg; |
160 | 192k | av1_get_fwd_txfm_cfg(tx_type, TX_16X32, &cfg); |
161 | 192k | fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf, bd); |
162 | 192k | } |
163 | | |
164 | | void av1_fwd_txfm2d_32x16_c(const int16_t *input, int32_t *output, int stride, |
165 | 195k | TX_TYPE tx_type, int bd) { |
166 | 195k | int32_t txfm_buf[32 * 16]; |
167 | 195k | TXFM_2D_FLIP_CFG cfg; |
168 | 195k | av1_get_fwd_txfm_cfg(tx_type, TX_32X16, &cfg); |
169 | 195k | fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf, bd); |
170 | 195k | } |
171 | | |
172 | | void av1_fwd_txfm2d_4x16_c(const int16_t *input, int32_t *output, int stride, |
173 | 798 | TX_TYPE tx_type, int bd) { |
174 | 798 | DECLARE_ALIGNED(32, int32_t, txfm_buf[4 * 16]); |
175 | 798 | TXFM_2D_FLIP_CFG cfg; |
176 | 798 | av1_get_fwd_txfm_cfg(tx_type, TX_4X16, &cfg); |
177 | 798 | fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf, bd); |
178 | 798 | } |
179 | | |
180 | | void av1_fwd_txfm2d_16x4_c(const int16_t *input, int32_t *output, int stride, |
181 | 0 | TX_TYPE tx_type, int bd) { |
182 | 0 | int32_t txfm_buf[16 * 4]; |
183 | 0 | TXFM_2D_FLIP_CFG cfg; |
184 | 0 | av1_get_fwd_txfm_cfg(tx_type, TX_16X4, &cfg); |
185 | 0 | fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf, bd); |
186 | 0 | } |
187 | | |
188 | | void av1_fwd_txfm2d_8x32_c(const int16_t *input, int32_t *output, int stride, |
189 | 2.43k | TX_TYPE tx_type, int bd) { |
190 | 2.43k | DECLARE_ALIGNED(32, int32_t, txfm_buf[32 * 8]); |
191 | 2.43k | TXFM_2D_FLIP_CFG cfg; |
192 | 2.43k | av1_get_fwd_txfm_cfg(tx_type, TX_8X32, &cfg); |
193 | 2.43k | fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf, bd); |
194 | 2.43k | } |
195 | | |
196 | | void av1_fwd_txfm2d_32x8_c(const int16_t *input, int32_t *output, int stride, |
197 | 0 | TX_TYPE tx_type, int bd) { |
198 | 0 | int32_t txfm_buf[32 * 8]; |
199 | 0 | TXFM_2D_FLIP_CFG cfg; |
200 | 0 | av1_get_fwd_txfm_cfg(tx_type, TX_32X8, &cfg); |
201 | 0 | fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf, bd); |
202 | 0 | } |
203 | | |
204 | | void av1_fwd_txfm2d_4x4_c(const int16_t *input, int32_t *output, int stride, |
205 | 1.13M | TX_TYPE tx_type, int bd) { |
206 | 1.13M | int32_t txfm_buf[4 * 4]; |
207 | 1.13M | TXFM_2D_FLIP_CFG cfg; |
208 | 1.13M | av1_get_fwd_txfm_cfg(tx_type, TX_4X4, &cfg); |
209 | 1.13M | fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf, bd); |
210 | 1.13M | } |
211 | | |
212 | | void av1_fwd_txfm2d_8x8_c(const int16_t *input, int32_t *output, int stride, |
213 | 1.49M | TX_TYPE tx_type, int bd) { |
214 | 1.49M | int32_t txfm_buf[8 * 8]; |
215 | 1.49M | TXFM_2D_FLIP_CFG cfg; |
216 | 1.49M | av1_get_fwd_txfm_cfg(tx_type, TX_8X8, &cfg); |
217 | 1.49M | fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf, bd); |
218 | 1.49M | } |
219 | | |
220 | | void av1_fwd_txfm2d_16x16_c(const int16_t *input, int32_t *output, int stride, |
221 | 699k | TX_TYPE tx_type, int bd) { |
222 | 699k | int32_t txfm_buf[16 * 16]; |
223 | 699k | TXFM_2D_FLIP_CFG cfg; |
224 | 699k | av1_get_fwd_txfm_cfg(tx_type, TX_16X16, &cfg); |
225 | 699k | fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf, bd); |
226 | 699k | } |
227 | | |
228 | | void av1_fwd_txfm2d_32x32_c(const int16_t *input, int32_t *output, int stride, |
229 | 296k | TX_TYPE tx_type, int bd) { |
230 | 296k | int32_t txfm_buf[32 * 32]; |
231 | 296k | TXFM_2D_FLIP_CFG cfg; |
232 | 296k | av1_get_fwd_txfm_cfg(tx_type, TX_32X32, &cfg); |
233 | 296k | fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf, bd); |
234 | 296k | } |
235 | | |
236 | | void av1_fwd_txfm2d_64x64_c(const int16_t *input, int32_t *output, int stride, |
237 | 222k | TX_TYPE tx_type, int bd) { |
238 | 222k | int32_t txfm_buf[64 * 64]; |
239 | 222k | TXFM_2D_FLIP_CFG cfg; |
240 | 222k | av1_get_fwd_txfm_cfg(tx_type, TX_64X64, &cfg); |
241 | 222k | fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf, bd); |
242 | | |
243 | | // Zero out top-right 32x32 area. |
244 | 7.35M | for (int row = 0; row < 32; ++row) { |
245 | 7.12M | memset(output + row * 64 + 32, 0, 32 * sizeof(*output)); |
246 | 7.12M | } |
247 | | // Zero out the bottom 64x32 area. |
248 | 222k | memset(output + 32 * 64, 0, 32 * 64 * sizeof(*output)); |
249 | | // Re-pack non-zero coeffs in the first 32x32 indices. |
250 | 7.12M | for (int row = 1; row < 32; ++row) { |
251 | 6.90M | memcpy(output + row * 32, output + row * 64, 32 * sizeof(*output)); |
252 | 6.90M | } |
253 | 222k | } |
254 | | |
255 | | void av1_fwd_txfm2d_32x64_c(const int16_t *input, int32_t *output, int stride, |
256 | 71.9k | TX_TYPE tx_type, int bd) { |
257 | 71.9k | DECLARE_ALIGNED(32, int32_t, txfm_buf[32 * 64]); |
258 | 71.9k | TXFM_2D_FLIP_CFG cfg; |
259 | 71.9k | av1_get_fwd_txfm_cfg(tx_type, TX_32X64, &cfg); |
260 | 71.9k | fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf, bd); |
261 | | // Zero out the bottom 32x32 area. |
262 | 71.9k | memset(output + 32 * 32, 0, 32 * 32 * sizeof(*output)); |
263 | | // Note: no repacking needed here. |
264 | 71.9k | } |
265 | | |
266 | | void av1_fwd_txfm2d_64x32_c(const int16_t *input, int32_t *output, int stride, |
267 | 69.5k | TX_TYPE tx_type, int bd) { |
268 | 69.5k | int32_t txfm_buf[64 * 32]; |
269 | 69.5k | TXFM_2D_FLIP_CFG cfg; |
270 | 69.5k | av1_get_fwd_txfm_cfg(tx_type, TX_64X32, &cfg); |
271 | 69.5k | fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf, bd); |
272 | | |
273 | | // Zero out right 32x32 area. |
274 | 2.29M | for (int row = 0; row < 32; ++row) { |
275 | 2.22M | memset(output + row * 64 + 32, 0, 32 * sizeof(*output)); |
276 | 2.22M | } |
277 | | // Re-pack non-zero coeffs in the first 32x32 indices. |
278 | 2.22M | for (int row = 1; row < 32; ++row) { |
279 | 2.15M | memcpy(output + row * 32, output + row * 64, 32 * sizeof(*output)); |
280 | 2.15M | } |
281 | 69.5k | } |
282 | | |
283 | | void av1_fwd_txfm2d_16x64_c(const int16_t *input, int32_t *output, int stride, |
284 | 0 | TX_TYPE tx_type, int bd) { |
285 | 0 | DECLARE_ALIGNED(32, int32_t, txfm_buf[64 * 16]); |
286 | 0 | TXFM_2D_FLIP_CFG cfg; |
287 | 0 | av1_get_fwd_txfm_cfg(tx_type, TX_16X64, &cfg); |
288 | 0 | fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf, bd); |
289 | | // Zero out the bottom 16x32 area. |
290 | 0 | memset(output + 16 * 32, 0, 16 * 32 * sizeof(*output)); |
291 | | // Note: no repacking needed here. |
292 | 0 | } |
293 | | |
294 | | void av1_fwd_txfm2d_64x16_c(const int16_t *input, int32_t *output, int stride, |
295 | 0 | TX_TYPE tx_type, int bd) { |
296 | 0 | int32_t txfm_buf[64 * 16]; |
297 | 0 | TXFM_2D_FLIP_CFG cfg; |
298 | 0 | av1_get_fwd_txfm_cfg(tx_type, TX_64X16, &cfg); |
299 | 0 | fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf, bd); |
300 | | // Zero out right 32x16 area. |
301 | 0 | for (int row = 0; row < 16; ++row) { |
302 | 0 | memset(output + row * 64 + 32, 0, 32 * sizeof(*output)); |
303 | 0 | } |
304 | | // Re-pack non-zero coeffs in the first 32x16 indices. |
305 | 0 | for (int row = 1; row < 16; ++row) { |
306 | 0 | memcpy(output + row * 32, output + row * 64, 32 * sizeof(*output)); |
307 | 0 | } |
308 | 0 | } |
309 | | |
310 | | static const int8_t fwd_shift_4x4[3] = { 2, 0, 0 }; |
311 | | static const int8_t fwd_shift_8x8[3] = { 2, -1, 0 }; |
312 | | static const int8_t fwd_shift_16x16[3] = { 2, -2, 0 }; |
313 | | static const int8_t fwd_shift_32x32[3] = { 2, -4, 0 }; |
314 | | static const int8_t fwd_shift_64x64[3] = { 0, -2, -2 }; |
315 | | static const int8_t fwd_shift_4x8[3] = { 2, -1, 0 }; |
316 | | static const int8_t fwd_shift_8x4[3] = { 2, -1, 0 }; |
317 | | static const int8_t fwd_shift_8x16[3] = { 2, -2, 0 }; |
318 | | static const int8_t fwd_shift_16x8[3] = { 2, -2, 0 }; |
319 | | static const int8_t fwd_shift_16x32[3] = { 2, -4, 0 }; |
320 | | static const int8_t fwd_shift_32x16[3] = { 2, -4, 0 }; |
321 | | static const int8_t fwd_shift_32x64[3] = { 0, -2, -2 }; |
322 | | static const int8_t fwd_shift_64x32[3] = { 2, -4, -2 }; |
323 | | static const int8_t fwd_shift_4x16[3] = { 2, -1, 0 }; |
324 | | static const int8_t fwd_shift_16x4[3] = { 2, -1, 0 }; |
325 | | static const int8_t fwd_shift_8x32[3] = { 2, -2, 0 }; |
326 | | static const int8_t fwd_shift_32x8[3] = { 2, -2, 0 }; |
327 | | static const int8_t fwd_shift_16x64[3] = { 0, -2, 0 }; |
328 | | static const int8_t fwd_shift_64x16[3] = { 2, -4, 0 }; |
329 | | |
330 | | const int8_t *av1_fwd_txfm_shift_ls[TX_SIZES_ALL] = { |
331 | | fwd_shift_4x4, fwd_shift_8x8, fwd_shift_16x16, fwd_shift_32x32, |
332 | | fwd_shift_64x64, fwd_shift_4x8, fwd_shift_8x4, fwd_shift_8x16, |
333 | | fwd_shift_16x8, fwd_shift_16x32, fwd_shift_32x16, fwd_shift_32x64, |
334 | | fwd_shift_64x32, fwd_shift_4x16, fwd_shift_16x4, fwd_shift_8x32, |
335 | | fwd_shift_32x8, fwd_shift_16x64, fwd_shift_64x16, |
336 | | }; |
337 | | |
338 | | const int8_t av1_fwd_cos_bit_col[MAX_TXWH_IDX /*txw_idx*/] |
339 | | [MAX_TXWH_IDX /*txh_idx*/] = { |
340 | | { 13, 13, 13, 0, 0 }, |
341 | | { 13, 13, 13, 12, 0 }, |
342 | | { 13, 13, 13, 12, 13 }, |
343 | | { 0, 13, 13, 12, 13 }, |
344 | | { 0, 0, 13, 12, 13 } |
345 | | }; |
346 | | |
347 | | const int8_t av1_fwd_cos_bit_row[MAX_TXWH_IDX /*txw_idx*/] |
348 | | [MAX_TXWH_IDX /*txh_idx*/] = { |
349 | | { 13, 13, 12, 0, 0 }, |
350 | | { 13, 13, 13, 12, 0 }, |
351 | | { 13, 13, 12, 13, 12 }, |
352 | | { 0, 12, 13, 12, 11 }, |
353 | | { 0, 0, 12, 11, 10 } |
354 | | }; |
355 | | |
356 | | static const int8_t fdct4_range_mult2[4] = { 0, 2, 3, 3 }; |
357 | | static const int8_t fdct8_range_mult2[6] = { 0, 2, 4, 5, 5, 5 }; |
358 | | static const int8_t fdct16_range_mult2[8] = { 0, 2, 4, 6, 7, 7, 7, 7 }; |
359 | | static const int8_t fdct32_range_mult2[10] = { 0, 2, 4, 6, 8, 9, 9, 9, 9, 9 }; |
360 | | static const int8_t fdct64_range_mult2[12] = { 0, 2, 4, 6, 8, 10, |
361 | | 11, 11, 11, 11, 11, 11 }; |
362 | | |
363 | | static const int8_t fadst4_range_mult2[7] = { 0, 2, 4, 3, 3, 3, 3 }; |
364 | | static const int8_t fadst8_range_mult2[8] = { 0, 0, 1, 3, 3, 5, 5, 5 }; |
365 | | static const int8_t fadst16_range_mult2[10] = { 0, 0, 1, 3, 3, 5, 5, 7, 7, 7 }; |
366 | | |
367 | | static const int8_t fidtx4_range_mult2[1] = { 1 }; |
368 | | static const int8_t fidtx8_range_mult2[1] = { 2 }; |
369 | | static const int8_t fidtx16_range_mult2[1] = { 3 }; |
370 | | static const int8_t fidtx32_range_mult2[1] = { 4 }; |
371 | | |
372 | | #if 0 |
373 | | const int8_t fwd_idtx_range_row[MAX_TXWH_IDX /*txw_idx*/] |
374 | | [MAX_TXWH_IDX /*txh_idx*/] = { { 2, 4, 5, 0, 0 }, |
375 | | { 3, 4, 5, 6, 0 }, |
376 | | { 4, 5, 6, 7, 8 }, |
377 | | { 0, 5, 6, 7, 8 }, |
378 | | { 0, 0, 7, 8, |
379 | | 9 } }; |
380 | | #endif |
381 | | |
382 | | static const int8_t *fwd_txfm_range_mult2_list[TXFM_TYPES] = { |
383 | | fdct4_range_mult2, fdct8_range_mult2, fdct16_range_mult2, |
384 | | fdct32_range_mult2, fdct64_range_mult2, fadst4_range_mult2, |
385 | | fadst8_range_mult2, fadst16_range_mult2, fidtx4_range_mult2, |
386 | | fidtx8_range_mult2, fidtx16_range_mult2, fidtx32_range_mult2 |
387 | | }; |
388 | | |
389 | 5.24M | static INLINE void set_fwd_txfm_non_scale_range(TXFM_2D_FLIP_CFG *cfg) { |
390 | 5.24M | av1_zero(cfg->stage_range_col); |
391 | 5.24M | av1_zero(cfg->stage_range_row); |
392 | | |
393 | 5.24M | const int8_t *range_mult2_col = fwd_txfm_range_mult2_list[cfg->txfm_type_col]; |
394 | 5.24M | if (cfg->txfm_type_col != TXFM_TYPE_INVALID) { |
395 | 5.24M | int stage_num_col = cfg->stage_num_col; |
396 | 42.1M | for (int i = 0; i < stage_num_col; ++i) |
397 | 36.9M | cfg->stage_range_col[i] = (range_mult2_col[i] + 1) >> 1; |
398 | 5.24M | } |
399 | | |
400 | 5.24M | if (cfg->txfm_type_row != TXFM_TYPE_INVALID) { |
401 | 5.24M | int stage_num_row = cfg->stage_num_row; |
402 | 5.24M | const int8_t *range_mult2_row = |
403 | 5.24M | fwd_txfm_range_mult2_list[cfg->txfm_type_row]; |
404 | 43.1M | for (int i = 0; i < stage_num_row; ++i) { |
405 | 37.8M | cfg->stage_range_row[i] = |
406 | 37.8M | (range_mult2_col[cfg->stage_num_col - 1] + range_mult2_row[i] + 1) >> |
407 | 37.8M | 1; |
408 | 37.8M | } |
409 | 5.24M | } |
410 | 5.24M | } |
411 | | |
412 | | void av1_get_fwd_txfm_cfg(TX_TYPE tx_type, TX_SIZE tx_size, |
413 | 5.24M | TXFM_2D_FLIP_CFG *cfg) { |
414 | 5.24M | assert(cfg != NULL); |
415 | 5.24M | cfg->tx_size = tx_size; |
416 | 5.24M | set_flip_cfg(tx_type, cfg); |
417 | 5.24M | const TX_TYPE_1D tx_type_1d_col = vtx_tab[tx_type]; |
418 | 5.24M | const TX_TYPE_1D tx_type_1d_row = htx_tab[tx_type]; |
419 | 5.24M | const int txw_idx = get_txw_idx(tx_size); |
420 | 5.24M | const int txh_idx = get_txh_idx(tx_size); |
421 | 5.24M | cfg->shift = av1_fwd_txfm_shift_ls[tx_size]; |
422 | 5.24M | cfg->cos_bit_col = av1_fwd_cos_bit_col[txw_idx][txh_idx]; |
423 | 5.24M | cfg->cos_bit_row = av1_fwd_cos_bit_row[txw_idx][txh_idx]; |
424 | 5.24M | cfg->txfm_type_col = av1_txfm_type_ls[txh_idx][tx_type_1d_col]; |
425 | 5.24M | cfg->txfm_type_row = av1_txfm_type_ls[txw_idx][tx_type_1d_row]; |
426 | 5.24M | cfg->stage_num_col = av1_txfm_stage_num_list[cfg->txfm_type_col]; |
427 | 5.24M | cfg->stage_num_row = av1_txfm_stage_num_list[cfg->txfm_type_row]; |
428 | 5.24M | set_fwd_txfm_non_scale_range(cfg); |
429 | 5.24M | } |