• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
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 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 = (coeff >> 31);
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 
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 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, tran_low_t *qcoeff_ptr,
111                          tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr,
112                          uint16_t *eob_ptr, const int16_t *scan,
113                          const int16_t *iscan, const qm_val_t *qm_ptr,
114                          const qm_val_t *iqm_ptr, const int log_scale) {
115   const int zbins[2] = { ROUND_POWER_OF_TWO(zbin_ptr[0], log_scale),
116                          ROUND_POWER_OF_TWO(zbin_ptr[1], log_scale) };
117   const int nzbins[2] = { zbins[0] * -1, zbins[1] * -1 };
118   int i, non_zero_count = (int)n_coeffs, eob = -1;
119   (void)iscan;
120 
121   memset(qcoeff_ptr, 0, n_coeffs * sizeof(*qcoeff_ptr));
122   memset(dqcoeff_ptr, 0, n_coeffs * sizeof(*dqcoeff_ptr));
123 
124   // Pre-scan pass
125   for (i = (int)n_coeffs - 1; i >= 0; i--) {
126     const int rc = scan[i];
127     const qm_val_t wt = qm_ptr != NULL ? qm_ptr[rc] : (1 << AOM_QM_BITS);
128     const int coeff = coeff_ptr[rc] * wt;
129 
130     if (coeff < (zbins[rc != 0] * (1 << AOM_QM_BITS)) &&
131         coeff > (nzbins[rc != 0] * (1 << AOM_QM_BITS)))
132       non_zero_count--;
133     else
134       break;
135   }
136 
137   // Quantization pass: All coefficients with index >= zero_flag are
138   // skippable. Note: zero_flag can be zero.
139   for (i = 0; i < non_zero_count; i++) {
140     const int rc = scan[i];
141     const int coeff = coeff_ptr[rc];
142     const int coeff_sign = (coeff >> 31);
143     const int abs_coeff = (coeff ^ coeff_sign) - coeff_sign;
144     int tmp32;
145 
146     const qm_val_t wt = qm_ptr != NULL ? qm_ptr[rc] : (1 << AOM_QM_BITS);
147     if (abs_coeff * wt >= (zbins[rc != 0] << AOM_QM_BITS)) {
148       int64_t tmp =
149           clamp(abs_coeff + ROUND_POWER_OF_TWO(round_ptr[rc != 0], log_scale),
150                 INT16_MIN, INT16_MAX);
151       tmp *= wt;
152       tmp32 = (int)(((((tmp * quant_ptr[rc != 0]) >> 16) + tmp) *
153                      quant_shift_ptr[rc != 0]) >>
154                     (16 - log_scale + AOM_QM_BITS));  // quantization
155       qcoeff_ptr[rc] = (tmp32 ^ coeff_sign) - coeff_sign;
156       const int iwt = iqm_ptr != NULL ? iqm_ptr[rc] : (1 << AOM_QM_BITS);
157       const int dequant =
158           (dequant_ptr[rc != 0] * iwt + (1 << (AOM_QM_BITS - 1))) >>
159           AOM_QM_BITS;
160       const tran_low_t abs_dqcoeff = (tmp32 * dequant) >> log_scale;
161       dqcoeff_ptr[rc] = (tran_low_t)((abs_dqcoeff ^ coeff_sign) - coeff_sign);
162 
163       if (tmp32) eob = i;
164     }
165   }
166   *eob_ptr = eob + 1;
167 }
168 
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)169 void highbd_quantize_b_adaptive_helper_c(
170     const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
171     const int16_t *round_ptr, const int16_t *quant_ptr,
172     const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
173     tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
174     const int16_t *scan, const int16_t *iscan, const qm_val_t *qm_ptr,
175     const qm_val_t *iqm_ptr, const int log_scale) {
176   int i, eob = -1;
177   const int zbins[2] = { ROUND_POWER_OF_TWO(zbin_ptr[0], log_scale),
178                          ROUND_POWER_OF_TWO(zbin_ptr[1], log_scale) };
179   const int nzbins[2] = { zbins[0] * -1, zbins[1] * -1 };
180   int dequant;
181   int idx_arr[4096];
182   (void)iscan;
183   int idx = 0;
184 
185   memset(qcoeff_ptr, 0, n_coeffs * sizeof(*qcoeff_ptr));
186   memset(dqcoeff_ptr, 0, n_coeffs * sizeof(*dqcoeff_ptr));
187 
188   int prescan_add[2];
189   for (i = 0; i < 2; ++i)
190     prescan_add[i] = ROUND_POWER_OF_TWO(dequant_ptr[i] * EOB_FACTOR, 7);
191 
192   // Pre-scan pass
193   for (i = 0; i < n_coeffs; i++) {
194     const int rc = scan[i];
195     const qm_val_t wt = qm_ptr != NULL ? qm_ptr[rc] : (1 << AOM_QM_BITS);
196     const int coeff = coeff_ptr[rc] * wt;
197 
198     // If the coefficient is out of the base ZBIN range, keep it for
199     // quantization.
200     const int prescan_add_val = prescan_add[rc != 0];
201     if (coeff >= (zbins[rc != 0] * (1 << AOM_QM_BITS) + prescan_add_val) &&
202         coeff <= (nzbins[rc != 0] * (1 << AOM_QM_BITS) - prescan_add_val))
203       idx_arr[idx++] = i;
204   }
205 
206   // Quantization pass: only process the coefficients selected in
207   // pre-scan pass. Note: idx can be zero.
208 #if SKIP_EOB_FACTOR_ADJUST
209   int first = -1;
210 #endif  // SKIP_EOB_FACTOR_ADJUST
211   for (i = 0; i < idx; i++) {
212     const int rc = scan[idx_arr[i]];
213     const int coeff = coeff_ptr[rc];
214     const int coeff_sign = (coeff >> 31);
215     const qm_val_t wt = qm_ptr != NULL ? qm_ptr[rc] : (1 << AOM_QM_BITS);
216     const qm_val_t iwt = iqm_ptr != NULL ? iqm_ptr[rc] : (1 << AOM_QM_BITS);
217     const int abs_coeff = (coeff ^ coeff_sign) - coeff_sign;
218     const int64_t tmp1 =
219         abs_coeff + ROUND_POWER_OF_TWO(round_ptr[rc != 0], log_scale);
220     const int64_t tmpw = tmp1 * wt;
221     const int64_t tmp2 = ((tmpw * quant_ptr[rc != 0]) >> 16) + tmpw;
222     const int abs_qcoeff = (int)((tmp2 * quant_shift_ptr[rc != 0]) >>
223                                  (16 - log_scale + AOM_QM_BITS));
224     qcoeff_ptr[rc] = (tran_low_t)((abs_qcoeff ^ coeff_sign) - coeff_sign);
225     dequant =
226         (dequant_ptr[rc != 0] * iwt + (1 << (AOM_QM_BITS - 1))) >> 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 = idx_arr[i];
231 #if SKIP_EOB_FACTOR_ADJUST
232       if (first == -1) first = eob;
233 #endif  // SKIP_EOB_FACTOR_ADJUST
234     }
235   }
236 #if SKIP_EOB_FACTOR_ADJUST
237   if (eob >= 0 && first == eob) {
238     const int rc = scan[eob];
239     if (qcoeff_ptr[rc] == 1 || qcoeff_ptr[rc] == -1) {
240       const qm_val_t wt = qm_ptr != NULL ? qm_ptr[rc] : (1 << AOM_QM_BITS);
241       const int coeff = coeff_ptr[rc] * wt;
242       const int factor = EOB_FACTOR + SKIP_EOB_FACTOR_ADJUST;
243       const int prescan_add_val =
244           ROUND_POWER_OF_TWO(dequant_ptr[rc != 0] * factor, 7);
245       if (coeff < (zbins[rc != 0] * (1 << AOM_QM_BITS) + prescan_add_val) &&
246           coeff > (nzbins[rc != 0] * (1 << AOM_QM_BITS) - prescan_add_val)) {
247         qcoeff_ptr[rc] = 0;
248         dqcoeff_ptr[rc] = 0;
249         eob = -1;
250       }
251     }
252   }
253 #endif  // SKIP_EOB_FACTOR_ADJUST
254   *eob_ptr = eob + 1;
255 }
256 
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)257 void highbd_quantize_b_helper_c(
258     const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
259     const int16_t *round_ptr, const int16_t *quant_ptr,
260     const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
261     tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
262     const int16_t *scan, const int16_t *iscan, const qm_val_t *qm_ptr,
263     const qm_val_t *iqm_ptr, const int log_scale) {
264   int i, eob = -1;
265   const int zbins[2] = { ROUND_POWER_OF_TWO(zbin_ptr[0], log_scale),
266                          ROUND_POWER_OF_TWO(zbin_ptr[1], log_scale) };
267   const int nzbins[2] = { zbins[0] * -1, zbins[1] * -1 };
268   int dequant;
269   int idx_arr[4096];
270   (void)iscan;
271   int idx = 0;
272 
273   memset(qcoeff_ptr, 0, n_coeffs * sizeof(*qcoeff_ptr));
274   memset(dqcoeff_ptr, 0, n_coeffs * sizeof(*dqcoeff_ptr));
275 
276   // Pre-scan pass
277   for (i = 0; i < n_coeffs; i++) {
278     const int rc = scan[i];
279     const qm_val_t wt = qm_ptr != NULL ? qm_ptr[rc] : (1 << AOM_QM_BITS);
280     const int coeff = coeff_ptr[rc] * wt;
281 
282     // If the coefficient is out of the base ZBIN range, keep it for
283     // quantization.
284     if (coeff >= (zbins[rc != 0] * (1 << AOM_QM_BITS)) ||
285         coeff <= (nzbins[rc != 0] * (1 << AOM_QM_BITS)))
286       idx_arr[idx++] = i;
287   }
288 
289   // Quantization pass: only process the coefficients selected in
290   // pre-scan pass. Note: idx can be zero.
291   for (i = 0; i < idx; i++) {
292     const int rc = scan[idx_arr[i]];
293     const int coeff = coeff_ptr[rc];
294     const int coeff_sign = (coeff >> 31);
295     const qm_val_t wt = qm_ptr != NULL ? qm_ptr[rc] : (1 << AOM_QM_BITS);
296     const qm_val_t iwt = iqm_ptr != NULL ? iqm_ptr[rc] : (1 << AOM_QM_BITS);
297     const int abs_coeff = (coeff ^ coeff_sign) - coeff_sign;
298     const int64_t tmp1 =
299         abs_coeff + ROUND_POWER_OF_TWO(round_ptr[rc != 0], log_scale);
300     const int64_t tmpw = tmp1 * wt;
301     const int64_t tmp2 = ((tmpw * quant_ptr[rc != 0]) >> 16) + tmpw;
302     const int abs_qcoeff = (int)((tmp2 * quant_shift_ptr[rc != 0]) >>
303                                  (16 - log_scale + AOM_QM_BITS));
304     qcoeff_ptr[rc] = (tran_low_t)((abs_qcoeff ^ coeff_sign) - coeff_sign);
305     dequant =
306         (dequant_ptr[rc != 0] * iwt + (1 << (AOM_QM_BITS - 1))) >> AOM_QM_BITS;
307     const tran_low_t abs_dqcoeff = (abs_qcoeff * dequant) >> log_scale;
308     dqcoeff_ptr[rc] = (tran_low_t)((abs_dqcoeff ^ coeff_sign) - coeff_sign);
309     if (abs_qcoeff) eob = idx_arr[i];
310   }
311   *eob_ptr = eob + 1;
312 }
313 
314 /* These functions should only be called when quantisation matrices
315    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)316 void aom_quantize_b_adaptive_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
317                                const int16_t *zbin_ptr,
318                                const int16_t *round_ptr,
319                                const int16_t *quant_ptr,
320                                const int16_t *quant_shift_ptr,
321                                tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr,
322                                const int16_t *dequant_ptr, uint16_t *eob_ptr,
323                                const int16_t *scan, const int16_t *iscan) {
324   quantize_b_adaptive_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr,
325                                quant_ptr, quant_shift_ptr, qcoeff_ptr,
326                                dqcoeff_ptr, dequant_ptr, eob_ptr, scan, iscan,
327                                NULL, NULL, 0);
328 }
329 
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)330 void aom_quantize_b_32x32_adaptive_c(
331     const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
332     const int16_t *round_ptr, const int16_t *quant_ptr,
333     const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
334     tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
335     const int16_t *scan, const int16_t *iscan) {
336   quantize_b_adaptive_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr,
337                                quant_ptr, quant_shift_ptr, qcoeff_ptr,
338                                dqcoeff_ptr, dequant_ptr, eob_ptr, scan, iscan,
339                                NULL, NULL, 1);
340 }
341 
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)342 void aom_quantize_b_64x64_adaptive_c(
343     const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
344     const int16_t *round_ptr, const int16_t *quant_ptr,
345     const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
346     tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
347     const int16_t *scan, const int16_t *iscan) {
348   quantize_b_adaptive_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr,
349                                quant_ptr, quant_shift_ptr, qcoeff_ptr,
350                                dqcoeff_ptr, dequant_ptr, eob_ptr, scan, iscan,
351                                NULL, NULL, 2);
352 }
353 
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)354 void aom_highbd_quantize_b_adaptive_c(
355     const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
356     const int16_t *round_ptr, const int16_t *quant_ptr,
357     const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
358     tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
359     const int16_t *scan, const int16_t *iscan) {
360   highbd_quantize_b_adaptive_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr,
361                                       quant_ptr, quant_shift_ptr, qcoeff_ptr,
362                                       dqcoeff_ptr, dequant_ptr, eob_ptr, scan,
363                                       iscan, NULL, NULL, 0);
364 }
365 
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)366 void aom_highbd_quantize_b_32x32_adaptive_c(
367     const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
368     const int16_t *round_ptr, const int16_t *quant_ptr,
369     const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
370     tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
371     const int16_t *scan, const int16_t *iscan) {
372   highbd_quantize_b_adaptive_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr,
373                                       quant_ptr, quant_shift_ptr, qcoeff_ptr,
374                                       dqcoeff_ptr, dequant_ptr, eob_ptr, scan,
375                                       iscan, NULL, NULL, 1);
376 }
377 
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)378 void aom_highbd_quantize_b_64x64_adaptive_c(
379     const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
380     const int16_t *round_ptr, const int16_t *quant_ptr,
381     const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
382     tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
383     const int16_t *scan, const int16_t *iscan) {
384   highbd_quantize_b_adaptive_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr,
385                                       quant_ptr, quant_shift_ptr, qcoeff_ptr,
386                                       dqcoeff_ptr, dequant_ptr, eob_ptr, scan,
387                                       iscan, NULL, NULL, 2);
388 }
389 
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)390 void aom_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
391                       const int16_t *zbin_ptr, const int16_t *round_ptr,
392                       const int16_t *quant_ptr, const int16_t *quant_shift_ptr,
393                       tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr,
394                       const int16_t *dequant_ptr, uint16_t *eob_ptr,
395                       const int16_t *scan, const int16_t *iscan) {
396   quantize_b_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr, quant_ptr,
397                       quant_shift_ptr, qcoeff_ptr, dqcoeff_ptr, dequant_ptr,
398                       eob_ptr, scan, iscan, NULL, NULL, 0);
399 }
400 
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)401 void aom_quantize_b_32x32_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
402                             const int16_t *zbin_ptr, const int16_t *round_ptr,
403                             const int16_t *quant_ptr,
404                             const int16_t *quant_shift_ptr,
405                             tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr,
406                             const int16_t *dequant_ptr, uint16_t *eob_ptr,
407                             const int16_t *scan, const int16_t *iscan) {
408   quantize_b_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr, quant_ptr,
409                       quant_shift_ptr, qcoeff_ptr, dqcoeff_ptr, dequant_ptr,
410                       eob_ptr, scan, iscan, NULL, NULL, 1);
411 }
412 
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)413 void aom_quantize_b_64x64_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
414                             const int16_t *zbin_ptr, const int16_t *round_ptr,
415                             const int16_t *quant_ptr,
416                             const int16_t *quant_shift_ptr,
417                             tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr,
418                             const int16_t *dequant_ptr, uint16_t *eob_ptr,
419                             const int16_t *scan, const int16_t *iscan) {
420   quantize_b_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr, quant_ptr,
421                       quant_shift_ptr, qcoeff_ptr, dqcoeff_ptr, dequant_ptr,
422                       eob_ptr, scan, iscan, NULL, NULL, 2);
423 }
424 
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)425 void aom_highbd_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
426                              const int16_t *zbin_ptr, const int16_t *round_ptr,
427                              const int16_t *quant_ptr,
428                              const int16_t *quant_shift_ptr,
429                              tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr,
430                              const int16_t *dequant_ptr, uint16_t *eob_ptr,
431                              const int16_t *scan, const int16_t *iscan) {
432   highbd_quantize_b_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr,
433                              quant_ptr, quant_shift_ptr, qcoeff_ptr,
434                              dqcoeff_ptr, dequant_ptr, eob_ptr, scan, iscan,
435                              NULL, NULL, 0);
436 }
437 
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)438 void aom_highbd_quantize_b_32x32_c(
439     const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
440     const int16_t *round_ptr, const int16_t *quant_ptr,
441     const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
442     tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
443     const int16_t *scan, const int16_t *iscan) {
444   highbd_quantize_b_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr,
445                              quant_ptr, quant_shift_ptr, qcoeff_ptr,
446                              dqcoeff_ptr, dequant_ptr, eob_ptr, scan, iscan,
447                              NULL, NULL, 1);
448 }
449 
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)450 void aom_highbd_quantize_b_64x64_c(
451     const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
452     const int16_t *round_ptr, const int16_t *quant_ptr,
453     const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
454     tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
455     const int16_t *scan, const int16_t *iscan) {
456   highbd_quantize_b_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr,
457                              quant_ptr, quant_shift_ptr, qcoeff_ptr,
458                              dqcoeff_ptr, dequant_ptr, eob_ptr, scan, iscan,
459                              NULL, NULL, 2);
460 }
461