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 "aom_dsp/quantize.h"
13*77c1e3ccSAndroid Build Coastguard Worker #include "aom_mem/aom_mem.h"
14*77c1e3ccSAndroid Build Coastguard Worker #include "config/aom_dsp_rtcd.h"
15*77c1e3ccSAndroid Build Coastguard Worker
16*77c1e3ccSAndroid Build Coastguard Worker #if !CONFIG_REALTIME_ONLY
aom_quantize_b_adaptive_helper_c(const tran_low_t * coeff_ptr,intptr_t n_coeffs,const int16_t * zbin_ptr,const int16_t * round_ptr,const int16_t * quant_ptr,const int16_t * quant_shift_ptr,tran_low_t * qcoeff_ptr,tran_low_t * dqcoeff_ptr,const int16_t * dequant_ptr,uint16_t * eob_ptr,const int16_t * scan,const int16_t * iscan,const qm_val_t * qm_ptr,const qm_val_t * iqm_ptr,const int log_scale)17*77c1e3ccSAndroid Build Coastguard Worker void aom_quantize_b_adaptive_helper_c(
18*77c1e3ccSAndroid Build Coastguard Worker const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
19*77c1e3ccSAndroid Build Coastguard Worker const int16_t *round_ptr, const int16_t *quant_ptr,
20*77c1e3ccSAndroid Build Coastguard Worker const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
21*77c1e3ccSAndroid Build Coastguard Worker tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
22*77c1e3ccSAndroid Build Coastguard Worker const int16_t *scan, const int16_t *iscan, const qm_val_t *qm_ptr,
23*77c1e3ccSAndroid Build Coastguard Worker const qm_val_t *iqm_ptr, const int log_scale) {
24*77c1e3ccSAndroid Build Coastguard Worker const int zbins[2] = { ROUND_POWER_OF_TWO(zbin_ptr[0], log_scale),
25*77c1e3ccSAndroid Build Coastguard Worker ROUND_POWER_OF_TWO(zbin_ptr[1], log_scale) };
26*77c1e3ccSAndroid Build Coastguard Worker const int nzbins[2] = { zbins[0] * -1, zbins[1] * -1 };
27*77c1e3ccSAndroid Build Coastguard Worker int i, non_zero_count = (int)n_coeffs, eob = -1;
28*77c1e3ccSAndroid Build Coastguard Worker (void)iscan;
29*77c1e3ccSAndroid Build Coastguard Worker
30*77c1e3ccSAndroid Build Coastguard Worker memset(qcoeff_ptr, 0, n_coeffs * sizeof(*qcoeff_ptr));
31*77c1e3ccSAndroid Build Coastguard Worker memset(dqcoeff_ptr, 0, n_coeffs * sizeof(*dqcoeff_ptr));
32*77c1e3ccSAndroid Build Coastguard Worker
33*77c1e3ccSAndroid Build Coastguard Worker int prescan_add[2];
34*77c1e3ccSAndroid Build Coastguard Worker for (i = 0; i < 2; ++i)
35*77c1e3ccSAndroid Build Coastguard Worker prescan_add[i] = ROUND_POWER_OF_TWO(dequant_ptr[i] * EOB_FACTOR, 7);
36*77c1e3ccSAndroid Build Coastguard Worker
37*77c1e3ccSAndroid Build Coastguard Worker // Pre-scan pass
38*77c1e3ccSAndroid Build Coastguard Worker for (i = (int)n_coeffs - 1; i >= 0; i--) {
39*77c1e3ccSAndroid Build Coastguard Worker const int rc = scan[i];
40*77c1e3ccSAndroid Build Coastguard Worker const qm_val_t wt = qm_ptr != NULL ? qm_ptr[rc] : (1 << AOM_QM_BITS);
41*77c1e3ccSAndroid Build Coastguard Worker const int coeff = coeff_ptr[rc] * wt;
42*77c1e3ccSAndroid Build Coastguard Worker const int prescan_add_val = prescan_add[rc != 0];
43*77c1e3ccSAndroid Build Coastguard Worker if (coeff < (zbins[rc != 0] * (1 << AOM_QM_BITS) + prescan_add_val) &&
44*77c1e3ccSAndroid Build Coastguard Worker coeff > (nzbins[rc != 0] * (1 << AOM_QM_BITS) - prescan_add_val))
45*77c1e3ccSAndroid Build Coastguard Worker non_zero_count--;
46*77c1e3ccSAndroid Build Coastguard Worker else
47*77c1e3ccSAndroid Build Coastguard Worker break;
48*77c1e3ccSAndroid Build Coastguard Worker }
49*77c1e3ccSAndroid Build Coastguard Worker
50*77c1e3ccSAndroid Build Coastguard Worker // Quantization pass: All coefficients with index >= zero_flag are
51*77c1e3ccSAndroid Build Coastguard Worker // skippable. Note: zero_flag can be zero.
52*77c1e3ccSAndroid Build Coastguard Worker #if SKIP_EOB_FACTOR_ADJUST
53*77c1e3ccSAndroid Build Coastguard Worker int first = -1;
54*77c1e3ccSAndroid Build Coastguard Worker #endif // SKIP_EOB_FACTOR_ADJUST
55*77c1e3ccSAndroid Build Coastguard Worker for (i = 0; i < non_zero_count; i++) {
56*77c1e3ccSAndroid Build Coastguard Worker const int rc = scan[i];
57*77c1e3ccSAndroid Build Coastguard Worker const int coeff = coeff_ptr[rc];
58*77c1e3ccSAndroid Build Coastguard Worker const int coeff_sign = AOMSIGN(coeff);
59*77c1e3ccSAndroid Build Coastguard Worker const int abs_coeff = (coeff ^ coeff_sign) - coeff_sign;
60*77c1e3ccSAndroid Build Coastguard Worker int tmp32;
61*77c1e3ccSAndroid Build Coastguard Worker
62*77c1e3ccSAndroid Build Coastguard Worker const qm_val_t wt = qm_ptr != NULL ? qm_ptr[rc] : (1 << AOM_QM_BITS);
63*77c1e3ccSAndroid Build Coastguard Worker if (abs_coeff * wt >= (zbins[rc != 0] << AOM_QM_BITS)) {
64*77c1e3ccSAndroid Build Coastguard Worker int64_t tmp =
65*77c1e3ccSAndroid Build Coastguard Worker clamp(abs_coeff + ROUND_POWER_OF_TWO(round_ptr[rc != 0], log_scale),
66*77c1e3ccSAndroid Build Coastguard Worker INT16_MIN, INT16_MAX);
67*77c1e3ccSAndroid Build Coastguard Worker tmp *= wt;
68*77c1e3ccSAndroid Build Coastguard Worker tmp32 = (int)(((((tmp * quant_ptr[rc != 0]) >> 16) + tmp) *
69*77c1e3ccSAndroid Build Coastguard Worker quant_shift_ptr[rc != 0]) >>
70*77c1e3ccSAndroid Build Coastguard Worker (16 - log_scale + AOM_QM_BITS)); // quantization
71*77c1e3ccSAndroid Build Coastguard Worker qcoeff_ptr[rc] = (tmp32 ^ coeff_sign) - coeff_sign;
72*77c1e3ccSAndroid Build Coastguard Worker const int iwt = iqm_ptr != NULL ? iqm_ptr[rc] : (1 << AOM_QM_BITS);
73*77c1e3ccSAndroid Build Coastguard Worker const int dequant =
74*77c1e3ccSAndroid Build Coastguard Worker (dequant_ptr[rc != 0] * iwt + (1 << (AOM_QM_BITS - 1))) >>
75*77c1e3ccSAndroid Build Coastguard Worker AOM_QM_BITS;
76*77c1e3ccSAndroid Build Coastguard Worker const tran_low_t abs_dqcoeff = (tmp32 * dequant) >> log_scale;
77*77c1e3ccSAndroid Build Coastguard Worker dqcoeff_ptr[rc] = (tran_low_t)((abs_dqcoeff ^ coeff_sign) - coeff_sign);
78*77c1e3ccSAndroid Build Coastguard Worker
79*77c1e3ccSAndroid Build Coastguard Worker if (tmp32) {
80*77c1e3ccSAndroid Build Coastguard Worker eob = i;
81*77c1e3ccSAndroid Build Coastguard Worker #if SKIP_EOB_FACTOR_ADJUST
82*77c1e3ccSAndroid Build Coastguard Worker if (first == -1) first = i;
83*77c1e3ccSAndroid Build Coastguard Worker #endif // SKIP_EOB_FACTOR_ADJUST
84*77c1e3ccSAndroid Build Coastguard Worker }
85*77c1e3ccSAndroid Build Coastguard Worker }
86*77c1e3ccSAndroid Build Coastguard Worker }
87*77c1e3ccSAndroid Build Coastguard Worker #if SKIP_EOB_FACTOR_ADJUST
88*77c1e3ccSAndroid Build Coastguard Worker if (eob >= 0 && first == eob) {
89*77c1e3ccSAndroid Build Coastguard Worker const int rc = scan[eob];
90*77c1e3ccSAndroid Build Coastguard Worker if (qcoeff_ptr[rc] == 1 || qcoeff_ptr[rc] == -1) {
91*77c1e3ccSAndroid Build Coastguard Worker const qm_val_t wt = qm_ptr != NULL ? qm_ptr[rc] : (1 << AOM_QM_BITS);
92*77c1e3ccSAndroid Build Coastguard Worker const int coeff = coeff_ptr[rc] * wt;
93*77c1e3ccSAndroid Build Coastguard Worker const int factor = EOB_FACTOR + SKIP_EOB_FACTOR_ADJUST;
94*77c1e3ccSAndroid Build Coastguard Worker const int prescan_add_val =
95*77c1e3ccSAndroid Build Coastguard Worker ROUND_POWER_OF_TWO(dequant_ptr[rc != 0] * factor, 7);
96*77c1e3ccSAndroid Build Coastguard Worker if (coeff < (zbins[rc != 0] * (1 << AOM_QM_BITS) + prescan_add_val) &&
97*77c1e3ccSAndroid Build Coastguard Worker coeff > (nzbins[rc != 0] * (1 << AOM_QM_BITS) - prescan_add_val)) {
98*77c1e3ccSAndroid Build Coastguard Worker qcoeff_ptr[rc] = 0;
99*77c1e3ccSAndroid Build Coastguard Worker dqcoeff_ptr[rc] = 0;
100*77c1e3ccSAndroid Build Coastguard Worker eob = -1;
101*77c1e3ccSAndroid Build Coastguard Worker }
102*77c1e3ccSAndroid Build Coastguard Worker }
103*77c1e3ccSAndroid Build Coastguard Worker }
104*77c1e3ccSAndroid Build Coastguard Worker #endif // SKIP_EOB_FACTOR_ADJUST
105*77c1e3ccSAndroid Build Coastguard Worker *eob_ptr = eob + 1;
106*77c1e3ccSAndroid Build Coastguard Worker }
107*77c1e3ccSAndroid Build Coastguard Worker #endif // !CONFIG_REALTIME_ONLY
108*77c1e3ccSAndroid Build Coastguard Worker
aom_quantize_b_helper_c(const tran_low_t * coeff_ptr,intptr_t n_coeffs,const int16_t * zbin_ptr,const int16_t * round_ptr,const int16_t * quant_ptr,const int16_t * quant_shift_ptr,tran_low_t * qcoeff_ptr,tran_low_t * dqcoeff_ptr,const int16_t * dequant_ptr,uint16_t * eob_ptr,const int16_t * scan,const int16_t * iscan,const qm_val_t * qm_ptr,const qm_val_t * iqm_ptr,const int log_scale)109*77c1e3ccSAndroid Build Coastguard Worker void aom_quantize_b_helper_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
110*77c1e3ccSAndroid Build Coastguard Worker const int16_t *zbin_ptr, const int16_t *round_ptr,
111*77c1e3ccSAndroid Build Coastguard Worker const int16_t *quant_ptr,
112*77c1e3ccSAndroid Build Coastguard Worker const int16_t *quant_shift_ptr,
113*77c1e3ccSAndroid Build Coastguard Worker tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr,
114*77c1e3ccSAndroid Build Coastguard Worker const int16_t *dequant_ptr, uint16_t *eob_ptr,
115*77c1e3ccSAndroid Build Coastguard Worker const int16_t *scan, const int16_t *iscan,
116*77c1e3ccSAndroid Build Coastguard Worker const qm_val_t *qm_ptr, const qm_val_t *iqm_ptr,
117*77c1e3ccSAndroid Build Coastguard Worker const int log_scale) {
118*77c1e3ccSAndroid Build Coastguard Worker const int zbins[2] = { ROUND_POWER_OF_TWO(zbin_ptr[0], log_scale),
119*77c1e3ccSAndroid Build Coastguard Worker ROUND_POWER_OF_TWO(zbin_ptr[1], log_scale) };
120*77c1e3ccSAndroid Build Coastguard Worker const int nzbins[2] = { zbins[0] * -1, zbins[1] * -1 };
121*77c1e3ccSAndroid Build Coastguard Worker int i, non_zero_count = (int)n_coeffs, eob = -1;
122*77c1e3ccSAndroid Build Coastguard Worker (void)iscan;
123*77c1e3ccSAndroid Build Coastguard Worker
124*77c1e3ccSAndroid Build Coastguard Worker memset(qcoeff_ptr, 0, n_coeffs * sizeof(*qcoeff_ptr));
125*77c1e3ccSAndroid Build Coastguard Worker memset(dqcoeff_ptr, 0, n_coeffs * sizeof(*dqcoeff_ptr));
126*77c1e3ccSAndroid Build Coastguard Worker
127*77c1e3ccSAndroid Build Coastguard Worker // Pre-scan pass
128*77c1e3ccSAndroid Build Coastguard Worker for (i = (int)n_coeffs - 1; i >= 0; i--) {
129*77c1e3ccSAndroid Build Coastguard Worker const int rc = scan[i];
130*77c1e3ccSAndroid Build Coastguard Worker const qm_val_t wt = qm_ptr != NULL ? qm_ptr[rc] : (1 << AOM_QM_BITS);
131*77c1e3ccSAndroid Build Coastguard Worker const int coeff = coeff_ptr[rc] * wt;
132*77c1e3ccSAndroid Build Coastguard Worker
133*77c1e3ccSAndroid Build Coastguard Worker if (coeff < (zbins[rc != 0] * (1 << AOM_QM_BITS)) &&
134*77c1e3ccSAndroid Build Coastguard Worker coeff > (nzbins[rc != 0] * (1 << AOM_QM_BITS)))
135*77c1e3ccSAndroid Build Coastguard Worker non_zero_count--;
136*77c1e3ccSAndroid Build Coastguard Worker else
137*77c1e3ccSAndroid Build Coastguard Worker break;
138*77c1e3ccSAndroid Build Coastguard Worker }
139*77c1e3ccSAndroid Build Coastguard Worker
140*77c1e3ccSAndroid Build Coastguard Worker // Quantization pass: All coefficients with index >= zero_flag are
141*77c1e3ccSAndroid Build Coastguard Worker // skippable. Note: zero_flag can be zero.
142*77c1e3ccSAndroid Build Coastguard Worker for (i = 0; i < non_zero_count; i++) {
143*77c1e3ccSAndroid Build Coastguard Worker const int rc = scan[i];
144*77c1e3ccSAndroid Build Coastguard Worker const int coeff = coeff_ptr[rc];
145*77c1e3ccSAndroid Build Coastguard Worker const int coeff_sign = AOMSIGN(coeff);
146*77c1e3ccSAndroid Build Coastguard Worker const int abs_coeff = (coeff ^ coeff_sign) - coeff_sign;
147*77c1e3ccSAndroid Build Coastguard Worker int tmp32;
148*77c1e3ccSAndroid Build Coastguard Worker
149*77c1e3ccSAndroid Build Coastguard Worker const qm_val_t wt = qm_ptr != NULL ? qm_ptr[rc] : (1 << AOM_QM_BITS);
150*77c1e3ccSAndroid Build Coastguard Worker if (abs_coeff * wt >= (zbins[rc != 0] << AOM_QM_BITS)) {
151*77c1e3ccSAndroid Build Coastguard Worker int64_t tmp =
152*77c1e3ccSAndroid Build Coastguard Worker clamp(abs_coeff + ROUND_POWER_OF_TWO(round_ptr[rc != 0], log_scale),
153*77c1e3ccSAndroid Build Coastguard Worker INT16_MIN, INT16_MAX);
154*77c1e3ccSAndroid Build Coastguard Worker tmp *= wt;
155*77c1e3ccSAndroid Build Coastguard Worker tmp32 = (int)(((((tmp * quant_ptr[rc != 0]) >> 16) + tmp) *
156*77c1e3ccSAndroid Build Coastguard Worker quant_shift_ptr[rc != 0]) >>
157*77c1e3ccSAndroid Build Coastguard Worker (16 - log_scale + AOM_QM_BITS)); // quantization
158*77c1e3ccSAndroid Build Coastguard Worker qcoeff_ptr[rc] = (tmp32 ^ coeff_sign) - coeff_sign;
159*77c1e3ccSAndroid Build Coastguard Worker const int iwt = iqm_ptr != NULL ? iqm_ptr[rc] : (1 << AOM_QM_BITS);
160*77c1e3ccSAndroid Build Coastguard Worker const int dequant =
161*77c1e3ccSAndroid Build Coastguard Worker (dequant_ptr[rc != 0] * iwt + (1 << (AOM_QM_BITS - 1))) >>
162*77c1e3ccSAndroid Build Coastguard Worker AOM_QM_BITS;
163*77c1e3ccSAndroid Build Coastguard Worker const tran_low_t abs_dqcoeff = (tmp32 * dequant) >> log_scale;
164*77c1e3ccSAndroid Build Coastguard Worker dqcoeff_ptr[rc] = (tran_low_t)((abs_dqcoeff ^ coeff_sign) - coeff_sign);
165*77c1e3ccSAndroid Build Coastguard Worker
166*77c1e3ccSAndroid Build Coastguard Worker if (tmp32) eob = i;
167*77c1e3ccSAndroid Build Coastguard Worker }
168*77c1e3ccSAndroid Build Coastguard Worker }
169*77c1e3ccSAndroid Build Coastguard Worker *eob_ptr = eob + 1;
170*77c1e3ccSAndroid Build Coastguard Worker }
171*77c1e3ccSAndroid Build Coastguard Worker
172*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_AV1_HIGHBITDEPTH
173*77c1e3ccSAndroid Build Coastguard Worker #if !CONFIG_REALTIME_ONLY
aom_highbd_quantize_b_adaptive_helper_c(const tran_low_t * coeff_ptr,intptr_t n_coeffs,const int16_t * zbin_ptr,const int16_t * round_ptr,const int16_t * quant_ptr,const int16_t * quant_shift_ptr,tran_low_t * qcoeff_ptr,tran_low_t * dqcoeff_ptr,const int16_t * dequant_ptr,uint16_t * eob_ptr,const int16_t * scan,const int16_t * iscan,const qm_val_t * qm_ptr,const qm_val_t * iqm_ptr,const int log_scale)174*77c1e3ccSAndroid Build Coastguard Worker void aom_highbd_quantize_b_adaptive_helper_c(
175*77c1e3ccSAndroid Build Coastguard Worker const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
176*77c1e3ccSAndroid Build Coastguard Worker const int16_t *round_ptr, const int16_t *quant_ptr,
177*77c1e3ccSAndroid Build Coastguard Worker const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
178*77c1e3ccSAndroid Build Coastguard Worker tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
179*77c1e3ccSAndroid Build Coastguard Worker const int16_t *scan, const int16_t *iscan, const qm_val_t *qm_ptr,
180*77c1e3ccSAndroid Build Coastguard Worker const qm_val_t *iqm_ptr, const int log_scale) {
181*77c1e3ccSAndroid Build Coastguard Worker const int zbins[2] = { ROUND_POWER_OF_TWO(zbin_ptr[0], log_scale),
182*77c1e3ccSAndroid Build Coastguard Worker ROUND_POWER_OF_TWO(zbin_ptr[1], log_scale) };
183*77c1e3ccSAndroid Build Coastguard Worker const int nzbins[2] = { zbins[0] * -1, zbins[1] * -1 };
184*77c1e3ccSAndroid Build Coastguard Worker (void)iscan;
185*77c1e3ccSAndroid Build Coastguard Worker int i, non_zero_count = (int)n_coeffs, eob = -1;
186*77c1e3ccSAndroid Build Coastguard Worker
187*77c1e3ccSAndroid Build Coastguard Worker memset(qcoeff_ptr, 0, n_coeffs * sizeof(*qcoeff_ptr));
188*77c1e3ccSAndroid Build Coastguard Worker memset(dqcoeff_ptr, 0, n_coeffs * sizeof(*dqcoeff_ptr));
189*77c1e3ccSAndroid Build Coastguard Worker
190*77c1e3ccSAndroid Build Coastguard Worker int prescan_add[2];
191*77c1e3ccSAndroid Build Coastguard Worker for (i = 0; i < 2; ++i)
192*77c1e3ccSAndroid Build Coastguard Worker prescan_add[i] = ROUND_POWER_OF_TWO(dequant_ptr[i] * EOB_FACTOR, 7);
193*77c1e3ccSAndroid Build Coastguard Worker
194*77c1e3ccSAndroid Build Coastguard Worker // Pre-scan pass
195*77c1e3ccSAndroid Build Coastguard Worker for (i = (int)n_coeffs - 1; i >= 0; i--) {
196*77c1e3ccSAndroid Build Coastguard Worker const int rc = scan[i];
197*77c1e3ccSAndroid Build Coastguard Worker const qm_val_t wt = qm_ptr != NULL ? qm_ptr[rc] : (1 << AOM_QM_BITS);
198*77c1e3ccSAndroid Build Coastguard Worker const int coeff = coeff_ptr[rc] * wt;
199*77c1e3ccSAndroid Build Coastguard Worker const int prescan_add_val = prescan_add[rc != 0];
200*77c1e3ccSAndroid Build Coastguard Worker if (coeff < (zbins[rc != 0] * (1 << AOM_QM_BITS) + prescan_add_val) &&
201*77c1e3ccSAndroid Build Coastguard Worker coeff > (nzbins[rc != 0] * (1 << AOM_QM_BITS) - prescan_add_val))
202*77c1e3ccSAndroid Build Coastguard Worker non_zero_count--;
203*77c1e3ccSAndroid Build Coastguard Worker else
204*77c1e3ccSAndroid Build Coastguard Worker break;
205*77c1e3ccSAndroid Build Coastguard Worker }
206*77c1e3ccSAndroid Build Coastguard Worker
207*77c1e3ccSAndroid Build Coastguard Worker // Quantization pass: All coefficients with index >= zero_flag are
208*77c1e3ccSAndroid Build Coastguard Worker // skippable. Note: zero_flag can be zero.
209*77c1e3ccSAndroid Build Coastguard Worker #if SKIP_EOB_FACTOR_ADJUST
210*77c1e3ccSAndroid Build Coastguard Worker int first = -1;
211*77c1e3ccSAndroid Build Coastguard Worker #endif // SKIP_EOB_FACTOR_ADJUST
212*77c1e3ccSAndroid Build Coastguard Worker for (i = 0; i < non_zero_count; i++) {
213*77c1e3ccSAndroid Build Coastguard Worker const int rc = scan[i];
214*77c1e3ccSAndroid Build Coastguard Worker const int coeff = coeff_ptr[rc];
215*77c1e3ccSAndroid Build Coastguard Worker const int coeff_sign = AOMSIGN(coeff);
216*77c1e3ccSAndroid Build Coastguard Worker const qm_val_t wt = qm_ptr != NULL ? qm_ptr[rc] : (1 << AOM_QM_BITS);
217*77c1e3ccSAndroid Build Coastguard Worker const int abs_coeff = (coeff ^ coeff_sign) - coeff_sign;
218*77c1e3ccSAndroid Build Coastguard Worker if (abs_coeff * wt >= (zbins[rc != 0] << AOM_QM_BITS)) {
219*77c1e3ccSAndroid Build Coastguard Worker const int64_t tmp1 =
220*77c1e3ccSAndroid Build Coastguard Worker abs_coeff + ROUND_POWER_OF_TWO(round_ptr[rc != 0], log_scale);
221*77c1e3ccSAndroid Build Coastguard Worker const int64_t tmpw = tmp1 * wt;
222*77c1e3ccSAndroid Build Coastguard Worker const int64_t tmp2 = ((tmpw * quant_ptr[rc != 0]) >> 16) + tmpw;
223*77c1e3ccSAndroid Build Coastguard Worker const int abs_qcoeff = (int)((tmp2 * quant_shift_ptr[rc != 0]) >>
224*77c1e3ccSAndroid Build Coastguard Worker (16 - log_scale + AOM_QM_BITS));
225*77c1e3ccSAndroid Build Coastguard Worker qcoeff_ptr[rc] = (tran_low_t)((abs_qcoeff ^ coeff_sign) - coeff_sign);
226*77c1e3ccSAndroid Build Coastguard Worker const qm_val_t iwt = iqm_ptr != NULL ? iqm_ptr[rc] : (1 << AOM_QM_BITS);
227*77c1e3ccSAndroid Build Coastguard Worker const int dequant =
228*77c1e3ccSAndroid Build Coastguard Worker (dequant_ptr[rc != 0] * iwt + (1 << (AOM_QM_BITS - 1))) >>
229*77c1e3ccSAndroid Build Coastguard Worker AOM_QM_BITS;
230*77c1e3ccSAndroid Build Coastguard Worker const tran_low_t abs_dqcoeff = (abs_qcoeff * dequant) >> log_scale;
231*77c1e3ccSAndroid Build Coastguard Worker dqcoeff_ptr[rc] = (tran_low_t)((abs_dqcoeff ^ coeff_sign) - coeff_sign);
232*77c1e3ccSAndroid Build Coastguard Worker if (abs_qcoeff) {
233*77c1e3ccSAndroid Build Coastguard Worker eob = i;
234*77c1e3ccSAndroid Build Coastguard Worker #if SKIP_EOB_FACTOR_ADJUST
235*77c1e3ccSAndroid Build Coastguard Worker if (first == -1) first = eob;
236*77c1e3ccSAndroid Build Coastguard Worker #endif // SKIP_EOB_FACTOR_ADJUST
237*77c1e3ccSAndroid Build Coastguard Worker }
238*77c1e3ccSAndroid Build Coastguard Worker }
239*77c1e3ccSAndroid Build Coastguard Worker }
240*77c1e3ccSAndroid Build Coastguard Worker #if SKIP_EOB_FACTOR_ADJUST
241*77c1e3ccSAndroid Build Coastguard Worker if (eob >= 0 && first == eob) {
242*77c1e3ccSAndroid Build Coastguard Worker const int rc = scan[eob];
243*77c1e3ccSAndroid Build Coastguard Worker if (qcoeff_ptr[rc] == 1 || qcoeff_ptr[rc] == -1) {
244*77c1e3ccSAndroid Build Coastguard Worker const qm_val_t wt = qm_ptr != NULL ? qm_ptr[rc] : (1 << AOM_QM_BITS);
245*77c1e3ccSAndroid Build Coastguard Worker const int coeff = coeff_ptr[rc] * wt;
246*77c1e3ccSAndroid Build Coastguard Worker const int factor = EOB_FACTOR + SKIP_EOB_FACTOR_ADJUST;
247*77c1e3ccSAndroid Build Coastguard Worker const int prescan_add_val =
248*77c1e3ccSAndroid Build Coastguard Worker ROUND_POWER_OF_TWO(dequant_ptr[rc != 0] * factor, 7);
249*77c1e3ccSAndroid Build Coastguard Worker if (coeff < (zbins[rc != 0] * (1 << AOM_QM_BITS) + prescan_add_val) &&
250*77c1e3ccSAndroid Build Coastguard Worker coeff > (nzbins[rc != 0] * (1 << AOM_QM_BITS) - prescan_add_val)) {
251*77c1e3ccSAndroid Build Coastguard Worker qcoeff_ptr[rc] = 0;
252*77c1e3ccSAndroid Build Coastguard Worker dqcoeff_ptr[rc] = 0;
253*77c1e3ccSAndroid Build Coastguard Worker eob = -1;
254*77c1e3ccSAndroid Build Coastguard Worker }
255*77c1e3ccSAndroid Build Coastguard Worker }
256*77c1e3ccSAndroid Build Coastguard Worker }
257*77c1e3ccSAndroid Build Coastguard Worker #endif // SKIP_EOB_FACTOR_ADJUST
258*77c1e3ccSAndroid Build Coastguard Worker *eob_ptr = eob + 1;
259*77c1e3ccSAndroid Build Coastguard Worker }
260*77c1e3ccSAndroid Build Coastguard Worker #endif // !CONFIG_REALTIME_ONLY
261*77c1e3ccSAndroid Build Coastguard Worker
aom_highbd_quantize_b_helper_c(const tran_low_t * coeff_ptr,intptr_t n_coeffs,const int16_t * zbin_ptr,const int16_t * round_ptr,const int16_t * quant_ptr,const int16_t * quant_shift_ptr,tran_low_t * qcoeff_ptr,tran_low_t * dqcoeff_ptr,const int16_t * dequant_ptr,uint16_t * eob_ptr,const int16_t * scan,const int16_t * iscan,const qm_val_t * qm_ptr,const qm_val_t * iqm_ptr,const int log_scale)262*77c1e3ccSAndroid Build Coastguard Worker void aom_highbd_quantize_b_helper_c(
263*77c1e3ccSAndroid Build Coastguard Worker const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
264*77c1e3ccSAndroid Build Coastguard Worker const int16_t *round_ptr, const int16_t *quant_ptr,
265*77c1e3ccSAndroid Build Coastguard Worker const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
266*77c1e3ccSAndroid Build Coastguard Worker tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
267*77c1e3ccSAndroid Build Coastguard Worker const int16_t *scan, const int16_t *iscan, const qm_val_t *qm_ptr,
268*77c1e3ccSAndroid Build Coastguard Worker const qm_val_t *iqm_ptr, const int log_scale) {
269*77c1e3ccSAndroid Build Coastguard Worker int i, eob = -1;
270*77c1e3ccSAndroid Build Coastguard Worker const int zbins[2] = { ROUND_POWER_OF_TWO(zbin_ptr[0], log_scale),
271*77c1e3ccSAndroid Build Coastguard Worker ROUND_POWER_OF_TWO(zbin_ptr[1], log_scale) };
272*77c1e3ccSAndroid Build Coastguard Worker const int nzbins[2] = { zbins[0] * -1, zbins[1] * -1 };
273*77c1e3ccSAndroid Build Coastguard Worker int dequant;
274*77c1e3ccSAndroid Build Coastguard Worker int idx_arr[4096];
275*77c1e3ccSAndroid Build Coastguard Worker (void)iscan;
276*77c1e3ccSAndroid Build Coastguard Worker int idx = 0;
277*77c1e3ccSAndroid Build Coastguard Worker
278*77c1e3ccSAndroid Build Coastguard Worker memset(qcoeff_ptr, 0, n_coeffs * sizeof(*qcoeff_ptr));
279*77c1e3ccSAndroid Build Coastguard Worker memset(dqcoeff_ptr, 0, n_coeffs * sizeof(*dqcoeff_ptr));
280*77c1e3ccSAndroid Build Coastguard Worker
281*77c1e3ccSAndroid Build Coastguard Worker // Pre-scan pass
282*77c1e3ccSAndroid Build Coastguard Worker for (i = 0; i < n_coeffs; i++) {
283*77c1e3ccSAndroid Build Coastguard Worker const int rc = scan[i];
284*77c1e3ccSAndroid Build Coastguard Worker const qm_val_t wt = qm_ptr != NULL ? qm_ptr[rc] : (1 << AOM_QM_BITS);
285*77c1e3ccSAndroid Build Coastguard Worker const int coeff = coeff_ptr[rc] * wt;
286*77c1e3ccSAndroid Build Coastguard Worker
287*77c1e3ccSAndroid Build Coastguard Worker // If the coefficient is out of the base ZBIN range, keep it for
288*77c1e3ccSAndroid Build Coastguard Worker // quantization.
289*77c1e3ccSAndroid Build Coastguard Worker if (coeff >= (zbins[rc != 0] * (1 << AOM_QM_BITS)) ||
290*77c1e3ccSAndroid Build Coastguard Worker coeff <= (nzbins[rc != 0] * (1 << AOM_QM_BITS)))
291*77c1e3ccSAndroid Build Coastguard Worker idx_arr[idx++] = i;
292*77c1e3ccSAndroid Build Coastguard Worker }
293*77c1e3ccSAndroid Build Coastguard Worker
294*77c1e3ccSAndroid Build Coastguard Worker // Quantization pass: only process the coefficients selected in
295*77c1e3ccSAndroid Build Coastguard Worker // pre-scan pass. Note: idx can be zero.
296*77c1e3ccSAndroid Build Coastguard Worker for (i = 0; i < idx; i++) {
297*77c1e3ccSAndroid Build Coastguard Worker const int rc = scan[idx_arr[i]];
298*77c1e3ccSAndroid Build Coastguard Worker const int coeff = coeff_ptr[rc];
299*77c1e3ccSAndroid Build Coastguard Worker const int coeff_sign = AOMSIGN(coeff);
300*77c1e3ccSAndroid Build Coastguard Worker const qm_val_t wt = qm_ptr != NULL ? qm_ptr[rc] : (1 << AOM_QM_BITS);
301*77c1e3ccSAndroid Build Coastguard Worker const qm_val_t iwt = iqm_ptr != NULL ? iqm_ptr[rc] : (1 << AOM_QM_BITS);
302*77c1e3ccSAndroid Build Coastguard Worker const int abs_coeff = (coeff ^ coeff_sign) - coeff_sign;
303*77c1e3ccSAndroid Build Coastguard Worker const int64_t tmp1 =
304*77c1e3ccSAndroid Build Coastguard Worker abs_coeff + ROUND_POWER_OF_TWO(round_ptr[rc != 0], log_scale);
305*77c1e3ccSAndroid Build Coastguard Worker const int64_t tmpw = tmp1 * wt;
306*77c1e3ccSAndroid Build Coastguard Worker const int64_t tmp2 = ((tmpw * quant_ptr[rc != 0]) >> 16) + tmpw;
307*77c1e3ccSAndroid Build Coastguard Worker const int abs_qcoeff = (int)((tmp2 * quant_shift_ptr[rc != 0]) >>
308*77c1e3ccSAndroid Build Coastguard Worker (16 - log_scale + AOM_QM_BITS));
309*77c1e3ccSAndroid Build Coastguard Worker qcoeff_ptr[rc] = (tran_low_t)((abs_qcoeff ^ coeff_sign) - coeff_sign);
310*77c1e3ccSAndroid Build Coastguard Worker dequant =
311*77c1e3ccSAndroid Build Coastguard Worker (dequant_ptr[rc != 0] * iwt + (1 << (AOM_QM_BITS - 1))) >> AOM_QM_BITS;
312*77c1e3ccSAndroid Build Coastguard Worker const tran_low_t abs_dqcoeff = (abs_qcoeff * dequant) >> log_scale;
313*77c1e3ccSAndroid Build Coastguard Worker dqcoeff_ptr[rc] = (tran_low_t)((abs_dqcoeff ^ coeff_sign) - coeff_sign);
314*77c1e3ccSAndroid Build Coastguard Worker if (abs_qcoeff) eob = idx_arr[i];
315*77c1e3ccSAndroid Build Coastguard Worker }
316*77c1e3ccSAndroid Build Coastguard Worker *eob_ptr = eob + 1;
317*77c1e3ccSAndroid Build Coastguard Worker }
318*77c1e3ccSAndroid Build Coastguard Worker #endif // CONFIG_AV1_HIGHBITDEPTH
319*77c1e3ccSAndroid Build Coastguard Worker
320*77c1e3ccSAndroid Build Coastguard Worker #if !CONFIG_REALTIME_ONLY
321*77c1e3ccSAndroid Build Coastguard Worker /* These functions should only be called when quantisation matrices
322*77c1e3ccSAndroid Build Coastguard Worker are not used. */
aom_quantize_b_adaptive_c(const tran_low_t * coeff_ptr,intptr_t n_coeffs,const int16_t * zbin_ptr,const int16_t * round_ptr,const int16_t * quant_ptr,const int16_t * quant_shift_ptr,tran_low_t * qcoeff_ptr,tran_low_t * dqcoeff_ptr,const int16_t * dequant_ptr,uint16_t * eob_ptr,const int16_t * scan,const int16_t * iscan)323*77c1e3ccSAndroid Build Coastguard Worker void aom_quantize_b_adaptive_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
324*77c1e3ccSAndroid Build Coastguard Worker const int16_t *zbin_ptr,
325*77c1e3ccSAndroid Build Coastguard Worker const int16_t *round_ptr,
326*77c1e3ccSAndroid Build Coastguard Worker const int16_t *quant_ptr,
327*77c1e3ccSAndroid Build Coastguard Worker const int16_t *quant_shift_ptr,
328*77c1e3ccSAndroid Build Coastguard Worker tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr,
329*77c1e3ccSAndroid Build Coastguard Worker const int16_t *dequant_ptr, uint16_t *eob_ptr,
330*77c1e3ccSAndroid Build Coastguard Worker const int16_t *scan, const int16_t *iscan) {
331*77c1e3ccSAndroid Build Coastguard Worker aom_quantize_b_adaptive_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr,
332*77c1e3ccSAndroid Build Coastguard Worker quant_ptr, quant_shift_ptr, qcoeff_ptr,
333*77c1e3ccSAndroid Build Coastguard Worker dqcoeff_ptr, dequant_ptr, eob_ptr, scan,
334*77c1e3ccSAndroid Build Coastguard Worker iscan, NULL, NULL, 0);
335*77c1e3ccSAndroid Build Coastguard Worker }
336*77c1e3ccSAndroid Build Coastguard Worker
aom_quantize_b_32x32_adaptive_c(const tran_low_t * coeff_ptr,intptr_t n_coeffs,const int16_t * zbin_ptr,const int16_t * round_ptr,const int16_t * quant_ptr,const int16_t * quant_shift_ptr,tran_low_t * qcoeff_ptr,tran_low_t * dqcoeff_ptr,const int16_t * dequant_ptr,uint16_t * eob_ptr,const int16_t * scan,const int16_t * iscan)337*77c1e3ccSAndroid Build Coastguard Worker void aom_quantize_b_32x32_adaptive_c(
338*77c1e3ccSAndroid Build Coastguard Worker const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
339*77c1e3ccSAndroid Build Coastguard Worker const int16_t *round_ptr, const int16_t *quant_ptr,
340*77c1e3ccSAndroid Build Coastguard Worker const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
341*77c1e3ccSAndroid Build Coastguard Worker tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
342*77c1e3ccSAndroid Build Coastguard Worker const int16_t *scan, const int16_t *iscan) {
343*77c1e3ccSAndroid Build Coastguard Worker aom_quantize_b_adaptive_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr,
344*77c1e3ccSAndroid Build Coastguard Worker quant_ptr, quant_shift_ptr, qcoeff_ptr,
345*77c1e3ccSAndroid Build Coastguard Worker dqcoeff_ptr, dequant_ptr, eob_ptr, scan,
346*77c1e3ccSAndroid Build Coastguard Worker iscan, NULL, NULL, 1);
347*77c1e3ccSAndroid Build Coastguard Worker }
348*77c1e3ccSAndroid Build Coastguard Worker
aom_quantize_b_64x64_adaptive_c(const tran_low_t * coeff_ptr,intptr_t n_coeffs,const int16_t * zbin_ptr,const int16_t * round_ptr,const int16_t * quant_ptr,const int16_t * quant_shift_ptr,tran_low_t * qcoeff_ptr,tran_low_t * dqcoeff_ptr,const int16_t * dequant_ptr,uint16_t * eob_ptr,const int16_t * scan,const int16_t * iscan)349*77c1e3ccSAndroid Build Coastguard Worker void aom_quantize_b_64x64_adaptive_c(
350*77c1e3ccSAndroid Build Coastguard Worker const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
351*77c1e3ccSAndroid Build Coastguard Worker const int16_t *round_ptr, const int16_t *quant_ptr,
352*77c1e3ccSAndroid Build Coastguard Worker const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
353*77c1e3ccSAndroid Build Coastguard Worker tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
354*77c1e3ccSAndroid Build Coastguard Worker const int16_t *scan, const int16_t *iscan) {
355*77c1e3ccSAndroid Build Coastguard Worker aom_quantize_b_adaptive_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr,
356*77c1e3ccSAndroid Build Coastguard Worker quant_ptr, quant_shift_ptr, qcoeff_ptr,
357*77c1e3ccSAndroid Build Coastguard Worker dqcoeff_ptr, dequant_ptr, eob_ptr, scan,
358*77c1e3ccSAndroid Build Coastguard Worker iscan, NULL, NULL, 2);
359*77c1e3ccSAndroid Build Coastguard Worker }
360*77c1e3ccSAndroid Build Coastguard Worker
361*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_AV1_HIGHBITDEPTH
aom_highbd_quantize_b_adaptive_c(const tran_low_t * coeff_ptr,intptr_t n_coeffs,const int16_t * zbin_ptr,const int16_t * round_ptr,const int16_t * quant_ptr,const int16_t * quant_shift_ptr,tran_low_t * qcoeff_ptr,tran_low_t * dqcoeff_ptr,const int16_t * dequant_ptr,uint16_t * eob_ptr,const int16_t * scan,const int16_t * iscan)362*77c1e3ccSAndroid Build Coastguard Worker void aom_highbd_quantize_b_adaptive_c(
363*77c1e3ccSAndroid Build Coastguard Worker const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
364*77c1e3ccSAndroid Build Coastguard Worker const int16_t *round_ptr, const int16_t *quant_ptr,
365*77c1e3ccSAndroid Build Coastguard Worker const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
366*77c1e3ccSAndroid Build Coastguard Worker tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
367*77c1e3ccSAndroid Build Coastguard Worker const int16_t *scan, const int16_t *iscan) {
368*77c1e3ccSAndroid Build Coastguard Worker aom_highbd_quantize_b_adaptive_helper_c(coeff_ptr, n_coeffs, zbin_ptr,
369*77c1e3ccSAndroid Build Coastguard Worker round_ptr, quant_ptr, quant_shift_ptr,
370*77c1e3ccSAndroid Build Coastguard Worker qcoeff_ptr, dqcoeff_ptr, dequant_ptr,
371*77c1e3ccSAndroid Build Coastguard Worker eob_ptr, scan, iscan, NULL, NULL, 0);
372*77c1e3ccSAndroid Build Coastguard Worker }
373*77c1e3ccSAndroid Build Coastguard Worker
aom_highbd_quantize_b_32x32_adaptive_c(const tran_low_t * coeff_ptr,intptr_t n_coeffs,const int16_t * zbin_ptr,const int16_t * round_ptr,const int16_t * quant_ptr,const int16_t * quant_shift_ptr,tran_low_t * qcoeff_ptr,tran_low_t * dqcoeff_ptr,const int16_t * dequant_ptr,uint16_t * eob_ptr,const int16_t * scan,const int16_t * iscan)374*77c1e3ccSAndroid Build Coastguard Worker void aom_highbd_quantize_b_32x32_adaptive_c(
375*77c1e3ccSAndroid Build Coastguard Worker const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
376*77c1e3ccSAndroid Build Coastguard Worker const int16_t *round_ptr, const int16_t *quant_ptr,
377*77c1e3ccSAndroid Build Coastguard Worker const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
378*77c1e3ccSAndroid Build Coastguard Worker tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
379*77c1e3ccSAndroid Build Coastguard Worker const int16_t *scan, const int16_t *iscan) {
380*77c1e3ccSAndroid Build Coastguard Worker aom_highbd_quantize_b_adaptive_helper_c(coeff_ptr, n_coeffs, zbin_ptr,
381*77c1e3ccSAndroid Build Coastguard Worker round_ptr, quant_ptr, quant_shift_ptr,
382*77c1e3ccSAndroid Build Coastguard Worker qcoeff_ptr, dqcoeff_ptr, dequant_ptr,
383*77c1e3ccSAndroid Build Coastguard Worker eob_ptr, scan, iscan, NULL, NULL, 1);
384*77c1e3ccSAndroid Build Coastguard Worker }
385*77c1e3ccSAndroid Build Coastguard Worker
aom_highbd_quantize_b_64x64_adaptive_c(const tran_low_t * coeff_ptr,intptr_t n_coeffs,const int16_t * zbin_ptr,const int16_t * round_ptr,const int16_t * quant_ptr,const int16_t * quant_shift_ptr,tran_low_t * qcoeff_ptr,tran_low_t * dqcoeff_ptr,const int16_t * dequant_ptr,uint16_t * eob_ptr,const int16_t * scan,const int16_t * iscan)386*77c1e3ccSAndroid Build Coastguard Worker void aom_highbd_quantize_b_64x64_adaptive_c(
387*77c1e3ccSAndroid Build Coastguard Worker const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
388*77c1e3ccSAndroid Build Coastguard Worker const int16_t *round_ptr, const int16_t *quant_ptr,
389*77c1e3ccSAndroid Build Coastguard Worker const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
390*77c1e3ccSAndroid Build Coastguard Worker tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
391*77c1e3ccSAndroid Build Coastguard Worker const int16_t *scan, const int16_t *iscan) {
392*77c1e3ccSAndroid Build Coastguard Worker aom_highbd_quantize_b_adaptive_helper_c(coeff_ptr, n_coeffs, zbin_ptr,
393*77c1e3ccSAndroid Build Coastguard Worker round_ptr, quant_ptr, quant_shift_ptr,
394*77c1e3ccSAndroid Build Coastguard Worker qcoeff_ptr, dqcoeff_ptr, dequant_ptr,
395*77c1e3ccSAndroid Build Coastguard Worker eob_ptr, scan, iscan, NULL, NULL, 2);
396*77c1e3ccSAndroid Build Coastguard Worker }
397*77c1e3ccSAndroid Build Coastguard Worker #endif // CONFIG_AV1_HIGHBITDEPTH
398*77c1e3ccSAndroid Build Coastguard Worker #endif // !CONFIG_REALTIME_ONLY
399*77c1e3ccSAndroid Build Coastguard Worker
aom_quantize_b_c(const tran_low_t * coeff_ptr,intptr_t n_coeffs,const int16_t * zbin_ptr,const int16_t * round_ptr,const int16_t * quant_ptr,const int16_t * quant_shift_ptr,tran_low_t * qcoeff_ptr,tran_low_t * dqcoeff_ptr,const int16_t * dequant_ptr,uint16_t * eob_ptr,const int16_t * scan,const int16_t * iscan)400*77c1e3ccSAndroid Build Coastguard Worker void aom_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
401*77c1e3ccSAndroid Build Coastguard Worker const int16_t *zbin_ptr, const int16_t *round_ptr,
402*77c1e3ccSAndroid Build Coastguard Worker const int16_t *quant_ptr, const int16_t *quant_shift_ptr,
403*77c1e3ccSAndroid Build Coastguard Worker tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr,
404*77c1e3ccSAndroid Build Coastguard Worker const int16_t *dequant_ptr, uint16_t *eob_ptr,
405*77c1e3ccSAndroid Build Coastguard Worker const int16_t *scan, const int16_t *iscan) {
406*77c1e3ccSAndroid Build Coastguard Worker aom_quantize_b_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr, quant_ptr,
407*77c1e3ccSAndroid Build Coastguard Worker quant_shift_ptr, qcoeff_ptr, dqcoeff_ptr, dequant_ptr,
408*77c1e3ccSAndroid Build Coastguard Worker eob_ptr, scan, iscan, NULL, NULL, 0);
409*77c1e3ccSAndroid Build Coastguard Worker }
410*77c1e3ccSAndroid Build Coastguard Worker
aom_quantize_b_32x32_c(const tran_low_t * coeff_ptr,intptr_t n_coeffs,const int16_t * zbin_ptr,const int16_t * round_ptr,const int16_t * quant_ptr,const int16_t * quant_shift_ptr,tran_low_t * qcoeff_ptr,tran_low_t * dqcoeff_ptr,const int16_t * dequant_ptr,uint16_t * eob_ptr,const int16_t * scan,const int16_t * iscan)411*77c1e3ccSAndroid Build Coastguard Worker void aom_quantize_b_32x32_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
412*77c1e3ccSAndroid Build Coastguard Worker const int16_t *zbin_ptr, const int16_t *round_ptr,
413*77c1e3ccSAndroid Build Coastguard Worker const int16_t *quant_ptr,
414*77c1e3ccSAndroid Build Coastguard Worker const int16_t *quant_shift_ptr,
415*77c1e3ccSAndroid Build Coastguard Worker tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr,
416*77c1e3ccSAndroid Build Coastguard Worker const int16_t *dequant_ptr, uint16_t *eob_ptr,
417*77c1e3ccSAndroid Build Coastguard Worker const int16_t *scan, const int16_t *iscan) {
418*77c1e3ccSAndroid Build Coastguard Worker aom_quantize_b_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr, quant_ptr,
419*77c1e3ccSAndroid Build Coastguard Worker quant_shift_ptr, qcoeff_ptr, dqcoeff_ptr, dequant_ptr,
420*77c1e3ccSAndroid Build Coastguard Worker eob_ptr, scan, iscan, NULL, NULL, 1);
421*77c1e3ccSAndroid Build Coastguard Worker }
422*77c1e3ccSAndroid Build Coastguard Worker
aom_quantize_b_64x64_c(const tran_low_t * coeff_ptr,intptr_t n_coeffs,const int16_t * zbin_ptr,const int16_t * round_ptr,const int16_t * quant_ptr,const int16_t * quant_shift_ptr,tran_low_t * qcoeff_ptr,tran_low_t * dqcoeff_ptr,const int16_t * dequant_ptr,uint16_t * eob_ptr,const int16_t * scan,const int16_t * iscan)423*77c1e3ccSAndroid Build Coastguard Worker void aom_quantize_b_64x64_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
424*77c1e3ccSAndroid Build Coastguard Worker const int16_t *zbin_ptr, const int16_t *round_ptr,
425*77c1e3ccSAndroid Build Coastguard Worker const int16_t *quant_ptr,
426*77c1e3ccSAndroid Build Coastguard Worker const int16_t *quant_shift_ptr,
427*77c1e3ccSAndroid Build Coastguard Worker tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr,
428*77c1e3ccSAndroid Build Coastguard Worker const int16_t *dequant_ptr, uint16_t *eob_ptr,
429*77c1e3ccSAndroid Build Coastguard Worker const int16_t *scan, const int16_t *iscan) {
430*77c1e3ccSAndroid Build Coastguard Worker aom_quantize_b_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr, quant_ptr,
431*77c1e3ccSAndroid Build Coastguard Worker quant_shift_ptr, qcoeff_ptr, dqcoeff_ptr, dequant_ptr,
432*77c1e3ccSAndroid Build Coastguard Worker eob_ptr, scan, iscan, NULL, NULL, 2);
433*77c1e3ccSAndroid Build Coastguard Worker }
434*77c1e3ccSAndroid Build Coastguard Worker
435*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_AV1_HIGHBITDEPTH
aom_highbd_quantize_b_c(const tran_low_t * coeff_ptr,intptr_t n_coeffs,const int16_t * zbin_ptr,const int16_t * round_ptr,const int16_t * quant_ptr,const int16_t * quant_shift_ptr,tran_low_t * qcoeff_ptr,tran_low_t * dqcoeff_ptr,const int16_t * dequant_ptr,uint16_t * eob_ptr,const int16_t * scan,const int16_t * iscan)436*77c1e3ccSAndroid Build Coastguard Worker void aom_highbd_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
437*77c1e3ccSAndroid Build Coastguard Worker const int16_t *zbin_ptr, const int16_t *round_ptr,
438*77c1e3ccSAndroid Build Coastguard Worker const int16_t *quant_ptr,
439*77c1e3ccSAndroid Build Coastguard Worker const int16_t *quant_shift_ptr,
440*77c1e3ccSAndroid Build Coastguard Worker tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr,
441*77c1e3ccSAndroid Build Coastguard Worker const int16_t *dequant_ptr, uint16_t *eob_ptr,
442*77c1e3ccSAndroid Build Coastguard Worker const int16_t *scan, const int16_t *iscan) {
443*77c1e3ccSAndroid Build Coastguard Worker aom_highbd_quantize_b_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr,
444*77c1e3ccSAndroid Build Coastguard Worker quant_ptr, quant_shift_ptr, qcoeff_ptr,
445*77c1e3ccSAndroid Build Coastguard Worker dqcoeff_ptr, dequant_ptr, eob_ptr, scan, iscan,
446*77c1e3ccSAndroid Build Coastguard Worker NULL, NULL, 0);
447*77c1e3ccSAndroid Build Coastguard Worker }
448*77c1e3ccSAndroid Build Coastguard Worker
aom_highbd_quantize_b_32x32_c(const tran_low_t * coeff_ptr,intptr_t n_coeffs,const int16_t * zbin_ptr,const int16_t * round_ptr,const int16_t * quant_ptr,const int16_t * quant_shift_ptr,tran_low_t * qcoeff_ptr,tran_low_t * dqcoeff_ptr,const int16_t * dequant_ptr,uint16_t * eob_ptr,const int16_t * scan,const int16_t * iscan)449*77c1e3ccSAndroid Build Coastguard Worker void aom_highbd_quantize_b_32x32_c(
450*77c1e3ccSAndroid Build Coastguard Worker const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
451*77c1e3ccSAndroid Build Coastguard Worker const int16_t *round_ptr, const int16_t *quant_ptr,
452*77c1e3ccSAndroid Build Coastguard Worker const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
453*77c1e3ccSAndroid Build Coastguard Worker tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
454*77c1e3ccSAndroid Build Coastguard Worker const int16_t *scan, const int16_t *iscan) {
455*77c1e3ccSAndroid Build Coastguard Worker aom_highbd_quantize_b_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr,
456*77c1e3ccSAndroid Build Coastguard Worker quant_ptr, quant_shift_ptr, qcoeff_ptr,
457*77c1e3ccSAndroid Build Coastguard Worker dqcoeff_ptr, dequant_ptr, eob_ptr, scan, iscan,
458*77c1e3ccSAndroid Build Coastguard Worker NULL, NULL, 1);
459*77c1e3ccSAndroid Build Coastguard Worker }
460*77c1e3ccSAndroid Build Coastguard Worker
aom_highbd_quantize_b_64x64_c(const tran_low_t * coeff_ptr,intptr_t n_coeffs,const int16_t * zbin_ptr,const int16_t * round_ptr,const int16_t * quant_ptr,const int16_t * quant_shift_ptr,tran_low_t * qcoeff_ptr,tran_low_t * dqcoeff_ptr,const int16_t * dequant_ptr,uint16_t * eob_ptr,const int16_t * scan,const int16_t * iscan)461*77c1e3ccSAndroid Build Coastguard Worker void aom_highbd_quantize_b_64x64_c(
462*77c1e3ccSAndroid Build Coastguard Worker const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
463*77c1e3ccSAndroid Build Coastguard Worker const int16_t *round_ptr, const int16_t *quant_ptr,
464*77c1e3ccSAndroid Build Coastguard Worker const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
465*77c1e3ccSAndroid Build Coastguard Worker tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
466*77c1e3ccSAndroid Build Coastguard Worker const int16_t *scan, const int16_t *iscan) {
467*77c1e3ccSAndroid Build Coastguard Worker aom_highbd_quantize_b_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr,
468*77c1e3ccSAndroid Build Coastguard Worker quant_ptr, quant_shift_ptr, qcoeff_ptr,
469*77c1e3ccSAndroid Build Coastguard Worker dqcoeff_ptr, dequant_ptr, eob_ptr, scan, iscan,
470*77c1e3ccSAndroid Build Coastguard Worker NULL, NULL, 2);
471*77c1e3ccSAndroid Build Coastguard Worker }
472*77c1e3ccSAndroid Build Coastguard Worker #endif // CONFIG_AV1_HIGHBITDEPTH
473