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