blob: de916ae970b5eb7fab4d20f5e3599c37d071a4a5 [file] [log] [blame]
Yaowu Xuc27fc142016-08-22 16:08:15 -07001/*
Yaowu Xu9c01aa12016-09-01 14:32:49 -07002 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
Yaowu Xuc27fc142016-08-22 16:08:15 -07003 *
Yaowu Xu9c01aa12016-09-01 14:32:49 -07004 * 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.
Yaowu Xuc27fc142016-08-22 16:08:15 -070010 */
11
Yaowu Xuc27fc142016-08-22 16:08:15 -070012#include "aom_dsp/quantize.h"
Yaowu Xuf883b422016-08-30 14:01:10 -070013#include "aom_mem/aom_mem.h"
Aniket Dhok64a5e402019-03-19 20:15:29 +053014#include "av1/encoder/av1_quantize.h"
Debargha Mukherjeeb52c5ce2019-03-06 11:39:31 -080015
Yaowu Xubbaa9662019-05-06 11:17:03 -070016void aom_quantize_b_adaptive_helper_c(
Sarah Parkereec52bb2019-01-17 15:04:35 -080017 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
Debargha Mukherjeeb52c5ce2019-03-06 11:39:31 -080032 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
Sarah Parkereec52bb2019-01-17 15:04:35 -080036 // 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;
Debargha Mukherjeeb52c5ce2019-03-06 11:39:31 -080041 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))
Sarah Parkereec52bb2019-01-17 15:04:35 -080044 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.
Debargha Mukherjeeb52c5ce2019-03-06 11:39:31 -080051#if SKIP_EOB_FACTOR_ADJUST
52 int first = -1;
53#endif // SKIP_EOB_FACTOR_ADJUST
Sarah Parkereec52bb2019-01-17 15:04:35 -080054 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
Debargha Mukherjeeb52c5ce2019-03-06 11:39:31 -080078 if (tmp32) {
79 eob = i;
80#if SKIP_EOB_FACTOR_ADJUST
81 if (first == -1) first = i;
82#endif // SKIP_EOB_FACTOR_ADJUST
83 }
Sarah Parkereec52bb2019-01-17 15:04:35 -080084 }
85 }
Debargha Mukherjeeb52c5ce2019-03-06 11:39:31 -080086#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
Sarah Parkereec52bb2019-01-17 15:04:35 -0800104 *eob_ptr = eob + 1;
105}
Sarah Parkere343b8c2019-01-22 15:11:32 -0800106
Yaowu Xubbaa9662019-05-06 11:17:03 -0700107void 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) {
Cheng Chence8275c2017-04-26 11:16:24 -0700116 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
Peng Binf36be562018-09-07 15:28:46 +0800125 // 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;
Cheng Chence8275c2017-04-26 11:16:24 -0700130
Peng Binf36be562018-09-07 15:28:46 +0800131 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 }
Cheng Chence8275c2017-04-26 11:16:24 -0700137
Peng Binf36be562018-09-07 15:28:46 +0800138 // 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 = (coeff >> 31);
144 const int abs_coeff = (coeff ^ coeff_sign) - coeff_sign;
145 int tmp32;
Cheng Chence8275c2017-04-26 11:16:24 -0700146
Peng Binf36be562018-09-07 15:28:46 +0800147 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);
Cheng Chence8275c2017-04-26 11:16:24 -0700163
Peng Binf36be562018-09-07 15:28:46 +0800164 if (tmp32) eob = i;
Cheng Chence8275c2017-04-26 11:16:24 -0700165 }
166 }
167 *eob_ptr = eob + 1;
168}
169
Jerome Jiangf8cc1c42019-08-02 16:34:32 -0700170#if CONFIG_AV1_HIGHBITDEPTH
Yaowu Xubbaa9662019-05-06 11:17:03 -0700171void aom_highbd_quantize_b_adaptive_helper_c(
Sarah Parkereec52bb2019-01-17 15:04:35 -0800172 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) {
Sarah Parkereec52bb2019-01-17 15:04:35 -0800178 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 };
Sarah Parkereec52bb2019-01-17 15:04:35 -0800181 (void)iscan;
Remyac3569812019-05-21 18:00:18 +0530182 int i, non_zero_count = (int)n_coeffs, eob = -1;
Sarah Parkereec52bb2019-01-17 15:04:35 -0800183
184 memset(qcoeff_ptr, 0, n_coeffs * sizeof(*qcoeff_ptr));
185 memset(dqcoeff_ptr, 0, n_coeffs * sizeof(*dqcoeff_ptr));
186
Debargha Mukherjeeb52c5ce2019-03-06 11:39:31 -0800187 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
Sarah Parkereec52bb2019-01-17 15:04:35 -0800191 // Pre-scan pass
Remyac3569812019-05-21 18:00:18 +0530192 for (i = (int)n_coeffs - 1; i >= 0; i--) {
Sarah Parkereec52bb2019-01-17 15:04:35 -0800193 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;
Debargha Mukherjeeb52c5ce2019-03-06 11:39:31 -0800196 const int prescan_add_val = prescan_add[rc != 0];
Remyac3569812019-05-21 18:00:18 +0530197 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;
Sarah Parkereec52bb2019-01-17 15:04:35 -0800202 }
203
Remyac3569812019-05-21 18:00:18 +0530204 // Quantization pass: All coefficients with index >= zero_flag are
205 // skippable. Note: zero_flag can be zero.
Debargha Mukherjeeb52c5ce2019-03-06 11:39:31 -0800206#if SKIP_EOB_FACTOR_ADJUST
207 int first = -1;
208#endif // SKIP_EOB_FACTOR_ADJUST
Remyac3569812019-05-21 18:00:18 +0530209 for (i = 0; i < non_zero_count; i++) {
210 const int rc = scan[i];
Sarah Parkereec52bb2019-01-17 15:04:35 -0800211 const int coeff = coeff_ptr[rc];
212 const int coeff_sign = (coeff >> 31);
213 const qm_val_t wt = qm_ptr != NULL ? qm_ptr[rc] : (1 << AOM_QM_BITS);
Sarah Parkereec52bb2019-01-17 15:04:35 -0800214 const int abs_coeff = (coeff ^ coeff_sign) - coeff_sign;
Remyac3569812019-05-21 18:00:18 +0530215 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;
Debargha Mukherjeeb52c5ce2019-03-06 11:39:31 -0800231#if SKIP_EOB_FACTOR_ADJUST
Remyac3569812019-05-21 18:00:18 +0530232 if (first == -1) first = eob;
Debargha Mukherjeeb52c5ce2019-03-06 11:39:31 -0800233#endif // SKIP_EOB_FACTOR_ADJUST
Remyac3569812019-05-21 18:00:18 +0530234 }
Debargha Mukherjeeb52c5ce2019-03-06 11:39:31 -0800235 }
Sarah Parkereec52bb2019-01-17 15:04:35 -0800236 }
Debargha Mukherjeeb52c5ce2019-03-06 11:39:31 -0800237#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
Sarah Parkereec52bb2019-01-17 15:04:35 -0800255 *eob_ptr = eob + 1;
256}
257
Yaowu Xubbaa9662019-05-06 11:17:03 -0700258void aom_highbd_quantize_b_helper_c(
Peng Bin6b971982018-09-07 15:21:40 +0800259 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,
Thomas Daviesf3b5ee12017-07-18 15:16:43 +0100261 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;
Thomas Daviesf3b5ee12017-07-18 15:16:43 +0100270 int idx_arr[4096];
Thomas Daviesf3b5ee12017-07-18 15:16:43 +0100271 (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
Peng Bin6b971982018-09-07 15:21:40 +0800277 // 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;
Thomas Daviesf3b5ee12017-07-18 15:16:43 +0100282
Peng Bin6b971982018-09-07 15:21:40 +0800283 // 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 }
Thomas Daviesf3b5ee12017-07-18 15:16:43 +0100289
Peng Bin6b971982018-09-07 15:21:40 +0800290 // 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 = (coeff >> 31);
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];
Thomas Daviesf3b5ee12017-07-18 15:16:43 +0100311 }
312 *eob_ptr = eob + 1;
313}
Jerome Jiangf8cc1c42019-08-02 16:34:32 -0700314#endif // CONFIG_AV1_HIGHBITDEPTH
Thomas Daviesf3b5ee12017-07-18 15:16:43 +0100315
Thomas Daviesf3b5ee12017-07-18 15:16:43 +0100316/* These functions should only be called when quantisation matrices
317 are not used. */
Sarah Parkere343b8c2019-01-22 15:11:32 -0800318void 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) {
Yaowu Xubbaa9662019-05-06 11:17:03 -0700326 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);
Sarah Parkere343b8c2019-01-22 15:11:32 -0800330}
331
332void 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) {
Yaowu Xubbaa9662019-05-06 11:17:03 -0700338 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);
Sarah Parkere343b8c2019-01-22 15:11:32 -0800342}
343
344void 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) {
Yaowu Xubbaa9662019-05-06 11:17:03 -0700350 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);
Sarah Parkere343b8c2019-01-22 15:11:32 -0800354}
355
Jerome Jiangf8cc1c42019-08-02 16:34:32 -0700356#if CONFIG_AV1_HIGHBITDEPTH
Sarah Parkere343b8c2019-01-22 15:11:32 -0800357void 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) {
Yaowu Xubbaa9662019-05-06 11:17:03 -0700363 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);
Sarah Parkere343b8c2019-01-22 15:11:32 -0800367}
368
369void 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) {
Yaowu Xubbaa9662019-05-06 11:17:03 -0700375 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);
Sarah Parkere343b8c2019-01-22 15:11:32 -0800379}
380
381void 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) {
Yaowu Xubbaa9662019-05-06 11:17:03 -0700387 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);
Sarah Parkere343b8c2019-01-22 15:11:32 -0800391}
Jerome Jiangf8cc1c42019-08-02 16:34:32 -0700392#endif // CONFIG_AV1_HIGHBITDEPTH
Sarah Parkere343b8c2019-01-22 15:11:32 -0800393
Cheng Chence8275c2017-04-26 11:16:24 -0700394void aom_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
Peng Binf36be562018-09-07 15:28:46 +0800395 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) {
Yaowu Xubbaa9662019-05-06 11:17:03 -0700400 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);
Cheng Chence8275c2017-04-26 11:16:24 -0700403}
404
405void aom_quantize_b_32x32_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
Peng Binf36be562018-09-07 15:28:46 +0800406 const int16_t *zbin_ptr, const int16_t *round_ptr,
407 const int16_t *quant_ptr,
Cheng Chence8275c2017-04-26 11:16:24 -0700408 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,
Thomas Daviesf3b5ee12017-07-18 15:16:43 +0100411 const int16_t *scan, const int16_t *iscan) {
Yaowu Xubbaa9662019-05-06 11:17:03 -0700412 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);
Cheng Chence8275c2017-04-26 11:16:24 -0700415}
416
Cheng Chence8275c2017-04-26 11:16:24 -0700417void aom_quantize_b_64x64_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
Peng Binf36be562018-09-07 15:28:46 +0800418 const int16_t *zbin_ptr, const int16_t *round_ptr,
419 const int16_t *quant_ptr,
Cheng Chence8275c2017-04-26 11:16:24 -0700420 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,
Thomas Daviesf3b5ee12017-07-18 15:16:43 +0100423 const int16_t *scan, const int16_t *iscan) {
Yaowu Xubbaa9662019-05-06 11:17:03 -0700424 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);
Cheng Chence8275c2017-04-26 11:16:24 -0700427}
Cheng Chence8275c2017-04-26 11:16:24 -0700428
Jerome Jiangf8cc1c42019-08-02 16:34:32 -0700429#if CONFIG_AV1_HIGHBITDEPTH
Yaowu Xuf883b422016-08-30 14:01:10 -0700430void aom_highbd_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
Peng Bin6b971982018-09-07 15:21:40 +0800431 const int16_t *zbin_ptr, const int16_t *round_ptr,
432 const int16_t *quant_ptr,
Yaowu Xuc27fc142016-08-22 16:08:15 -0700433 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) {
Yaowu Xubbaa9662019-05-06 11:17:03 -0700437 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);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700441}
Yaowu Xuc27fc142016-08-22 16:08:15 -0700442
Yaowu Xuf883b422016-08-30 14:01:10 -0700443void aom_highbd_quantize_b_32x32_c(
Peng Bin6b971982018-09-07 15:21:40 +0800444 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,
Yaowu Xuc27fc142016-08-22 16:08:15 -0700446 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) {
Yaowu Xubbaa9662019-05-06 11:17:03 -0700449 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);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700453}
Debargha Mukherjee0e119122016-11-04 12:10:23 -0700454
Debargha Mukherjee0e119122016-11-04 12:10:23 -0700455void aom_highbd_quantize_b_64x64_c(
Peng Bin6b971982018-09-07 15:21:40 +0800456 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,
Debargha Mukherjee0e119122016-11-04 12:10:23 -0700458 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) {
Yaowu Xubbaa9662019-05-06 11:17:03 -0700461 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);
Debargha Mukherjee0e119122016-11-04 12:10:23 -0700465}
Jerome Jiangf8cc1c42019-08-02 16:34:32 -0700466#endif // CONFIG_AV1_HIGHBITDEPTH