Coverage Report

Created: 2026-02-26 06:26

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/work/aom/av1/encoder/av1_fwd_txfm2d.c
Line
Count
Source
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
2.44M
static INLINE TxfmFunc fwd_txfm_type_to_func(TXFM_TYPE txfm_type) {
24
2.44M
  switch (txfm_type) {
25
285k
    case TXFM_TYPE_DCT4: return av1_fdct4;
26
504k
    case TXFM_TYPE_DCT8: return av1_fdct8;
27
673k
    case TXFM_TYPE_DCT16: return av1_fdct16;
28
507k
    case TXFM_TYPE_DCT32: return av1_fdct32;
29
0
    case TXFM_TYPE_DCT64: return av1_fdct64;
30
38.4k
    case TXFM_TYPE_ADST4: return av1_fadst4;
31
257k
    case TXFM_TYPE_ADST8: return av1_fadst8;
32
181k
    case TXFM_TYPE_ADST16: return av1_fadst16;
33
0
    case TXFM_TYPE_IDENTITY4: return av1_fidentity4_c;
34
0
    case TXFM_TYPE_IDENTITY8: return av1_fidentity8_c;
35
0
    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
2.44M
  }
39
2.44M
}
40
41
void av1_gen_fwd_stage_range(int8_t *stage_range_col, int8_t *stage_range_row,
42
1.22M
                             const TXFM_2D_FLIP_CFG *cfg, int bd) {
43
  // Take the shift from the larger dimension in the rectangular case.
44
1.22M
  const int8_t *shift = cfg->shift;
45
  // i < MAX_TXFM_STAGE_NUM will mute above array bounds warning
46
10.5M
  for (int i = 0; i < cfg->stage_num_col && i < MAX_TXFM_STAGE_NUM; ++i) {
47
9.35M
    stage_range_col[i] = cfg->stage_range_col[i] + shift[0] + bd + 1;
48
9.35M
  }
49
50
  // i < MAX_TXFM_STAGE_NUM will mute above array bounds warning
51
10.6M
  for (int i = 0; i < cfg->stage_num_row && i < MAX_TXFM_STAGE_NUM; ++i) {
52
9.41M
    stage_range_row[i] = cfg->stage_range_row[i] + shift[0] + shift[1] + bd + 1;
53
9.41M
  }
54
1.22M
}
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
1.22M
                                int32_t *buf, int bd) {
59
1.22M
  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
1.22M
  const int txfm_size_col = tx_size_wide[cfg->tx_size];
67
1.22M
  const int txfm_size_row = tx_size_high[cfg->tx_size];
68
  // Take the shift from the larger dimension in the rectangular case.
69
1.22M
  const int8_t *shift = cfg->shift;
70
1.22M
  const int rect_type = get_rect_tx_log_ratio(txfm_size_col, txfm_size_row);
71
1.22M
  int8_t stage_range_col[MAX_TXFM_STAGE_NUM];
72
1.22M
  int8_t stage_range_row[MAX_TXFM_STAGE_NUM];
73
1.22M
  assert(cfg->stage_num_col <= MAX_TXFM_STAGE_NUM);
74
1.22M
  assert(cfg->stage_num_row <= MAX_TXFM_STAGE_NUM);
75
1.22M
  av1_gen_fwd_stage_range(stage_range_col, stage_range_row, cfg, bd);
76
77
1.22M
  const int8_t cos_bit_col = cfg->cos_bit_col;
78
1.22M
  const int8_t cos_bit_row = cfg->cos_bit_row;
79
1.22M
  const TxfmFunc txfm_func_col = fwd_txfm_type_to_func(cfg->txfm_type_col);
80
1.22M
  const TxfmFunc txfm_func_row = fwd_txfm_type_to_func(cfg->txfm_type_row);
81
82
  // use output buffer as temp buffer
83
1.22M
  int32_t *temp_in = output;
84
1.22M
  int32_t *temp_out = output + txfm_size_row;
85
86
  // Columns
87
19.9M
  for (c = 0; c < txfm_size_col; ++c) {
88
18.6M
    if (cfg->ud_flip == 0) {
89
399M
      for (r = 0; r < txfm_size_row; ++r) temp_in[r] = input[r * stride + c];
90
18.6M
    } else {
91
3.82k
      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
3.82k
    }
95
18.6M
    av1_round_shift_array(temp_in, txfm_size_row, -shift[0]);
96
18.6M
    txfm_func_col(temp_in, temp_out, cos_bit_col, stage_range_col);
97
18.6M
    av1_round_shift_array(temp_out, txfm_size_row, -shift[1]);
98
18.6M
    if (cfg->lr_flip == 0) {
99
399M
      for (r = 0; r < txfm_size_row; ++r)
100
380M
        buf[r * txfm_size_col + c] = temp_out[r];
101
18.6M
    } else {
102
6.76k
      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
6.76k
    }
106
18.6M
  }
107
108
  // Rows
109
19.7M
  for (r = 0; r < txfm_size_row; ++r) {
110
18.5M
    txfm_func_row(buf + r * txfm_size_col, output + r * txfm_size_col,
111
18.5M
                  cos_bit_row, stage_range_row);
112
18.5M
    av1_round_shift_array(output + r * txfm_size_col, txfm_size_col, -shift[2]);
113
18.5M
    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
57.9M
      for (c = 0; c < txfm_size_col; ++c) {
117
54.3M
        output[r * txfm_size_col + c] = round_shift(
118
54.3M
            (int64_t)output[r * txfm_size_col + c] * NewSqrt2, NewSqrt2Bits);
119
54.3M
      }
120
3.59M
    }
121
18.5M
  }
