Coverage Report

Created: 2022-08-24 06:17

/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
0
static INLINE TxfmFunc fwd_txfm_type_to_func(TXFM_TYPE txfm_type) {
24
0
  switch (txfm_type) {
25
0
    case TXFM_TYPE_DCT4: return av1_fdct4;
26
0
    case TXFM_TYPE_DCT8: return av1_fdct8;
27
0
    case TXFM_TYPE_DCT16: return av1_fdct16;
28
0
    case TXFM_TYPE_DCT32: return av1_fdct32;
29
0
    case TXFM_TYPE_DCT64: return av1_fdct64;
30
0
    case TXFM_TYPE_ADST4: return av1_fadst4;
31
0
    case TXFM_TYPE_ADST8: return av1_fadst8;
32
0
    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
0
  }
39
0
}
40
41
void av1_gen_fwd_stage_range(int8_t *stage_range_col, int8_t *stage_range_row,
42
0
                             const TXFM_2D_FLIP_CFG *cfg, int bd) {
43
  // Take the shift from the larger dimension in the rectangular case.
44
0
  const int8_t *shift = cfg->shift;
45
  // i < MAX_TXFM_STAGE_NUM will mute above array bounds warning
46
0
  for (int i = 0; i < cfg->stage_num_col && i < MAX_TXFM_STAGE_NUM; ++i) {
47
0
    stage_range_col[i] = cfg->stage_range_col[i] + shift[0] + bd + 1;
48
0
  }
49
50
  // i < MAX_TXFM_STAGE_NUM will mute above array bounds warning
51
0
  for (int i = 0; i < cfg->stage_num_row && i < MAX_TXFM_STAGE_NUM; ++i) {
52
0
    stage_range_row[i] = cfg->stage_range_row[i] + shift[0] + shift[1] + bd + 1;
53
0
  }
54
0
}
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
0
                                int32_t *buf, int bd) {
59
0
  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
0
  const int txfm_size_col = tx_size_wide[cfg->tx_size];
67
0
  const int txfm_size_row = tx_size_high[cfg->tx_size];
68
  // Take the shift from the larger dimension in the rectangular case.
69
0
  const int8_t *shift = cfg->shift;
70
0
  const int rect_type = get_rect_tx_log_ratio(txfm_size_col, txfm_size_row);
71
0
  int8_t stage_range_col[MAX_TXFM_STAGE_NUM];
72
0
  int8_t stage_range_row[MAX_TXFM_STAGE_NUM];
73
0
  assert(cfg->stage_num_col <= MAX_TXFM_STAGE_NUM);
74
0
  assert(cfg->stage_num_row <= MAX_TXFM_STAGE_NUM);
75
0
  av1_gen_fwd_stage_range(stage_range_col, stage_range_row, cfg, bd);
76
77
0
  const int8_t cos_bit_col = cfg->cos_bit_col;
78
0
  const int8_t cos_bit_row = cfg->cos_bit_row;
79
0
  const TxfmFunc txfm_func_col = fwd_txfm_type_to_func(cfg->txfm_type_col);
80
0
  const TxfmFunc txfm_func_row = fwd_txfm_type_to_func(cfg->txfm_type_row);
81
82
  // use output buffer as temp buffer
83
0
  int32_t *temp_in = output;
84
0
  int32_t *temp_out = output + txfm_size_row;
85
86
  // Columns
87
0
  for (c = 0; c < txfm_size_col; ++c) {
88
0
    if (cfg->ud_flip == 0) {
89
0
      for (r = 0; r < txfm_size_row; ++r) temp_in[r] = input[r * stride + c];
90
0
    } else {
91
0
      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
0
    }
95
0
    av1_round_shift_array(temp_in, txfm_size_row, -shift[0]);
96
0
    txfm_func_col(temp_in, temp_out, cos_bit_col, stage_range_col);
97
0
    av1_round_shift_array(temp_out, txfm_size_row, -shift[1]);
98
0
    if (cfg->lr_flip == 0) {
99
0
      for (r = 0; r < txfm_size_row; ++r)
100
0
        buf[r * txfm_size_col + c] = temp_out[r];
101
0
    } else {
102
0
      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
0
    }
106
0
  }
107
108
  // Rows
109
0
  for (r = 0; r < txfm_size_row; ++r) {
110
0
    txfm_func_row(buf + r * txfm_size_col, output + r * txfm_size_col,
111
0
                  cos_bit_row, stage_range_row);
112
0
    av1_round_shift_array(output + r * txfm_size_col, txfm_size_col, -shift[2]);
113
0
    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
0
      for (c = 0; c < txfm_size_col; ++c) {
117
0
        output[r * txfm_size_col + c] = round_shift(
118
0
            (int64_t)output[r * txfm_size_col + c] * NewSqrt2, NewSqrt2Bits);
119
0
      }
120
0
    }
121
0
  }
