xref: /aosp_15_r20/external/libaom/av1/encoder/hybrid_fwd_txfm.c (revision 77c1e3ccc04c968bd2bc212e87364f250e820521)
1*77c1e3ccSAndroid Build Coastguard Worker /*
2*77c1e3ccSAndroid Build Coastguard Worker  * Copyright (c) 2016, Alliance for Open Media. All rights reserved.
3*77c1e3ccSAndroid Build Coastguard Worker  *
4*77c1e3ccSAndroid Build Coastguard Worker  * This source code is subject to the terms of the BSD 2 Clause License and
5*77c1e3ccSAndroid Build Coastguard Worker  * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6*77c1e3ccSAndroid Build Coastguard Worker  * was not distributed with this source code in the LICENSE file, you can
7*77c1e3ccSAndroid Build Coastguard Worker  * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8*77c1e3ccSAndroid Build Coastguard Worker  * Media Patent License 1.0 was not distributed with this source code in the
9*77c1e3ccSAndroid Build Coastguard Worker  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10*77c1e3ccSAndroid Build Coastguard Worker  */
11*77c1e3ccSAndroid Build Coastguard Worker 
12*77c1e3ccSAndroid Build Coastguard Worker #include "config/aom_config.h"
13*77c1e3ccSAndroid Build Coastguard Worker #include "config/av1_rtcd.h"
14*77c1e3ccSAndroid Build Coastguard Worker #include "config/aom_dsp_rtcd.h"
15*77c1e3ccSAndroid Build Coastguard Worker 
16*77c1e3ccSAndroid Build Coastguard Worker #include "av1/common/idct.h"
17*77c1e3ccSAndroid Build Coastguard Worker #include "av1/common/blockd.h"
18*77c1e3ccSAndroid Build Coastguard Worker #include "av1/encoder/hybrid_fwd_txfm.h"
19*77c1e3ccSAndroid Build Coastguard Worker 
20*77c1e3ccSAndroid Build Coastguard Worker /* 4-point reversible, orthonormal Walsh-Hadamard in 3.5 adds, 0.5 shifts per
21*77c1e3ccSAndroid Build Coastguard Worker    pixel.
22*77c1e3ccSAndroid Build Coastguard Worker    Shared for both high and low bit depth.
23*77c1e3ccSAndroid Build Coastguard Worker  */
av1_fwht4x4_c(const int16_t * input,tran_low_t * output,int stride)24*77c1e3ccSAndroid Build Coastguard Worker void av1_fwht4x4_c(const int16_t *input, tran_low_t *output, int stride) {
25*77c1e3ccSAndroid Build Coastguard Worker   int i;
26*77c1e3ccSAndroid Build Coastguard Worker   tran_high_t a1, b1, c1, d1, e1;
27*77c1e3ccSAndroid Build Coastguard Worker   const int16_t *ip_pass0 = input;
28*77c1e3ccSAndroid Build Coastguard Worker   const tran_low_t *ip = NULL;
29*77c1e3ccSAndroid Build Coastguard Worker   tran_low_t *op = output;
30*77c1e3ccSAndroid Build Coastguard Worker 
31*77c1e3ccSAndroid Build Coastguard Worker   for (i = 0; i < 4; i++) {
32*77c1e3ccSAndroid Build Coastguard Worker     a1 = ip_pass0[0 * stride];
33*77c1e3ccSAndroid Build Coastguard Worker     b1 = ip_pass0[1 * stride];
34*77c1e3ccSAndroid Build Coastguard Worker     c1 = ip_pass0[2 * stride];
35*77c1e3ccSAndroid Build Coastguard Worker     d1 = ip_pass0[3 * stride];
36*77c1e3ccSAndroid Build Coastguard Worker 
37*77c1e3ccSAndroid Build Coastguard Worker     a1 += b1;
38*77c1e3ccSAndroid Build Coastguard Worker     d1 = d1 - c1;
39*77c1e3ccSAndroid Build Coastguard Worker     e1 = (a1 - d1) >> 1;
40*77c1e3ccSAndroid Build Coastguard Worker     b1 = e1 - b1;
41*77c1e3ccSAndroid Build Coastguard Worker     c1 = e1 - c1;
42*77c1e3ccSAndroid Build Coastguard Worker     a1 -= c1;
43*77c1e3ccSAndroid Build Coastguard Worker     d1 += b1;
44*77c1e3ccSAndroid Build Coastguard Worker     op[0] = (tran_low_t)a1;
45*77c1e3ccSAndroid Build Coastguard Worker     op[1] = (tran_low_t)c1;
46*77c1e3ccSAndroid Build Coastguard Worker     op[2] = (tran_low_t)d1;
47*77c1e3ccSAndroid Build Coastguard Worker     op[3] = (tran_low_t)b1;
48*77c1e3ccSAndroid Build Coastguard Worker 
49*77c1e3ccSAndroid Build Coastguard Worker     ip_pass0++;
50*77c1e3ccSAndroid Build Coastguard Worker     op += 4;
51*77c1e3ccSAndroid Build Coastguard Worker   }
52*77c1e3ccSAndroid Build Coastguard Worker   ip = output;
53*77c1e3ccSAndroid Build Coastguard Worker   op = output;
54*77c1e3ccSAndroid Build Coastguard Worker 
55*77c1e3ccSAndroid Build Coastguard Worker   for (i = 0; i < 4; i++) {
56*77c1e3ccSAndroid Build Coastguard Worker     a1 = ip[4 * 0];
57*77c1e3ccSAndroid Build Coastguard Worker     b1 = ip[4 * 1];
58*77c1e3ccSAndroid Build Coastguard Worker     c1 = ip[4 * 2];
59*77c1e3ccSAndroid Build Coastguard Worker     d1 = ip[4 * 3];
60*77c1e3ccSAndroid Build Coastguard Worker 
61*77c1e3ccSAndroid Build Coastguard Worker     a1 += b1;
62*77c1e3ccSAndroid Build Coastguard Worker     d1 -= c1;
63*77c1e3ccSAndroid Build Coastguard Worker     e1 = (a1 - d1) >> 1;
64*77c1e3ccSAndroid Build Coastguard Worker     b1 = e1 - b1;
65*77c1e3ccSAndroid Build Coastguard Worker     c1 = e1 - c1;
66*77c1e3ccSAndroid Build Coastguard Worker     a1 -= c1;
67*77c1e3ccSAndroid Build Coastguard Worker     d1 += b1;
68*77c1e3ccSAndroid Build Coastguard Worker     op[4 * 0] = (tran_low_t)(a1 * UNIT_QUANT_FACTOR);
69*77c1e3ccSAndroid Build Coastguard Worker     op[4 * 1] = (tran_low_t)(c1 * UNIT_QUANT_FACTOR);
70*77c1e3ccSAndroid Build Coastguard Worker     op[4 * 2] = (tran_low_t)(d1 * UNIT_QUANT_FACTOR);
71*77c1e3ccSAndroid Build Coastguard Worker     op[4 * 3] = (tran_low_t)(b1 * UNIT_QUANT_FACTOR);
72*77c1e3ccSAndroid Build Coastguard Worker 
73*77c1e3ccSAndroid Build Coastguard Worker     ip++;
74*77c1e3ccSAndroid Build Coastguard Worker     op++;
75*77c1e3ccSAndroid Build Coastguard Worker   }
76*77c1e3ccSAndroid Build Coastguard Worker }
77*77c1e3ccSAndroid Build Coastguard Worker 
highbd_fwd_txfm_4x4(const int16_t * src_diff,tran_low_t * coeff,int diff_stride,TxfmParam * txfm_param)78*77c1e3ccSAndroid Build Coastguard Worker static void highbd_fwd_txfm_4x4(const int16_t *src_diff, tran_low_t *coeff,
79*77c1e3ccSAndroid Build Coastguard Worker                                 int diff_stride, TxfmParam *txfm_param) {
80*77c1e3ccSAndroid Build Coastguard Worker   int32_t *dst_coeff = (int32_t *)coeff;
81*77c1e3ccSAndroid Build Coastguard Worker   const TX_TYPE tx_type = txfm_param->tx_type;
82*77c1e3ccSAndroid Build Coastguard Worker   const int bd = txfm_param->bd;
83*77c1e3ccSAndroid Build Coastguard Worker   if (txfm_param->lossless) {
84*77c1e3ccSAndroid Build Coastguard Worker     assert(tx_type == DCT_DCT);
85*77c1e3ccSAndroid Build Coastguard Worker     av1_fwht4x4(src_diff, coeff, diff_stride);
86*77c1e3ccSAndroid Build Coastguard Worker     return;
87*77c1e3ccSAndroid Build Coastguard Worker   }
88*77c1e3ccSAndroid Build Coastguard Worker   av1_fwd_txfm2d_4x4(src_diff, dst_coeff, diff_stride, tx_type, bd);
89*77c1e3ccSAndroid Build Coastguard Worker }
90*77c1e3ccSAndroid Build Coastguard Worker 
highbd_fwd_txfm_4x8(const int16_t * src_diff,tran_low_t * coeff,int diff_stride,TxfmParam * txfm_param)91*77c1e3ccSAndroid Build Coastguard Worker static void highbd_fwd_txfm_4x8(const int16_t *src_diff, tran_low_t *coeff,
92*77c1e3ccSAndroid Build Coastguard Worker                                 int diff_stride, TxfmParam *txfm_param) {
93*77c1e3ccSAndroid Build Coastguard Worker   int32_t *dst_coeff = (int32_t *)coeff;
94*77c1e3ccSAndroid Build Coastguard Worker   av1_fwd_txfm2d_4x8(src_diff, dst_coeff, diff_stride, txfm_param->tx_type,
95*77c1e3ccSAndroid Build Coastguard Worker                      txfm_param->bd);
96*77c1e3ccSAndroid Build Coastguard Worker }
97*77c1e3ccSAndroid Build Coastguard Worker 
highbd_fwd_txfm_8x4(const int16_t * src_diff,tran_low_t * coeff,int diff_stride,TxfmParam * txfm_param)98*77c1e3ccSAndroid Build Coastguard Worker static void highbd_fwd_txfm_8x4(const int16_t *src_diff, tran_low_t *coeff,
99*77c1e3ccSAndroid Build Coastguard Worker                                 int diff_stride, TxfmParam *txfm_param) {
100*77c1e3ccSAndroid Build Coastguard Worker   int32_t *dst_coeff = (int32_t *)coeff;
101*77c1e3ccSAndroid Build Coastguard Worker   av1_fwd_txfm2d_8x4(src_diff, dst_coeff, diff_stride, txfm_param->tx_type,
102*77c1e3ccSAndroid Build Coastguard Worker                      txfm_param->bd);
103*77c1e3ccSAndroid Build Coastguard Worker }
104*77c1e3ccSAndroid Build Coastguard Worker 
highbd_fwd_txfm_8x16(const int16_t * src_diff,tran_low_t * coeff,int diff_stride,TxfmParam * txfm_param)105*77c1e3ccSAndroid Build Coastguard Worker static void highbd_fwd_txfm_8x16(const int16_t *src_diff, tran_low_t *coeff,
106*77c1e3ccSAndroid Build Coastguard Worker                                  int diff_stride, TxfmParam *txfm_param) {
107*77c1e3ccSAndroid Build Coastguard Worker   int32_t *dst_coeff = (int32_t *)coeff;
108*77c1e3ccSAndroid Build Coastguard Worker   const TX_TYPE tx_type = txfm_param->tx_type;
109*77c1e3ccSAndroid Build Coastguard Worker   const int bd = txfm_param->bd;
110*77c1e3ccSAndroid Build Coastguard Worker   av1_fwd_txfm2d_8x16(src_diff, dst_coeff, diff_stride, tx_type, bd);
111*77c1e3ccSAndroid Build Coastguard Worker }
112*77c1e3ccSAndroid Build Coastguard Worker 
highbd_fwd_txfm_16x8(const int16_t * src_diff,tran_low_t * coeff,int diff_stride,TxfmParam * txfm_param)113*77c1e3ccSAndroid Build Coastguard Worker static void highbd_fwd_txfm_16x8(const int16_t *src_diff, tran_low_t *coeff,
114*77c1e3ccSAndroid Build Coastguard Worker                                  int diff_stride, TxfmParam *txfm_param) {
115*77c1e3ccSAndroid Build Coastguard Worker   int32_t *dst_coeff = (int32_t *)coeff;
116*77c1e3ccSAndroid Build Coastguard Worker   const TX_TYPE tx_type = txfm_param->tx_type;
117*77c1e3ccSAndroid Build Coastguard Worker   const int bd = txfm_param->bd;
118*77c1e3ccSAndroid Build Coastguard Worker   av1_fwd_txfm2d_16x8(src_diff, dst_coeff, diff_stride, tx_type, bd);
119*77c1e3ccSAndroid Build Coastguard Worker }
120*77c1e3ccSAndroid Build Coastguard Worker 
highbd_fwd_txfm_16x32(const int16_t * src_diff,tran_low_t * coeff,int diff_stride,TxfmParam * txfm_param)121*77c1e3ccSAndroid Build Coastguard Worker static void highbd_fwd_txfm_16x32(const int16_t *src_diff, tran_low_t *coeff,
122*77c1e3ccSAndroid Build Coastguard Worker                                   int diff_stride, TxfmParam *txfm_param) {
123*77c1e3ccSAndroid Build Coastguard Worker   int32_t *dst_coeff = (int32_t *)coeff;
124*77c1e3ccSAndroid Build Coastguard Worker   av1_fwd_txfm2d_16x32(src_diff, dst_coeff, diff_stride, txfm_param->tx_type,
125*77c1e3ccSAndroid Build Coastguard Worker                        txfm_param->bd);
126*77c1e3ccSAndroid Build Coastguard Worker }
127*77c1e3ccSAndroid Build Coastguard Worker 
highbd_fwd_txfm_32x16(const int16_t * src_diff,tran_low_t * coeff,int diff_stride,TxfmParam * txfm_param)128*77c1e3ccSAndroid Build Coastguard Worker static void highbd_fwd_txfm_32x16(const int16_t *src_diff, tran_low_t *coeff,
129*77c1e3ccSAndroid Build Coastguard Worker                                   int diff_stride, TxfmParam *txfm_param) {
130*77c1e3ccSAndroid Build Coastguard Worker   int32_t *dst_coeff = (int32_t *)coeff;
131*77c1e3ccSAndroid Build Coastguard Worker   av1_fwd_txfm2d_32x16(src_diff, dst_coeff, diff_stride, txfm_param->tx_type,
132*77c1e3ccSAndroid Build Coastguard Worker                        txfm_param->bd);
133*77c1e3ccSAndroid Build Coastguard Worker }
134*77c1e3ccSAndroid Build Coastguard Worker 
135*77c1e3ccSAndroid Build Coastguard Worker #if !CONFIG_REALTIME_ONLY
highbd_fwd_txfm_16x4(const int16_t * src_diff,tran_low_t * coeff,int diff_stride,TxfmParam * txfm_param)136*77c1e3ccSAndroid Build Coastguard Worker static void highbd_fwd_txfm_16x4(const int16_t *src_diff, tran_low_t *coeff,
137*77c1e3ccSAndroid Build Coastguard Worker                                  int diff_stride, TxfmParam *txfm_param) {
138*77c1e3ccSAndroid Build Coastguard Worker   int32_t *dst_coeff = (int32_t *)coeff;
139*77c1e3ccSAndroid Build Coastguard Worker   av1_fwd_txfm2d_16x4(src_diff, dst_coeff, diff_stride, txfm_param->tx_type,
140*77c1e3ccSAndroid Build Coastguard Worker                       txfm_param->bd);
141*77c1e3ccSAndroid Build Coastguard Worker }
142*77c1e3ccSAndroid Build Coastguard Worker 
highbd_fwd_txfm_4x16(const int16_t * src_diff,tran_low_t * coeff,int diff_stride,TxfmParam * txfm_param)143*77c1e3ccSAndroid Build Coastguard Worker static void highbd_fwd_txfm_4x16(const int16_t *src_diff, tran_low_t *coeff,
144*77c1e3ccSAndroid Build Coastguard Worker                                  int diff_stride, TxfmParam *txfm_param) {
145*77c1e3ccSAndroid Build Coastguard Worker   int32_t *dst_coeff = (int32_t *)coeff;
146*77c1e3ccSAndroid Build Coastguard Worker   av1_fwd_txfm2d_4x16(src_diff, dst_coeff, diff_stride, txfm_param->tx_type,
147*77c1e3ccSAndroid Build Coastguard Worker                       txfm_param->bd);
148*77c1e3ccSAndroid Build Coastguard Worker }
149*77c1e3ccSAndroid Build Coastguard Worker 
highbd_fwd_txfm_32x8(const int16_t * src_diff,tran_low_t * coeff,int diff_stride,TxfmParam * txfm_param)150*77c1e3ccSAndroid Build Coastguard Worker static void highbd_fwd_txfm_32x8(const int16_t *src_diff, tran_low_t *coeff,
151*77c1e3ccSAndroid Build Coastguard Worker                                  int diff_stride, TxfmParam *txfm_param) {
152*77c1e3ccSAndroid Build Coastguard Worker   int32_t *dst_coeff = (int32_t *)coeff;
153*77c1e3ccSAndroid Build Coastguard Worker   av1_fwd_txfm2d_32x8(src_diff, dst_coeff, diff_stride, txfm_param->tx_type,
154*77c1e3ccSAndroid Build Coastguard Worker                       txfm_param->bd);
155*77c1e3ccSAndroid Build Coastguard Worker }
156*77c1e3ccSAndroid Build Coastguard Worker 
highbd_fwd_txfm_8x32(const int16_t * src_diff,tran_low_t * coeff,int diff_stride,TxfmParam * txfm_param)157*77c1e3ccSAndroid Build Coastguard Worker static void highbd_fwd_txfm_8x32(const int16_t *src_diff, tran_low_t *coeff,
158*77c1e3ccSAndroid Build Coastguard Worker                                  int diff_stride, TxfmParam *txfm_param) {
159*77c1e3ccSAndroid Build Coastguard Worker   int32_t *dst_coeff = (int32_t *)coeff;
160*77c1e3ccSAndroid Build Coastguard Worker   av1_fwd_txfm2d_8x32(src_diff, dst_coeff, diff_stride, txfm_param->tx_type,
161*77c1e3ccSAndroid Build Coastguard Worker                       txfm_param->bd);
162*77c1e3ccSAndroid Build Coastguard Worker }
163*77c1e3ccSAndroid Build Coastguard Worker #endif
164*77c1e3ccSAndroid Build Coastguard Worker 
highbd_fwd_txfm_8x8(const int16_t * src_diff,tran_low_t * coeff,int diff_stride,TxfmParam * txfm_param)165*77c1e3ccSAndroid Build Coastguard Worker static void highbd_fwd_txfm_8x8(const int16_t *src_diff, tran_low_t *coeff,
166*77c1e3ccSAndroid Build Coastguard Worker                                 int diff_stride, TxfmParam *txfm_param) {
167*77c1e3ccSAndroid Build Coastguard Worker   int32_t *dst_coeff = (int32_t *)coeff;
168*77c1e3ccSAndroid Build Coastguard Worker   const TX_TYPE tx_type = txfm_param->tx_type;
169*77c1e3ccSAndroid Build Coastguard Worker   const int bd = txfm_param->bd;
170*77c1e3ccSAndroid Build Coastguard Worker   av1_fwd_txfm2d_8x8(src_diff, dst_coeff, diff_stride, tx_type, bd);
171*77c1e3ccSAndroid Build Coastguard Worker }
172*77c1e3ccSAndroid Build Coastguard Worker 
highbd_fwd_txfm_16x16(const int16_t * src_diff,tran_low_t * coeff,int diff_stride,TxfmParam * txfm_param)173*77c1e3ccSAndroid Build Coastguard Worker static void highbd_fwd_txfm_16x16(const int16_t *src_diff, tran_low_t *coeff,
174*77c1e3ccSAndroid Build Coastguard Worker                                   int diff_stride, TxfmParam *txfm_param) {
175*77c1e3ccSAndroid Build Coastguard Worker   int32_t *dst_coeff = (int32_t *)coeff;
176*77c1e3ccSAndroid Build Coastguard Worker   const TX_TYPE tx_type = txfm_param->tx_type;
177*77c1e3ccSAndroid Build Coastguard Worker   const int bd = txfm_param->bd;
178*77c1e3ccSAndroid Build Coastguard Worker   av1_fwd_txfm2d_16x16(src_diff, dst_coeff, diff_stride, tx_type, bd);
179*77c1e3ccSAndroid Build Coastguard Worker }
180*77c1e3ccSAndroid Build Coastguard Worker 
highbd_fwd_txfm_32x32(const int16_t * src_diff,tran_low_t * coeff,int diff_stride,TxfmParam * txfm_param)181*77c1e3ccSAndroid Build Coastguard Worker static void highbd_fwd_txfm_32x32(const int16_t *src_diff, tran_low_t *coeff,
182*77c1e3ccSAndroid Build Coastguard Worker                                   int diff_stride, TxfmParam *txfm_param) {
183*77c1e3ccSAndroid Build Coastguard Worker   int32_t *dst_coeff = (int32_t *)coeff;
184*77c1e3ccSAndroid Build Coastguard Worker   const TX_TYPE tx_type = txfm_param->tx_type;
185*77c1e3ccSAndroid Build Coastguard Worker   const int bd = txfm_param->bd;
186*77c1e3ccSAndroid Build Coastguard Worker   av1_fwd_txfm2d_32x32(src_diff, dst_coeff, diff_stride, tx_type, bd);
187*77c1e3ccSAndroid Build Coastguard Worker }
188*77c1e3ccSAndroid Build Coastguard Worker 
highbd_fwd_txfm_32x64(const int16_t * src_diff,tran_low_t * coeff,int diff_stride,TxfmParam * txfm_param)189*77c1e3ccSAndroid Build Coastguard Worker static void highbd_fwd_txfm_32x64(const int16_t *src_diff, tran_low_t *coeff,
190*77c1e3ccSAndroid Build Coastguard Worker                                   int diff_stride, TxfmParam *txfm_param) {
191*77c1e3ccSAndroid Build Coastguard Worker   assert(txfm_param->tx_type == DCT_DCT);
192*77c1e3ccSAndroid Build Coastguard Worker   int32_t *dst_coeff = (int32_t *)coeff;
193*77c1e3ccSAndroid Build Coastguard Worker   const int bd = txfm_param->bd;
194*77c1e3ccSAndroid Build Coastguard Worker   av1_fwd_txfm2d_32x64(src_diff, dst_coeff, diff_stride, txfm_param->tx_type,
195*77c1e3ccSAndroid Build Coastguard Worker                        bd);
196*77c1e3ccSAndroid Build Coastguard Worker }
197*77c1e3ccSAndroid Build Coastguard Worker 
highbd_fwd_txfm_64x32(const int16_t * src_diff,tran_low_t * coeff,int diff_stride,TxfmParam * txfm_param)198*77c1e3ccSAndroid Build Coastguard Worker static void highbd_fwd_txfm_64x32(const int16_t *src_diff, tran_low_t *coeff,
199*77c1e3ccSAndroid Build Coastguard Worker                                   int diff_stride, TxfmParam *txfm_param) {
200*77c1e3ccSAndroid Build Coastguard Worker   assert(txfm_param->tx_type == DCT_DCT);
201*77c1e3ccSAndroid Build Coastguard Worker   int32_t *dst_coeff = (int32_t *)coeff;
202*77c1e3ccSAndroid Build Coastguard Worker   const int bd = txfm_param->bd;
203*77c1e3ccSAndroid Build Coastguard Worker   av1_fwd_txfm2d_64x32(src_diff, dst_coeff, diff_stride, txfm_param->tx_type,
204*77c1e3ccSAndroid Build Coastguard Worker                        bd);
205*77c1e3ccSAndroid Build Coastguard Worker }
206*77c1e3ccSAndroid Build Coastguard Worker 
207*77c1e3ccSAndroid Build Coastguard Worker #if !CONFIG_REALTIME_ONLY
highbd_fwd_txfm_16x64(const int16_t * src_diff,tran_low_t * coeff,int diff_stride,TxfmParam * txfm_param)208*77c1e3ccSAndroid Build Coastguard Worker static void highbd_fwd_txfm_16x64(const int16_t *src_diff, tran_low_t *coeff,
209*77c1e3ccSAndroid Build Coastguard Worker                                   int diff_stride, TxfmParam *txfm_param) {
210*77c1e3ccSAndroid Build Coastguard Worker   assert(txfm_param->tx_type == DCT_DCT);
211*77c1e3ccSAndroid Build Coastguard Worker   int32_t *dst_coeff = (int32_t *)coeff;
212*77c1e3ccSAndroid Build Coastguard Worker   const int bd = txfm_param->bd;
213*77c1e3ccSAndroid Build Coastguard Worker   av1_fwd_txfm2d_16x64(src_diff, dst_coeff, diff_stride, DCT_DCT, bd);
214*77c1e3ccSAndroid Build Coastguard Worker }
215*77c1e3ccSAndroid Build Coastguard Worker 
highbd_fwd_txfm_64x16(const int16_t * src_diff,tran_low_t * coeff,int diff_stride,TxfmParam * txfm_param)216*77c1e3ccSAndroid Build Coastguard Worker static void highbd_fwd_txfm_64x16(const int16_t *src_diff, tran_low_t *coeff,
217*77c1e3ccSAndroid Build Coastguard Worker                                   int diff_stride, TxfmParam *txfm_param) {
218*77c1e3ccSAndroid Build Coastguard Worker   assert(txfm_param->tx_type == DCT_DCT);
219*77c1e3ccSAndroid Build Coastguard Worker   int32_t *dst_coeff = (int32_t *)coeff;
220*77c1e3ccSAndroid Build Coastguard Worker   const int bd = txfm_param->bd;
221*77c1e3ccSAndroid Build Coastguard Worker   av1_fwd_txfm2d_64x16(src_diff, dst_coeff, diff_stride, DCT_DCT, bd);
222*77c1e3ccSAndroid Build Coastguard Worker }
223*77c1e3ccSAndroid Build Coastguard Worker #endif
224*77c1e3ccSAndroid Build Coastguard Worker 
highbd_fwd_txfm_64x64(const int16_t * src_diff,tran_low_t * coeff,int diff_stride,TxfmParam * txfm_param)225*77c1e3ccSAndroid Build Coastguard Worker static void highbd_fwd_txfm_64x64(const int16_t *src_diff, tran_low_t *coeff,
226*77c1e3ccSAndroid Build Coastguard Worker                                   int diff_stride, TxfmParam *txfm_param) {
227*77c1e3ccSAndroid Build Coastguard Worker   assert(txfm_param->tx_type == DCT_DCT);
228*77c1e3ccSAndroid Build Coastguard Worker   int32_t *dst_coeff = (int32_t *)coeff;
229*77c1e3ccSAndroid Build Coastguard Worker   const int bd = txfm_param->bd;
230*77c1e3ccSAndroid Build Coastguard Worker   av1_fwd_txfm2d_64x64(src_diff, dst_coeff, diff_stride, DCT_DCT, bd);
231*77c1e3ccSAndroid Build Coastguard Worker }
232*77c1e3ccSAndroid Build Coastguard Worker 
av1_fwd_txfm(const int16_t * src_diff,tran_low_t * coeff,int diff_stride,TxfmParam * txfm_param)233*77c1e3ccSAndroid Build Coastguard Worker void av1_fwd_txfm(const int16_t *src_diff, tran_low_t *coeff, int diff_stride,
234*77c1e3ccSAndroid Build Coastguard Worker                   TxfmParam *txfm_param) {
235*77c1e3ccSAndroid Build Coastguard Worker   if (txfm_param->bd == 8)
236*77c1e3ccSAndroid Build Coastguard Worker     av1_lowbd_fwd_txfm(src_diff, coeff, diff_stride, txfm_param);
237*77c1e3ccSAndroid Build Coastguard Worker   else
238*77c1e3ccSAndroid Build Coastguard Worker     av1_highbd_fwd_txfm(src_diff, coeff, diff_stride, txfm_param);
239*77c1e3ccSAndroid Build Coastguard Worker }
240*77c1e3ccSAndroid Build Coastguard Worker 
av1_lowbd_fwd_txfm_c(const int16_t * src_diff,tran_low_t * coeff,int diff_stride,TxfmParam * txfm_param)241*77c1e3ccSAndroid Build Coastguard Worker void av1_lowbd_fwd_txfm_c(const int16_t *src_diff, tran_low_t *coeff,
242*77c1e3ccSAndroid Build Coastguard Worker                           int diff_stride, TxfmParam *txfm_param) {
243*77c1e3ccSAndroid Build Coastguard Worker   av1_highbd_fwd_txfm(src_diff, coeff, diff_stride, txfm_param);
244*77c1e3ccSAndroid Build Coastguard Worker }
245*77c1e3ccSAndroid Build Coastguard Worker 
av1_highbd_fwd_txfm(const int16_t * src_diff,tran_low_t * coeff,int diff_stride,TxfmParam * txfm_param)246*77c1e3ccSAndroid Build Coastguard Worker void av1_highbd_fwd_txfm(const int16_t *src_diff, tran_low_t *coeff,
247*77c1e3ccSAndroid Build Coastguard Worker                          int diff_stride, TxfmParam *txfm_param) {
248*77c1e3ccSAndroid Build Coastguard Worker   assert(av1_ext_tx_used[txfm_param->tx_set_type][txfm_param->tx_type]);
249*77c1e3ccSAndroid Build Coastguard Worker   const TX_SIZE tx_size = txfm_param->tx_size;
250*77c1e3ccSAndroid Build Coastguard Worker   switch (tx_size) {
251*77c1e3ccSAndroid Build Coastguard Worker     case TX_64X64:
252*77c1e3ccSAndroid Build Coastguard Worker       highbd_fwd_txfm_64x64(src_diff, coeff, diff_stride, txfm_param);
253*77c1e3ccSAndroid Build Coastguard Worker       break;
254*77c1e3ccSAndroid Build Coastguard Worker     case TX_32X64:
255*77c1e3ccSAndroid Build Coastguard Worker       highbd_fwd_txfm_32x64(src_diff, coeff, diff_stride, txfm_param);
256*77c1e3ccSAndroid Build Coastguard Worker       break;
257*77c1e3ccSAndroid Build Coastguard Worker     case TX_64X32:
258*77c1e3ccSAndroid Build Coastguard Worker       highbd_fwd_txfm_64x32(src_diff, coeff, diff_stride, txfm_param);
259*77c1e3ccSAndroid Build Coastguard Worker       break;
260*77c1e3ccSAndroid Build Coastguard Worker 
261*77c1e3ccSAndroid Build Coastguard Worker     case TX_32X32:
262*77c1e3ccSAndroid Build Coastguard Worker       highbd_fwd_txfm_32x32(src_diff, coeff, diff_stride, txfm_param);
263*77c1e3ccSAndroid Build Coastguard Worker       break;
264*77c1e3ccSAndroid Build Coastguard Worker     case TX_16X16:
265*77c1e3ccSAndroid Build Coastguard Worker       highbd_fwd_txfm_16x16(src_diff, coeff, diff_stride, txfm_param);
266*77c1e3ccSAndroid Build Coastguard Worker       break;
267*77c1e3ccSAndroid Build Coastguard Worker     case TX_8X8:
268*77c1e3ccSAndroid Build Coastguard Worker       highbd_fwd_txfm_8x8(src_diff, coeff, diff_stride, txfm_param);
269*77c1e3ccSAndroid Build Coastguard Worker       break;
270*77c1e3ccSAndroid Build Coastguard Worker     case TX_4X8:
271*77c1e3ccSAndroid Build Coastguard Worker       highbd_fwd_txfm_4x8(src_diff, coeff, diff_stride, txfm_param);
272*77c1e3ccSAndroid Build Coastguard Worker       break;
273*77c1e3ccSAndroid Build Coastguard Worker     case TX_8X4:
274*77c1e3ccSAndroid Build Coastguard Worker       highbd_fwd_txfm_8x4(src_diff, coeff, diff_stride, txfm_param);
275*77c1e3ccSAndroid Build Coastguard Worker       break;
276*77c1e3ccSAndroid Build Coastguard Worker     case TX_8X16:
277*77c1e3ccSAndroid Build Coastguard Worker       highbd_fwd_txfm_8x16(src_diff, coeff, diff_stride, txfm_param);
278*77c1e3ccSAndroid Build Coastguard Worker       break;
279*77c1e3ccSAndroid Build Coastguard Worker     case TX_16X8:
280*77c1e3ccSAndroid Build Coastguard Worker       highbd_fwd_txfm_16x8(src_diff, coeff, diff_stride, txfm_param);
281*77c1e3ccSAndroid Build Coastguard Worker       break;
282*77c1e3ccSAndroid Build Coastguard Worker     case TX_16X32:
283*77c1e3ccSAndroid Build Coastguard Worker       highbd_fwd_txfm_16x32(src_diff, coeff, diff_stride, txfm_param);
284*77c1e3ccSAndroid Build Coastguard Worker       break;
285*77c1e3ccSAndroid Build Coastguard Worker     case TX_32X16:
286*77c1e3ccSAndroid Build Coastguard Worker       highbd_fwd_txfm_32x16(src_diff, coeff, diff_stride, txfm_param);
287*77c1e3ccSAndroid Build Coastguard Worker       break;
288*77c1e3ccSAndroid Build Coastguard Worker     case TX_4X4:
289*77c1e3ccSAndroid Build Coastguard Worker       highbd_fwd_txfm_4x4(src_diff, coeff, diff_stride, txfm_param);
290*77c1e3ccSAndroid Build Coastguard Worker       break;
291*77c1e3ccSAndroid Build Coastguard Worker #if !CONFIG_REALTIME_ONLY
292*77c1e3ccSAndroid Build Coastguard Worker     case TX_4X16:
293*77c1e3ccSAndroid Build Coastguard Worker       highbd_fwd_txfm_4x16(src_diff, coeff, diff_stride, txfm_param);
294*77c1e3ccSAndroid Build Coastguard Worker       break;
295*77c1e3ccSAndroid Build Coastguard Worker     case TX_16X4:
296*77c1e3ccSAndroid Build Coastguard Worker       highbd_fwd_txfm_16x4(src_diff, coeff, diff_stride, txfm_param);
297*77c1e3ccSAndroid Build Coastguard Worker       break;
298*77c1e3ccSAndroid Build Coastguard Worker     case TX_8X32:
299*77c1e3ccSAndroid Build Coastguard Worker       highbd_fwd_txfm_8x32(src_diff, coeff, diff_stride, txfm_param);
300*77c1e3ccSAndroid Build Coastguard Worker       break;
301*77c1e3ccSAndroid Build Coastguard Worker     case TX_32X8:
302*77c1e3ccSAndroid Build Coastguard Worker       highbd_fwd_txfm_32x8(src_diff, coeff, diff_stride, txfm_param);
303*77c1e3ccSAndroid Build Coastguard Worker       break;
304*77c1e3ccSAndroid Build Coastguard Worker     case TX_16X64:
305*77c1e3ccSAndroid Build Coastguard Worker       highbd_fwd_txfm_16x64(src_diff, coeff, diff_stride, txfm_param);
306*77c1e3ccSAndroid Build Coastguard Worker       break;
307*77c1e3ccSAndroid Build Coastguard Worker     case TX_64X16:
308*77c1e3ccSAndroid Build Coastguard Worker       highbd_fwd_txfm_64x16(src_diff, coeff, diff_stride, txfm_param);
309*77c1e3ccSAndroid Build Coastguard Worker       break;
310*77c1e3ccSAndroid Build Coastguard Worker #endif
311*77c1e3ccSAndroid Build Coastguard Worker     default: assert(0); break;
312*77c1e3ccSAndroid Build Coastguard Worker   }
313*77c1e3ccSAndroid Build Coastguard Worker }
314*77c1e3ccSAndroid Build Coastguard Worker 
315*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_AV1_HIGHBITDEPTH
highbd_wht_fwd_txfm(TX_SIZE tx_size,const int16_t * src_diff,ptrdiff_t src_stride,tran_low_t * coeff)316*77c1e3ccSAndroid Build Coastguard Worker static inline void highbd_wht_fwd_txfm(TX_SIZE tx_size, const int16_t *src_diff,
317*77c1e3ccSAndroid Build Coastguard Worker                                        ptrdiff_t src_stride,
318*77c1e3ccSAndroid Build Coastguard Worker                                        tran_low_t *coeff) {
319*77c1e3ccSAndroid Build Coastguard Worker   switch (tx_size) {
320*77c1e3ccSAndroid Build Coastguard Worker     // As the output transform co-efficients of 4x4 Hadamard transform can be
321*77c1e3ccSAndroid Build Coastguard Worker     // represented using 15 bits (for 12-bit clip) use lowbd variant of
322*77c1e3ccSAndroid Build Coastguard Worker     // hadamard_4x4.
323*77c1e3ccSAndroid Build Coastguard Worker     case TX_4X4: aom_hadamard_4x4(src_diff, src_stride, coeff); break;
324*77c1e3ccSAndroid Build Coastguard Worker     case TX_8X8: aom_highbd_hadamard_8x8(src_diff, src_stride, coeff); break;
325*77c1e3ccSAndroid Build Coastguard Worker     case TX_16X16:
326*77c1e3ccSAndroid Build Coastguard Worker       aom_highbd_hadamard_16x16(src_diff, src_stride, coeff);
327*77c1e3ccSAndroid Build Coastguard Worker       break;
328*77c1e3ccSAndroid Build Coastguard Worker     case TX_32X32:
329*77c1e3ccSAndroid Build Coastguard Worker       aom_highbd_hadamard_32x32(src_diff, src_stride, coeff);
330*77c1e3ccSAndroid Build Coastguard Worker       break;
331*77c1e3ccSAndroid Build Coastguard Worker     default: assert(0);
332*77c1e3ccSAndroid Build Coastguard Worker   }
333*77c1e3ccSAndroid Build Coastguard Worker }
334*77c1e3ccSAndroid Build Coastguard Worker #endif  // CONFIG_AV1_HIGHBITDEPTH
335*77c1e3ccSAndroid Build Coastguard Worker 
wht_fwd_txfm(TX_SIZE tx_size,const int16_t * src_diff,ptrdiff_t src_stride,tran_low_t * coeff)336*77c1e3ccSAndroid Build Coastguard Worker static inline void wht_fwd_txfm(TX_SIZE tx_size, const int16_t *src_diff,
337*77c1e3ccSAndroid Build Coastguard Worker                                 ptrdiff_t src_stride, tran_low_t *coeff) {
338*77c1e3ccSAndroid Build Coastguard Worker   switch (tx_size) {
339*77c1e3ccSAndroid Build Coastguard Worker     case TX_4X4: aom_hadamard_4x4(src_diff, src_stride, coeff); break;
340*77c1e3ccSAndroid Build Coastguard Worker     case TX_8X8: aom_hadamard_8x8(src_diff, src_stride, coeff); break;
341*77c1e3ccSAndroid Build Coastguard Worker     case TX_16X16: aom_hadamard_16x16(src_diff, src_stride, coeff); break;
342*77c1e3ccSAndroid Build Coastguard Worker     case TX_32X32: aom_hadamard_32x32(src_diff, src_stride, coeff); break;
343*77c1e3ccSAndroid Build Coastguard Worker     default: assert(0);
344*77c1e3ccSAndroid Build Coastguard Worker   }
345*77c1e3ccSAndroid Build Coastguard Worker }
346*77c1e3ccSAndroid Build Coastguard Worker 
av1_quick_txfm(int use_hadamard,TX_SIZE tx_size,BitDepthInfo bd_info,const int16_t * src_diff,int src_stride,tran_low_t * coeff)347*77c1e3ccSAndroid Build Coastguard Worker void av1_quick_txfm(int use_hadamard, TX_SIZE tx_size, BitDepthInfo bd_info,
348*77c1e3ccSAndroid Build Coastguard Worker                     const int16_t *src_diff, int src_stride,
349*77c1e3ccSAndroid Build Coastguard Worker                     tran_low_t *coeff) {
350*77c1e3ccSAndroid Build Coastguard Worker   if (use_hadamard) {
351*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_AV1_HIGHBITDEPTH
352*77c1e3ccSAndroid Build Coastguard Worker     if (bd_info.use_highbitdepth_buf) {
353*77c1e3ccSAndroid Build Coastguard Worker       highbd_wht_fwd_txfm(tx_size, src_diff, src_stride, coeff);
354*77c1e3ccSAndroid Build Coastguard Worker     } else {
355*77c1e3ccSAndroid Build Coastguard Worker       wht_fwd_txfm(tx_size, src_diff, src_stride, coeff);
356*77c1e3ccSAndroid Build Coastguard Worker     }
357*77c1e3ccSAndroid Build Coastguard Worker #else
358*77c1e3ccSAndroid Build Coastguard Worker     wht_fwd_txfm(tx_size, src_diff, src_stride, coeff);
359*77c1e3ccSAndroid Build Coastguard Worker #endif  // CONFIG_AV1_HIGHBITDEPTH
360*77c1e3ccSAndroid Build Coastguard Worker   } else {
361*77c1e3ccSAndroid Build Coastguard Worker     TxfmParam txfm_param;
362*77c1e3ccSAndroid Build Coastguard Worker     txfm_param.tx_type = DCT_DCT;
363*77c1e3ccSAndroid Build Coastguard Worker     txfm_param.tx_size = tx_size;
364*77c1e3ccSAndroid Build Coastguard Worker     txfm_param.lossless = 0;
365*77c1e3ccSAndroid Build Coastguard Worker     txfm_param.bd = bd_info.bit_depth;
366*77c1e3ccSAndroid Build Coastguard Worker     txfm_param.is_hbd = bd_info.use_highbitdepth_buf;
367*77c1e3ccSAndroid Build Coastguard Worker     txfm_param.tx_set_type = EXT_TX_SET_ALL16;
368*77c1e3ccSAndroid Build Coastguard Worker     av1_fwd_txfm(src_diff, coeff, src_stride, &txfm_param);
369*77c1e3ccSAndroid Build Coastguard Worker   }
370*77c1e3ccSAndroid Build Coastguard Worker }
371