122
1.22M
}
123
124
void av1_fwd_txfm2d_4x8_c(const int16_t *input, int32_t *output, int stride,
125
23.1k
                          TX_TYPE tx_type, int bd) {
126
23.1k
  DECLARE_ALIGNED(32, int32_t, txfm_buf[4 * 8]);
127
23.1k
  TXFM_2D_FLIP_CFG cfg;
128
23.1k
  av1_get_fwd_txfm_cfg(tx_type, TX_4X8, &cfg);
129
23.1k
  fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf, bd);
130
23.1k
}
131
132
void av1_fwd_txfm2d_8x4_c(const int16_t *input, int32_t *output, int stride,
133
28.1k
                          TX_TYPE tx_type, int bd) {
134
28.1k
  int32_t txfm_buf[8 * 4];
135
28.1k
  TXFM_2D_FLIP_CFG cfg;
136
28.1k
  av1_get_fwd_txfm_cfg(tx_type, TX_8X4, &cfg);
137
28.1k
  fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf, bd);
138
28.1k
}
139
140
void av1_fwd_txfm2d_8x16_c(const int16_t *input, int32_t *output, int stride,
141
68.2k
                           TX_TYPE tx_type, int bd) {
142
68.2k
  DECLARE_ALIGNED(32, int32_t, txfm_buf[8 * 16]);
143
68.2k
  TXFM_2D_FLIP_CFG cfg;
144
68.2k
  av1_get_fwd_txfm_cfg(tx_type, TX_8X16, &cfg);
145
68.2k
  fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf, bd);
146
68.2k
}
147
148
void av1_fwd_txfm2d_16x8_c(const int16_t *input, int32_t *output, int stride,
149
79.5k
                           TX_TYPE tx_type, int bd) {
150
79.5k
  int32_t txfm_buf[16 * 8];
151
79.5k
  TXFM_2D_FLIP_CFG cfg;
152
79.5k
  av1_get_fwd_txfm_cfg(tx_type, TX_16X8, &cfg);
153
79.5k
  fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf, bd);
154
79.5k
}
155
156
void av1_fwd_txfm2d_16x32_c(const int16_t *input, int32_t *output, int stride,
157
31.8k
                            TX_TYPE tx_type, int bd) {
158
31.8k
  DECLARE_ALIGNED(32, int32_t, txfm_buf[16 * 32]);
159
31.8k
  TXFM_2D_FLIP_CFG cfg;
160
31.8k
  av1_get_fwd_txfm_cfg(tx_type, TX_16X32, &cfg);
161
31.8k
  fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf, bd);
162
31.8k
}
163
164
void av1_fwd_txfm2d_32x16_c(const int16_t *input, int32_t *output, int stride,
165
34.2k
                            TX_TYPE tx_type, int bd) {
166
34.2k
  int32_t txfm_buf[32 * 16];
167
34.2k
  TXFM_2D_FLIP_CFG cfg;
168
34.2k
  av1_get_fwd_txfm_cfg(tx_type, TX_32X16, &cfg);
169
34.2k
  fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf, bd);
