/src/avm/av2/common/entropy.c
Line | Count | Source |
1 | | /* |
2 | | * Copyright (c) 2021, Alliance for Open Media. All rights reserved |
3 | | * |
4 | | * This source code is subject to the terms of the BSD 3-Clause Clear License |
5 | | * and the Alliance for Open Media Patent License 1.0. If the BSD 3-Clause Clear |
6 | | * License was not distributed with this source code in the LICENSE file, you |
7 | | * can obtain it at aomedia.org/license/software-license/bsd-3-c-c/. If the |
8 | | * Alliance for Open Media Patent License 1.0 was not distributed with this |
9 | | * source code in the PATENTS file, you can obtain it at |
10 | | * aomedia.org/license/patent-license/. |
11 | | */ |
12 | | |
13 | | #include "config/avm_config.h" |
14 | | |
15 | | #include "avm/avm_integer.h" |
16 | | #include "avm_mem/avm_mem.h" |
17 | | #include "av2/common/av2_common_int.h" |
18 | | #include "av2/common/entropy.h" |
19 | | #include "av2/common/entropymode.h" |
20 | | #include "av2/common/scan.h" |
21 | | #include "av2/common/txb_common.h" |
22 | | |
23 | | // Context tables for coefficient coding |
24 | | #include "av2/common/entropy_inits_coeffs.h" |
25 | | |
26 | 7.62k | static int get_q_ctx(int q) { |
27 | 7.62k | if (q <= 90) return 0; |
28 | 4.25k | if (q <= 140) return 1; |
29 | 3.98k | if (q <= 190) return 2; |
30 | 3.85k | return 3; |
31 | 3.98k | } |
32 | | |
33 | 7.62k | void av2_default_coef_probs(AV2_COMMON *cm) { |
34 | 7.62k | const int index = get_q_ctx(cm->quant_params.base_qindex); |
35 | | #if CONFIG_ENTROPY_STATS |
36 | | cm->coef_cdf_category = index; |
37 | | #endif |
38 | | |
39 | 7.62k | av2_copy(cm->fc->txb_skip_cdf[0], av2_default_txb_skip_cdfs[index][0]); |
40 | 7.62k | av2_copy(cm->fc->txb_skip_cdf[1], av2_default_txb_skip_cdfs[index][1]); |
41 | 7.62k | av2_copy(cm->fc->v_txb_skip_cdf, av2_default_v_txb_skip_cdfs[index]); |
42 | 7.62k | av2_copy(cm->fc->eob_extra_cdf, av2_default_eob_extra_cdfs[index]); |
43 | 7.62k | av2_copy(cm->fc->dc_sign_cdf, av2_default_dc_sign_cdfs[index]); |
44 | 7.62k | av2_copy(cm->fc->coeff_base_lf_cdf, |
45 | 7.62k | av2_default_coeff_base_lf_multi_cdfs[index]); |
46 | 7.62k | av2_copy(cm->fc->coeff_base_lf_eob_cdf, |
47 | 7.62k | av2_default_coeff_base_lf_eob_multi_cdfs[index]); |
48 | 7.62k | av2_copy(cm->fc->coeff_br_lf_cdf, av2_default_coeff_lps_lf_multi_cdfs[index]); |
49 | 7.62k | av2_copy(cm->fc->coeff_br_cdf, av2_default_coeff_lps_multi_cdfs[index]); |
50 | 7.62k | av2_copy(cm->fc->coeff_base_cdf, av2_default_coeff_base_multi_cdfs[index]); |
51 | 7.62k | av2_copy(cm->fc->idtx_sign_cdf, av2_default_idtx_sign_cdfs[index]); |
52 | 7.62k | av2_copy(cm->fc->coeff_base_cdf_idtx, |
53 | 7.62k | av2_default_coeff_base_multi_cdfs_idtx[index]); |
54 | 7.62k | av2_copy(cm->fc->coeff_br_cdf_idtx, |
55 | 7.62k | av2_default_coeff_lps_multi_cdfs_idtx[index]); |
56 | 7.62k | av2_copy(cm->fc->coeff_base_eob_cdf, |
57 | 7.62k | av2_default_coeff_base_eob_multi_cdfs[index]); |
58 | 7.62k | av2_copy(cm->fc->coeff_base_lf_uv_cdf, |
59 | 7.62k | av2_default_coeff_base_lf_multi_uv_cdfs[index]); |
60 | 7.62k | av2_copy(cm->fc->coeff_base_lf_eob_uv_cdf, |
61 | 7.62k | av2_default_coeff_base_lf_eob_multi_uv_cdfs[index]); |
62 | 7.62k | av2_copy(cm->fc->coeff_br_uv_cdf, av2_default_coeff_lps_multi_uv_cdfs[index]); |
63 | 7.62k | av2_copy(cm->fc->coeff_base_uv_cdf, |
64 | 7.62k | av2_default_coeff_base_multi_uv_cdfs[index]); |
65 | 7.62k | av2_copy(cm->fc->coeff_base_eob_uv_cdf, |
66 | 7.62k | av2_default_coeff_base_eob_multi_uv_cdfs[index]); |
67 | 7.62k | av2_copy(cm->fc->eob_flag_cdf16, av2_default_eob_multi16_cdfs[index]); |
68 | 7.62k | av2_copy(cm->fc->eob_flag_cdf32, av2_default_eob_multi32_cdfs[index]); |
69 | 7.62k | av2_copy(cm->fc->eob_flag_cdf64, av2_default_eob_multi64_cdfs[index]); |
70 | 7.62k | av2_copy(cm->fc->eob_flag_cdf128, av2_default_eob_multi128_cdfs[index]); |
71 | 7.62k | av2_copy(cm->fc->eob_flag_cdf256, av2_default_eob_multi256_cdfs[index]); |
72 | 7.62k | av2_copy(cm->fc->eob_flag_cdf512, av2_default_eob_multi512_cdfs[index]); |
73 | 7.62k | av2_copy(cm->fc->eob_flag_cdf1024, av2_default_eob_multi1024_cdfs[index]); |
74 | 7.62k | av2_copy(cm->fc->coeff_base_ph_cdf, av2_default_coeff_base_ph_cdfs[index]); |
75 | 7.62k | av2_copy(cm->fc->coeff_base_bob_cdf, |
76 | 7.62k | av2_default_coeff_base_bob_multi_cdfs[index]); |
77 | 7.62k | } |
78 | | |
79 | | static AVM_INLINE void reset_cdf_symbol_counter(avm_cdf_prob *cdf_ptr, |
80 | | int num_cdfs, int cdf_stride, |
81 | 30.3k | int nsymbs) { |
82 | 117k | for (int i = 0; i < num_cdfs; i++) { |
83 | 87.2k | cdf_ptr[i * cdf_stride + nsymbs] = |
84 | 87.2k | (cdf_ptr[i * cdf_stride + nsymbs] * 3) >> 2; |
85 | 87.2k | } |
86 | 30.3k | } |
87 | | |
88 | | #define RESET_CDF_COUNTER(cname, nsymbs) \ |
89 | 29.3k | RESET_CDF_COUNTER_STRIDE(cname, nsymbs, CDF_SIZE(nsymbs)) |
90 | | |
91 | | #define RESET_CDF_COUNTER_STRIDE(cname, nsymbs, cdf_stride) \ |
92 | 30.3k | do { \ |
93 | 30.3k | avm_cdf_prob *cdf_ptr = (avm_cdf_prob *)cname; \ |
94 | 30.3k | int array_size = (int)sizeof(cname) / sizeof(avm_cdf_prob); \ |
95 | 30.3k | int num_cdfs = array_size / cdf_stride; \ |
96 | 30.3k | reset_cdf_symbol_counter(cdf_ptr, num_cdfs, cdf_stride, nsymbs); \ |
97 | 30.3k | } while (0) |
98 | | |
99 | 80 | static AVM_INLINE void reset_nmv_counter(nmv_context *nmv) { |
100 | 80 | RESET_CDF_COUNTER(nmv->joint_shell_set_cdf, 2); |
101 | 640 | for (int prec = 0; prec < NUM_MV_PRECISIONS; prec++) { |
102 | 560 | const int num_mv_class = get_default_num_shell_class(prec); |
103 | 560 | int num_mv_class_0, num_mv_class_1; |
104 | 560 | split_num_shell_class(num_mv_class, &num_mv_class_0, &num_mv_class_1); |
105 | 560 | RESET_CDF_COUNTER(nmv->joint_shell_class_cdf_0[prec], num_mv_class_0); |
106 | 560 | if (prec == MV_PRECISION_ONE_EIGHTH_PEL) { |
107 | 80 | RESET_CDF_COUNTER(nmv->joint_shell_class_cdf_1[prec], num_mv_class_1 - 1); |
108 | 80 | RESET_CDF_COUNTER(nmv->joint_shell_last_two_classes_cdf, 2); |
109 | 480 | } else { |
110 | 480 | RESET_CDF_COUNTER(nmv->joint_shell_class_cdf_1[prec], num_mv_class_1); |
111 | 480 | } |
112 | 560 | } |
113 | 80 | RESET_CDF_COUNTER(nmv->shell_offset_low_class_cdf, 2); |
114 | 80 | RESET_CDF_COUNTER(nmv->shell_offset_class2_cdf, 2); |
115 | 160 | for (int i = 0; i < NUM_CTX_CLASS_OFFSETS; i++) { |
116 | 80 | RESET_CDF_COUNTER(nmv->shell_offset_other_class_cdf[i], 2); |
117 | 80 | } |
118 | 80 | RESET_CDF_COUNTER(nmv->col_mv_greater_flags_cdf, 2); |
119 | 80 | RESET_CDF_COUNTER(nmv->col_mv_index_cdf, 2); |
120 | | |
121 | 80 | RESET_CDF_COUNTER(nmv->amvd_joints_cdf, 4); |
122 | 240 | for (int i = 0; i < 2; i++) { |
123 | 160 | RESET_CDF_COUNTER(nmv->comps[i].amvd_indices_cdf, MAX_AMVD_INDEX); |
124 | 160 | } |
125 | 80 | } |
126 | | |
127 | 40 | void av2_reset_cdf_symbol_counters(FRAME_CONTEXT *fc) { |
128 | 40 | RESET_CDF_COUNTER(fc->txb_skip_cdf, 2); |
129 | 40 | RESET_CDF_COUNTER(fc->v_txb_skip_cdf, 2); |
130 | 40 | RESET_CDF_COUNTER(fc->eob_extra_cdf, 2); |
131 | 40 | RESET_CDF_COUNTER(fc->dc_sign_cdf, 2); |
132 | 40 | RESET_CDF_COUNTER(fc->eob_flag_cdf16, EOB_MAX_SYMS - 6); |
133 | 40 | RESET_CDF_COUNTER(fc->eob_flag_cdf32, EOB_MAX_SYMS - 5); |
134 | 40 | RESET_CDF_COUNTER(fc->eob_flag_cdf64, EOB_MAX_SYMS - 4); |
135 | 40 | RESET_CDF_COUNTER(fc->eob_flag_cdf128, EOB_MAX_SYMS - 3); |
136 | 40 | RESET_CDF_COUNTER(fc->eob_flag_cdf256, EOB_MAX_SYMS - 3); |
137 | 40 | RESET_CDF_COUNTER(fc->eob_flag_cdf512, EOB_MAX_SYMS - 3); |
138 | 40 | RESET_CDF_COUNTER(fc->eob_flag_cdf1024, EOB_MAX_SYMS - 3); |
139 | 40 | RESET_CDF_COUNTER(fc->coeff_base_eob_cdf, 3); |
140 | 40 | RESET_CDF_COUNTER(fc->coeff_base_bob_cdf, 3); |
141 | 40 | RESET_CDF_COUNTER(fc->coeff_base_lf_cdf, LF_BASE_SYMBOLS); |
142 | 40 | RESET_CDF_COUNTER(fc->coeff_base_lf_eob_cdf, LF_BASE_SYMBOLS - 1); |
143 | 40 | RESET_CDF_COUNTER(fc->coeff_br_lf_cdf, BR_CDF_SIZE); |
144 | 40 | RESET_CDF_COUNTER(fc->coeff_base_lf_uv_cdf, LF_BASE_SYMBOLS); |
145 | 40 | RESET_CDF_COUNTER(fc->coeff_base_lf_eob_uv_cdf, LF_BASE_SYMBOLS - 1); |
146 | 40 | RESET_CDF_COUNTER(fc->coeff_base_uv_cdf, 4); |
147 | 40 | RESET_CDF_COUNTER(fc->coeff_base_eob_uv_cdf, 3); |
148 | 40 | RESET_CDF_COUNTER(fc->coeff_br_uv_cdf, BR_CDF_SIZE); |
149 | 40 | RESET_CDF_COUNTER(fc->coeff_base_cdf, 4); |
150 | 40 | RESET_CDF_COUNTER(fc->idtx_sign_cdf, 2); |
151 | 40 | RESET_CDF_COUNTER(fc->coeff_base_cdf_idtx, 4); |
152 | 40 | RESET_CDF_COUNTER(fc->coeff_br_cdf_idtx, BR_CDF_SIZE); |
153 | 40 | RESET_CDF_COUNTER(fc->coeff_br_cdf, BR_CDF_SIZE); |
154 | 40 | RESET_CDF_COUNTER(fc->inter_single_mode_cdf, INTER_SINGLE_MODES); |
155 | 40 | RESET_CDF_COUNTER(fc->inter_warp_mode_cdf, 2); |
156 | 40 | RESET_CDF_COUNTER(fc->is_warpmv_or_warp_newmv_cdf, 2); |
157 | 40 | RESET_CDF_COUNTER(fc->drl_cdf[0], 2); |
158 | 40 | RESET_CDF_COUNTER(fc->drl_cdf[1], 2); |
159 | 40 | RESET_CDF_COUNTER(fc->drl_cdf[2], 2); |
160 | 40 | RESET_CDF_COUNTER(fc->skip_drl_cdf, 2); |
161 | 40 | RESET_CDF_COUNTER(fc->tip_drl_cdf, 2); |
162 | 40 | RESET_CDF_COUNTER(fc->use_optflow_cdf, 2); |
163 | 40 | RESET_CDF_COUNTER(fc->inter_compound_mode_is_joint_cdf, NUM_OPTIONS_IS_JOINT); |
164 | 40 | RESET_CDF_COUNTER(fc->inter_compound_mode_non_joint_type_cdf, |
165 | 40 | NUM_OPTIONS_NON_JOINT_TYPE); |
166 | | |
167 | 40 | RESET_CDF_COUNTER(fc->inter_compound_mode_same_refs_cdf, |
168 | 40 | INTER_COMPOUND_SAME_REFS_TYPES); |
169 | 40 | RESET_CDF_COUNTER(fc->amvd_mode_cdf, 2); |
170 | 40 | RESET_CDF_COUNTER(fc->cwp_idx_cdf, 2); |
171 | 40 | RESET_CDF_COUNTER(fc->jmvd_scale_mode_cdf, JOINT_NEWMV_SCALE_FACTOR_CNT); |
172 | 40 | RESET_CDF_COUNTER(fc->jmvd_amvd_scale_mode_cdf, JOINT_AMVD_SCALE_FACTOR_CNT); |
173 | 40 | RESET_CDF_COUNTER(fc->compound_type_cdf, MASKED_COMPOUND_TYPES); |
174 | 40 | RESET_CDF_COUNTER(fc->wedge_quad_cdf, WEDGE_QUADS); |
175 | 40 | RESET_CDF_COUNTER(fc->wedge_angle_cdf, QUAD_WEDGE_ANGLES); |
176 | 40 | RESET_CDF_COUNTER(fc->wedge_dist_cdf, NUM_WEDGE_DIST); |
177 | 40 | RESET_CDF_COUNTER(fc->wedge_dist_cdf2, NUM_WEDGE_DIST - 1); |
178 | 40 | RESET_CDF_COUNTER(fc->interintra_cdf, 2); |
179 | 40 | RESET_CDF_COUNTER(fc->wedge_interintra_cdf, 2); |
180 | 40 | RESET_CDF_COUNTER(fc->interintra_mode_cdf, INTERINTRA_MODES); |
181 | | |
182 | 40 | RESET_CDF_COUNTER(fc->warp_interintra_cdf, 2); |
183 | 40 | RESET_CDF_COUNTER(fc->refinemv_flag_cdf, REFINEMV_NUM_MODES); |
184 | | |
185 | 40 | RESET_CDF_COUNTER(fc->warp_causal_cdf, 2); |
186 | 40 | RESET_CDF_COUNTER(fc->warp_ref_idx_cdf[0], 2); |
187 | 40 | RESET_CDF_COUNTER(fc->warp_ref_idx_cdf[1], 2); |
188 | 40 | RESET_CDF_COUNTER(fc->warp_ref_idx_cdf[2], 2); |
189 | 40 | RESET_CDF_COUNTER(fc->warpmv_with_mvd_flag_cdf, 2); |
190 | 40 | RESET_CDF_COUNTER(fc->warp_precision_idx_cdf, NUM_WARP_PRECISION_MODES); |
191 | | |
192 | 40 | RESET_CDF_COUNTER(fc->warp_delta_param_cdf, WARP_DELTA_NUMSYMBOLS_LOW); |
193 | 40 | RESET_CDF_COUNTER(fc->warp_delta_param_high_cdf, WARP_DELTA_NUMSYMBOLS_HIGH); |
194 | 40 | RESET_CDF_COUNTER(fc->warp_param_sign_cdf, 2); |
195 | 40 | RESET_CDF_COUNTER(fc->warp_extend_cdf, 2); |
196 | 40 | RESET_CDF_COUNTER(fc->bawp_cdf[0], 2); |
197 | 40 | RESET_CDF_COUNTER(fc->bawp_cdf[1], 2); |
198 | 40 | RESET_CDF_COUNTER(fc->explicit_bawp_cdf, 2); |
199 | 40 | RESET_CDF_COUNTER(fc->explicit_bawp_scale_cdf, EXPLICIT_BAWP_SCALE_CNT); |
200 | 40 | RESET_CDF_COUNTER(fc->tip_cdf, 2); |
201 | 40 | RESET_CDF_COUNTER(fc->tip_pred_mode_cdf, TIP_PRED_MODES); |
202 | 40 | RESET_CDF_COUNTER(fc->palette_y_size_cdf, PALETTE_SIZES); |
203 | 40 | RESET_CDF_COUNTER(fc->palette_uv_size_cdf, PALETTE_SIZES); |
204 | 40 | RESET_CDF_COUNTER(fc->identity_row_cdf_y, 3); |
205 | 40 | RESET_CDF_COUNTER(fc->identity_row_cdf_uv, 3); |
206 | 320 | for (int j = 0; j < PALETTE_SIZES; j++) { |
207 | 280 | int nsymbs = j + PALETTE_MIN_SIZE; |
208 | 280 | RESET_CDF_COUNTER_STRIDE(fc->palette_y_color_index_cdf[j], nsymbs, |
209 | 280 | CDF_SIZE(PALETTE_COLORS)); |
210 | 280 | } |
211 | 40 | RESET_CDF_COUNTER(fc->palette_y_mode_cdf, 2); |
212 | 40 | RESET_CDF_COUNTER(fc->palette_uv_mode_cdf, 2); |
213 | 40 | RESET_CDF_COUNTER(fc->comp_inter_cdf, 2); |
214 | 40 | RESET_CDF_COUNTER(fc->single_ref_cdf, 2); |
215 | 40 | RESET_CDF_COUNTER(fc->comp_ref0_cdf, 2); |
216 | 40 | RESET_CDF_COUNTER(fc->comp_ref1_cdf, 2); |
217 | 40 | RESET_CDF_COUNTER(fc->txfm_do_partition_cdf, 2); |
218 | 40 | RESET_CDF_COUNTER(fc->txfm_2or3_way_partition_type_cdf, 2); |
219 | 40 | RESET_CDF_COUNTER(fc->txfm_4way_partition_type_cdf, TX_PARTITION_TYPE_NUM); |
220 | 40 | RESET_CDF_COUNTER(fc->lossless_tx_size_cdf, 2); |
221 | 40 | RESET_CDF_COUNTER(fc->lossless_inter_tx_type_cdf, 2); |
222 | 40 | RESET_CDF_COUNTER(fc->comp_group_idx_cdf, 2); |
223 | 40 | RESET_CDF_COUNTER(fc->skip_mode_cdfs, 2); |
224 | 40 | RESET_CDF_COUNTER(fc->bru_mode_cdf, 3); |
225 | 40 | RESET_CDF_COUNTER(fc->intra_inter_cdf, 2); |
226 | 40 | RESET_CDF_COUNTER(fc->skip_txfm_cdfs, 2); |
227 | 40 | reset_nmv_counter(&fc->nmvc); |
228 | 40 | reset_nmv_counter(&fc->ndvc); |
229 | 40 | RESET_CDF_COUNTER(fc->intrabc_cdf, 2); |
230 | 40 | RESET_CDF_COUNTER(fc->intrabc_mode_cdf, 2); |
231 | 40 | RESET_CDF_COUNTER(fc->intrabc_bv_precision_cdf, NUM_ALLOWED_BV_PRECISIONS); |
232 | 40 | RESET_CDF_COUNTER(fc->morph_pred_cdf, 2); |
233 | 40 | RESET_CDF_COUNTER(fc->seg.pred_cdf, 2); |
234 | 40 | RESET_CDF_COUNTER(fc->seg.tree_cdf, MAX_SEGMENTS_8); |
235 | 40 | RESET_CDF_COUNTER(fc->seg.tree_cdf1, MAX_SEGMENTS_8); |
236 | 40 | RESET_CDF_COUNTER(fc->seg.spatial_pred_seg_cdf, MAX_SEGMENTS_8); |
237 | 40 | RESET_CDF_COUNTER(fc->seg.spatial_pred_seg_cdf1, MAX_SEGMENTS_8); |
238 | 40 | RESET_CDF_COUNTER(fc->seg.seg_id_ext_flag_cdf, 2); |
239 | 40 | RESET_CDF_COUNTER(fc->mrl_index_cdf, MRL_LINE_NUMBER); |
240 | 40 | RESET_CDF_COUNTER(fc->multi_line_mrl_cdf, 2); |
241 | 40 | RESET_CDF_COUNTER(fc->fsc_mode_cdf, FSC_MODES); |
242 | | |
243 | | // CDF for dpcm related symbols |
244 | 40 | RESET_CDF_COUNTER(fc->dpcm_cdf, 2); |
245 | 40 | RESET_CDF_COUNTER(fc->dpcm_vert_horz_cdf, 2); |
246 | 40 | RESET_CDF_COUNTER(fc->dpcm_uv_cdf, 2); |
247 | 40 | RESET_CDF_COUNTER(fc->dpcm_uv_vert_horz_cdf, 2); |
248 | | |
249 | 40 | RESET_CDF_COUNTER(fc->cfl_mhccp_cdf, CFL_MHCCP_SWITCH_NUM); |
250 | 40 | RESET_CDF_COUNTER(fc->cfl_index_cdf, CFL_TYPE_COUNT - 1); |
251 | 40 | RESET_CDF_COUNTER(fc->filter_dir_cdf, MHCCP_MODE_NUM); |
252 | 40 | RESET_CDF_COUNTER(fc->intra_dip_cdf, 2); |
253 | 40 | RESET_CDF_COUNTER(fc->intra_dip_mode_n6_cdf, 6); |
254 | 40 | RESET_CDF_COUNTER(fc->switchable_flex_restore_cdf, 2); |
255 | 160 | for (int plane = 0; plane < CCSO_PLANES; plane++) { |
256 | 600 | for (int ctx = 0; ctx < CCSO_CONTEXT; ctx++) { |
257 | 480 | RESET_CDF_COUNTER(fc->ccso_cdf[plane][ctx], 2); |
258 | 480 | } |
259 | 120 | } |
260 | 40 | RESET_CDF_COUNTER(fc->cdef_strength_index0_cdf, 2); |
261 | 280 | for (int j = 0; j < CDEF_STRENGTHS_NUM - 1; j++) { |
262 | 240 | RESET_CDF_COUNTER_STRIDE(fc->cdef_cdf[j], j + 2, |
263 | 240 | CDF_SIZE(CDEF_STRENGTHS_NUM)); |
264 | 240 | } |
265 | 40 | RESET_CDF_COUNTER(fc->gdf_cdf, 2); |
266 | 40 | RESET_CDF_COUNTER(fc->wienerns_restore_cdf, 2); |
267 | 40 | RESET_CDF_COUNTER(fc->wienerns_length_cdf, 2); |
268 | 40 | RESET_CDF_COUNTER(fc->wienerns_uv_sym_cdf, 2); |
269 | 40 | RESET_CDF_COUNTER(fc->wienerns_4part_cdf, 4); |
270 | 40 | RESET_CDF_COUNTER(fc->pc_wiener_restore_cdf, 2); |
271 | 40 | RESET_CDF_COUNTER(fc->y_mode_set_cdf, INTRA_MODE_SETS); |
272 | 40 | RESET_CDF_COUNTER(fc->y_mode_idx_cdf, LUMA_INTRA_MODE_INDEX_COUNT); |
273 | 40 | RESET_CDF_COUNTER(fc->y_mode_idx_offset_cdf, LUMA_INTRA_MODE_OFFSET_COUNT); |
274 | 40 | RESET_CDF_COUNTER(fc->uv_mode_cdf, CHROMA_INTRA_MODE_INDEX_COUNT); |
275 | 40 | RESET_CDF_COUNTER(fc->cfl_cdf, 2); |
276 | | |
277 | 200 | for (int i = 0; i < INTER_SDP_BSIZE_GROUP; i++) { |
278 | 160 | RESET_CDF_COUNTER(fc->region_type_cdf[i], REGION_TYPES); |
279 | 160 | } |
280 | | |
281 | 120 | for (int plane_index = 0; plane_index < PARTITION_STRUCTURE_NUM; |
282 | 80 | plane_index++) { |
283 | 5.20k | for (int i = 0; i < PARTITION_CONTEXTS; i++) { |
284 | 5.12k | RESET_CDF_COUNTER(fc->do_split_cdf[plane_index][i], 2); |
285 | 5.12k | } |
286 | 80 | } |
287 | 120 | for (int plane_index = 0; plane_index < PARTITION_STRUCTURE_NUM; |
288 | 80 | plane_index++) { |
289 | 720 | for (int i = 0; i < SQUARE_SPLIT_CONTEXTS; i++) { |
290 | 640 | RESET_CDF_COUNTER(fc->do_square_split_cdf[plane_index][i], 2); |
291 | 640 | } |
292 | 80 | } |
293 | 120 | for (int plane_index = 0; plane_index < PARTITION_STRUCTURE_NUM; |
294 | 80 | plane_index++) { |
295 | 5.20k | for (int i = 0; i < PARTITION_CONTEXTS; i++) { |
296 | 5.12k | RESET_CDF_COUNTER(fc->rect_type_cdf[plane_index][i], 2); |
297 | 5.12k | } |
298 | 80 | } |
299 | 120 | for (int plane_index = 0; plane_index < PARTITION_STRUCTURE_NUM; |
300 | 80 | plane_index++) { |
301 | 160 | for (RECT_PART_TYPE rect = 0; rect < NUM_RECT_CONTEXTS; rect++) { |
302 | 5.20k | for (int i = 0; i < PARTITION_CONTEXTS; i++) { |
303 | 5.12k | RESET_CDF_COUNTER(fc->do_ext_partition_cdf[plane_index][rect][i], 2); |
304 | 5.12k | RESET_CDF_COUNTER( |
305 | 5.12k | fc->do_uneven_4way_partition_cdf[plane_index][rect][i], 2); |
306 | 5.12k | } |
307 | 80 | } |
308 | 80 | } |
309 | 40 | RESET_CDF_COUNTER(fc->switchable_interp_cdf, SWITCHABLE_FILTERS); |
310 | 40 | RESET_CDF_COUNTER(fc->delta_q_cdf, DELTA_Q_PROBS + 1); |
311 | | |
312 | 40 | RESET_CDF_COUNTER_STRIDE(fc->intra_ext_tx_cdf[1], INTRA_TX_SET1, |
313 | 40 | CDF_SIZE(TX_TYPES)); |
314 | 40 | RESET_CDF_COUNTER_STRIDE(fc->intra_ext_tx_cdf[2], INTRA_TX_SET2, |
315 | 40 | CDF_SIZE(TX_TYPES)); |
316 | 40 | RESET_CDF_COUNTER_STRIDE(fc->inter_ext_tx_cdf[1], INTER_TX_SET1, |
317 | 40 | CDF_SIZE(TX_TYPES)); |
318 | 40 | RESET_CDF_COUNTER_STRIDE(fc->inter_ext_tx_cdf[2], INTER_TX_SET2, |
319 | 40 | CDF_SIZE(TX_TYPES)); |
320 | 40 | RESET_CDF_COUNTER_STRIDE(fc->inter_ext_tx_cdf[3], INTER_TX_SET3, |
321 | 40 | CDF_SIZE(TX_TYPES)); |
322 | 40 | RESET_CDF_COUNTER_STRIDE(fc->inter_ext_tx_cdf[4], INTER_TX_SET4, |
323 | 40 | CDF_SIZE(TX_TYPES)); |
324 | 40 | RESET_CDF_COUNTER(fc->inter_tx_type_set, 2); |
325 | 40 | RESET_CDF_COUNTER(fc->inter_tx_type_idx, INTER_TX_TYPE_INDEX_COUNT); |
326 | 40 | RESET_CDF_COUNTER(fc->inter_tx_type_offset_1, INTER_TX_TYPE_OFFSET1_COUNT); |
327 | 40 | RESET_CDF_COUNTER(fc->inter_tx_type_offset_2, INTER_TX_TYPE_OFFSET2_COUNT); |
328 | 40 | RESET_CDF_COUNTER(fc->inter_ext_tx_short_side_cdf, 4); |
329 | 40 | RESET_CDF_COUNTER(fc->intra_ext_tx_short_side_cdf, 4); |
330 | 40 | RESET_CDF_COUNTER(fc->tx_ext_32_cdf, 2); |
331 | 40 | RESET_CDF_COUNTER(fc->cfl_sign_cdf, CFL_JOINT_SIGNS); |
332 | 40 | RESET_CDF_COUNTER(fc->cfl_alpha_cdf, CFL_ALPHABET_SIZE); |
333 | | |
334 | 40 | RESET_CDF_COUNTER_STRIDE(fc->stx_cdf, STX_TYPES, CDF_SIZE(STX_TYPES)); |
335 | 40 | RESET_CDF_COUNTER(fc->most_probable_stx_set_cdf, IST_SET_SIZE); |
336 | 40 | RESET_CDF_COUNTER(fc->most_probable_stx_set_cdf_ADST_ADST, |
337 | 40 | IST_REDUCED_SET_SIZE); |
338 | 160 | for (int p = 0; p < NUM_MV_PREC_MPP_CONTEXT; ++p) { |
339 | 120 | RESET_CDF_COUNTER(fc->pb_mv_mpp_flag_cdf[p], 2); |
340 | 120 | } |
341 | | |
342 | 160 | for (int p = MV_PRECISION_HALF_PEL; p < NUM_MV_PRECISIONS; ++p) { |
343 | 120 | int num_precisions = MAX_NUM_OF_SUPPORTED_PRECISIONS; |
344 | 360 | for (int j = 0; j < MV_PREC_DOWN_CONTEXTS; ++j) { |
345 | 240 | RESET_CDF_COUNTER_STRIDE( |
346 | 240 | fc->pb_mv_precision_cdf[j][p - MV_PRECISION_HALF_PEL], |
347 | 240 | num_precisions - 1, CDF_SIZE(FLEX_MV_COSTS_SIZE)); |
348 | 240 | } |
349 | 120 | } |
350 | | |
351 | 40 | RESET_CDF_COUNTER(fc->coeff_base_ph_cdf, NUM_BASE_LEVELS + 2); |
352 | 40 | RESET_CDF_COUNTER(fc->cctx_type_cdf, CCTX_TYPES); |
353 | 40 | } |