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