170
34.2k
}
171
172
void av1_fwd_txfm2d_4x16_c(const int16_t *input, int32_t *output, int stride,
173
0
                           TX_TYPE tx_type, int bd) {
174
0
  DECLARE_ALIGNED(32, int32_t, txfm_buf[4 * 16]);
175
0
  TXFM_2D_FLIP_CFG cfg;
176
0
  av1_get_fwd_txfm_cfg(tx_type, TX_4X16, &cfg);
177
0
  fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf, bd);
178
0
}
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
0
                           TX_TYPE tx_type, int bd) {
190
0
  DECLARE_ALIGNED(32, int32_t, txfm_buf[32 * 8]);
191
0
  TXFM_2D_FLIP_CFG cfg;
192
0
  av1_get_fwd_txfm_cfg(tx_type, TX_8X32, &cfg);
193
0
  fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf, bd);
194
0
}
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
136k
                          TX_TYPE tx_type, int bd) {
206
136k
  int32_t txfm_buf[4 * 4];
207
136k
  TXFM_2D_FLIP_CFG cfg;
208
136k
  av1_get_fwd_txfm_cfg(tx_type, TX_4X4, &cfg);
209
136k
  fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf, bd);
210
136k
}
211
212
void av1_fwd_txfm2d_8x8_c(const int16_t *input, int32_t *output, int stride,
213
281k
                          TX_TYPE tx_type, int bd) {
214
281k
  int32_t txfm_buf[8 * 8];
215
281k
  TXFM_2D_FLIP_CFG cfg;
216
281k
  av1_get_fwd_txfm_cfg(tx_type, TX_8X8, &cfg);
217
281k
  fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf, bd);
218
281k
}
219
220
void av1_fwd_txfm2d_16x16_c(const int16_t *input, int32_t *output, int stride,
221
320k
                            TX_TYPE tx_type, int bd) {
222
320k
  int32_t txfm_buf[16 * 16];
223
320k
  TXFM_2D_FLIP_CFG cfg;
224
320k
  av1_get_fwd_txfm_cfg(tx_type, TX_16X16, &cfg);
225
320k
  fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf, bd);
226
320k
}
227
228
void av1_fwd_txfm2d_32x32_c(const int16_t *input, int32_t *output, int stride,
229
220k
                            TX_TYPE tx_type, int bd) {
230
220k
  int32_t txfm_buf[32 * 32];
231
220k
  TXFM_2D_FLIP_CFG cfg;
232
220k
  av1_get_fwd_txfm_cfg(tx_type, TX_32X32, &cfg);
233
220k
  fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf, bd);
234
220k
}
235
236
void av1_fwd_txfm2d_64x64_c(const int16_t *input, int32_t *output, int stride,
237
0
                            TX_TYPE tx_type, int bd) {
238
0
  int32_t txfm_buf[64 * 64];
239
0
  TXFM_2D_FLIP_CFG cfg;
240
0
  av1_get_fwd_txfm_cfg(tx_type, TX_64X64, &cfg);
241
0
  fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf, bd);
242
243
  // Zero out top-right 32x32 area.
244
0
  for (int row = 0; row < 32; ++row) {
245
0
    memset(output + row * 64 + 32, 0, 32 * sizeof(*output));
246
0
  }
247
  // Zero out the bottom 64x32 area.
248
0
  memset(output + 32 * 64, 0, 32 * 64 * sizeof(*output));
249
  // Re-pack non-zero coeffs in the first 32x32 indices.
250
0
  for (int row = 1; row < 32; ++row) {
251
0
    memcpy(output + row * 32, output + row * 64, 32 * sizeof(*output));
252
0
  }
253
0
}
254
255
void av1_fwd_txfm2d_32x64_c(const int16_t *input, int32_t *output, int stride,
256
0
                            TX_TYPE tx_type, int bd) {
257
0
  DECLARE_ALIGNED(32, int32_t, txfm_buf[32 * 64]);
258
0
  TXFM_2D_FLIP_CFG cfg;
259
0
  av1_get_fwd_txfm_cfg(tx_type, TX_32X64, &cfg);
260
0
  fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf, bd);
