xref: /aosp_15_r20/external/libaom/av1/common/entropymode.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_AV1_COMMON_ENTROPYMODE_H_
13*77c1e3ccSAndroid Build Coastguard Worker #define AOM_AV1_COMMON_ENTROPYMODE_H_
14*77c1e3ccSAndroid Build Coastguard Worker 
15*77c1e3ccSAndroid Build Coastguard Worker #include "aom_ports/bitops.h"
16*77c1e3ccSAndroid Build Coastguard Worker #include "av1/common/entropy.h"
17*77c1e3ccSAndroid Build Coastguard Worker #include "av1/common/entropymv.h"
18*77c1e3ccSAndroid Build Coastguard Worker #include "av1/common/filter.h"
19*77c1e3ccSAndroid Build Coastguard Worker #include "av1/common/seg_common.h"
20*77c1e3ccSAndroid Build Coastguard Worker 
21*77c1e3ccSAndroid Build Coastguard Worker #ifdef __cplusplus
22*77c1e3ccSAndroid Build Coastguard Worker extern "C" {
23*77c1e3ccSAndroid Build Coastguard Worker #endif
24*77c1e3ccSAndroid Build Coastguard Worker 
25*77c1e3ccSAndroid Build Coastguard Worker #define BLOCK_SIZE_GROUPS 4
26*77c1e3ccSAndroid Build Coastguard Worker 
27*77c1e3ccSAndroid Build Coastguard Worker #define TX_SIZE_CONTEXTS 3
28*77c1e3ccSAndroid Build Coastguard Worker 
29*77c1e3ccSAndroid Build Coastguard Worker #define INTER_OFFSET(mode) ((mode)-NEARESTMV)
30*77c1e3ccSAndroid Build Coastguard Worker #define INTER_COMPOUND_OFFSET(mode) (uint8_t)((mode)-NEAREST_NEARESTMV)
31*77c1e3ccSAndroid Build Coastguard Worker 
32*77c1e3ccSAndroid Build Coastguard Worker // Number of possible contexts for a color index.
33*77c1e3ccSAndroid Build Coastguard Worker // As can be seen from av1_get_palette_color_index_context(), the possible
34*77c1e3ccSAndroid Build Coastguard Worker // contexts are (2,0,0), (2,2,1), (3,2,0), (4,1,0), (5,0,0). These are mapped to
35*77c1e3ccSAndroid Build Coastguard Worker // a value from 0 to 4 using 'av1_palette_color_index_context_lookup' table.
36*77c1e3ccSAndroid Build Coastguard Worker #define PALETTE_COLOR_INDEX_CONTEXTS 5
37*77c1e3ccSAndroid Build Coastguard Worker 
38*77c1e3ccSAndroid Build Coastguard Worker // Palette Y mode context for a block is determined by number of neighboring
39*77c1e3ccSAndroid Build Coastguard Worker // blocks (top and/or left) using a palette for Y plane. So, possible Y mode'
40*77c1e3ccSAndroid Build Coastguard Worker // context values are:
41*77c1e3ccSAndroid Build Coastguard Worker // 0 if neither left nor top block uses palette for Y plane,
42*77c1e3ccSAndroid Build Coastguard Worker // 1 if exactly one of left or top block uses palette for Y plane, and
43*77c1e3ccSAndroid Build Coastguard Worker // 2 if both left and top blocks use palette for Y plane.
44*77c1e3ccSAndroid Build Coastguard Worker #define PALETTE_Y_MODE_CONTEXTS 3
45*77c1e3ccSAndroid Build Coastguard Worker 
46*77c1e3ccSAndroid Build Coastguard Worker // Palette UV mode context for a block is determined by whether this block uses
47*77c1e3ccSAndroid Build Coastguard Worker // palette for the Y plane. So, possible values are:
48*77c1e3ccSAndroid Build Coastguard Worker // 0 if this block doesn't use palette for Y plane.
49*77c1e3ccSAndroid Build Coastguard Worker // 1 if this block uses palette for Y plane (i.e. Y palette size > 0).
50*77c1e3ccSAndroid Build Coastguard Worker #define PALETTE_UV_MODE_CONTEXTS 2
51*77c1e3ccSAndroid Build Coastguard Worker 
52*77c1e3ccSAndroid Build Coastguard Worker // Map the number of pixels in a block size to a context
53*77c1e3ccSAndroid Build Coastguard Worker //   64(BLOCK_8X8, BLOCK_4x16, BLOCK_16X4)  -> 0
54*77c1e3ccSAndroid Build Coastguard Worker //  128(BLOCK_8X16, BLOCK_16x8)             -> 1
55*77c1e3ccSAndroid Build Coastguard Worker //   ...
56*77c1e3ccSAndroid Build Coastguard Worker // 4096(BLOCK_64X64)                        -> 6
57*77c1e3ccSAndroid Build Coastguard Worker #define PALATTE_BSIZE_CTXS 7
58*77c1e3ccSAndroid Build Coastguard Worker 
59*77c1e3ccSAndroid Build Coastguard Worker #define MAX_COLOR_CONTEXT_HASH 8
60*77c1e3ccSAndroid Build Coastguard Worker 
61*77c1e3ccSAndroid Build Coastguard Worker #define NUM_PALETTE_NEIGHBORS 3  // left, top-left and top.
62*77c1e3ccSAndroid Build Coastguard Worker 
63*77c1e3ccSAndroid Build Coastguard Worker #define KF_MODE_CONTEXTS 5
64*77c1e3ccSAndroid Build Coastguard Worker 
65*77c1e3ccSAndroid Build Coastguard Worker struct AV1Common;
66*77c1e3ccSAndroid Build Coastguard Worker 
67*77c1e3ccSAndroid Build Coastguard Worker typedef struct {
68*77c1e3ccSAndroid Build Coastguard Worker   const int16_t *scan;
69*77c1e3ccSAndroid Build Coastguard Worker   const int16_t *iscan;
70*77c1e3ccSAndroid Build Coastguard Worker } SCAN_ORDER;
71*77c1e3ccSAndroid Build Coastguard Worker 
72*77c1e3ccSAndroid Build Coastguard Worker typedef struct frame_contexts {
73*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob txb_skip_cdf[TX_SIZES][TXB_SKIP_CONTEXTS][CDF_SIZE(2)];
74*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob eob_extra_cdf[TX_SIZES][PLANE_TYPES][EOB_COEF_CONTEXTS]
75*77c1e3ccSAndroid Build Coastguard Worker                             [CDF_SIZE(2)];
76*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob dc_sign_cdf[PLANE_TYPES][DC_SIGN_CONTEXTS][CDF_SIZE(2)];
77*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob eob_flag_cdf16[PLANE_TYPES][2][CDF_SIZE(5)];
78*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob eob_flag_cdf32[PLANE_TYPES][2][CDF_SIZE(6)];
79*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob eob_flag_cdf64[PLANE_TYPES][2][CDF_SIZE(7)];
80*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob eob_flag_cdf128[PLANE_TYPES][2][CDF_SIZE(8)];
81*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob eob_flag_cdf256[PLANE_TYPES][2][CDF_SIZE(9)];
82*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob eob_flag_cdf512[PLANE_TYPES][2][CDF_SIZE(10)];
83*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob eob_flag_cdf1024[PLANE_TYPES][2][CDF_SIZE(11)];
84*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob coeff_base_eob_cdf[TX_SIZES][PLANE_TYPES][SIG_COEF_CONTEXTS_EOB]
85*77c1e3ccSAndroid Build Coastguard Worker                                  [CDF_SIZE(3)];
86*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob coeff_base_cdf[TX_SIZES][PLANE_TYPES][SIG_COEF_CONTEXTS]
87*77c1e3ccSAndroid Build Coastguard Worker                              [CDF_SIZE(4)];
88*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob coeff_br_cdf[TX_SIZES][PLANE_TYPES][LEVEL_CONTEXTS]
89*77c1e3ccSAndroid Build Coastguard Worker                            [CDF_SIZE(BR_CDF_SIZE)];
90*77c1e3ccSAndroid Build Coastguard Worker 
91*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob newmv_cdf[NEWMV_MODE_CONTEXTS][CDF_SIZE(2)];
92*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob zeromv_cdf[GLOBALMV_MODE_CONTEXTS][CDF_SIZE(2)];
93*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob refmv_cdf[REFMV_MODE_CONTEXTS][CDF_SIZE(2)];
94*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob drl_cdf[DRL_MODE_CONTEXTS][CDF_SIZE(2)];
95*77c1e3ccSAndroid Build Coastguard Worker 
96*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob inter_compound_mode_cdf[INTER_MODE_CONTEXTS]
97*77c1e3ccSAndroid Build Coastguard Worker                                       [CDF_SIZE(INTER_COMPOUND_MODES)];
98*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob compound_type_cdf[BLOCK_SIZES_ALL]
99*77c1e3ccSAndroid Build Coastguard Worker                                 [CDF_SIZE(MASKED_COMPOUND_TYPES)];
100*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob wedge_idx_cdf[BLOCK_SIZES_ALL][CDF_SIZE(16)];
101*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob interintra_cdf[BLOCK_SIZE_GROUPS][CDF_SIZE(2)];
102*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob wedge_interintra_cdf[BLOCK_SIZES_ALL][CDF_SIZE(2)];
103*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob interintra_mode_cdf[BLOCK_SIZE_GROUPS]
104*77c1e3ccSAndroid Build Coastguard Worker                                   [CDF_SIZE(INTERINTRA_MODES)];
105*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob motion_mode_cdf[BLOCK_SIZES_ALL][CDF_SIZE(MOTION_MODES)];
106*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob obmc_cdf[BLOCK_SIZES_ALL][CDF_SIZE(2)];
107*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob palette_y_size_cdf[PALATTE_BSIZE_CTXS][CDF_SIZE(PALETTE_SIZES)];
108*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob palette_uv_size_cdf[PALATTE_BSIZE_CTXS][CDF_SIZE(PALETTE_SIZES)];
109*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob palette_y_color_index_cdf[PALETTE_SIZES]
110*77c1e3ccSAndroid Build Coastguard Worker                                         [PALETTE_COLOR_INDEX_CONTEXTS]
111*77c1e3ccSAndroid Build Coastguard Worker                                         [CDF_SIZE(PALETTE_COLORS)];
112*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob palette_uv_color_index_cdf[PALETTE_SIZES]
113*77c1e3ccSAndroid Build Coastguard Worker                                          [PALETTE_COLOR_INDEX_CONTEXTS]
114*77c1e3ccSAndroid Build Coastguard Worker                                          [CDF_SIZE(PALETTE_COLORS)];
115*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob palette_y_mode_cdf[PALATTE_BSIZE_CTXS][PALETTE_Y_MODE_CONTEXTS]
116*77c1e3ccSAndroid Build Coastguard Worker                                  [CDF_SIZE(2)];
117*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob palette_uv_mode_cdf[PALETTE_UV_MODE_CONTEXTS][CDF_SIZE(2)];
118*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob comp_inter_cdf[COMP_INTER_CONTEXTS][CDF_SIZE(2)];
119*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob single_ref_cdf[REF_CONTEXTS][SINGLE_REFS - 1][CDF_SIZE(2)];
120*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob comp_ref_type_cdf[COMP_REF_TYPE_CONTEXTS][CDF_SIZE(2)];
121*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob uni_comp_ref_cdf[UNI_COMP_REF_CONTEXTS][UNIDIR_COMP_REFS - 1]
122*77c1e3ccSAndroid Build Coastguard Worker                                [CDF_SIZE(2)];
123*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob comp_ref_cdf[REF_CONTEXTS][FWD_REFS - 1][CDF_SIZE(2)];
124*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob comp_bwdref_cdf[REF_CONTEXTS][BWD_REFS - 1][CDF_SIZE(2)];
125*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob txfm_partition_cdf[TXFM_PARTITION_CONTEXTS][CDF_SIZE(2)];
126*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob compound_index_cdf[COMP_INDEX_CONTEXTS][CDF_SIZE(2)];
127*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob comp_group_idx_cdf[COMP_GROUP_IDX_CONTEXTS][CDF_SIZE(2)];
128*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob skip_mode_cdfs[SKIP_MODE_CONTEXTS][CDF_SIZE(2)];
129*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob skip_txfm_cdfs[SKIP_CONTEXTS][CDF_SIZE(2)];
130*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob intra_inter_cdf[INTRA_INTER_CONTEXTS][CDF_SIZE(2)];
131*77c1e3ccSAndroid Build Coastguard Worker   nmv_context nmvc;
132*77c1e3ccSAndroid Build Coastguard Worker   nmv_context ndvc;
133*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob intrabc_cdf[CDF_SIZE(2)];
134*77c1e3ccSAndroid Build Coastguard Worker   struct segmentation_probs seg;
135*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob filter_intra_cdfs[BLOCK_SIZES_ALL][CDF_SIZE(2)];
136*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob filter_intra_mode_cdf[CDF_SIZE(FILTER_INTRA_MODES)];
137*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob switchable_restore_cdf[CDF_SIZE(RESTORE_SWITCHABLE_TYPES)];
138*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob wiener_restore_cdf[CDF_SIZE(2)];
139*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob sgrproj_restore_cdf[CDF_SIZE(2)];
140*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob y_mode_cdf[BLOCK_SIZE_GROUPS][CDF_SIZE(INTRA_MODES)];
141*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob uv_mode_cdf[CFL_ALLOWED_TYPES][INTRA_MODES]
142*77c1e3ccSAndroid Build Coastguard Worker                           [CDF_SIZE(UV_INTRA_MODES)];
143*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob partition_cdf[PARTITION_CONTEXTS][CDF_SIZE(EXT_PARTITION_TYPES)];
144*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob switchable_interp_cdf[SWITCHABLE_FILTER_CONTEXTS]
145*77c1e3ccSAndroid Build Coastguard Worker                                     [CDF_SIZE(SWITCHABLE_FILTERS)];
146*77c1e3ccSAndroid Build Coastguard Worker   /* kf_y_cdf is discarded after use, so does not require persistent storage.
147*77c1e3ccSAndroid Build Coastguard Worker      However, we keep it with the other CDFs in this struct since it needs to
148*77c1e3ccSAndroid Build Coastguard Worker      be copied to each tile to support parallelism just like the others.
149*77c1e3ccSAndroid Build Coastguard Worker   */
150*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob kf_y_cdf[KF_MODE_CONTEXTS][KF_MODE_CONTEXTS]
151*77c1e3ccSAndroid Build Coastguard Worker                        [CDF_SIZE(INTRA_MODES)];
152*77c1e3ccSAndroid Build Coastguard Worker 
153*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob angle_delta_cdf[DIRECTIONAL_MODES]
154*77c1e3ccSAndroid Build Coastguard Worker                               [CDF_SIZE(2 * MAX_ANGLE_DELTA + 1)];
155*77c1e3ccSAndroid Build Coastguard Worker 
156*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob tx_size_cdf[MAX_TX_CATS][TX_SIZE_CONTEXTS]
157*77c1e3ccSAndroid Build Coastguard Worker                           [CDF_SIZE(MAX_TX_DEPTH + 1)];
158*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob delta_q_cdf[CDF_SIZE(DELTA_Q_PROBS + 1)];
159*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob delta_lf_multi_cdf[FRAME_LF_COUNT][CDF_SIZE(DELTA_LF_PROBS + 1)];
160*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob delta_lf_cdf[CDF_SIZE(DELTA_LF_PROBS + 1)];
161*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob intra_ext_tx_cdf[EXT_TX_SETS_INTRA][EXT_TX_SIZES][INTRA_MODES]
162*77c1e3ccSAndroid Build Coastguard Worker                                [CDF_SIZE(TX_TYPES)];
163*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob inter_ext_tx_cdf[EXT_TX_SETS_INTER][EXT_TX_SIZES]
164*77c1e3ccSAndroid Build Coastguard Worker                                [CDF_SIZE(TX_TYPES)];
165*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob cfl_sign_cdf[CDF_SIZE(CFL_JOINT_SIGNS)];
166*77c1e3ccSAndroid Build Coastguard Worker   aom_cdf_prob cfl_alpha_cdf[CFL_ALPHA_CONTEXTS][CDF_SIZE(CFL_ALPHABET_SIZE)];
167*77c1e3ccSAndroid Build Coastguard Worker   int initialized;
168*77c1e3ccSAndroid Build Coastguard Worker } FRAME_CONTEXT;
169*77c1e3ccSAndroid Build Coastguard Worker 
170*77c1e3ccSAndroid Build Coastguard Worker static const int av1_ext_tx_ind[EXT_TX_SET_TYPES][TX_TYPES] = {
171*77c1e3ccSAndroid Build Coastguard Worker   { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
172*77c1e3ccSAndroid Build Coastguard Worker   { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
173*77c1e3ccSAndroid Build Coastguard Worker   { 1, 3, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
174*77c1e3ccSAndroid Build Coastguard Worker   { 1, 5, 6, 4, 0, 0, 0, 0, 0, 0, 2, 3, 0, 0, 0, 0 },
175*77c1e3ccSAndroid Build Coastguard Worker   { 3, 4, 5, 8, 6, 7, 9, 10, 11, 0, 1, 2, 0, 0, 0, 0 },
176*77c1e3ccSAndroid Build Coastguard Worker   { 7, 8, 9, 12, 10, 11, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6 },
177*77c1e3ccSAndroid Build Coastguard Worker };
178*77c1e3ccSAndroid Build Coastguard Worker 
179*77c1e3ccSAndroid Build Coastguard Worker static const int av1_ext_tx_inv[EXT_TX_SET_TYPES][TX_TYPES] = {
180*77c1e3ccSAndroid Build Coastguard Worker   { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
181*77c1e3ccSAndroid Build Coastguard Worker   { 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
182*77c1e3ccSAndroid Build Coastguard Worker   { 9, 0, 3, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
183*77c1e3ccSAndroid Build Coastguard Worker   { 9, 0, 10, 11, 3, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
184*77c1e3ccSAndroid Build Coastguard Worker   { 9, 10, 11, 0, 1, 2, 4, 5, 3, 6, 7, 8, 0, 0, 0, 0 },
185*77c1e3ccSAndroid Build Coastguard Worker   { 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 4, 5, 3, 6, 7, 8 },
186*77c1e3ccSAndroid Build Coastguard Worker };
187*77c1e3ccSAndroid Build Coastguard Worker 
188*77c1e3ccSAndroid Build Coastguard Worker void av1_set_default_ref_deltas(int8_t *ref_deltas);
189*77c1e3ccSAndroid Build Coastguard Worker void av1_set_default_mode_deltas(int8_t *mode_deltas);
190*77c1e3ccSAndroid Build Coastguard Worker void av1_setup_frame_contexts(struct AV1Common *cm);
191*77c1e3ccSAndroid Build Coastguard Worker void av1_setup_past_independence(struct AV1Common *cm);
192*77c1e3ccSAndroid Build Coastguard Worker 
193*77c1e3ccSAndroid Build Coastguard Worker // Returns (int)ceil(log2(n)).
av1_ceil_log2(int n)194*77c1e3ccSAndroid Build Coastguard Worker static inline int av1_ceil_log2(int n) {
195*77c1e3ccSAndroid Build Coastguard Worker   if (n < 2) return 0;
196*77c1e3ccSAndroid Build Coastguard Worker   return get_msb(n - 1) + 1;
197*77c1e3ccSAndroid Build Coastguard Worker }
198*77c1e3ccSAndroid Build Coastguard Worker 
199*77c1e3ccSAndroid Build Coastguard Worker // Returns the context for palette color index at row 'r' and column 'c',
200*77c1e3ccSAndroid Build Coastguard Worker // along with the 'color_order' of neighbors and the 'color_idx'.
201*77c1e3ccSAndroid Build Coastguard Worker // The 'color_map' is a 2D array with the given 'stride'.
202*77c1e3ccSAndroid Build Coastguard Worker int av1_get_palette_color_index_context(const uint8_t *color_map, int stride,
203*77c1e3ccSAndroid Build Coastguard Worker                                         int r, int c, int palette_size,
204*77c1e3ccSAndroid Build Coastguard Worker                                         uint8_t *color_order, int *color_idx);
205*77c1e3ccSAndroid Build Coastguard Worker 
206*77c1e3ccSAndroid Build Coastguard Worker extern const int
207*77c1e3ccSAndroid Build Coastguard Worker     av1_palette_color_index_context_lookup[MAX_COLOR_CONTEXT_HASH + 1];
208*77c1e3ccSAndroid Build Coastguard Worker 
209*77c1e3ccSAndroid Build Coastguard Worker #ifdef __cplusplus
210*77c1e3ccSAndroid Build Coastguard Worker }  // extern "C"
211*77c1e3ccSAndroid Build Coastguard Worker #endif
212*77c1e3ccSAndroid Build Coastguard Worker 
213*77c1e3ccSAndroid Build Coastguard Worker #endif  // AOM_AV1_COMMON_ENTROPYMODE_H_
214