1*09537850SAkhilesh Sanikop // Copyright 2019 The libgav1 Authors
2*09537850SAkhilesh Sanikop //
3*09537850SAkhilesh Sanikop // Licensed under the Apache License, Version 2.0 (the "License");
4*09537850SAkhilesh Sanikop // you may not use this file except in compliance with the License.
5*09537850SAkhilesh Sanikop // You may obtain a copy of the License at
6*09537850SAkhilesh Sanikop //
7*09537850SAkhilesh Sanikop // http://www.apache.org/licenses/LICENSE-2.0
8*09537850SAkhilesh Sanikop //
9*09537850SAkhilesh Sanikop // Unless required by applicable law or agreed to in writing, software
10*09537850SAkhilesh Sanikop // distributed under the License is distributed on an "AS IS" BASIS,
11*09537850SAkhilesh Sanikop // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12*09537850SAkhilesh Sanikop // See the License for the specific language governing permissions and
13*09537850SAkhilesh Sanikop // limitations under the License.
14*09537850SAkhilesh Sanikop
15*09537850SAkhilesh Sanikop #include "src/symbol_decoder_context.h"
16*09537850SAkhilesh Sanikop
17*09537850SAkhilesh Sanikop #include <cassert>
18*09537850SAkhilesh Sanikop #include <cstring>
19*09537850SAkhilesh Sanikop #include <type_traits>
20*09537850SAkhilesh Sanikop
21*09537850SAkhilesh Sanikop namespace libgav1 {
22*09537850SAkhilesh Sanikop namespace {
23*09537850SAkhilesh Sanikop
24*09537850SAkhilesh Sanikop // Import all the constants in the anonymous namespace.
25*09537850SAkhilesh Sanikop #include "src/symbol_decoder_context_cdfs.inc"
26*09537850SAkhilesh Sanikop
GetQuantizerContext(int base_quantizer_index)27*09537850SAkhilesh Sanikop uint8_t GetQuantizerContext(int base_quantizer_index) {
28*09537850SAkhilesh Sanikop if (base_quantizer_index <= 20) return 0;
29*09537850SAkhilesh Sanikop if (base_quantizer_index <= 60) return 1;
30*09537850SAkhilesh Sanikop if (base_quantizer_index <= 120) return 2;
31*09537850SAkhilesh Sanikop return 3;
32*09537850SAkhilesh Sanikop }
33*09537850SAkhilesh Sanikop
34*09537850SAkhilesh Sanikop // Reset*Counters() are helper functions to reset the CDF arrays where the
35*09537850SAkhilesh Sanikop // counters are not in the last element of the innermost dimension.
36*09537850SAkhilesh Sanikop
ResetPartitionCounters(SymbolDecoderContext * const context)37*09537850SAkhilesh Sanikop void ResetPartitionCounters(SymbolDecoderContext* const context) {
38*09537850SAkhilesh Sanikop int block_size_log2 = k4x4WidthLog2[kBlock8x8];
39*09537850SAkhilesh Sanikop for (auto& d1 : context->partition_cdf) {
40*09537850SAkhilesh Sanikop const int cdf_size =
41*09537850SAkhilesh Sanikop SymbolDecoderContext::PartitionCdfSize(block_size_log2++);
42*09537850SAkhilesh Sanikop for (auto& d2 : d1) {
43*09537850SAkhilesh Sanikop d2[cdf_size] = 0;
44*09537850SAkhilesh Sanikop }
45*09537850SAkhilesh Sanikop }
46*09537850SAkhilesh Sanikop }
47*09537850SAkhilesh Sanikop
ResetPaletteColorIndexCounters(SymbolDecoderContext * const context)48*09537850SAkhilesh Sanikop void ResetPaletteColorIndexCounters(SymbolDecoderContext* const context) {
49*09537850SAkhilesh Sanikop for (auto& d1 : context->palette_color_index_cdf) {
50*09537850SAkhilesh Sanikop int cdf_size = kMinPaletteSize;
51*09537850SAkhilesh Sanikop for (auto& d2 : d1) {
52*09537850SAkhilesh Sanikop for (auto& d3 : d2) {
53*09537850SAkhilesh Sanikop d3[cdf_size] = 0;
54*09537850SAkhilesh Sanikop }
55*09537850SAkhilesh Sanikop ++cdf_size;
56*09537850SAkhilesh Sanikop }
57*09537850SAkhilesh Sanikop }
58*09537850SAkhilesh Sanikop }
59*09537850SAkhilesh Sanikop
ResetTxTypeCounters(SymbolDecoderContext * const context)60*09537850SAkhilesh Sanikop void ResetTxTypeCounters(SymbolDecoderContext* const context) {
61*09537850SAkhilesh Sanikop int set_index = kTransformSetIntra1;
62*09537850SAkhilesh Sanikop for (auto& d1 : context->intra_tx_type_cdf) {
63*09537850SAkhilesh Sanikop const int cdf_size = kNumTransformTypesInSet[set_index++];
64*09537850SAkhilesh Sanikop for (auto& d2 : d1) {
65*09537850SAkhilesh Sanikop for (auto& d3 : d2) {
66*09537850SAkhilesh Sanikop d3[cdf_size] = 0;
67*09537850SAkhilesh Sanikop }
68*09537850SAkhilesh Sanikop }
69*09537850SAkhilesh Sanikop }
70*09537850SAkhilesh Sanikop for (auto& d1 : context->inter_tx_type_cdf) {
71*09537850SAkhilesh Sanikop const int cdf_size = kNumTransformTypesInSet[set_index++];
72*09537850SAkhilesh Sanikop for (auto& d2 : d1) {
73*09537850SAkhilesh Sanikop d2[cdf_size] = 0;
74*09537850SAkhilesh Sanikop }
75*09537850SAkhilesh Sanikop }
76*09537850SAkhilesh Sanikop }
77*09537850SAkhilesh Sanikop
ResetTxDepthCounters(SymbolDecoderContext * const context)78*09537850SAkhilesh Sanikop void ResetTxDepthCounters(SymbolDecoderContext* const context) {
79*09537850SAkhilesh Sanikop int delta = 1;
80*09537850SAkhilesh Sanikop for (auto& d1 : context->tx_depth_cdf) {
81*09537850SAkhilesh Sanikop const int cdf_size = kMaxTxDepthSymbolCount - delta;
82*09537850SAkhilesh Sanikop delta = 0;
83*09537850SAkhilesh Sanikop for (auto& d2 : d1) {
84*09537850SAkhilesh Sanikop d2[cdf_size] = 0;
85*09537850SAkhilesh Sanikop }
86*09537850SAkhilesh Sanikop }
87*09537850SAkhilesh Sanikop }
88*09537850SAkhilesh Sanikop
ResetUVModeCounters(SymbolDecoderContext * const context)89*09537850SAkhilesh Sanikop void ResetUVModeCounters(SymbolDecoderContext* const context) {
90*09537850SAkhilesh Sanikop int cdf_size = kIntraPredictionModesUV - 1;
91*09537850SAkhilesh Sanikop for (auto& d1 : context->uv_mode_cdf) {
92*09537850SAkhilesh Sanikop for (auto& d2 : d1) {
93*09537850SAkhilesh Sanikop d2[cdf_size] = 0;
94*09537850SAkhilesh Sanikop }
95*09537850SAkhilesh Sanikop ++cdf_size;
96*09537850SAkhilesh Sanikop }
97*09537850SAkhilesh Sanikop }
98*09537850SAkhilesh Sanikop
99*09537850SAkhilesh Sanikop } // namespace
100*09537850SAkhilesh Sanikop
101*09537850SAkhilesh Sanikop #define CDF_COPY(source, destination) \
102*09537850SAkhilesh Sanikop static_assert(sizeof(source) == sizeof(destination), ""); \
103*09537850SAkhilesh Sanikop memcpy(destination, source, sizeof(source))
104*09537850SAkhilesh Sanikop
Initialize(int base_quantizer_index)105*09537850SAkhilesh Sanikop void SymbolDecoderContext::Initialize(int base_quantizer_index) {
106*09537850SAkhilesh Sanikop CDF_COPY(kDefaultPartitionCdf, partition_cdf);
107*09537850SAkhilesh Sanikop CDF_COPY(kDefaultSkipCdf, skip_cdf);
108*09537850SAkhilesh Sanikop CDF_COPY(kDefaultSkipModeCdf, skip_mode_cdf);
109*09537850SAkhilesh Sanikop CDF_COPY(kDefaultSegmentIdCdf, segment_id_cdf);
110*09537850SAkhilesh Sanikop CDF_COPY(kDefaultUsePredictedSegmentIdCdf, use_predicted_segment_id_cdf);
111*09537850SAkhilesh Sanikop CDF_COPY(kDefaultDeltaQCdf, delta_q_cdf);
112*09537850SAkhilesh Sanikop CDF_COPY(kDefaultDeltaQCdf, delta_lf_cdf);
113*09537850SAkhilesh Sanikop for (auto& delta_lf_multi_cdf_entry : delta_lf_multi_cdf) {
114*09537850SAkhilesh Sanikop CDF_COPY(kDefaultDeltaQCdf, delta_lf_multi_cdf_entry);
115*09537850SAkhilesh Sanikop }
116*09537850SAkhilesh Sanikop CDF_COPY(kDefaultIntraBlockCopyCdf, intra_block_copy_cdf);
117*09537850SAkhilesh Sanikop CDF_COPY(kDefaultIntraFrameYModeCdf, intra_frame_y_mode_cdf);
118*09537850SAkhilesh Sanikop CDF_COPY(kDefaultYModeCdf, y_mode_cdf);
119*09537850SAkhilesh Sanikop CDF_COPY(kDefaultAngleDeltaCdf, angle_delta_cdf);
120*09537850SAkhilesh Sanikop CDF_COPY(kDefaultUVModeCdf, uv_mode_cdf);
121*09537850SAkhilesh Sanikop CDF_COPY(kDefaultCflAlphaSignsCdf, cfl_alpha_signs_cdf);
122*09537850SAkhilesh Sanikop CDF_COPY(kDefaultCflAlphaCdf, cfl_alpha_cdf);
123*09537850SAkhilesh Sanikop CDF_COPY(kDefaultUseFilterIntraCdf, use_filter_intra_cdf);
124*09537850SAkhilesh Sanikop CDF_COPY(kDefaultFilterIntraModeCdf, filter_intra_mode_cdf);
125*09537850SAkhilesh Sanikop CDF_COPY(kDefaultTxDepthCdf, tx_depth_cdf);
126*09537850SAkhilesh Sanikop CDF_COPY(kDefaultTxSplitCdf, tx_split_cdf);
127*09537850SAkhilesh Sanikop CDF_COPY(kDefaultInterTxTypeCdf, inter_tx_type_cdf);
128*09537850SAkhilesh Sanikop CDF_COPY(kDefaultIntraTxTypeCdf, intra_tx_type_cdf);
129*09537850SAkhilesh Sanikop CDF_COPY(kDefaultRestorationTypeCdf, restoration_type_cdf);
130*09537850SAkhilesh Sanikop CDF_COPY(kDefaultUseWienerCdf, use_wiener_cdf);
131*09537850SAkhilesh Sanikop CDF_COPY(kDefaultUseSgrProjCdf, use_sgrproj_cdf);
132*09537850SAkhilesh Sanikop CDF_COPY(kDefaultHasPaletteYCdf, has_palette_y_cdf);
133*09537850SAkhilesh Sanikop CDF_COPY(kDefaultPaletteYSizeCdf, palette_y_size_cdf);
134*09537850SAkhilesh Sanikop CDF_COPY(kDefaultHasPaletteUVCdf, has_palette_uv_cdf);
135*09537850SAkhilesh Sanikop CDF_COPY(kDefaultPaletteUVSizeCdf, palette_uv_size_cdf);
136*09537850SAkhilesh Sanikop CDF_COPY(kDefaultPaletteColorIndexCdf, palette_color_index_cdf);
137*09537850SAkhilesh Sanikop CDF_COPY(kDefaultIsInterCdf, is_inter_cdf);
138*09537850SAkhilesh Sanikop CDF_COPY(kDefaultUseCompoundReferenceCdf, use_compound_reference_cdf);
139*09537850SAkhilesh Sanikop CDF_COPY(kDefaultCompoundReferenceTypeCdf, compound_reference_type_cdf);
140*09537850SAkhilesh Sanikop CDF_COPY(kDefaultCompoundReferenceCdf, compound_reference_cdf);
141*09537850SAkhilesh Sanikop CDF_COPY(kDefaultCompoundBackwardReferenceCdf,
142*09537850SAkhilesh Sanikop compound_backward_reference_cdf);
143*09537850SAkhilesh Sanikop CDF_COPY(kDefaultSingleReferenceCdf, single_reference_cdf);
144*09537850SAkhilesh Sanikop CDF_COPY(kDefaultCompoundPredictionModeCdf, compound_prediction_mode_cdf);
145*09537850SAkhilesh Sanikop CDF_COPY(kDefaultNewMvCdf, new_mv_cdf);
146*09537850SAkhilesh Sanikop CDF_COPY(kDefaultZeroMvCdf, zero_mv_cdf);
147*09537850SAkhilesh Sanikop CDF_COPY(kDefaultReferenceMvCdf, reference_mv_cdf);
148*09537850SAkhilesh Sanikop CDF_COPY(kDefaultRefMvIndexCdf, ref_mv_index_cdf);
149*09537850SAkhilesh Sanikop CDF_COPY(kDefaultIsInterIntraCdf, is_inter_intra_cdf);
150*09537850SAkhilesh Sanikop CDF_COPY(kDefaultInterIntraModeCdf, inter_intra_mode_cdf);
151*09537850SAkhilesh Sanikop CDF_COPY(kDefaultIsWedgeInterIntraCdf, is_wedge_inter_intra_cdf);
152*09537850SAkhilesh Sanikop CDF_COPY(kDefaultWedgeIndexCdf, wedge_index_cdf);
153*09537850SAkhilesh Sanikop CDF_COPY(kDefaultUseObmcCdf, use_obmc_cdf);
154*09537850SAkhilesh Sanikop CDF_COPY(kDefaultMotionModeCdf, motion_mode_cdf);
155*09537850SAkhilesh Sanikop CDF_COPY(kDefaultIsExplicitCompoundTypeCdf, is_explicit_compound_type_cdf);
156*09537850SAkhilesh Sanikop CDF_COPY(kDefaultIsCompoundTypeAverageCdf, is_compound_type_average_cdf);
157*09537850SAkhilesh Sanikop CDF_COPY(kDefaultCompoundTypeCdf, compound_type_cdf);
158*09537850SAkhilesh Sanikop CDF_COPY(kDefaultInterpolationFilterCdf, interpolation_filter_cdf);
159*09537850SAkhilesh Sanikop for (int i = 0; i < kMvContexts; ++i) {
160*09537850SAkhilesh Sanikop CDF_COPY(kDefaultMvJointCdf, mv_joint_cdf[i]);
161*09537850SAkhilesh Sanikop for (int j = 0; j < kNumMvComponents; ++j) {
162*09537850SAkhilesh Sanikop CDF_COPY(kDefaultMvSignCdf, mv_sign_cdf[i][j]);
163*09537850SAkhilesh Sanikop CDF_COPY(kDefaultMvClassCdf, mv_class_cdf[i][j]);
164*09537850SAkhilesh Sanikop CDF_COPY(kDefaultMvClass0BitCdf, mv_class0_bit_cdf[i][j]);
165*09537850SAkhilesh Sanikop CDF_COPY(kDefaultMvClass0FractionCdf, mv_class0_fraction_cdf[i][j]);
166*09537850SAkhilesh Sanikop CDF_COPY(kDefaultMvClass0HighPrecisionCdf,
167*09537850SAkhilesh Sanikop mv_class0_high_precision_cdf[i][j]);
168*09537850SAkhilesh Sanikop CDF_COPY(kDefaultMvBitCdf, mv_bit_cdf[i][j]);
169*09537850SAkhilesh Sanikop CDF_COPY(kDefaultMvFractionCdf, mv_fraction_cdf[i][j]);
170*09537850SAkhilesh Sanikop CDF_COPY(kDefaultMvHighPrecisionCdf, mv_high_precision_cdf[i][j]);
171*09537850SAkhilesh Sanikop }
172*09537850SAkhilesh Sanikop }
173*09537850SAkhilesh Sanikop const int quantizer_context = GetQuantizerContext(base_quantizer_index);
174*09537850SAkhilesh Sanikop CDF_COPY(kDefaultAllZeroCdf[quantizer_context], all_zero_cdf);
175*09537850SAkhilesh Sanikop CDF_COPY(kDefaultEobPt16Cdf[quantizer_context], eob_pt_16_cdf);
176*09537850SAkhilesh Sanikop CDF_COPY(kDefaultEobPt32Cdf[quantizer_context], eob_pt_32_cdf);
177*09537850SAkhilesh Sanikop CDF_COPY(kDefaultEobPt64Cdf[quantizer_context], eob_pt_64_cdf);
178*09537850SAkhilesh Sanikop CDF_COPY(kDefaultEobPt128Cdf[quantizer_context], eob_pt_128_cdf);
179*09537850SAkhilesh Sanikop CDF_COPY(kDefaultEobPt256Cdf[quantizer_context], eob_pt_256_cdf);
180*09537850SAkhilesh Sanikop CDF_COPY(kDefaultEobPt512Cdf[quantizer_context], eob_pt_512_cdf);
181*09537850SAkhilesh Sanikop CDF_COPY(kDefaultEobPt1024Cdf[quantizer_context], eob_pt_1024_cdf);
182*09537850SAkhilesh Sanikop CDF_COPY(kDefaultEobExtraCdf[quantizer_context], eob_extra_cdf);
183*09537850SAkhilesh Sanikop CDF_COPY(kDefaultCoeffBaseEobCdf[quantizer_context], coeff_base_eob_cdf);
184*09537850SAkhilesh Sanikop CDF_COPY(kDefaultCoeffBaseCdf[quantizer_context], coeff_base_cdf);
185*09537850SAkhilesh Sanikop CDF_COPY(kDefaultCoeffBaseRangeCdf[quantizer_context], coeff_base_range_cdf);
186*09537850SAkhilesh Sanikop CDF_COPY(kDefaultDcSignCdf[quantizer_context], dc_sign_cdf);
187*09537850SAkhilesh Sanikop }
188*09537850SAkhilesh Sanikop
ResetIntraFrameYModeCdf()189*09537850SAkhilesh Sanikop void SymbolDecoderContext::ResetIntraFrameYModeCdf() {
190*09537850SAkhilesh Sanikop CDF_COPY(kDefaultIntraFrameYModeCdf, intra_frame_y_mode_cdf);
191*09537850SAkhilesh Sanikop }
192*09537850SAkhilesh Sanikop
193*09537850SAkhilesh Sanikop #undef CDF_COPY
194*09537850SAkhilesh Sanikop
195*09537850SAkhilesh Sanikop // These macros set the last element in the inner-most dimension of the array to
196*09537850SAkhilesh Sanikop // zero.
197*09537850SAkhilesh Sanikop #define RESET_COUNTER_1D(array) \
198*09537850SAkhilesh Sanikop do { \
199*09537850SAkhilesh Sanikop (array)[std::extent<decltype(array), 0>::value - 1] = 0; \
200*09537850SAkhilesh Sanikop } while (false)
201*09537850SAkhilesh Sanikop
202*09537850SAkhilesh Sanikop #define RESET_COUNTER_2D(array) \
203*09537850SAkhilesh Sanikop do { \
204*09537850SAkhilesh Sanikop for (auto& d1 : (array)) { \
205*09537850SAkhilesh Sanikop d1[std::extent<decltype(array), 1>::value - 1] = 0; \
206*09537850SAkhilesh Sanikop } \
207*09537850SAkhilesh Sanikop } while (false)
208*09537850SAkhilesh Sanikop
209*09537850SAkhilesh Sanikop #define RESET_COUNTER_3D(array) \
210*09537850SAkhilesh Sanikop do { \
211*09537850SAkhilesh Sanikop for (auto& d1 : (array)) { \
212*09537850SAkhilesh Sanikop for (auto& d2 : d1) { \
213*09537850SAkhilesh Sanikop d2[std::extent<decltype(array), 2>::value - 1] = 0; \
214*09537850SAkhilesh Sanikop } \
215*09537850SAkhilesh Sanikop } \
216*09537850SAkhilesh Sanikop } while (false)
217*09537850SAkhilesh Sanikop
218*09537850SAkhilesh Sanikop #define RESET_COUNTER_4D(array) \
219*09537850SAkhilesh Sanikop do { \
220*09537850SAkhilesh Sanikop for (auto& d1 : (array)) { \
221*09537850SAkhilesh Sanikop for (auto& d2 : d1) { \
222*09537850SAkhilesh Sanikop for (auto& d3 : d2) { \
223*09537850SAkhilesh Sanikop d3[std::extent<decltype(array), 3>::value - 1] = 0; \
224*09537850SAkhilesh Sanikop } \
225*09537850SAkhilesh Sanikop } \
226*09537850SAkhilesh Sanikop } \
227*09537850SAkhilesh Sanikop } while (false)
228*09537850SAkhilesh Sanikop
ResetCounters()229*09537850SAkhilesh Sanikop void SymbolDecoderContext::ResetCounters() {
230*09537850SAkhilesh Sanikop ResetPartitionCounters(this);
231*09537850SAkhilesh Sanikop RESET_COUNTER_2D(segment_id_cdf);
232*09537850SAkhilesh Sanikop RESET_COUNTER_2D(use_predicted_segment_id_cdf);
233*09537850SAkhilesh Sanikop RESET_COUNTER_2D(skip_cdf);
234*09537850SAkhilesh Sanikop RESET_COUNTER_2D(skip_mode_cdf);
235*09537850SAkhilesh Sanikop RESET_COUNTER_1D(delta_q_cdf);
236*09537850SAkhilesh Sanikop RESET_COUNTER_1D(delta_lf_cdf);
237*09537850SAkhilesh Sanikop RESET_COUNTER_2D(delta_lf_multi_cdf);
238*09537850SAkhilesh Sanikop RESET_COUNTER_1D(intra_block_copy_cdf);
239*09537850SAkhilesh Sanikop RESET_COUNTER_3D(intra_frame_y_mode_cdf);
240*09537850SAkhilesh Sanikop RESET_COUNTER_2D(y_mode_cdf);
241*09537850SAkhilesh Sanikop RESET_COUNTER_2D(angle_delta_cdf);
242*09537850SAkhilesh Sanikop ResetUVModeCounters(this);
243*09537850SAkhilesh Sanikop RESET_COUNTER_1D(cfl_alpha_signs_cdf);
244*09537850SAkhilesh Sanikop RESET_COUNTER_2D(cfl_alpha_cdf);
245*09537850SAkhilesh Sanikop RESET_COUNTER_2D(use_filter_intra_cdf);
246*09537850SAkhilesh Sanikop RESET_COUNTER_1D(filter_intra_mode_cdf);
247*09537850SAkhilesh Sanikop ResetTxDepthCounters(this);
248*09537850SAkhilesh Sanikop RESET_COUNTER_2D(tx_split_cdf);
249*09537850SAkhilesh Sanikop RESET_COUNTER_3D(all_zero_cdf);
250*09537850SAkhilesh Sanikop ResetTxTypeCounters(this);
251*09537850SAkhilesh Sanikop RESET_COUNTER_3D(eob_pt_16_cdf);
252*09537850SAkhilesh Sanikop RESET_COUNTER_3D(eob_pt_32_cdf);
253*09537850SAkhilesh Sanikop RESET_COUNTER_3D(eob_pt_64_cdf);
254*09537850SAkhilesh Sanikop RESET_COUNTER_3D(eob_pt_128_cdf);
255*09537850SAkhilesh Sanikop RESET_COUNTER_3D(eob_pt_256_cdf);
256*09537850SAkhilesh Sanikop RESET_COUNTER_2D(eob_pt_512_cdf);
257*09537850SAkhilesh Sanikop RESET_COUNTER_2D(eob_pt_1024_cdf);
258*09537850SAkhilesh Sanikop RESET_COUNTER_4D(eob_extra_cdf);
259*09537850SAkhilesh Sanikop RESET_COUNTER_4D(coeff_base_eob_cdf);
260*09537850SAkhilesh Sanikop RESET_COUNTER_4D(coeff_base_cdf);
261*09537850SAkhilesh Sanikop RESET_COUNTER_4D(coeff_base_range_cdf);
262*09537850SAkhilesh Sanikop RESET_COUNTER_3D(dc_sign_cdf);
263*09537850SAkhilesh Sanikop RESET_COUNTER_1D(restoration_type_cdf);
264*09537850SAkhilesh Sanikop RESET_COUNTER_1D(use_wiener_cdf);
265*09537850SAkhilesh Sanikop RESET_COUNTER_1D(use_sgrproj_cdf);
266*09537850SAkhilesh Sanikop RESET_COUNTER_3D(has_palette_y_cdf);
267*09537850SAkhilesh Sanikop RESET_COUNTER_2D(palette_y_size_cdf);
268*09537850SAkhilesh Sanikop RESET_COUNTER_2D(has_palette_uv_cdf);
269*09537850SAkhilesh Sanikop RESET_COUNTER_2D(palette_uv_size_cdf);
270*09537850SAkhilesh Sanikop ResetPaletteColorIndexCounters(this);
271*09537850SAkhilesh Sanikop RESET_COUNTER_2D(is_inter_cdf);
272*09537850SAkhilesh Sanikop RESET_COUNTER_2D(use_compound_reference_cdf);
273*09537850SAkhilesh Sanikop RESET_COUNTER_2D(compound_reference_type_cdf);
274*09537850SAkhilesh Sanikop RESET_COUNTER_4D(compound_reference_cdf);
275*09537850SAkhilesh Sanikop RESET_COUNTER_3D(compound_backward_reference_cdf);
276*09537850SAkhilesh Sanikop RESET_COUNTER_3D(single_reference_cdf);
277*09537850SAkhilesh Sanikop RESET_COUNTER_2D(compound_prediction_mode_cdf);
278*09537850SAkhilesh Sanikop RESET_COUNTER_2D(new_mv_cdf);
279*09537850SAkhilesh Sanikop RESET_COUNTER_2D(zero_mv_cdf);
280*09537850SAkhilesh Sanikop RESET_COUNTER_2D(reference_mv_cdf);
281*09537850SAkhilesh Sanikop RESET_COUNTER_2D(ref_mv_index_cdf);
282*09537850SAkhilesh Sanikop RESET_COUNTER_2D(is_inter_intra_cdf);
283*09537850SAkhilesh Sanikop RESET_COUNTER_2D(inter_intra_mode_cdf);
284*09537850SAkhilesh Sanikop RESET_COUNTER_2D(is_wedge_inter_intra_cdf);
285*09537850SAkhilesh Sanikop RESET_COUNTER_2D(wedge_index_cdf);
286*09537850SAkhilesh Sanikop RESET_COUNTER_2D(use_obmc_cdf);
287*09537850SAkhilesh Sanikop RESET_COUNTER_2D(motion_mode_cdf);
288*09537850SAkhilesh Sanikop RESET_COUNTER_2D(is_explicit_compound_type_cdf);
289*09537850SAkhilesh Sanikop RESET_COUNTER_2D(is_compound_type_average_cdf);
290*09537850SAkhilesh Sanikop RESET_COUNTER_2D(compound_type_cdf);
291*09537850SAkhilesh Sanikop RESET_COUNTER_2D(interpolation_filter_cdf);
292*09537850SAkhilesh Sanikop RESET_COUNTER_2D(mv_joint_cdf);
293*09537850SAkhilesh Sanikop RESET_COUNTER_3D(mv_sign_cdf);
294*09537850SAkhilesh Sanikop RESET_COUNTER_3D(mv_class_cdf);
295*09537850SAkhilesh Sanikop RESET_COUNTER_3D(mv_class0_bit_cdf);
296*09537850SAkhilesh Sanikop RESET_COUNTER_4D(mv_class0_fraction_cdf);
297*09537850SAkhilesh Sanikop RESET_COUNTER_3D(mv_class0_high_precision_cdf);
298*09537850SAkhilesh Sanikop RESET_COUNTER_4D(mv_bit_cdf);
299*09537850SAkhilesh Sanikop RESET_COUNTER_3D(mv_fraction_cdf);
300*09537850SAkhilesh Sanikop RESET_COUNTER_3D(mv_high_precision_cdf);
301*09537850SAkhilesh Sanikop }
302*09537850SAkhilesh Sanikop
303*09537850SAkhilesh Sanikop #undef RESET_COUNTER_1D
304*09537850SAkhilesh Sanikop #undef RESET_COUNTER_2D
305*09537850SAkhilesh Sanikop #undef RESET_COUNTER_3D
306*09537850SAkhilesh Sanikop #undef RESET_COUNTER_4D
307*09537850SAkhilesh Sanikop
PartitionCdfSize(int block_size_log2)308*09537850SAkhilesh Sanikop int SymbolDecoderContext::PartitionCdfSize(int block_size_log2) {
309*09537850SAkhilesh Sanikop assert(block_size_log2 > 0);
310*09537850SAkhilesh Sanikop assert(block_size_log2 < 6);
311*09537850SAkhilesh Sanikop
312*09537850SAkhilesh Sanikop switch (block_size_log2) {
313*09537850SAkhilesh Sanikop case 1:
314*09537850SAkhilesh Sanikop return kPartitionSplit + 1;
315*09537850SAkhilesh Sanikop case 5:
316*09537850SAkhilesh Sanikop return kPartitionVerticalWithRightSplit + 1;
317*09537850SAkhilesh Sanikop default:
318*09537850SAkhilesh Sanikop return kMaxPartitionTypes;
319*09537850SAkhilesh Sanikop }
320*09537850SAkhilesh Sanikop }
321*09537850SAkhilesh Sanikop
322*09537850SAkhilesh Sanikop } // namespace libgav1
323