122
0
}
123
124
void av1_fwd_txfm2d_4x8_c(const int16_t *input, int32_t *output, int stride,
125
0
                          TX_TYPE tx_type, int bd) {
126
0
  DECLARE_ALIGNED(32, int32_t, txfm_buf[4 * 8]);
127
0
  TXFM_2D_FLIP_CFG cfg;
128
0
  av1_get_fwd_txfm_cfg(tx_type, TX_4X8, &cfg);
129
0
  fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf, bd);
130
0
}
131
132
void av1_fwd_txfm2d_8x4_c(const int16_t *input, int32_t *output, int stride,
133
0
                          TX_TYPE tx_type, int bd) {
134
0
  int32_t txfm_buf[8 * 4];
135
0
  TXFM_2D_FLIP_CFG cfg;
136
0
  av1_get_fwd_txfm_cfg(tx_type, TX_8X4, &cfg);
137
0
  fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf, bd);
138
0
}
139
140
void av1_fwd_txfm2d_8x16_c(const int16_t *input, int32_t *output, int stride,
141
0
                           TX_TYPE tx_type, int bd) {
142
0
  DECLARE_ALIGNED(32, int32_t, txfm_buf[8 * 16]);
143
0
  TXFM_2D_FLIP_CFG cfg;
144
0
  av1_get_fwd_txfm_cfg(tx_type, TX_8X16, &cfg);
145
0
  fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf, bd);
146
0
}
147
148
void av1_fwd_txfm2d_16x8_c(const int16_t *input, int32_t *output, int stride,
149
0
                           TX_TYPE tx_type, int bd) {
150
0
  int32_t txfm_buf[16 * 8];
151
0
  TXFM_2D_FLIP_CFG cfg;
152
0
  av1_get_fwd_txfm_cfg(tx_type, TX_16X8, &cfg);
153
0
  fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf, bd);
154
0
}
155
156
void av1_fwd_txfm2d_16x32_c(const int16_t *input, int32_t *output, int stride,
157
0
                            TX_TYPE tx_type, int bd) {
158
0
  DECLARE_ALIGNED(32, int32_t, txfm_buf[16 * 32]);
159
0
  TXFM_2D_FLIP_CFG cfg;
160
0
  av1_get_fwd_txfm_cfg(tx_type, TX_16X32, &cfg);
161
0
  fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf, bd);
162
0
}
163
164
void av1_fwd_txfm2d_32x16_c(const int16_t *input, int32_t *output, int stride,
165
0
                            TX_TYPE tx_type, int bd) {
166
0
  int32_t txfm_buf[32 * 16];
167
0
  TXFM_2D_FLIP_CFG cfg;
168
0
  av1_get_fwd_txfm_cfg(tx_type, TX_32X16, &cfg);
169
0
  fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf, bd);
170
0
}
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
0
                          TX_TYPE tx_type, int bd) {
206
0
  int32_t txfm_buf[4 * 4];
207
0
  TXFM_2D_FLIP_CFG cfg;
208
0
  av1_get_fwd_txfm_cfg(tx_type, TX_4X4, &cfg);
209
0
  fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf, bd);
