Coverage Report

Created: 2026-02-26 06:26

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/work/aom/av1/common/av1_inv_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 "config/aom_dsp_rtcd.h"
13
#include "config/av1_rtcd.h"
14
15
#include "av1/common/enums.h"
16
#include "av1/common/av1_txfm.h"
17
#include "av1/common/av1_inv_txfm1d.h"
18
#include "av1/common/av1_inv_txfm1d_cfg.h"
19
20
void av1_highbd_iwht4x4_16_add_c(const tran_low_t *input, uint8_t *dest8,
21
2.49k
                                 int stride, int bd) {
22
  /* 4-point reversible, orthonormal inverse Walsh-Hadamard in 3.5 adds,
23
     0.5 shifts per pixel. */
24
2.49k
  int i;
25
2.49k
  tran_low_t output[16];
26
2.49k
  tran_low_t a1, b1, c1, d1, e1;
27
2.49k
  const tran_low_t *ip = input;
28
2.49k
  tran_low_t *op = output;
29
2.49k
  uint16_t *dest = CONVERT_TO_SHORTPTR(dest8);
30
31
12.4k
  for (i = 0; i < 4; i++) {
32
9.99k
    a1 = ip[0] >> UNIT_QUANT_SHIFT;
33
9.99k
    c1 = ip[1] >> UNIT_QUANT_SHIFT;
34
9.99k
    d1 = ip[2] >> UNIT_QUANT_SHIFT;
35
9.99k
    b1 = ip[3] >> UNIT_QUANT_SHIFT;
36
9.99k
    a1 += c1;
37
9.99k
    d1 -= b1;
38
9.99k
    e1 = (a1 - d1) >> 1;
39
9.99k
    b1 = e1 - b1;
40
9.99k
    c1 = e1 - c1;
41
9.99k
    a1 -= b1;
42
9.99k
    d1 += c1;
43
44
9.99k
    op[0] = a1;
45
9.99k
    op[1] = b1;
46
9.99k
    op[2] = c1;
47
9.99k
    op[3] = d1;
48
9.99k
    ip += 4;
49
9.99k
    op += 4;
50
9.99k
  }
51
52
2.49k
  ip = output;
53
12.4k
  for (i = 0; i < 4; i++) {
54
9.99k
    a1 = ip[4 * 0];
55
9.99k
    c1 = ip[4 * 1];
56
9.99k
    d1 = ip[4 * 2];
57
9.99k
    b1 = ip[4 * 3];
58
9.99k
    a1 += c1;
59
9.99k
    d1 -= b1;
60
9.99k
    e1 = (a1 - d1) >> 1;
61
9.99k
    b1 = e1 - b1;
62
9.99k
    c1 = e1 - c1;
63
9.99k
    a1 -= b1;
64
9.99k
    d1 += c1;
65
66
9.99k
    range_check_value(a1, bd + 1);
67
9.99k
    range_check_value(b1, bd + 1);
68
9.99k
    range_check_value(c1, bd + 1);
69
9.99k
    range_check_value(d1, bd + 1);
70
71
9.99k
    dest[stride * 0] = highbd_clip_pixel_add(dest[stride * 0], a1, bd);
72
9.99k
    dest[stride * 1] = highbd_clip_pixel_add(dest[stride * 1], b1, bd);
73
9.99k
    dest[stride * 2] = highbd_clip_pixel_add(dest[stride * 2], c1, bd);
74
9.99k
    dest[stride * 3] = highbd_clip_pixel_add(dest[stride * 3], d1, bd);
75
76
9.99k
    ip++;
77
9.99k
    dest++;
78
9.99k
  }
79
2.49k
}
80
81
void av1_highbd_iwht4x4_1_add_c(const tran_low_t *in, uint8_t *dest8,
82
10.3k
                                int dest_stride, int bd) {
83
10.3k
  int i;
84
10.3k
  tran_low_t a1, e1;
85
10.3k
  tran_low_t tmp[4];
86
10.3k
  const tran_low_t *ip = in;
87
10.3k
  tran_low_t *op = tmp;
88
10.3k
  uint16_t *dest = CONVERT_TO_SHORTPTR(dest8);
89
10.3k
  (void)bd;
90
91
10.3k
  a1 = ip[0] >> UNIT_QUANT_SHIFT;
92
10.3k
  e1 = a1 >> 1;
93
10.3k
  a1 -= e1;
94
10.3k
  op[0] = a1;
95
10.3k
  op[1] = op[2] = op[3] = e1;
96
97
10.3k
  ip = tmp;
98
51.5k
  for (i = 0; i < 4; i++) {
99
41.2k
    e1 = ip[0] >> 1;
100
41.2k
    a1 = ip[0] - e1;
101
41.2k
    dest[dest_stride * 0] =
102
41.2k
        highbd_clip_pixel_add(dest[dest_stride * 0], a1, bd);
103
41.2k
    dest[dest_stride * 1] =
104
41.2k
        highbd_clip_pixel_add(dest[dest_stride * 1], e1, bd);
105
41.2k
    dest[dest_stride * 2] =
106
41.2k
        highbd_clip_pixel_add(dest[dest_stride * 2], e1, bd);
107
41.2k
    dest[dest_stride * 3] =
108
41.2k
        highbd_clip_pixel_add(dest[dest_stride * 3], e1, bd);
109
41.2k
    ip++;
110
41.2k
    dest++;
111
41.2k
  }
112
10.3k
}
113
114
40.9k
static INLINE TxfmFunc inv_txfm_type_to_func(TXFM_TYPE txfm_type) {
115
40.9k
  switch (txfm_type) {
116
5.79k
    case TXFM_TYPE_DCT4: return av1_idct4;
117
9.36k
    case TXFM_TYPE_DCT8: return av1_idct8;
118
15.9k
    case TXFM_TYPE_DCT16: return av1_idct16;
119
5.70k
    case TXFM_TYPE_DCT32: return av1_idct32;
120
0
    case TXFM_TYPE_DCT64: return av1_idct64;
121
1.11k
    case TXFM_TYPE_ADST4: return av1_iadst4;
122
1.29k
    case TXFM_TYPE_ADST8: return av1_iadst8;
123
1.77k
    case TXFM_TYPE_ADST16: return av1_iadst16;
124
0
    case TXFM_TYPE_IDENTITY4: return av1_iidentity4_c;
125
0
    case TXFM_TYPE_IDENTITY8: return av1_iidentity8_c;
126
0
    case TXFM_TYPE_IDENTITY16: return av1_iidentity16_c;
127
0
    case TXFM_TYPE_IDENTITY32: return av1_iidentity32_c;
128
0
    default: assert(0); return NULL;
129
40.9k
  }
130
40.9k
}
131
132
static const int8_t inv_shift_4x4[2] = { 0, -4 };
133
static const int8_t inv_shift_8x8[2] = { -1, -4 };
134
static const int8_t inv_shift_16x16[2] = { -2, -4 };
135
static const int8_t inv_shift_32x32[2] = { -2, -4 };
136
static const int8_t inv_shift_64x64[2] = { -2, -4 };
137
static const int8_t inv_shift_4x8[2] = { 0, -4 };
138
static const int8_t inv_shift_8x4[2] = { 0, -4 };
139
static const int8_t inv_shift_8x16[2] = { -1, -4 };
140
static const int8_t inv_shift_16x8[2] = { -1, -4 };
141
static const int8_t inv_shift_16x32[2] = { -1, -4 };
142
static const int8_t inv_shift_32x16[2] = { -1, -4 };
143
static const int8_t inv_shift_32x64[2] = { -1, -4 };
144
static const int8_t inv_shift_64x32[2] = { -1, -4 };
145
static const int8_t inv_shift_4x16[2] = { -1, -4 };
146
static const int8_t inv_shift_16x4[2] = { -1, -4 };
147
static const int8_t inv_shift_8x32[2] = { -2, -4 };
148
static const int8_t inv_shift_32x8[2] = { -2, -4 };
149
static const int8_t inv_shift_16x64[2] = { -2, -4 };
150
static const int8_t inv_shift_64x16[2] = { -2, -4 };
151
152
const int8_t *av1_inv_txfm_shift_ls[TX_SIZES_ALL] = {
153
  inv_shift_4x4,   inv_shift_8x8,   inv_shift_16x16, inv_shift_32x32,
154
  inv_shift_64x64, inv_shift_4x8,   inv_shift_8x4,   inv_shift_8x16,
155
  inv_shift_16x8,  inv_shift_16x32, inv_shift_32x16, inv_shift_32x64,
156
  inv_shift_64x32, inv_shift_4x16,  inv_shift_16x4,  inv_shift_8x32,
157
  inv_shift_32x8,  inv_shift_16x64, inv_shift_64x16,
158
};
159
160
/* clang-format off */
161
const int8_t av1_inv_cos_bit_col[MAX_TXWH_IDX]      // txw_idx
162
                            [MAX_TXWH_IDX] = {  // txh_idx
163
    { INV_COS_BIT, INV_COS_BIT, INV_COS_BIT,           0,           0 },
164
    { INV_COS_BIT, INV_COS_BIT, INV_COS_BIT, INV_COS_BIT,           0 },
165
    { INV_COS_BIT, INV_COS_BIT, INV_COS_BIT, INV_COS_BIT, INV_COS_BIT },
166
    {           0, INV_COS_BIT, INV_COS_BIT, INV_COS_BIT, INV_COS_BIT },
167
    {           0,           0, INV_COS_BIT, INV_COS_BIT, INV_COS_BIT }
168
  };