261
  // Zero out the bottom 32x32 area.
262
0
  memset(output + 32 * 32, 0, 32 * 32 * sizeof(*output));
263
  // Note: no repacking needed here.
264
0
}
265
266
void av1_fwd_txfm2d_64x32_c(const int16_t *input, int32_t *output, int stride,
267
0
                            TX_TYPE tx_type, int bd) {
268
0
  int32_t txfm_buf[64 * 32];
269
0
  TXFM_2D_FLIP_CFG cfg;
270
0
  av1_get_fwd_txfm_cfg(tx_type, TX_64X32, &cfg);
271
0
  fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf, bd);
272
273
  // Zero out right 32x32 area.
274
0
  for (int row = 0; row < 32; ++row) {
275
0
    memset(output + row * 64 + 32, 0, 32 * sizeof(*output));
276
0
  }
277
  // Re-pack non-zero coeffs in the first 32x32 indices.
278
0
  for (int row = 1; row < 32; ++row) {
279
0
    memcpy(output + row * 32, output + row * 64, 32 * sizeof(*output));
280
0
  }
281
0
}
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
1.22M
static INLINE void set_fwd_txfm_non_scale_range(TXFM_2D_FLIP_CFG *cfg) {
390
1.22M
  av1_zero(cfg->stage_range_col);
391
1.22M
  av1_zero(cfg->stage_range_row);
392
393
1.22M
  const int8_t *range_mult2_col = fwd_txfm_range_mult2_list[cfg->txfm_type_col];
394
1.22M
  if (cfg->txfm_type_col != TXFM_TYPE_INVALID) {
395
1.22M
    int stage_num_col = cfg->stage_num_col;
396
10.5M
    for (int i = 0; i < stage_num_col; ++i)
397
9.36M
      cfg->stage_range_col[i] = (range_mult2_col[i] + 1) >> 1;
398
1.22M
  }
399
400
1.22M
  if (cfg->txfm_type_row != TXFM_TYPE_INVALID) {
401
1.22M
    int stage_num_row = cfg->stage_num_row;
402
1.22M
    const int8_t *range_mult2_row =
403
1.22M
        fwd_txfm_range_mult2_list[cfg->txfm_type_row];
404
10.6M
    for (int i = 0; i < stage_num_row; ++i) {
405
9.41M
      cfg->stage_range_row[i] =
406
9.41M
          (range_mult2_col[cfg->stage_num_col - 1] + range_mult2_row[i] + 1) >>
407
9.41M
          1;
408
9.41M
    }
409
1.22M
  }
410
1.22M
}
411
412
void av1_get_fwd_txfm_cfg(TX_TYPE tx_type, TX_SIZE tx_size,
413
1.22M
                          TXFM_2D_FLIP_CFG *cfg) {
414
  assert(cfg != NULL);
415
1.22M
  cfg->tx_size = tx_size;
416
1.22M
  set_flip_cfg(tx_type, cfg);
417
1.22M
  const TX_TYPE_1D tx_type_1d_col = vtx_tab[tx_type];
418
1.22M
  const TX_TYPE_1D tx_type_1d_row = htx_tab[tx_type];
419
1.22M
  const int txw_idx = get_txw_idx(tx_size);
420
1.22M
  const int txh_idx = get_txh_idx(tx_size);
421
1.22M
  cfg->shift = av1_fwd_txfm_shift_ls[tx_size];
422
1.22M
  cfg->cos_bit_col = av1_fwd_cos_bit_col[txw_idx][txh_idx];
423
1.22M
  cfg->cos_bit_row = av1_fwd_cos_bit_row[txw_idx][txh_idx];
424
1.22M
  cfg->txfm_type_col = av1_txfm_type_ls[txh_idx][tx_type_1d_col];
425
1.22M
  cfg->txfm_type_row = av1_txfm_type_ls[txw_idx][tx_type_1d_row];
426
1.22M
  cfg->stage_num_col = av1_txfm_stage_num_list[cfg->txfm_type_col];
427
1.22M
  cfg->stage_num_row = av1_txfm_stage_num_list[cfg->txfm_type_row];
428
1.22M
  set_fwd_txfm_non_scale_range(cfg);
429
1.22M
}