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