169
170
const int8_t av1_inv_cos_bit_row[MAX_TXWH_IDX]      // txw_idx
171
                            [MAX_TXWH_IDX] = {  // txh_idx
172
    { INV_COS_BIT, INV_COS_BIT, INV_COS_BIT,           0,           0 },
173
    { INV_COS_BIT, INV_COS_BIT, INV_COS_BIT, INV_COS_BIT,           0 },
174
    { INV_COS_BIT, INV_COS_BIT, INV_COS_BIT, INV_COS_BIT, INV_COS_BIT },
175
    {           0, INV_COS_BIT, INV_COS_BIT, INV_COS_BIT, INV_COS_BIT },
176
    {           0,           0, INV_COS_BIT, INV_COS_BIT, INV_COS_BIT }
177
  };
178
/* clang-format on */
179
180
static const int8_t iadst4_range[7] = { 0, 1, 0, 0, 0, 0, 0 };
181
182
void av1_get_inv_txfm_cfg(TX_TYPE tx_type, TX_SIZE tx_size,
183
20.4k
                          TXFM_2D_FLIP_CFG *cfg) {
184
20.4k
  assert(cfg != NULL);
185
20.4k
  cfg->tx_size = tx_size;
186
20.4k
  av1_zero(cfg->stage_range_col);
187
20.4k
  av1_zero(cfg->stage_range_row);
188
20.4k
  set_flip_cfg(tx_type, cfg);
189
20.4k
  const TX_TYPE_1D tx_type_1d_col = vtx_tab[tx_type];
190
20.4k
  const TX_TYPE_1D tx_type_1d_row = htx_tab[tx_type];
191
20.4k
  cfg->shift = av1_inv_txfm_shift_ls[tx_size];
192
20.4k
  const int txw_idx = get_txw_idx(tx_size);
193
20.4k
  const int txh_idx = get_txh_idx(tx_size);
194
20.4k
  cfg->cos_bit_col = av1_inv_cos_bit_col[txw_idx][txh_idx];
195
20.4k
  cfg->cos_bit_row = av1_inv_cos_bit_row[txw_idx][txh_idx];
196
20.4k
  cfg->txfm_type_col = av1_txfm_type_ls[txh_idx][tx_type_1d_col];
197
20.4k
  if (cfg->txfm_type_col == TXFM_TYPE_ADST4) {
198
556
    memcpy(cfg->stage_range_col, iadst4_range, sizeof(iadst4_range));
199
556
  }
200
20.4k
  cfg->txfm_type_row = av1_txfm_type_ls[txw_idx][tx_type_1d_row];
201
20.4k
  if (cfg->txfm_type_row == TXFM_TYPE_ADST4) {
202
556
    memcpy(cfg->stage_range_row, iadst4_range, sizeof(iadst4_range));
203
556
  }
204
20.4k
  cfg->stage_num_col = av1_txfm_stage_num_list[cfg->txfm_type_col];
205
20.4k
  cfg->stage_num_row = av1_txfm_stage_num_list[cfg->txfm_type_row];
206
20.4k
}
207
208
void av1_gen_inv_stage_range(int8_t *stage_range_col, int8_t *stage_range_row,
209
                             const TXFM_2D_FLIP_CFG *cfg, TX_SIZE tx_size,
210
20.4k
                             int bd) {
211
20.4k
  const int fwd_shift = inv_start_range[tx_size];
212
20.4k
  const int8_t *shift = cfg->shift;
213
20.4k
  int8_t opt_range_row, opt_range_col;
214
20.4k
  if (bd == 8) {
215
20.4k
    opt_range_row = 16;
216
20.4k
    opt_range_col = 16;
217
20.4k
  } else if (bd == 10) {
218
0
    opt_range_row = 18;
219
0
    opt_range_col = 16;
220
0
  } else {
221
0
    assert(bd == 12);
222
0
    opt_range_row = 20;
223
0
    opt_range_col = 18;
224
0
  }
225
  // i < MAX_TXFM_STAGE_NUM will mute above array bounds warning
226
170k
  for (int i = 0; i < cfg->stage_num_row && i < MAX_TXFM_STAGE_NUM; ++i) {
227
150k
    int real_range_row = cfg->stage_range_row[i] + fwd_shift + bd + 1;
228
150k
    (void)real_range_row;
229
150k
    if (cfg->txfm_type_row == TXFM_TYPE_ADST4 && i == 1) {
230
      // the adst4 may use 1 extra bit on top of opt_range_row at stage 1
231
      // so opt_range_row >= real_range_row will not hold
232
556
      stage_range_row[i] = opt_range_row;
233
149k
    } else {
234
149k
      assert(opt_range_row >= real_range_row);
235
149k
      stage_range_row[i] = opt_range_row;
236
149k
    }
237
150k
  }
238
  // i < MAX_TXFM_STAGE_NUM will mute above array bounds warning
239
170k
  for (int i = 0; i < cfg->stage_num_col && i < MAX_TXFM_STAGE_NUM; ++i) {
240
149k
    int real_range_col =
241
149k
        cfg->stage_range_col[i] + fwd_shift + shift[0] + bd + 1;
242
149k
    (void)real_range_col;
243
149k
    if (cfg->txfm_type_col == TXFM_TYPE_ADST4 && i == 1) {
244
      // the adst4 may use 1 extra bit on top of opt_range_col at stage 1
245
      // so opt_range_col >= real_range_col will not hold
246
556
      stage_range_col[i] = opt_range_col;
247
148k
    } else {
248
148k
      assert(opt_range_col >= real_range_col);
249
148k
      stage_range_col[i] = opt_range_col;
250
148k
    }
251
149k
  }
252
20.4k
}
253
254
static INLINE void inv_txfm2d_add_c(const int32_t *input, uint16_t *output,
255
                                    int stride, TXFM_2D_FLIP_CFG *cfg,
256
                                    int32_t *txfm_buf, TX_SIZE tx_size,
257
20.4k
                                    int bd) {
258
  // Note when assigning txfm_size_col, we use the txfm_size from the
259
  // row configuration and vice versa. This is intentionally done to
260
  // accurately perform rectangular transforms. When the transform is
261
  // rectangular, the number of columns will be the same as the
262
  // txfm_size stored in the row cfg struct. It will make no difference
263
  // for square transforms.
264
20.4k
  const int txfm_size_col = tx_size_wide[cfg->tx_size];
265
20.4k
  const int txfm_size_row = tx_size_high[cfg->tx_size];
266
  // Take the shift from the larger dimension in the rectangular case.
267
20.4k
  const int8_t *shift = cfg->shift;
268
20.4k
  const int rect_type = get_rect_tx_log_ratio(txfm_size_col, txfm_size_row);
269
20.4k
  int8_t stage_range_row[MAX_TXFM_STAGE_NUM];
270
20.4k
  int8_t stage_range_col[MAX_TXFM_STAGE_NUM];
271
20.4k
  assert(cfg->stage_num_row <= MAX_TXFM_STAGE_NUM);
272
20.4k
  assert(cfg->stage_num_col <= MAX_TXFM_STAGE_NUM);
273
20.4k
  av1_gen_inv_stage_range(stage_range_col, stage_range_row, cfg, tx_size, bd);
274
275
20.4k
  const int8_t cos_bit_col = cfg->cos_bit_col;
276
20.4k
  const int8_t cos_bit_row = cfg->cos_bit_row;
277
20.4k
  const TxfmFunc txfm_func_col = inv_txfm_type_to_func(cfg->txfm_type_col);
278
20.4k
  const TxfmFunc txfm_func_row = inv_txfm_type_to_func(cfg->txfm_type_row);
279
280
  // txfm_buf's length is  txfm_size_row * txfm_size_col + 2 *
281
  // AOMMAX(txfm_size_row, txfm_size_col)
282
  // it is used for intermediate data buffering
283
20.4k
  const int buf_offset = AOMMAX(txfm_size_row, txfm_size_col);
284
20.4k
  int32_t *temp_in = txfm_buf;
285
20.4k
  int32_t *temp_out = temp_in + buf_offset;
286
20.4k
  int32_t *buf = temp_out + buf_offset;
287
20.4k
  int32_t *buf_ptr = buf;
288
20.4k
  int c, r;
289
290
  // Rows
291
308k
  for (r = 0; r < txfm_size_row; ++r) {
292
287k
    if (abs(rect_type) == 1) {
293
669k
      for (c = 0; c < txfm_size_col; ++c) {
294
614k
        temp_in[c] = round_shift((int64_t)input[c] * NewInvSqrt2, NewSqrt2Bits);
295
614k
      }
296
55.2k
      clamp_buf(temp_in, txfm_size_col, bd + 8);
297
55.2k
      txfm_func_row(temp_in, buf_ptr, cos_bit_row, stage_range_row);
298
232k
    } else {
299
5.04M
      for (c = 0; c < txfm_size_col; ++c) {
300
4.81M
        temp_in[c] = input[c];
301
4.81M
      }
302
232k
      clamp_buf(temp_in, txfm_size_col, bd + 8);
303
232k
      txfm_func_row(temp_in, buf_ptr, cos_bit_row, stage_range_row);
304
232k
    }
305
287k
    av1_round_shift_array(buf_ptr, txfm_size_col, -shift[0]);
306
287k
    input += txfm_size_col;
307
287k
    buf_ptr += txfm_size_col;
308
287k
  }
309
310
  // Columns
311
311k
  for (c = 0; c < txfm_size_col; ++c) {
312
290k
    if (cfg->lr_flip == 0) {
313
5.72M
      for (r = 0; r < txfm_size_row; ++r)
314
5.42M
        temp_in[r] = buf[r * txfm_size_col + c];
315
290k
    } else {
316
      // flip left right
317
0
      for (r = 0; r < txfm_size_row; ++r)
318
0
        temp_in[r] = buf[r * txfm_size_col + (txfm_size_col - c - 1)];
319
0
    }
320
290k
    clamp_buf(temp_in, txfm_size_row, AOMMAX(bd + 6, 16));
321
290k
    txfm_func_col(temp_in, temp_out, cos_bit_col, stage_range_col);
322
290k
    av1_round_shift_array(temp_out, txfm_size_row, -shift[1]);
323
290k
    if (cfg->ud_flip == 0) {
324
5.72M
      for (r = 0; r < txfm_size_row; ++r) {
325
5.42M
        output[r * stride + c] =
326
5.42M
            highbd_clip_pixel_add(output[r * stride + c], temp_out[r], bd);
327
5.42M
      }
328
290k
    } else {
329
      // flip upside down
330
0
      for (r = 0; r < txfm_size_row; ++r) {
331
0
        output[r * stride + c] = highbd_clip_pixel_add(
332
0
            output[r * stride + c], temp_out[txfm_size_row - r - 1], bd);
333
0
      }
334
0
    }
335
290k
  }
336
20.4k
}
337
338
static INLINE void inv_txfm2d_add_facade(const int32_t *input, uint16_t *output,
339
                                         int stride, int32_t *txfm_buf,
340
                                         TX_TYPE tx_type, TX_SIZE tx_size,
341
20.4k
                                         int bd) {
342
20.4k
  TXFM_2D_FLIP_CFG cfg;
343
20.4k
  av1_get_inv_txfm_cfg(tx_type, tx_size, &cfg);
344
  // Forward shift sum uses larger square size, to be consistent with what
345
  // av1_gen_inv_stage_range() does for inverse shifts.
346
20.4k
  inv_txfm2d_add_c(input, output, stride, &cfg, txfm_buf, tx_size, bd);
347
20.4k
}
348
349
void av1_inv_txfm2d_add_4x8_c(const int32_t *input, uint16_t *output,
350
1.64k
                              int stride, TX_TYPE tx_type, int bd) {
351
1.64k
  DECLARE_ALIGNED(32, int, txfm_buf[4 * 8 + 8 + 8]);
352
1.64k
  inv_txfm2d_add_facade(input, output, stride, txfm_buf, tx_type, TX_4X8, bd);
353
1.64k
}
354
355
void av1_inv_txfm2d_add_8x4_c(const int32_t *input, uint16_t *output,
356
1.64k
                              int stride, TX_TYPE tx_type, int bd) {
357
1.64k
  DECLARE_ALIGNED(32, int, txfm_buf[8 * 4 + 8 + 8]);
358
1.64k
  inv_txfm2d_add_facade(input, output, stride, txfm_buf, tx_type, TX_8X4, bd);
359
1.64k
}
360
361
void av1_inv_txfm2d_add_8x16_c(const int32_t *input, uint16_t *output,
362
959
                               int stride, TX_TYPE tx_type, int bd) {
363
959
  DECLARE_ALIGNED(32, int, txfm_buf[8 * 16 + 16 + 16]);
364
959
  inv_txfm2d_add_facade(input, output, stride, txfm_buf, tx_type, TX_8X16, bd);
365
959
}
366
367
void av1_inv_txfm2d_add_16x8_c(const int32_t *input, uint16_t *output,
368
1.24k
                               int stride, TX_TYPE tx_type, int bd) {
369
1.24k
  DECLARE_ALIGNED(32, int, txfm_buf[16 * 8 + 16 + 16]);
370
1.24k
  inv_txfm2d_add_facade(input, output, stride, txfm_buf, tx_type, TX_16X8, bd);
371
1.24k
}
372
373
void av1_inv_txfm2d_add_16x32_c(const int32_t *input, uint16_t *output,
374
199
                                int stride, TX_TYPE tx_type, int bd) {
375
199
  DECLARE_ALIGNED(32, int, txfm_buf[16 * 32 + 32 + 32]);
376
199
  inv_txfm2d_add_facade(input, output, stride, txfm_buf, tx_type, TX_16X32, bd);
377
199
}
378
379
void av1_inv_txfm2d_add_32x16_c(const int32_t *input, uint16_t *output,
380
245
                                int stride, TX_TYPE tx_type, int bd) {
381
245
  DECLARE_ALIGNED(32, int, txfm_buf[32 * 16 + 32 + 32]);
382
245
  inv_txfm2d_add_facade(input, output, stride, txfm_buf, tx_type, TX_32X16, bd);
383
245
}
384
385
void av1_inv_txfm2d_add_4x4_c(const int32_t *input, uint16_t *output,
386
1.81k
                              int stride, TX_TYPE tx_type, int bd) {
387
1.81k
  DECLARE_ALIGNED(32, int, txfm_buf[4 * 4 + 4 + 4]);
388
1.81k
  inv_txfm2d_add_facade(input, output, stride, txfm_buf, tx_type, TX_4X4, bd);
389
1.81k
}
390
391
void av1_inv_txfm2d_add_8x8_c(const int32_t *input, uint16_t *output,
392
2.58k
                              int stride, TX_TYPE tx_type, int bd) {
393
2.58k
  DECLARE_ALIGNED(32, int, txfm_buf[8 * 8 + 8 + 8]);
394
2.58k
  inv_txfm2d_add_facade(input, output, stride, txfm_buf, tx_type, TX_8X8, bd);
395
2.58k
}
396
397
void av1_inv_txfm2d_add_16x16_c(const int32_t *input, uint16_t *output,
398
7.52k
                                int stride, TX_TYPE tx_type, int bd) {
399
7.52k
  DECLARE_ALIGNED(32, int, txfm_buf[16 * 16 + 16 + 16]);
400
7.52k
  inv_txfm2d_add_facade(input, output, stride, txfm_buf, tx_type, TX_16X16, bd);
401
7.52k
}
402
403
void av1_inv_txfm2d_add_32x32_c(const int32_t *input, uint16_t *output,
404
2.63k
                                int stride, TX_TYPE tx_type, int bd) {
405
2.63k
  DECLARE_ALIGNED(32, int, txfm_buf[32 * 32 + 32 + 32]);
406
2.63k
  inv_txfm2d_add_facade(input, output, stride, txfm_buf, tx_type, TX_32X32, bd);
407
2.63k
}
408
409
void av1_inv_txfm2d_add_64x64_c(const int32_t *input, uint16_t *output,
410
0
                                int stride, TX_TYPE tx_type, int bd) {
411
  // TODO(urvang): Can the same array be reused, instead of using a new array?
412
  // Remap 32x32 input into a modified 64x64 by:
413
  // - Copying over these values in top-left 32x32 locations.
414
  // - Setting the rest of the locations to 0.
415
0
  int32_t mod_input[64 * 64];
416
0
  for (int row = 0; row < 32; ++row) {
417
0
    memcpy(mod_input + row * 64, input + row * 32, 32 * sizeof(*mod_input));
418
0
    memset(mod_input + row * 64 + 32, 0, 32 * sizeof(*mod_input));
419
0
  }
420
0
  memset(mod_input + 32 * 64, 0, 32 * 64 * sizeof(*mod_input));
421
0
  DECLARE_ALIGNED(32, int, txfm_buf[64 * 64 + 64 + 64]);
422
0
  inv_txfm2d_add_facade(mod_input, output, stride, txfm_buf, tx_type, TX_64X64,
423
0
                        bd);
424
0
}
425
426
void av1_inv_txfm2d_add_64x32_c(const int32_t *input, uint16_t *output,
427
0
                                int stride, TX_TYPE tx_type, int bd) {
428
  // Remap 32x32 input into a modified 64x32 by:
429
  // - Copying over these values in top-left 32x32 locations.
430
  // - Setting the rest of the locations to 0.
431
0
  int32_t mod_input[64 * 32];
432
0
  for (int row = 0; row < 32; ++row) {
433
0
    memcpy(mod_input + row * 64, input + row * 32, 32 * sizeof(*mod_input));
434
0
    memset(mod_input + row * 64 + 32, 0, 32 * sizeof(*mod_input));
435
0
  }
436
0
  DECLARE_ALIGNED(32, int, txfm_buf[64 * 32 + 64 + 64]);
437
0
  inv_txfm2d_add_facade(mod_input, output, stride, txfm_buf, tx_type, TX_64X32,
438
0
                        bd);
439
0
}
440
441
void av1_inv_txfm2d_add_32x64_c(const int32_t *input, uint16_t *output,
442
0
                                int stride, TX_TYPE tx_type, int bd) {
443
  // Remap 32x32 input into a modified 32x64 input by:
444
  // - Copying over these values in top-left 32x32 locations.
445
  // - Setting the rest of the locations to 0.
446
0
  int32_t mod_input[32 * 64];
447
0
  memcpy(mod_input, input, 32 * 32 * sizeof(*mod_input));
448
0
  memset(mod_input + 32 * 32, 0, 32 * 32 * sizeof(*mod_input));
449
0
  DECLARE_ALIGNED(32, int, txfm_buf[64 * 32 + 64 + 64]);
450
0
  inv_txfm2d_add_facade(mod_input, output, stride, txfm_buf, tx_type, TX_32X64,
451
0
                        bd);
452
0
}
453
454
void av1_inv_txfm2d_add_16x64_c(const int32_t *input, uint16_t *output,
455
0
                                int stride, TX_TYPE tx_type, int bd) {
456
  // Remap 16x32 input into a modified 16x64 input by:
457
  // - Copying over these values in top-left 16x32 locations.
458
  // - Setting the rest of the locations to 0.
459
0
  int32_t mod_input[16 * 64];
460
0
  memcpy(mod_input, input, 16 * 32 * sizeof(*mod_input));
461
0
  memset(mod_input + 16 * 32, 0, 16 * 32 * sizeof(*mod_input));
462
0
  DECLARE_ALIGNED(32, int, txfm_buf[16 * 64 + 64 + 64]);
463
0
  inv_txfm2d_add_facade(mod_input, output, stride, txfm_buf, tx_type, TX_16X64,
464
0
                        bd);
465
0
}
466
467
void av1_inv_txfm2d_add_64x16_c(const int32_t *input, uint16_t *output,
468
0
                                int stride, TX_TYPE tx_type, int bd) {
469
  // Remap 32x16 input into a modified 64x16 by:
470
  // - Copying over these values in top-left 32x16 locations.
471
  // - Setting the rest of the locations to 0.
472
0
  int32_t mod_input[64 * 16];
473
0
  for (int row = 0; row < 16; ++row) {
474
0
    memcpy(mod_input + row * 64, input + row * 32, 32 * sizeof(*mod_input));
475
0
    memset(mod_input + row * 64 + 32, 0, 32 * sizeof(*mod_input));
476
0
  }
477
0
  DECLARE_ALIGNED(32, int, txfm_buf[16 * 64 + 64 + 64]);
478
0
  inv_txfm2d_add_facade(mod_input, output, stride, txfm_buf, tx_type, TX_64X16,
479
0
                        bd);
480
0
}
481
482
void av1_inv_txfm2d_add_4x16_c(const int32_t *input, uint16_t *output,
483
0
                               int stride, TX_TYPE tx_type, int bd) {
484
0
  DECLARE_ALIGNED(32, int, txfm_buf[4 * 16 + 16 + 16]);
485
0
  inv_txfm2d_add_facade(input, output, stride, txfm_buf, tx_type, TX_4X16, bd);
486
0
}
487
488
void av1_inv_txfm2d_add_16x4_c(const int32_t *input, uint16_t *output,
489
0
                               int stride, TX_TYPE tx_type, int bd) {
490
0
  DECLARE_ALIGNED(32, int, txfm_buf[4 * 16 + 16 + 16]);
491
0
  inv_txfm2d_add_facade(input, output, stride, txfm_buf, tx_type, TX_16X4, bd);
492
0
}
493
494
void av1_inv_txfm2d_add_8x32_c(const int32_t *input, uint16_t *output,
495
0
                               int stride, TX_TYPE tx_type, int bd) {
496
0
  DECLARE_ALIGNED(32, int, txfm_buf[8 * 32 + 32 + 32]);
497
0
  inv_txfm2d_add_facade(input, output, stride, txfm_buf, tx_type, TX_8X32, bd);
498
0
}
499
500
void av1_inv_txfm2d_add_32x8_c(const int32_t *input, uint16_t *output,
501
0
                               int stride, TX_TYPE tx_type, int bd) {
502
0
  DECLARE_ALIGNED(32, int, txfm_buf[8 * 32 + 32 + 32]);
503
0
  inv_txfm2d_add_facade(input, output, stride, txfm_buf, tx_type, TX_32X8, bd);
504
0
}