xref: /aosp_15_r20/external/libaom/aom_dsp/quantize.h (revision 77c1e3ccc04c968bd2bc212e87364f250e820521)
1*77c1e3ccSAndroid Build Coastguard Worker /*
2*77c1e3ccSAndroid Build Coastguard Worker  * Copyright (c) 2016, Alliance for Open Media. All rights reserved.
3*77c1e3ccSAndroid Build Coastguard Worker  *
4*77c1e3ccSAndroid Build Coastguard Worker  * This source code is subject to the terms of the BSD 2 Clause License and
5*77c1e3ccSAndroid Build Coastguard Worker  * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6*77c1e3ccSAndroid Build Coastguard Worker  * was not distributed with this source code in the LICENSE file, you can
7*77c1e3ccSAndroid Build Coastguard Worker  * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8*77c1e3ccSAndroid Build Coastguard Worker  * Media Patent License 1.0 was not distributed with this source code in the
9*77c1e3ccSAndroid Build Coastguard Worker  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10*77c1e3ccSAndroid Build Coastguard Worker  */
11*77c1e3ccSAndroid Build Coastguard Worker 
12*77c1e3ccSAndroid Build Coastguard Worker #ifndef AOM_AOM_DSP_QUANTIZE_H_
13*77c1e3ccSAndroid Build Coastguard Worker #define AOM_AOM_DSP_QUANTIZE_H_
14*77c1e3ccSAndroid Build Coastguard Worker 
15*77c1e3ccSAndroid Build Coastguard Worker #include "config/aom_config.h"
16*77c1e3ccSAndroid Build Coastguard Worker 
17*77c1e3ccSAndroid Build Coastguard Worker #include "aom_dsp/aom_dsp_common.h"
18*77c1e3ccSAndroid Build Coastguard Worker 
19*77c1e3ccSAndroid Build Coastguard Worker #ifdef __cplusplus
20*77c1e3ccSAndroid Build Coastguard Worker extern "C" {
21*77c1e3ccSAndroid Build Coastguard Worker #endif
22*77c1e3ccSAndroid Build Coastguard Worker 
23*77c1e3ccSAndroid Build Coastguard Worker #define EOB_FACTOR 325
24*77c1e3ccSAndroid Build Coastguard Worker #define SKIP_EOB_FACTOR_ADJUST 200
25*77c1e3ccSAndroid Build Coastguard Worker 
26*77c1e3ccSAndroid Build Coastguard Worker void aom_quantize_b_adaptive_helper_c(
27*77c1e3ccSAndroid Build Coastguard Worker     const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
28*77c1e3ccSAndroid Build Coastguard Worker     const int16_t *round_ptr, const int16_t *quant_ptr,
29*77c1e3ccSAndroid Build Coastguard Worker     const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
30*77c1e3ccSAndroid Build Coastguard Worker     tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
31*77c1e3ccSAndroid Build Coastguard Worker     const int16_t *scan, const int16_t *iscan, const qm_val_t *qm_ptr,
32*77c1e3ccSAndroid Build Coastguard Worker     const qm_val_t *iqm_ptr, const int log_scale);
33*77c1e3ccSAndroid Build Coastguard Worker 
34*77c1e3ccSAndroid Build Coastguard Worker void aom_quantize_b_adaptive_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
35*77c1e3ccSAndroid Build Coastguard Worker                                const int16_t *zbin_ptr,
36*77c1e3ccSAndroid Build Coastguard Worker                                const int16_t *round_ptr,
37*77c1e3ccSAndroid Build Coastguard Worker                                const int16_t *quant_ptr,
38*77c1e3ccSAndroid Build Coastguard Worker                                const int16_t *quant_shift_ptr,
39*77c1e3ccSAndroid Build Coastguard Worker                                tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr,
40*77c1e3ccSAndroid Build Coastguard Worker                                const int16_t *dequant_ptr, uint16_t *eob_ptr,
41*77c1e3ccSAndroid Build Coastguard Worker                                const int16_t *scan, const int16_t *iscan);
42*77c1e3ccSAndroid Build Coastguard Worker 
43*77c1e3ccSAndroid Build Coastguard Worker void aom_quantize_b_32x32_adaptive_c(
44*77c1e3ccSAndroid Build Coastguard Worker     const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
45*77c1e3ccSAndroid Build Coastguard Worker     const int16_t *round_ptr, const int16_t *quant_ptr,
46*77c1e3ccSAndroid Build Coastguard Worker     const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
47*77c1e3ccSAndroid Build Coastguard Worker     tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
48*77c1e3ccSAndroid Build Coastguard Worker     const int16_t *scan, const int16_t *iscan);
49*77c1e3ccSAndroid Build Coastguard Worker 
50*77c1e3ccSAndroid Build Coastguard Worker void aom_quantize_b_64x64_adaptive_c(
51*77c1e3ccSAndroid Build Coastguard Worker     const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
52*77c1e3ccSAndroid Build Coastguard Worker     const int16_t *round_ptr, const int16_t *quant_ptr,
53*77c1e3ccSAndroid Build Coastguard Worker     const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
54*77c1e3ccSAndroid Build Coastguard Worker     tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
55*77c1e3ccSAndroid Build Coastguard Worker     const int16_t *scan, const int16_t *iscan);
56*77c1e3ccSAndroid Build Coastguard Worker 
57*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_AV1_HIGHBITDEPTH
58*77c1e3ccSAndroid Build Coastguard Worker void aom_highbd_quantize_b_adaptive_helper_c(
59*77c1e3ccSAndroid Build Coastguard Worker     const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
60*77c1e3ccSAndroid Build Coastguard Worker     const int16_t *round_ptr, const int16_t *quant_ptr,
61*77c1e3ccSAndroid Build Coastguard Worker     const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
62*77c1e3ccSAndroid Build Coastguard Worker     tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
63*77c1e3ccSAndroid Build Coastguard Worker     const int16_t *scan, const int16_t *iscan, const qm_val_t *qm_ptr,
64*77c1e3ccSAndroid Build Coastguard Worker     const qm_val_t *iqm_ptr, const int log_scale);
65*77c1e3ccSAndroid Build Coastguard Worker 
66*77c1e3ccSAndroid Build Coastguard Worker void aom_highbd_quantize_b_adaptive_c(
67*77c1e3ccSAndroid Build Coastguard Worker     const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
68*77c1e3ccSAndroid Build Coastguard Worker     const int16_t *round_ptr, const int16_t *quant_ptr,
69*77c1e3ccSAndroid Build Coastguard Worker     const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
70*77c1e3ccSAndroid Build Coastguard Worker     tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
71*77c1e3ccSAndroid Build Coastguard Worker     const int16_t *scan, const int16_t *iscan);
72*77c1e3ccSAndroid Build Coastguard Worker 
73*77c1e3ccSAndroid Build Coastguard Worker void aom_highbd_quantize_b_32x32_adaptive_c(
74*77c1e3ccSAndroid Build Coastguard Worker     const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
75*77c1e3ccSAndroid Build Coastguard Worker     const int16_t *round_ptr, const int16_t *quant_ptr,
76*77c1e3ccSAndroid Build Coastguard Worker     const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
77*77c1e3ccSAndroid Build Coastguard Worker     tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
78*77c1e3ccSAndroid Build Coastguard Worker     const int16_t *scan, const int16_t *iscan);
79*77c1e3ccSAndroid Build Coastguard Worker 
80*77c1e3ccSAndroid Build Coastguard Worker void aom_highbd_quantize_b_64x64_adaptive_c(
81*77c1e3ccSAndroid Build Coastguard Worker     const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
82*77c1e3ccSAndroid Build Coastguard Worker     const int16_t *round_ptr, const int16_t *quant_ptr,
83*77c1e3ccSAndroid Build Coastguard Worker     const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
84*77c1e3ccSAndroid Build Coastguard Worker     tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
85*77c1e3ccSAndroid Build Coastguard Worker     const int16_t *scan, const int16_t *iscan);
86*77c1e3ccSAndroid Build Coastguard Worker #endif  // CONFIG_AV1_HIGHBITDEPTH
87*77c1e3ccSAndroid Build Coastguard Worker 
88*77c1e3ccSAndroid Build Coastguard Worker void aom_quantize_b_helper_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
89*77c1e3ccSAndroid Build Coastguard Worker                              const int16_t *zbin_ptr, const int16_t *round_ptr,
90*77c1e3ccSAndroid Build Coastguard Worker                              const int16_t *quant_ptr,
91*77c1e3ccSAndroid Build Coastguard Worker                              const int16_t *quant_shift_ptr,
92*77c1e3ccSAndroid Build Coastguard Worker                              tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr,
93*77c1e3ccSAndroid Build Coastguard Worker                              const int16_t *dequant_ptr, uint16_t *eob_ptr,
94*77c1e3ccSAndroid Build Coastguard Worker                              const int16_t *scan, const int16_t *iscan,
95*77c1e3ccSAndroid Build Coastguard Worker                              const qm_val_t *qm_ptr, const qm_val_t *iqm_ptr,
96*77c1e3ccSAndroid Build Coastguard Worker                              const int log_scale);
97*77c1e3ccSAndroid Build Coastguard Worker 
98*77c1e3ccSAndroid Build Coastguard Worker void aom_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
99*77c1e3ccSAndroid Build Coastguard Worker                       const int16_t *zbin_ptr, const int16_t *round_ptr,
100*77c1e3ccSAndroid Build Coastguard Worker                       const int16_t *quant_ptr, const int16_t *quant_shift_ptr,
101*77c1e3ccSAndroid Build Coastguard Worker                       tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr,
102*77c1e3ccSAndroid Build Coastguard Worker                       const int16_t *dequant_ptr, uint16_t *eob_ptr,
103*77c1e3ccSAndroid Build Coastguard Worker                       const int16_t *scan, const int16_t *iscan);
104*77c1e3ccSAndroid Build Coastguard Worker 
105*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_AV1_HIGHBITDEPTH
106*77c1e3ccSAndroid Build Coastguard Worker void aom_highbd_quantize_b_helper_c(
107*77c1e3ccSAndroid Build Coastguard Worker     const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
108*77c1e3ccSAndroid Build Coastguard Worker     const int16_t *round_ptr, const int16_t *quant_ptr,
109*77c1e3ccSAndroid Build Coastguard Worker     const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
110*77c1e3ccSAndroid Build Coastguard Worker     tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
111*77c1e3ccSAndroid Build Coastguard Worker     const int16_t *scan, const int16_t *iscan, const qm_val_t *qm_ptr,
112*77c1e3ccSAndroid Build Coastguard Worker     const qm_val_t *iqm_ptr, const int log_scale);
113*77c1e3ccSAndroid Build Coastguard Worker 
114*77c1e3ccSAndroid Build Coastguard Worker void aom_highbd_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
115*77c1e3ccSAndroid Build Coastguard Worker                              const int16_t *zbin_ptr, const int16_t *round_ptr,
116*77c1e3ccSAndroid Build Coastguard Worker                              const int16_t *quant_ptr,
117*77c1e3ccSAndroid Build Coastguard Worker                              const int16_t *quant_shift_ptr,
118*77c1e3ccSAndroid Build Coastguard Worker                              tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr,
119*77c1e3ccSAndroid Build Coastguard Worker                              const int16_t *dequant_ptr, uint16_t *eob_ptr,
120*77c1e3ccSAndroid Build Coastguard Worker                              const int16_t *scan, const int16_t *iscan);
121*77c1e3ccSAndroid Build Coastguard Worker #endif  // CONFIG_AV1_HIGHBITDEPTH
122*77c1e3ccSAndroid Build Coastguard Worker 
123*77c1e3ccSAndroid Build Coastguard Worker #ifdef __cplusplus
124*77c1e3ccSAndroid Build Coastguard Worker }  // extern "C"
125*77c1e3ccSAndroid Build Coastguard Worker #endif
126*77c1e3ccSAndroid Build Coastguard Worker 
127*77c1e3ccSAndroid Build Coastguard Worker #endif  // AOM_AOM_DSP_QUANTIZE_H_
128