210
0
}
211
212
void av1_fwd_txfm2d_8x8_c(const int16_t *input, int32_t *output, int stride,
213
0
                          TX_TYPE tx_type, int bd) {
214
0
  int32_t txfm_buf[8 * 8];
215
0
  TXFM_2D_FLIP_CFG cfg;
216
0
  av1_get_fwd_txfm_cfg(tx_type, TX_8X8, &cfg);
217
0
  fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf, bd);
218
0
}
219
220
void av1_fwd_txfm2d_16x16_c(const int16_t *input, int32_t *output, int stride,
221
0
                            TX_TYPE tx_type, int bd) {
222
0
  int32_t txfm_buf[16 * 16];
223
0
  TXFM_2D_FLIP_CFG cfg;
224
0
  av1_get_fwd_txfm_cfg(tx_type, TX_16X16, &cfg);
225
0
  fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf, bd);
226
0
}
227
228
void av1_fwd_txfm2d_32x32_c(const int16_t *input, int32_t *output, int stride,
229
0
                            TX_TYPE tx_type, int bd) {
230
0
  int32_t txfm_buf[32 * 32];
231
0
  TXFM_2D_FLIP_CFG cfg;
232
0
  av1_get_fwd_txfm_cfg(tx_type, TX_32X32, &cfg);
233
0
  fwd_txfm2d_c(input, output, stride, &cfg, txfm_buf, bd);
234
0
}
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
0
static INLINE void set_fwd_txfm_non_scale_range(TXFM_2D_FLIP_CFG *cfg) {
390
0
  av1_zero(cfg->stage_range_col);
391
0
  av1_zero(cfg->stage_range_row);
392
393
0
  const int8_t *range_mult2_col = fwd_txfm_range_mult2_list[cfg->txfm_type_col];
394
0
  if (cfg->txfm_type_col != TXFM_TYPE_INVALID) {
395
0
    int stage_num_col = cfg->stage_num_col;
396
0
    for (int i = 0; i < stage_num_col; ++i)
397
0
      cfg->stage_range_col[i] = (range_mult2_col[i] + 1) >> 1;
398
0
  }
399
400
0
  if (cfg->txfm_type_row != TXFM_TYPE_INVALID) {
401
0
    int stage_num_row = cfg->stage_num_row;
402
0
    const int8_t *range_mult2_row =
403
0
        fwd_txfm_range_mult2_list[cfg->txfm_type_row];
404
0
    for (int i = 0; i < stage_num_row; ++i) {
405
0
      cfg->stage_range_row[i] =
406
0
          (range_mult2_col[cfg->stage_num_col - 1] + range_mult2_row[i] + 1) >>
407
0
          1;
408
0
    }
409
0
  }
410
0
}
411
412
void av1_get_fwd_txfm_cfg(TX_TYPE tx_type, TX_SIZE tx_size,
413
0
                          TXFM_2D_FLIP_CFG *cfg) {
414
0
  assert(cfg != NULL);
415
0
  cfg->tx_size = tx_size;
416
0
  set_flip_cfg(tx_type, cfg);
417
0
  const TX_TYPE_1D tx_type_1d_col = vtx_tab[tx_type];
418
0
  const TX_TYPE_1D tx_type_1d_row = htx_tab[tx_type];
419
0
  const int txw_idx = get_txw_idx(tx_size);
420
0
  const int txh_idx = get_txh_idx(tx_size);
421
0
  cfg->shift = av1_fwd_txfm_shift_ls[tx_size];
422
0
  cfg->cos_bit_col = av1_fwd_cos_bit_col[txw_idx][txh_idx];
423
0
  cfg->cos_bit_row = av1_fwd_cos_bit_row[txw_idx][txh_idx];
424
0
  cfg->txfm_type_col = av1_txfm_type_ls[txh_idx][tx_type_1d_col];
425
0
  cfg->txfm_type_row = av1_txfm_type_ls[txw_idx][tx_type_1d_row];
426
0
  cfg->stage_num_col = av1_txfm_stage_num_list[cfg->txfm_type_col];
427
0
  cfg->stage_num_row = av1_txfm_stage_num_list[cfg->txfm_type_row];
428
0
  set_fwd_txfm_non_scale_range(cfg);
429
0
}