AOMedia AV1 Codec: av1/common/av1_common_int.h Source File

| AOMedia AV1 Codec

av1_common_int.h
1 /*
2 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
3 *
4 * 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.
10 */
11
12 #ifndef AOM_AV1_COMMON_AV1_COMMON_INT_H_
13 #define AOM_AV1_COMMON_AV1_COMMON_INT_H_
14
15 #include "config/aom_config.h"
16 #include "config/av1_rtcd.h"
17
18 #include "aom/internal/aom_codec_internal.h"
19 #include "aom_util/aom_thread.h"
20 #include "av1/common/alloccommon.h"
21 #include "av1/common/av1_loopfilter.h"
22 #include "av1/common/entropy.h"
23 #include "av1/common/entropymode.h"
24 #include "av1/common/entropymv.h"
25 #include "av1/common/enums.h"
26 #include "av1/common/frame_buffers.h"
27 #include "av1/common/mv.h"
28 #include "av1/common/quant_common.h"
29 #include "av1/common/restoration.h"
30 #include "av1/common/tile_common.h"
31 #include "av1/common/timing.h"
32 #include "av1/common/odintrin.h"
33 #include "av1/encoder/hash_motion.h"
34 #include "aom_dsp/grain_synthesis.h"
35 #include "aom_dsp/grain_table.h"
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39
40 #if defined(__clang__) && defined(__has_warning)
41 #if __has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough")
42 #define AOM_FALLTHROUGH_INTENDED [[clang::fallthrough]] // NOLINT
43 #endif
44 #elif defined(__GNUC__) && __GNUC__ >= 7
45 #define AOM_FALLTHROUGH_INTENDED __attribute__((fallthrough)) // NOLINT
46 #endif
47
48 #ifndef AOM_FALLTHROUGH_INTENDED
49 #define AOM_FALLTHROUGH_INTENDED \
50 do { \
51 } while (0)
52 #endif
53
54 #define CDEF_MAX_STRENGTHS 16
55
56 /* Constant values while waiting for the sequence header */
57 #define FRAME_ID_LENGTH 15
58 #define DELTA_FRAME_ID_LENGTH 14
59
60 #define FRAME_CONTEXTS (FRAME_BUFFERS + 1)
61 // Extra frame context which is always kept at default values
62 #define FRAME_CONTEXT_DEFAULTS (FRAME_CONTEXTS - 1)
63 #define PRIMARY_REF_BITS 3
64 #define PRIMARY_REF_NONE 7
65
66 #define NUM_PING_PONG_BUFFERS 2
67
68 #define MAX_NUM_TEMPORAL_LAYERS 8
69 #define MAX_NUM_SPATIAL_LAYERS 4
70 /* clang-format off */
71 // clang-format seems to think this is a pointer dereference and not a
72 // multiplication.
73 #define MAX_NUM_OPERATING_POINTS \
74 (MAX_NUM_TEMPORAL_LAYERS * MAX_NUM_SPATIAL_LAYERS)
75 /* clang-format on */
76
77 // TODO(jingning): Turning this on to set up transform coefficient
78 // processing timer.
79 #define TXCOEFF_TIMER 0
80 #define TXCOEFF_COST_TIMER 0
81
84 enum {
85 SINGLE_REFERENCE = 0,
86 COMPOUND_REFERENCE = 1,
87 REFERENCE_MODE_SELECT = 2,
88 REFERENCE_MODES = 3,
89 } UENUM1BYTE(REFERENCE_MODE);
90
91 enum {
95 REFRESH_FRAME_CONTEXT_DISABLED,
100 REFRESH_FRAME_CONTEXT_BACKWARD,
101 } UENUM1BYTE(REFRESH_FRAME_CONTEXT_MODE);
102
103 #define MFMV_STACK_SIZE 3
104 typedef struct {
105 int_mv mfmv0;
106 uint8_t ref_frame_offset;
107 } TPL_MV_REF;
108
109 typedef struct {
110 int_mv mv;
111 MV_REFERENCE_FRAME ref_frame;
112 } MV_REF;
113
114 typedef struct RefCntBuffer {
115 // For a RefCntBuffer, the following are reference-holding variables:
116 // - cm->ref_frame_map[]
117 // - cm->cur_frame
118 // - cm->scaled_ref_buf[] (encoder only)
119 // - pbi->output_frame_index[] (decoder only)
120 // With that definition, 'ref_count' is the number of reference-holding
121 // variables that are currently referencing this buffer.
122 // For example:
123 // - suppose this buffer is at index 'k' in the buffer pool, and
124 // - Total 'n' of the variables / array elements above have value 'k' (that
125 // is, they are pointing to buffer at index 'k').
126 // Then, pool->frame_bufs[k].ref_count = n.
127 int ref_count;
128
129 unsigned int order_hint;
130 unsigned int ref_order_hints[INTER_REFS_PER_FRAME];
131
132 // These variables are used only in encoder and compare the absolute
133 // display order hint to compute the relative distance and overcome
134 // the limitation of get_relative_dist() which returns incorrect
135 // distance when a very old frame is used as a reference.
136 unsigned int display_order_hint;
137 unsigned int ref_display_order_hint[INTER_REFS_PER_FRAME];
138
139 MV_REF *mvs;
140 uint8_t *seg_map;
141 struct segmentation seg;
142 int mi_rows;
143 int mi_cols;
144 // Width and height give the size of the buffer (before any upscaling, unlike
145 // the sizes that can be derived from the buf structure)
146 int width;
147 int height;
148 WarpedMotionParams global_motion[REF_FRAMES];
149 int showable_frame; // frame can be used as show existing frame in future
150 uint8_t film_grain_params_present;
151 aom_film_grain_t film_grain_params;
152 aom_codec_frame_buffer_t raw_frame_buffer;
153 YV12_BUFFER_CONFIG buf;
154 int temporal_id; // Temporal layer ID of the frame
155 int spatial_id; // Spatial layer ID of the frame
156 FRAME_TYPE frame_type;
157
158 // This is only used in the encoder but needs to be indexed per ref frame
159 // so it's extremely convenient to keep it here.
160 int interp_filter_selected[SWITCHABLE];
161
162 // Inter frame reference frame delta for loop filter
163 int8_t ref_deltas[REF_FRAMES];
164
165 // 0 = ZERO_MV, MV
166 int8_t mode_deltas[MAX_MODE_LF_DELTAS];
167
168 FRAME_CONTEXT frame_context;
169 } RefCntBuffer;
170
171 typedef struct BufferPool {
172 // Protect BufferPool from being accessed by several FrameWorkers at
173 // the same time during frame parallel decode.
174 // TODO(hkuang): Try to use atomic variable instead of locking the whole pool.
175 // TODO(wtc): Remove this. See
176 // https://chromium-review.googlesource.com/c/webm/libvpx/+/560630.
177 #if CONFIG_MULTITHREAD
178 pthread_mutex_t pool_mutex;
179 #endif
180
181 // Private data associated with the frame buffer callbacks.
182 void *cb_priv;
183
184 aom_get_frame_buffer_cb_fn_t get_fb_cb;
185 aom_release_frame_buffer_cb_fn_t release_fb_cb;
186
187 RefCntBuffer frame_bufs[FRAME_BUFFERS];
188
189 // Frame buffers allocated internally by the codec.
190 InternalFrameBufferList int_frame_buffers;
191 } BufferPool;
192
196 typedef struct {
197 int cdef_damping;
198 int nb_cdef_strengths;
199 int cdef_strengths[CDEF_MAX_STRENGTHS];
200 int cdef_uv_strengths[CDEF_MAX_STRENGTHS];
202 int cdef_bits;
203 } CdefInfo;
204
207 typedef struct {
208 int delta_q_present_flag;
209 // Resolution of delta quant
210 int delta_q_res;
211 int delta_lf_present_flag;
212 // Resolution of delta lf level
213 int delta_lf_res;
214 // This is a flag for number of deltas of loop filter level
215 // 0: use 1 delta, for y_vertical, y_horizontal, u, and v
216 // 1: use separate deltas for each filter level
217 int delta_lf_multi;
218 } DeltaQInfo;
219
220 typedef struct {
221 int enable_order_hint; // 0 - disable order hint, and related tools
222 int order_hint_bits_minus_1; // dist_wtd_comp, ref_frame_mvs,
223 // frame_sign_bias
224 // if 0, enable_dist_wtd_comp and
225 // enable_ref_frame_mvs must be set as 0.
226 int enable_dist_wtd_comp; // 0 - disable dist-wtd compound modes
227 // 1 - enable it
228 int enable_ref_frame_mvs; // 0 - disable ref frame mvs
229 // 1 - enable it
230 } OrderHintInfo;
231
232 // Sequence header structure.
233 // Note: All syntax elements of sequence_header_obu that need to be
234 // bit-identical across multiple sequence headers must be part of this struct,
235 // so that consistency is checked by are_seq_headers_consistent() function.
236 // One exception is the last member 'op_params' that is ignored by
237 // are_seq_headers_consistent() function.
238 typedef struct SequenceHeader {
239 int num_bits_width;
240 int num_bits_height;
241 int max_frame_width;
242 int max_frame_height;
243 // Whether current and reference frame IDs are signaled in the bitstream.
244 // Frame id numbers are additional information that do not affect the
245 // decoding process, but provide decoders with a way of detecting missing
246 // reference frames so that appropriate action can be taken.
247 uint8_t frame_id_numbers_present_flag;
248 int frame_id_length;
249 int delta_frame_id_length;
250 BLOCK_SIZE sb_size; // Size of the superblock used for this frame
251 int mib_size; // Size of the superblock in units of MI blocks
252 int mib_size_log2; // Log 2 of above.
253
254 OrderHintInfo order_hint_info;
255
256 uint8_t force_screen_content_tools; // 0 - force off
257 // 1 - force on
258 // 2 - adaptive
259 uint8_t still_picture; // Video is a single frame still picture
260 uint8_t reduced_still_picture_hdr; // Use reduced header for still picture
261 uint8_t force_integer_mv; // 0 - Don't force. MV can use subpel
262 // 1 - force to integer
263 // 2 - adaptive
264 uint8_t enable_filter_intra; // enables/disables filterintra
265 uint8_t enable_intra_edge_filter; // enables/disables edge upsampling
266 uint8_t enable_interintra_compound; // enables/disables interintra_compound
267 uint8_t enable_masked_compound; // enables/disables masked compound
268 uint8_t enable_dual_filter; // 0 - disable dual interpolation filter
269 // 1 - enable vert/horz filter selection
270 uint8_t enable_warped_motion; // 0 - disable warp for the sequence
271 // 1 - enable warp for the sequence
272 uint8_t enable_superres; // 0 - Disable superres for the sequence
273 // and no frame level superres flag
274 // 1 - Enable superres for the sequence
275 // enable per-frame superres flag
276 uint8_t enable_cdef; // To turn on/off CDEF
277 uint8_t enable_restoration; // To turn on/off loop restoration
278 BITSTREAM_PROFILE profile;
279
280 // Color config.
281 aom_bit_depth_t bit_depth; // AOM_BITS_8 in profile 0 or 1,
282 // AOM_BITS_10 or AOM_BITS_12 in profile 2 or 3.
283 uint8_t use_highbitdepth; // If true, we need to use 16bit frame buffers.
284 uint8_t monochrome; // Monochorme video
285 aom_color_primaries_t color_primaries;
286 aom_transfer_characteristics_t transfer_characteristics;
287 aom_matrix_coefficients_t matrix_coefficients;
288 int color_range;
289 int subsampling_x; // Chroma subsampling for x
290 int subsampling_y; // Chroma subsampling for y
291 aom_chroma_sample_position_t chroma_sample_position;
292 uint8_t separate_uv_delta_q;
293 uint8_t film_grain_params_present;
294
295 // Operating point info.
296 int operating_points_cnt_minus_1;
297 int operating_point_idc[MAX_NUM_OPERATING_POINTS];
298 int timing_info_present;
299 aom_timing_info_t timing_info;
300 uint8_t decoder_model_info_present_flag;
301 aom_dec_model_info_t decoder_model_info;
302 uint8_t display_model_info_present_flag;
303 AV1_LEVEL seq_level_idx[MAX_NUM_OPERATING_POINTS];
304 uint8_t tier[MAX_NUM_OPERATING_POINTS]; // seq_tier in spec. One bit: 0 or 1.
305
306 // IMPORTANT: the op_params member must be at the end of the struct so that
307 // are_seq_headers_consistent() can be implemented with a memcmp() call.
308 // TODO(urvang): We probably don't need the +1 here.
309 aom_dec_model_op_parameters_t op_params[MAX_NUM_OPERATING_POINTS + 1];
310 } SequenceHeader;
311
312 typedef struct {
313 int skip_mode_allowed;
314 int skip_mode_flag;
315 int ref_frame_idx_0;
316 int ref_frame_idx_1;
317 } SkipModeInfo;
318
319 typedef struct {
320 FRAME_TYPE frame_type;
321 REFERENCE_MODE reference_mode;
322
323 unsigned int order_hint;
324 unsigned int display_order_hint;
325 unsigned int frame_number;
326 SkipModeInfo skip_mode_info;
327 int refresh_frame_flags; // Which ref frames are overwritten by this frame
328 int frame_refs_short_signaling;
329 } CurrentFrame;
330
336 typedef struct {
340 bool disable_cdf_update;
345 bool allow_high_precision_mv;
349 bool cur_frame_force_integer_mv;
353 bool allow_screen_content_tools;
354 bool allow_intrabc;
355 bool allow_warped_motion;
359 bool allow_ref_frame_mvs;
363 bool coded_lossless;
367 bool all_lossless;
372 bool reduced_tx_set_used;
378 bool error_resilient_mode;
383 bool switchable_motion_mode;
384 TX_MODE tx_mode;
385 InterpFilter interp_filter;
390 int primary_ref_frame;
394 int byte_alignment;
399 REFRESH_FRAME_CONTEXT_MODE refresh_frame_context;
400 } FeatureFlags;
401
405 typedef struct CommonTileParams {
406 int cols;
407 int rows;
408 int max_width_sb;
409 int max_height_sb;
414 int min_inner_width;
415
421 int uniform_spacing;
422
427 int log2_cols;
428 int log2_rows;
429 int width;
430 int height;
436 int min_log2_cols;
440 int min_log2_rows;
444 int max_log2_cols;
448 int max_log2_rows;
452 int min_log2;
457 int col_start_sb[MAX_TILE_COLS + 1];
462 int row_start_sb[MAX_TILE_ROWS + 1];
466 unsigned int large_scale;
472 unsigned int single_tile_decoding;
473 } CommonTileParams;
474
475 typedef struct CommonModeInfoParams CommonModeInfoParams;
479 struct CommonModeInfoParams {
484 int mb_rows;
489 int mb_cols;
490
494 int MBs;
495
500 int mi_rows;
505 int mi_cols;
506
513 MB_MODE_INFO *mi_alloc;
517 int mi_alloc_size;
521 int mi_alloc_stride;
528 BLOCK_SIZE mi_alloc_bsize;
529
537 MB_MODE_INFO **mi_grid_base;
541 int mi_grid_size;
545 int mi_stride;
546
553 TX_TYPE *tx_type_map;
554
563 void (*free_mi)(struct CommonModeInfoParams *mi_params);
568 void (*setup_mi)(struct CommonModeInfoParams *mi_params);
575 void (*set_mb_mi)(struct CommonModeInfoParams *mi_params, int width,
576 int height);
578 };
579
580 typedef struct CommonQuantParams CommonQuantParams;
584 struct CommonQuantParams {
588 int base_qindex;
589
594 int y_dc_delta_q;
595
599 int u_dc_delta_q;
603 int v_dc_delta_q;
604
609 int u_ac_delta_q;
614 int v_ac_delta_q;
615
616 /*
617 * Note: The qindex per superblock may have a delta from the qindex obtained
618 * at frame level from parameters above, based on 'cm->delta_q_info'.
619 */
620
628 int16_t y_dequant_QTX[MAX_SEGMENTS][2];
629 int16_t u_dequant_QTX[MAX_SEGMENTS][2];
630 int16_t v_dequant_QTX[MAX_SEGMENTS][2];
640 const qm_val_t *giqmatrix[NUM_QM_LEVELS][3][TX_SIZES_ALL];
644 const qm_val_t *gqmatrix[NUM_QM_LEVELS][3][TX_SIZES_ALL];
654 const qm_val_t *y_iqmatrix[MAX_SEGMENTS][TX_SIZES_ALL];
658 const qm_val_t *u_iqmatrix[MAX_SEGMENTS][TX_SIZES_ALL];
662 const qm_val_t *v_iqmatrix[MAX_SEGMENTS][TX_SIZES_ALL];
671 bool using_qmatrix;
678 int qmatrix_level_y;
679 int qmatrix_level_u;
680 int qmatrix_level_v;
682 };
683
684 typedef struct CommonContexts CommonContexts;
688 struct CommonContexts {
693 PARTITION_CONTEXT **partition;
694
703 ENTROPY_CONTEXT **entropy[MAX_MB_PLANE];
704
711 TXFM_CONTEXT **txfm;
712
717 int num_planes;
718 int num_tile_rows;
719 int num_mi_cols;
720 };
721
725 typedef struct AV1Common {
729 CurrentFrame current_frame;
733 struct aom_internal_error_info error;
734
750 int width;
751 int height;
761 int render_width;
762 int render_height;
774 int superres_upscaled_width;
775 int superres_upscaled_height;
782 uint8_t superres_scale_denominator;
783
787 bool buffer_removal_time_present;
794 uint32_t buffer_removal_times[MAX_NUM_OPERATING_POINTS + 1];
800 uint32_t frame_presentation_time;
801
805 RefCntBuffer *prev_frame;
806
811 RefCntBuffer *cur_frame;
812
833 int remapped_ref_idx[REF_FRAMES];
834
840 struct scale_factors sf_identity;
841
848 struct scale_factors ref_scale_factors[REF_FRAMES];
849
857 RefCntBuffer *ref_frame_map[REF_FRAMES];
858
864 int show_frame;
865
872 int showable_frame;
873
879 int show_existing_frame;
880
884 FeatureFlags features;
885
889 CommonModeInfoParams mi_params;
890
891 #if CONFIG_ENTROPY_STATS
895 int coef_cdf_category;
896 #endif // CONFIG_ENTROPY_STATS
897
901 CommonQuantParams quant_params;
902
906 struct segmentation seg;
907
911 uint8_t *last_frame_seg_map;
912
917 loop_filter_info_n lf_info;
918 struct loopfilter lf;
925 RestorationInfo rst_info[MAX_MB_PLANE];
926 int32_t *rst_tmpbuf;
927 RestorationLineBuffers *rlbs;
928 YV12_BUFFER_CONFIG rst_frame;
934 CdefInfo cdef_info;
935
939 aom_film_grain_t film_grain_params;
940
944 DeltaQInfo delta_q_info;
945
949 WarpedMotionParams global_motion[REF_FRAMES];
950
955 SequenceHeader seq_params;
956
960 FRAME_CONTEXT *fc;
966 FRAME_CONTEXT *default_frame_context;
967
971 CommonTileParams tiles;
972
976 BufferPool *buffer_pool;
977
984 CommonContexts above_contexts;
985
990 int current_frame_id;
991 int ref_frame_id[REF_FRAMES];
1001 TPL_MV_REF *tpl_mvs;
1005 int tpl_mvs_mem_size;
1010 int ref_frame_sign_bias[REF_FRAMES];
1016 int8_t ref_frame_side[REF_FRAMES];
1017
1021 unsigned int number_temporal_layers;
1026 int temporal_layer_id;
1027
1031 unsigned int number_spatial_layers;
1036 int spatial_layer_id;
1037
1038 #if TXCOEFF_TIMER
1039 int64_t cum_txcoeff_timer;
1040 int64_t txcoeff_timer;
1041 int txb_count;
1042 #endif // TXCOEFF_TIMER
1043
1044 #if TXCOEFF_COST_TIMER
1045 int64_t cum_txcoeff_cost_timer;
1046 int64_t txcoeff_cost_timer;
1047 int64_t txcoeff_cost_count;
1048 #endif // TXCOEFF_COST_TIMER
1049
1050 #if CONFIG_LPF_MASK
1051 int is_decoding;
1052 #endif // CONFIG_LPF_MASK
1053 } AV1_COMMON;
1054
1057 // TODO(hkuang): Don't need to lock the whole pool after implementing atomic
1058 // frame reference count.
1059 static void lock_buffer_pool(BufferPool *const pool) {
1060 #if CONFIG_MULTITHREAD
1061 pthread_mutex_lock(&pool->pool_mutex);
1062 #else
1063 (void)pool;
1064 #endif
1065 }
1066
1067 static void unlock_buffer_pool(BufferPool *const pool) {
1068 #if CONFIG_MULTITHREAD
1069 pthread_mutex_unlock(&pool->pool_mutex);
1070 #else
1071 (void)pool;
1072 #endif
1073 }
1074
1075 static INLINE YV12_BUFFER_CONFIG *get_ref_frame(AV1_COMMON *cm, int index) {
1076 if (index < 0 || index >= REF_FRAMES) return NULL;
1077 if (cm->ref_frame_map[index] == NULL) return NULL;
1078 return &cm->ref_frame_map[index]->buf;
1079 }
1080
1081 static INLINE int get_free_fb(AV1_COMMON *cm) {
1082 RefCntBuffer *const frame_bufs = cm->buffer_pool->frame_bufs;
1083 int i;
1084
1085 lock_buffer_pool(cm->buffer_pool);
1086 for (i = 0; i < FRAME_BUFFERS; ++i)
1087 if (frame_bufs[i].ref_count == 0) break;
1088
1089 if (i != FRAME_BUFFERS) {
1090 if (frame_bufs[i].buf.use_external_reference_buffers) {
1091 // If this frame buffer's y_buffer, u_buffer, and v_buffer point to the
1092 // external reference buffers. Restore the buffer pointers to point to the
1093 // internally allocated memory.
1094 YV12_BUFFER_CONFIG *ybf = &frame_bufs[i].buf;
1095 ybf->y_buffer = ybf->store_buf_adr[0];
1096 ybf->u_buffer = ybf->store_buf_adr[1];
1097 ybf->v_buffer = ybf->store_buf_adr[2];
1098 ybf->use_external_reference_buffers = 0;
1099 }
1100
1101 frame_bufs[i].ref_count = 1;
1102 } else {
1103 // We should never run out of free buffers. If this assertion fails, there
1104 // is a reference leak.
1105 assert(0 && "Ran out of free frame buffers. Likely a reference leak.");
1106 // Reset i to be INVALID_IDX to indicate no free buffer found.
1107 i = INVALID_IDX;
1108 }
1109
1110 unlock_buffer_pool(cm->buffer_pool);
1111 return i;
1112 }
1113
1114 static INLINE RefCntBuffer *assign_cur_frame_new_fb(AV1_COMMON *const cm) {
1115 // Release the previously-used frame-buffer
1116 if (cm->cur_frame != NULL) {
1117 --cm->cur_frame->ref_count;
1118 cm->cur_frame = NULL;
1119 }
1120
1121 // Assign a new framebuffer
1122 const int new_fb_idx = get_free_fb(cm);
1123 if (new_fb_idx == INVALID_IDX) return NULL;
1124
1125 cm->cur_frame = &cm->buffer_pool->frame_bufs[new_fb_idx];
1126 cm->cur_frame->buf.buf_8bit_valid = 0;
1127 av1_zero(cm->cur_frame->interp_filter_selected);
1128 return cm->cur_frame;
1129 }
1130
1131 // Modify 'lhs_ptr' to reference the buffer at 'rhs_ptr', and update the ref
1132 // counts accordingly.
1133 static INLINE void assign_frame_buffer_p(RefCntBuffer **lhs_ptr,
1134 RefCntBuffer *rhs_ptr) {
1135 RefCntBuffer *const old_ptr = *lhs_ptr;
1136 if (old_ptr != NULL) {
1137 assert(old_ptr->ref_count > 0);
1138 // One less reference to the buffer at 'old_ptr', so decrease ref count.
1139 --old_ptr->ref_count;
1140 }
1141
1142 *lhs_ptr = rhs_ptr;
1143 // One more reference to the buffer at 'rhs_ptr', so increase ref count.
1144 ++rhs_ptr->ref_count;
1145 }
1146
1147 static INLINE int frame_is_intra_only(const AV1_COMMON *const cm) {
1148 return cm->current_frame.frame_type == KEY_FRAME ||
1149 cm->current_frame.frame_type == INTRA_ONLY_FRAME;
1150 }
1151
1152 static INLINE int frame_is_sframe(const AV1_COMMON *cm) {
1153 return cm->current_frame.frame_type == S_FRAME;
1154 }
1155
1156 // These functions take a reference frame label between LAST_FRAME and
1157 // EXTREF_FRAME inclusive. Note that this is different to the indexing
1158 // previously used by the frame_refs[] array.
1159 static INLINE int get_ref_frame_map_idx(const AV1_COMMON *const cm,
1160 const MV_REFERENCE_FRAME ref_frame) {
1161 return (ref_frame >= LAST_FRAME && ref_frame <= EXTREF_FRAME)
1162 ? cm->remapped_ref_idx[ref_frame - LAST_FRAME]
1163 : INVALID_IDX;
1164 }
1165
1166 static INLINE RefCntBuffer *get_ref_frame_buf(
1167 const AV1_COMMON *const cm, const MV_REFERENCE_FRAME ref_frame) {
1168 const int map_idx = get_ref_frame_map_idx(cm, ref_frame);
1169 return (map_idx != INVALID_IDX) ? cm->ref_frame_map[map_idx] : NULL;
1170 }
1171
1172 // Both const and non-const versions of this function are provided so that it
1173 // can be used with a const AV1_COMMON if needed.
1174 static INLINE const struct scale_factors *get_ref_scale_factors_const(
1175 const AV1_COMMON *const cm, const MV_REFERENCE_FRAME ref_frame) {
1176 const int map_idx = get_ref_frame_map_idx(cm, ref_frame);
1177 return (map_idx != INVALID_IDX) ? &cm->ref_scale_factors[map_idx] : NULL;
1178 }
1179
1180 static INLINE struct scale_factors *get_ref_scale_factors(
1181 AV1_COMMON *const cm, const MV_REFERENCE_FRAME ref_frame) {
1182 const int map_idx = get_ref_frame_map_idx(cm, ref_frame);
1183 return (map_idx != INVALID_IDX) ? &cm->ref_scale_factors[map_idx] : NULL;
1184 }
1185
1186 static INLINE RefCntBuffer *get_primary_ref_frame_buf(
1187 const AV1_COMMON *const cm) {
1188 const int primary_ref_frame = cm->features.primary_ref_frame;
1189 if (primary_ref_frame == PRIMARY_REF_NONE) return NULL;
1190 const int map_idx = get_ref_frame_map_idx(cm, primary_ref_frame + 1);
1191 return (map_idx != INVALID_IDX) ? cm->ref_frame_map[map_idx] : NULL;
1192 }
1193
1194 // Returns 1 if this frame might allow mvs from some reference frame.
1195 static INLINE int frame_might_allow_ref_frame_mvs(const AV1_COMMON *cm) {
1196 return !cm->features.error_resilient_mode &&
1197 cm->seq_params.order_hint_info.enable_ref_frame_mvs &&
1198 cm->seq_params.order_hint_info.enable_order_hint &&
1199 !frame_is_intra_only(cm);
1200 }
1201
1202 // Returns 1 if this frame might use warped_motion
1203 static INLINE int frame_might_allow_warped_motion(const AV1_COMMON *cm) {
1204 return !cm->features.error_resilient_mode && !frame_is_intra_only(cm) &&
1205 cm->seq_params.enable_warped_motion;
1206 }
1207
1208 static INLINE void ensure_mv_buffer(RefCntBuffer *buf, AV1_COMMON *cm) {
1209 const int buf_rows = buf->mi_rows;
1210 const int buf_cols = buf->mi_cols;
1211 const CommonModeInfoParams *const mi_params = &cm->mi_params;
1212
1213 if (buf->mvs == NULL || buf_rows != mi_params->mi_rows ||
1214 buf_cols != mi_params->mi_cols) {
1215 aom_free(buf->mvs);
1216 buf->mi_rows = mi_params->mi_rows;
1217 buf->mi_cols = mi_params->mi_cols;
1218 CHECK_MEM_ERROR(cm, buf->mvs,
1219 (MV_REF *)aom_calloc(((mi_params->mi_rows + 1) >> 1) *
1220 ((mi_params->mi_cols + 1) >> 1),
1221 sizeof(*buf->mvs)));
1222 aom_free(buf->seg_map);
1223 CHECK_MEM_ERROR(
1224 cm, buf->seg_map,
1225 (uint8_t *)aom_calloc(mi_params->mi_rows * mi_params->mi_cols,
1226 sizeof(*buf->seg_map)));
1227 }
1228
1229 const int mem_size =
1230 ((mi_params->mi_rows + MAX_MIB_SIZE) >> 1) * (mi_params->mi_stride >> 1);
1231 int realloc = cm->tpl_mvs == NULL;
1232 if (cm->tpl_mvs) realloc |= cm->tpl_mvs_mem_size < mem_size;
1233
1234 if (realloc) {
1235 aom_free(cm->tpl_mvs);
1236 CHECK_MEM_ERROR(cm, cm->tpl_mvs,
1237 (TPL_MV_REF *)aom_calloc(mem_size, sizeof(*cm->tpl_mvs)));
1238 cm->tpl_mvs_mem_size = mem_size;
1239 }
1240 }
1241
1242 void cfl_init(CFL_CTX *cfl, const SequenceHeader *seq_params);
1243
1244 static INLINE int av1_num_planes(const AV1_COMMON *cm) {
1245 return cm->seq_params.monochrome ? 1 : MAX_MB_PLANE;
1246 }
1247
1248 static INLINE void av1_init_above_context(CommonContexts *above_contexts,
1249 int num_planes, int tile_row,
1250 MACROBLOCKD *xd) {
1251 for (int i = 0; i < num_planes; ++i) {
1252 xd->above_entropy_context[i] = above_contexts->entropy[i][tile_row];
1253 }
1254 xd->above_partition_context = above_contexts->partition[tile_row];
1255 xd->above_txfm_context = above_contexts->txfm[tile_row];
1256 }
1257
1258 static INLINE void av1_init_macroblockd(AV1_COMMON *cm, MACROBLOCKD *xd) {
1259 const int num_planes = av1_num_planes(cm);
1260 const CommonQuantParams *const quant_params = &cm->quant_params;
1261
1262 for (int i = 0; i < num_planes; ++i) {
1263 if (xd->plane[i].plane_type == PLANE_TYPE_Y) {
1264 memcpy(xd->plane[i].seg_dequant_QTX, quant_params->y_dequant_QTX,
1265 sizeof(quant_params->y_dequant_QTX));
1266 memcpy(xd->plane[i].seg_iqmatrix, quant_params->y_iqmatrix,
1267 sizeof(quant_params->y_iqmatrix));
1268
1269 } else {
1270 if (i == AOM_PLANE_U) {
1271 memcpy(xd->plane[i].seg_dequant_QTX, quant_params->u_dequant_QTX,
1272 sizeof(quant_params->u_dequant_QTX));
1273 memcpy(xd->plane[i].seg_iqmatrix, quant_params->u_iqmatrix,
1274 sizeof(quant_params->u_iqmatrix));
1275 } else {
1276 memcpy(xd->plane[i].seg_dequant_QTX, quant_params->v_dequant_QTX,
1277 sizeof(quant_params->v_dequant_QTX));
1278 memcpy(xd->plane[i].seg_iqmatrix, quant_params->v_iqmatrix,
1279 sizeof(quant_params->v_iqmatrix));
1280 }
1281 }
1282 }
1283 xd->mi_stride = cm->mi_params.mi_stride;
1284 xd->error_info = &cm->error;
1285 cfl_init(&xd->cfl, &cm->seq_params);
1286 }
1287
1288 static INLINE void set_entropy_context(MACROBLOCKD *xd, int mi_row, int mi_col,
1289 const int num_planes) {
1290 int i;
1291 int row_offset = mi_row;
1292 int col_offset = mi_col;
1293 for (i = 0; i < num_planes; ++i) {
1294 struct macroblockd_plane *const pd = &xd->plane[i];
1295 // Offset the buffer pointer
1296 const BLOCK_SIZE bsize = xd->mi[0]->bsize;
1297 if (pd->subsampling_y && (mi_row & 0x01) && (mi_size_high[bsize] == 1))
1298 row_offset = mi_row - 1;
1299 if (pd->subsampling_x && (mi_col & 0x01) && (mi_size_wide[bsize] == 1))
1300 col_offset = mi_col - 1;
1301 int above_idx = col_offset;
1302 int left_idx = row_offset & MAX_MIB_MASK;
1303 pd->above_entropy_context =
1304 &xd->above_entropy_context[i][above_idx >> pd->subsampling_x];
1305 pd->left_entropy_context =
1306 &xd->left_entropy_context[i][left_idx >> pd->subsampling_y];
1307 }
1308 }
1309
1310 static INLINE int calc_mi_size(int len) {
1311 // len is in mi units. Align to a multiple of SBs.
1312 return ALIGN_POWER_OF_TWO(len, MAX_MIB_SIZE_LOG2);
1313 }
1314
1315 static INLINE void set_plane_n4(MACROBLOCKD *const xd, int bw, int bh,
1316 const int num_planes) {
1317 int i;
1318 for (i = 0; i < num_planes; i++) {
1319 xd->plane[i].width = (bw * MI_SIZE) >> xd->plane[i].subsampling_x;
1320 xd->plane[i].height = (bh * MI_SIZE) >> xd->plane[i].subsampling_y;
1321
1322 xd->plane[i].width = AOMMAX(xd->plane[i].width, 4);
1323 xd->plane[i].height = AOMMAX(xd->plane[i].height, 4);
1324 }
1325 }
1326
1327 static INLINE void set_mi_row_col(MACROBLOCKD *xd, const TileInfo *const tile,
1328 int mi_row, int bh, int mi_col, int bw,
1329 int mi_rows, int mi_cols) {
1330 xd->mb_to_top_edge = -GET_MV_SUBPEL(mi_row * MI_SIZE);
1331 xd->mb_to_bottom_edge = GET_MV_SUBPEL((mi_rows - bh - mi_row) * MI_SIZE);
1332 xd->mb_to_left_edge = -GET_MV_SUBPEL((mi_col * MI_SIZE));
1333 xd->mb_to_right_edge = GET_MV_SUBPEL((mi_cols - bw - mi_col) * MI_SIZE);
1334
1335 xd->mi_row = mi_row;
1336 xd->mi_col = mi_col;
1337
1338 // Are edges available for intra prediction?
1339 xd->up_available = (mi_row > tile->mi_row_start);
1340
1341 const int ss_x = xd->plane[1].subsampling_x;
1342 const int ss_y = xd->plane[1].subsampling_y;
1343
1344 xd->left_available = (mi_col > tile->mi_col_start);
1345 xd->chroma_up_available = xd->up_available;
1346 xd->chroma_left_available = xd->left_available;
1347 if (ss_x && bw < mi_size_wide[BLOCK_8X8])
1348 xd->chroma_left_available = (mi_col - 1) > tile->mi_col_start;
1349 if (ss_y && bh < mi_size_high[BLOCK_8X8])
1350 xd->chroma_up_available = (mi_row - 1) > tile->mi_row_start;
1351 if (xd->up_available) {
1352 xd->above_mbmi = xd->mi[-xd->mi_stride];
1353 } else {
1354 xd->above_mbmi = NULL;
1355 }
1356
1357 if (xd->left_available) {
1358 xd->left_mbmi = xd->mi[-1];
1359 } else {
1360 xd->left_mbmi = NULL;
1361 }
1362
1363 const int chroma_ref = ((mi_row & 0x01) || !(bh & 0x01) || !ss_y) &&
1364 ((mi_col & 0x01) || !(bw & 0x01) || !ss_x);
1365 xd->is_chroma_ref = chroma_ref;
1366 if (chroma_ref) {
1367 // To help calculate the "above" and "left" chroma blocks, note that the
1368 // current block may cover multiple luma blocks (eg, if partitioned into
1369 // 4x4 luma blocks).
1370 // First, find the top-left-most luma block covered by this chroma block
1371 MB_MODE_INFO **base_mi =
1372 &xd->mi[-(mi_row & ss_y) * xd->mi_stride - (mi_col & ss_x)];
1373
1374 // Then, we consider the luma region covered by the left or above 4x4 chroma
1375 // prediction. We want to point to the chroma reference block in that
1376 // region, which is the bottom-right-most mi unit.
1377 // This leads to the following offsets:
1378 MB_MODE_INFO *chroma_above_mi =
1379 xd->chroma_up_available ? base_mi[-xd->mi_stride + ss_x] : NULL;
1380 xd->chroma_above_mbmi = chroma_above_mi;
1381
1382 MB_MODE_INFO *chroma_left_mi =
1383 xd->chroma_left_available ? base_mi[ss_y * xd->mi_stride - 1] : NULL;
1384 xd->chroma_left_mbmi = chroma_left_mi;
1385 }
1386
1387 xd->height = bh;
1388 xd->width = bw;
1389
1390 xd->is_last_vertical_rect = 0;
1391 if (xd->width < xd->height) {
1392 if (!((mi_col + xd->width) & (xd->height - 1))) {
1393 xd->is_last_vertical_rect = 1;
1394 }
1395 }
1396
1397 xd->is_first_horizontal_rect = 0;
1398 if (xd->width > xd->height)
1399 if (!(mi_row & (xd->width - 1))) xd->is_first_horizontal_rect = 1;
1400 }
1401
1402 static INLINE aom_cdf_prob *get_y_mode_cdf(FRAME_CONTEXT *tile_ctx,
1403 const MB_MODE_INFO *above_mi,
1404 const MB_MODE_INFO *left_mi) {
1405 const PREDICTION_MODE above = av1_above_block_mode(above_mi);
1406 const PREDICTION_MODE left = av1_left_block_mode(left_mi);
1407 const int above_ctx = intra_mode_context[above];
1408 const int left_ctx = intra_mode_context[left];
1409 return tile_ctx->kf_y_cdf[above_ctx][left_ctx];
1410 }
1411
1412 static INLINE void update_partition_context(MACROBLOCKD *xd, int mi_row,
1413 int mi_col, BLOCK_SIZE subsize,
1414 BLOCK_SIZE bsize) {
1415 PARTITION_CONTEXT *const above_ctx = xd->above_partition_context + mi_col;
1416 PARTITION_CONTEXT *const left_ctx =
1417 xd->left_partition_context + (mi_row & MAX_MIB_MASK);
1418
1419 const int bw = mi_size_wide[bsize];
1420 const int bh = mi_size_high[bsize];
1421 memset(above_ctx, partition_context_lookup[subsize].above, bw);
1422 memset(left_ctx, partition_context_lookup[subsize].left, bh);
1423 }
1424
1425 static INLINE int is_chroma_reference(int mi_row, int mi_col, BLOCK_SIZE bsize,
1426 int subsampling_x, int subsampling_y) {
1427 assert(bsize < BLOCK_SIZES_ALL);
1428 const int bw = mi_size_wide[bsize];
1429 const int bh = mi_size_high[bsize];
1430 int ref_pos = ((mi_row & 0x01) || !(bh & 0x01) || !subsampling_y) &&
1431 ((mi_col & 0x01) || !(bw & 0x01) || !subsampling_x);
1432 return ref_pos;
1433 }
1434
1435 static INLINE aom_cdf_prob cdf_element_prob(const aom_cdf_prob *cdf,
1436 size_t element) {
1437 assert(cdf != NULL);
1438 return (element > 0 ? cdf[element - 1] : CDF_PROB_TOP) - cdf[element];
1439 }
1440
1441 static INLINE void partition_gather_horz_alike(aom_cdf_prob *out,
1442 const aom_cdf_prob *const in,
1443 BLOCK_SIZE bsize) {
1444 (void)bsize;
1445 out[0] = CDF_PROB_TOP;
1446 out[0] -= cdf_element_prob(in, PARTITION_HORZ);
1447 out[0] -= cdf_element_prob(in, PARTITION_SPLIT);
1448 out[0] -= cdf_element_prob(in, PARTITION_HORZ_A);
1449 out[0] -= cdf_element_prob(in, PARTITION_HORZ_B);
1450 out[0] -= cdf_element_prob(in, PARTITION_VERT_A);
1451 if (bsize != BLOCK_128X128) out[0] -= cdf_element_prob(in, PARTITION_HORZ_4);
1452 out[0] = AOM_ICDF(out[0]);
1453 out[1] = AOM_ICDF(CDF_PROB_TOP);
1454 }
1455
1456 static INLINE void partition_gather_vert_alike(aom_cdf_prob *out,
1457 const aom_cdf_prob *const in,
1458 BLOCK_SIZE bsize) {
1459 (void)bsize;
1460 out[0] = CDF_PROB_TOP;
1461 out[0] -= cdf_element_prob(in, PARTITION_VERT);
1462 out[0] -= cdf_element_prob(in, PARTITION_SPLIT);
1463 out[0] -= cdf_element_prob(in, PARTITION_HORZ_A);
1464 out[0] -= cdf_element_prob(in, PARTITION_VERT_A);
1465 out[0] -= cdf_element_prob(in, PARTITION_VERT_B);
1466 if (bsize != BLOCK_128X128) out[0] -= cdf_element_prob(in, PARTITION_VERT_4);
1467 out[0] = AOM_ICDF(out[0]);
1468 out[1] = AOM_ICDF(CDF_PROB_TOP);
1469 }
1470
1471 static INLINE void update_ext_partition_context(MACROBLOCKD *xd, int mi_row,
1472 int mi_col, BLOCK_SIZE subsize,
1473 BLOCK_SIZE bsize,
1474 PARTITION_TYPE partition) {
1475 if (bsize >= BLOCK_8X8) {
1476 const int hbs = mi_size_wide[bsize] / 2;
1477 BLOCK_SIZE bsize2 = get_partition_subsize(bsize, PARTITION_SPLIT);
1478 switch (partition) {
1479 case PARTITION_SPLIT:
1480 if (bsize != BLOCK_8X8) break;
1481 AOM_FALLTHROUGH_INTENDED;
1482 case PARTITION_NONE:
1483 case PARTITION_HORZ:
1484 case PARTITION_VERT:
1485 case PARTITION_HORZ_4:
1486 case PARTITION_VERT_4:
1487 update_partition_context(xd, mi_row, mi_col, subsize, bsize);
1488 break;
1489 case PARTITION_HORZ_A:
1490 update_partition_context(xd, mi_row, mi_col, bsize2, subsize);
1491 update_partition_context(xd, mi_row + hbs, mi_col, subsize, subsize);
1492 break;
1493 case PARTITION_HORZ_B:
1494 update_partition_context(xd, mi_row, mi_col, subsize, subsize);
1495 update_partition_context(xd, mi_row + hbs, mi_col, bsize2, subsize);
1496 break;
1497 case PARTITION_VERT_A:
1498 update_partition_context(xd, mi_row, mi_col, bsize2, subsize);
1499 update_partition_context(xd, mi_row, mi_col + hbs, subsize, subsize);
1500 break;
1501 case PARTITION_VERT_B:
1502 update_partition_context(xd, mi_row, mi_col, subsize, subsize);
1503 update_partition_context(xd, mi_row, mi_col + hbs, bsize2, subsize);
1504 break;
1505 default: assert(0 && "Invalid partition type");
1506 }
1507 }
1508 }
1509
1510 static INLINE int partition_plane_context(const MACROBLOCKD *xd, int mi_row,
1511 int mi_col, BLOCK_SIZE bsize) {
1512 const PARTITION_CONTEXT *above_ctx = xd->above_partition_context + mi_col;
1513 const PARTITION_CONTEXT *left_ctx =
1514 xd->left_partition_context + (mi_row & MAX_MIB_MASK);
1515 // Minimum partition point is 8x8. Offset the bsl accordingly.
1516 const int bsl = mi_size_wide_log2[bsize] - mi_size_wide_log2[BLOCK_8X8];
1517 int above = (*above_ctx >> bsl) & 1, left = (*left_ctx >> bsl) & 1;
1518
1519 assert(mi_size_wide_log2[bsize] == mi_size_high_log2[bsize]);
1520 assert(bsl >= 0);
1521
1522 return (left * 2 + above) + bsl * PARTITION_PLOFFSET;
1523 }
1524
1525 // Return the number of elements in the partition CDF when
1526 // partitioning the (square) block with luma block size of bsize.
1527 static INLINE int partition_cdf_length(BLOCK_SIZE bsize) {
1528 if (bsize <= BLOCK_8X8)
1529 return PARTITION_TYPES;
1530 else if (bsize == BLOCK_128X128)
1531 return EXT_PARTITION_TYPES - 2;
1532 else
1533 return EXT_PARTITION_TYPES;
1534 }
1535
1536 static INLINE int max_block_wide(const MACROBLOCKD *xd, BLOCK_SIZE bsize,
1537 int plane) {
1538 assert(bsize < BLOCK_SIZES_ALL);
1539 int max_blocks_wide = block_size_wide[bsize];
1540
1541 if (xd->mb_to_right_edge < 0) {
1542 const struct macroblockd_plane *const pd = &xd->plane[plane];
1543 max_blocks_wide += xd->mb_to_right_edge >> (3 + pd->subsampling_x);
1544 }
1545
1546 // Scale the width in the transform block unit.
1547 return max_blocks_wide >> MI_SIZE_LOG2;
1548 }
1549
1550 static INLINE int max_block_high(const MACROBLOCKD *xd, BLOCK_SIZE bsize,
1551 int plane) {
1552 int max_blocks_high = block_size_high[bsize];
1553
1554 if (xd->mb_to_bottom_edge < 0) {
1555 const struct macroblockd_plane *const pd = &xd->plane[plane];
1556 max_blocks_high += xd->mb_to_bottom_edge >> (3 + pd->subsampling_y);
1557 }
1558
1559 // Scale the height in the transform block unit.
1560 return max_blocks_high >> MI_SIZE_LOG2;
1561 }
1562
1563 static INLINE void av1_zero_above_context(AV1_COMMON *const cm,
1564 const MACROBLOCKD *xd,
1565 int mi_col_start, int mi_col_end,
1566 const int tile_row) {
1567 const SequenceHeader *const seq_params = &cm->seq_params;
1568 const int num_planes = av1_num_planes(cm);
1569 const int width = mi_col_end - mi_col_start;
1570 const int aligned_width =
1571 ALIGN_POWER_OF_TWO(width, seq_params->mib_size_log2);
1572 const int offset_y = mi_col_start;
1573 const int width_y = aligned_width;
1574 const int offset_uv = offset_y >> seq_params->subsampling_x;
1575 const int width_uv = width_y >> seq_params->subsampling_x;
1576 CommonContexts *const above_contexts = &cm->above_contexts;
1577
1578 av1_zero_array(above_contexts->entropy[0][tile_row] + offset_y, width_y);
1579 if (num_planes > 1) {
1580 if (above_contexts->entropy[1][tile_row] &&
1581 above_contexts->entropy[2][tile_row]) {
1582 av1_zero_array(above_contexts->entropy[1][tile_row] + offset_uv,
1583 width_uv);
1584 av1_zero_array(above_contexts->entropy[2][tile_row] + offset_uv,
1585 width_uv);
1586 } else {
1587 aom_internal_error(xd->error_info, AOM_CODEC_CORRUPT_FRAME,
1588 "Invalid value of planes");
1589 }
1590 }
1591
1592 av1_zero_array(above_contexts->partition[tile_row] + mi_col_start,
1593 aligned_width);
1594
1595 memset(above_contexts->txfm[tile_row] + mi_col_start,
1596 tx_size_wide[TX_SIZES_LARGEST], aligned_width * sizeof(TXFM_CONTEXT));
1597 }
1598
1599 static INLINE void av1_zero_left_context(MACROBLOCKD *const xd) {
1600 av1_zero(xd->left_entropy_context);
1601 av1_zero(xd->left_partition_context);
1602
1603 memset(xd->left_txfm_context_buffer, tx_size_high[TX_SIZES_LARGEST],
1604 sizeof(xd->left_txfm_context_buffer));
1605 }
1606
1607 // Disable array-bounds checks as the TX_SIZE enum contains values larger than
1608 // TX_SIZES_ALL (TX_INVALID) which make extending the array as a workaround
1609 // infeasible. The assert is enough for static analysis and this or other tools
1610 // asan, valgrind would catch oob access at runtime.
1611 #if defined(__GNUC__) && __GNUC__ >= 4
1612 #pragma GCC diagnostic ignored "-Warray-bounds"
1613 #endif
1614
1615 #if defined(__GNUC__) && __GNUC__ >= 4
1616 #pragma GCC diagnostic warning "-Warray-bounds"
1617 #endif
1618
1619 static INLINE void set_txfm_ctx(TXFM_CONTEXT *txfm_ctx, uint8_t txs, int len) {
1620 int i;
1621 for (i = 0; i < len; ++i) txfm_ctx[i] = txs;
1622 }
1623
1624 static INLINE void set_txfm_ctxs(TX_SIZE tx_size, int n4_w, int n4_h, int skip,
1625 const MACROBLOCKD *xd) {
1626 uint8_t bw = tx_size_wide[tx_size];
1627 uint8_t bh = tx_size_high[tx_size];
1628
1629 if (skip) {
1630 bw = n4_w * MI_SIZE;
1631 bh = n4_h * MI_SIZE;
1632 }
1633
1634 set_txfm_ctx(xd->above_txfm_context, bw, n4_w);
1635 set_txfm_ctx(xd->left_txfm_context, bh, n4_h);
1636 }
1637
1638 static INLINE int get_mi_grid_idx(const CommonModeInfoParams *const mi_params,
1639 int mi_row, int mi_col) {
1640 return mi_row * mi_params->mi_stride + mi_col;
1641 }
1642
1643 static INLINE int get_alloc_mi_idx(const CommonModeInfoParams *const mi_params,
1644 int mi_row, int mi_col) {
1645 const int mi_alloc_size_1d = mi_size_wide[mi_params->mi_alloc_bsize];
1646 const int mi_alloc_row = mi_row / mi_alloc_size_1d;
1647 const int mi_alloc_col = mi_col / mi_alloc_size_1d;
1648
1649 return mi_alloc_row * mi_params->mi_alloc_stride + mi_alloc_col;
1650 }
1651
1652 // For this partition block, set pointers in mi_params->mi_grid_base and xd->mi.
1653 static INLINE void set_mi_offsets(const CommonModeInfoParams *const mi_params,
1654 MACROBLOCKD *const xd, int mi_row,
1655 int mi_col) {
1656 // 'mi_grid_base' should point to appropriate memory in 'mi'.
1657 const int mi_grid_idx = get_mi_grid_idx(mi_params, mi_row, mi_col);
1658 const int mi_alloc_idx = get_alloc_mi_idx(mi_params, mi_row, mi_col);
1659 mi_params->mi_grid_base[mi_grid_idx] = &mi_params->mi_alloc[mi_alloc_idx];
1660 // 'xd->mi' should point to an offset in 'mi_grid_base';
1661 xd->mi = mi_params->mi_grid_base + mi_grid_idx;
1662 // 'xd->tx_type_map' should point to an offset in 'mi_params->tx_type_map'.
1663 xd->tx_type_map = mi_params->tx_type_map + mi_grid_idx;
1664 xd->tx_type_map_stride = mi_params->mi_stride;
1665 }
1666
1667 static INLINE void txfm_partition_update(TXFM_CONTEXT *above_ctx,
1668 TXFM_CONTEXT *left_ctx,
1669 TX_SIZE tx_size, TX_SIZE txb_size) {
1670 BLOCK_SIZE bsize = txsize_to_bsize[txb_size];
1671 int bh = mi_size_high[bsize];
1672 int bw = mi_size_wide[bsize];
1673 uint8_t txw = tx_size_wide[tx_size];
1674 uint8_t txh = tx_size_high[tx_size];
1675 int i;
1676 for (i = 0; i < bh; ++i) left_ctx[i] = txh;
1677 for (i = 0; i < bw; ++i) above_ctx[i] = txw;
1678 }
1679
1680 static INLINE TX_SIZE get_sqr_tx_size(int tx_dim) {
1681 switch (tx_dim) {
1682 case 128:
1683 case 64: return TX_64X64; break;
1684 case 32: return TX_32X32; break;
1685 case 16: return TX_16X16; break;
1686 case 8: return TX_8X8; break;
1687 default: return TX_4X4;
1688 }
1689 }
1690
1691 static INLINE TX_SIZE get_tx_size(int width, int height) {
1692 if (width == height) {
1693 return get_sqr_tx_size(width);
1694 }
1695 if (width < height) {
1696 if (width + width == height) {
1697 switch (width) {
1698 case 4: return TX_4X8; break;
1699 case 8: return TX_8X16; break;
1700 case 16: return TX_16X32; break;
1701 case 32: return TX_32X64; break;
1702 }
1703 } else {
1704 switch (width) {
1705 case 4: return TX_4X16; break;
1706 case 8: return TX_8X32; break;
1707 case 16: return TX_16X64; break;
1708 }
1709 }
1710 } else {
1711 if (height + height == width) {
1712 switch (height) {
1713 case 4: return TX_8X4; break;
1714 case 8: return TX_16X8; break;
1715 case 16: return TX_32X16; break;
1716 case 32: return TX_64X32; break;
1717 }
1718 } else {
1719 switch (height) {
1720 case 4: return TX_16X4; break;
1721 case 8: return TX_32X8; break;
1722 case 16: return TX_64X16; break;
1723 }
1724 }
1725 }
1726 assert(0);
1727 return TX_4X4;
1728 }
1729
1730 static INLINE int txfm_partition_context(const TXFM_CONTEXT *const above_ctx,
1731 const TXFM_CONTEXT *const left_ctx,
1732 BLOCK_SIZE bsize, TX_SIZE tx_size) {
1733 const uint8_t txw = tx_size_wide[tx_size];
1734 const uint8_t txh = tx_size_high[tx_size];
1735 const int above = *above_ctx < txw;
1736 const int left = *left_ctx < txh;
1737 int category = TXFM_PARTITION_CONTEXTS;
1738
1739 // dummy return, not used by others.
1740 if (tx_size <= TX_4X4) return 0;
1741
1742 TX_SIZE max_tx_size =
1743 get_sqr_tx_size(AOMMAX(block_size_wide[bsize], block_size_high[bsize]));
1744
1745 if (max_tx_size >= TX_8X8) {
1746 category =
1747 (txsize_sqr_up_map[tx_size] != max_tx_size && max_tx_size > TX_8X8) +
1748 (TX_SIZES - 1 - max_tx_size) * 2;
1749 }
1750 assert(category != TXFM_PARTITION_CONTEXTS);
1751 return category * 3 + above + left;
1752 }
1753
1754 // Compute the next partition in the direction of the sb_type stored in the mi
1755 // array, starting with bsize.
1756 static INLINE PARTITION_TYPE get_partition(const AV1_COMMON *const cm,
1757 int mi_row, int mi_col,
1758 BLOCK_SIZE bsize) {
1759 const CommonModeInfoParams *const mi_params = &cm->mi_params;
1760 if (mi_row >= mi_params->mi_rows || mi_col >= mi_params->mi_cols)
1761 return PARTITION_INVALID;
1762
1763 const int offset = mi_row * mi_params->mi_stride + mi_col;
1764 MB_MODE_INFO **mi = mi_params->mi_grid_base + offset;
1765 const BLOCK_SIZE subsize = mi[0]->bsize;
1766
1767 assert(bsize < BLOCK_SIZES_ALL);
1768
1769 if (subsize == bsize) return PARTITION_NONE;
1770
1771 const int bhigh = mi_size_high[bsize];
1772 const int bwide = mi_size_wide[bsize];
1773 const int sshigh = mi_size_high[subsize];
1774 const int sswide = mi_size_wide[subsize];
1775
1776 if (bsize > BLOCK_8X8 && mi_row + bwide / 2 < mi_params->mi_rows &&
1777 mi_col + bhigh / 2 < mi_params->mi_cols) {
1778 // In this case, the block might be using an extended partition
1779 // type.
1780 const MB_MODE_INFO *const mbmi_right = mi[bwide / 2];
1781 const MB_MODE_INFO *const mbmi_below = mi[bhigh / 2 * mi_params->mi_stride];
1782
1783 if (sswide == bwide) {
1784 // Smaller height but same width. Is PARTITION_HORZ_4, PARTITION_HORZ or
1785 // PARTITION_HORZ_B. To distinguish the latter two, check if the lower
1786 // half was split.
1787 if (sshigh * 4 == bhigh) return PARTITION_HORZ_4;
1788 assert(sshigh * 2 == bhigh);
1789
1790 if (mbmi_below->bsize == subsize)
1791 return PARTITION_HORZ;
1792 else
1793 return PARTITION_HORZ_B;
1794 } else if (sshigh == bhigh) {
1795 // Smaller width but same height. Is PARTITION_VERT_4, PARTITION_VERT or
1796 // PARTITION_VERT_B. To distinguish the latter two, check if the right
1797 // half was split.
1798 if (sswide * 4 == bwide) return PARTITION_VERT_4;
1799 assert(sswide * 2 == bhigh);
1800
1801 if (mbmi_right->bsize == subsize)
1802 return PARTITION_VERT;
1803 else
1804 return PARTITION_VERT_B;
1805 } else {
1806 // Smaller width and smaller height. Might be PARTITION_SPLIT or could be
1807 // PARTITION_HORZ_A or PARTITION_VERT_A. If subsize isn't halved in both
1808 // dimensions, we immediately know this is a split (which will recurse to
1809 // get to subsize). Otherwise look down and to the right. With
1810 // PARTITION_VERT_A, the right block will have height bhigh; with
1811 // PARTITION_HORZ_A, the lower block with have width bwide. Otherwise
1812 // it's PARTITION_SPLIT.
1813 if (sswide * 2 != bwide || sshigh * 2 != bhigh) return PARTITION_SPLIT;
1814
1815 if (mi_size_wide[mbmi_below->bsize] == bwide) return PARTITION_HORZ_A;
1816 if (mi_size_high[mbmi_right->bsize] == bhigh) return PARTITION_VERT_A;
1817
1818 return PARTITION_SPLIT;
1819 }
1820 }
1821 const int vert_split = sswide < bwide;
1822 const int horz_split = sshigh < bhigh;
1823 const int split_idx = (vert_split << 1) | horz_split;
1824 assert(split_idx != 0);
1825
1826 static const PARTITION_TYPE base_partitions[4] = {
1827 PARTITION_INVALID, PARTITION_HORZ, PARTITION_VERT, PARTITION_SPLIT
1828 };
1829
1830 return base_partitions[split_idx];
1831 }
1832
1833 static INLINE void set_sb_size(SequenceHeader *const seq_params,
1834 BLOCK_SIZE sb_size) {
1835 seq_params->sb_size = sb_size;
1836 seq_params->mib_size = mi_size_wide[seq_params->sb_size];
1837 seq_params->mib_size_log2 = mi_size_wide_log2[seq_params->sb_size];
1838 }
1839
1840 // Returns true if the frame is fully lossless at the coded resolution.
1841 // Note: If super-resolution is used, such a frame will still NOT be lossless at
1842 // the upscaled resolution.
1843 static INLINE int is_coded_lossless(const AV1_COMMON *cm,
1844 const MACROBLOCKD *xd) {
1845 int coded_lossless = 1;
1846 if (cm->seg.enabled) {
1847 for (int i = 0; i < MAX_SEGMENTS; ++i) {
1848 if (!xd->lossless[i]) {
1849 coded_lossless = 0;
1850 break;
1851 }
1852 }
1853 } else {
1854 coded_lossless = xd->lossless[0];
1855 }
1856 return coded_lossless;
1857 }
1858
1859 static INLINE int is_valid_seq_level_idx(AV1_LEVEL seq_level_idx) {
1860 return seq_level_idx == SEQ_LEVEL_MAX ||
1861 (seq_level_idx < SEQ_LEVELS &&
1862 // The following levels are currently undefined.
1863 seq_level_idx != SEQ_LEVEL_2_2 && seq_level_idx != SEQ_LEVEL_2_3 &&
1864 seq_level_idx != SEQ_LEVEL_3_2 && seq_level_idx != SEQ_LEVEL_3_3 &&
1865 seq_level_idx != SEQ_LEVEL_4_2 && seq_level_idx != SEQ_LEVEL_4_3 &&
1866 seq_level_idx != SEQ_LEVEL_7_0 && seq_level_idx != SEQ_LEVEL_7_1 &&
1867 seq_level_idx != SEQ_LEVEL_7_2 && seq_level_idx != SEQ_LEVEL_7_3);
1868 }
1869
1872 #ifdef __cplusplus
1873 } // extern "C"
1874 #endif
1875
1876 #endif // AOM_AV1_COMMON_AV1_COMMON_INT_H_
aom_get_frame_buffer_cb_fn_t
int(* aom_get_frame_buffer_cb_fn_t)(void *priv, size_t min_size, aom_codec_frame_buffer_t *fb)
get frame buffer callback prototype
Definition: aom_frame_buffer.h:64
aom_release_frame_buffer_cb_fn_t
int(* aom_release_frame_buffer_cb_fn_t)(void *priv, aom_codec_frame_buffer_t *fb)
release frame buffer callback prototype
Definition: aom_frame_buffer.h:77
AOM_PLANE_U
#define AOM_PLANE_U
Definition: aom_image.h:200
aom_chroma_sample_position_t
enum aom_chroma_sample_position aom_chroma_sample_position_t
List of chroma sample positions.
aom_transfer_characteristics_t
enum aom_transfer_characteristics aom_transfer_characteristics_t
List of supported transfer functions.
aom_color_primaries_t
enum aom_color_primaries aom_color_primaries_t
List of supported color primaries.
aom_matrix_coefficients_t
enum aom_matrix_coefficients aom_matrix_coefficients_t
List of supported matrix coefficients.
enums.h
aom_bit_depth_t
enum aom_bit_depth aom_bit_depth_t
Bit depth for codecThis enumeration determines the bit depth of the codec.
AOM_CODEC_CORRUPT_FRAME
@ AOM_CODEC_CORRUPT_FRAME
The coded data for this stream is corrupt or incomplete.
Definition: aom_codec.h:195
restoration.h
AV1Common
Top level common structure used by both encoder and decoder.
Definition: av1_common_int.h:725
AV1Common::last_frame_seg_map
uint8_t * last_frame_seg_map
Definition: av1_common_int.h:911
AV1Common::rst_info
RestorationInfo rst_info[3]
Definition: av1_common_int.h:925
AV1Common::global_motion
WarpedMotionParams global_motion[REF_FRAMES]
Definition: av1_common_int.h:949
AV1Common::superres_upscaled_width
int superres_upscaled_width
Definition: av1_common_int.h:774
AV1Common::buffer_removal_time_present
bool buffer_removal_time_present
Definition: av1_common_int.h:787
AV1Common::ref_frame_side
int8_t ref_frame_side[REF_FRAMES]
Definition: av1_common_int.h:1016
AV1Common::ref_scale_factors
struct scale_factors ref_scale_factors[REF_FRAMES]
Definition: av1_common_int.h:848
AV1Common::prev_frame
RefCntBuffer * prev_frame
Definition: av1_common_int.h:805
AV1Common::default_frame_context
FRAME_CONTEXT * default_frame_context
Definition: av1_common_int.h:966
AV1Common::ref_frame_id
int ref_frame_id[REF_FRAMES]
Definition: av1_common_int.h:991
AV1Common::superres_upscaled_height
int superres_upscaled_height
Definition: av1_common_int.h:775
AV1Common::delta_q_info
DeltaQInfo delta_q_info
Definition: av1_common_int.h:944
AV1Common::width
int width
Definition: av1_common_int.h:750
AV1Common::cur_frame
RefCntBuffer * cur_frame
Definition: av1_common_int.h:811
AV1Common::cdef_info
CdefInfo cdef_info
Definition: av1_common_int.h:934
AV1Common::lf_info
loop_filter_info_n lf_info
Definition: av1_common_int.h:917
AV1Common::current_frame
CurrentFrame current_frame
Definition: av1_common_int.h:729
AV1Common::number_spatial_layers
unsigned int number_spatial_layers
Definition: av1_common_int.h:1031
AV1Common::remapped_ref_idx
int remapped_ref_idx[REF_FRAMES]
Definition: av1_common_int.h:833
AV1Common::number_temporal_layers
unsigned int number_temporal_layers
Definition: av1_common_int.h:1021
AV1Common::rlbs
RestorationLineBuffers * rlbs
Definition: av1_common_int.h:927
AV1Common::film_grain_params
aom_film_grain_t film_grain_params
Definition: av1_common_int.h:939
AV1Common::show_existing_frame
int show_existing_frame
Definition: av1_common_int.h:879
AV1Common::buffer_removal_times
uint32_t buffer_removal_times[(8 *4)+1]
Definition: av1_common_int.h:794
AV1Common::temporal_layer_id
int temporal_layer_id
Definition: av1_common_int.h:1026
AV1Common::seq_params
SequenceHeader seq_params
Definition: av1_common_int.h:955
AV1Common::showable_frame
int showable_frame
Definition: av1_common_int.h:872
AV1Common::tpl_mvs_mem_size
int tpl_mvs_mem_size
Definition: av1_common_int.h:1005
AV1Common::frame_presentation_time
uint32_t frame_presentation_time
Definition: av1_common_int.h:800
AV1Common::error
struct aom_internal_error_info error
Definition: av1_common_int.h:733
AV1Common::lf
struct loopfilter lf
Definition: av1_common_int.h:918
AV1Common::spatial_layer_id
int spatial_layer_id
Definition: av1_common_int.h:1036
AV1Common::features
FeatureFlags features
Definition: av1_common_int.h:884
AV1Common::sf_identity
struct scale_factors sf_identity
Definition: av1_common_int.h:840
AV1Common::rst_frame
YV12_BUFFER_CONFIG rst_frame
Definition: av1_common_int.h:928
AV1Common::mi_params
CommonModeInfoParams mi_params
Definition: av1_common_int.h:889
AV1Common::superres_scale_denominator
uint8_t superres_scale_denominator
Definition: av1_common_int.h:782
AV1Common::show_frame
int show_frame
Definition: av1_common_int.h:864
AV1Common::seg
struct segmentation seg
Definition: av1_common_int.h:906
AV1Common::quant_params
CommonQuantParams quant_params
Definition: av1_common_int.h:901
AV1Common::tpl_mvs
TPL_MV_REF * tpl_mvs
Definition: av1_common_int.h:1001
AV1Common::current_frame_id
int current_frame_id
Definition: av1_common_int.h:990
AV1Common::rst_tmpbuf
int32_t * rst_tmpbuf
Definition: av1_common_int.h:926
AV1Common::ref_frame_map
RefCntBuffer * ref_frame_map[REF_FRAMES]
Definition: av1_common_int.h:857
AV1Common::above_contexts
CommonContexts above_contexts
Definition: av1_common_int.h:984
AV1Common::tiles
CommonTileParams tiles
Definition: av1_common_int.h:971
AV1Common::buffer_pool
BufferPool * buffer_pool
Definition: av1_common_int.h:976
AV1Common::ref_frame_sign_bias
int ref_frame_sign_bias[REF_FRAMES]
Definition: av1_common_int.h:1010
AV1Common::fc
FRAME_CONTEXT * fc
Definition: av1_common_int.h:960
AV1Common::height
int height
Definition: av1_common_int.h:751
AV1Common::render_width
int render_width
Definition: av1_common_int.h:761
AV1Common::render_height
int render_height
Definition: av1_common_int.h:762
CdefInfo
Parameters related to CDEF.
Definition: av1_common_int.h:196
CdefInfo::cdef_bits
int cdef_bits
Definition: av1_common_int.h:202
CdefInfo::nb_cdef_strengths
int nb_cdef_strengths
Definition: av1_common_int.h:198
CdefInfo::cdef_damping
int cdef_damping
Definition: av1_common_int.h:197
CommonContexts
Contexts used for transmitting various symbols in the bitstream.
Definition: av1_common_int.h:688
CommonContexts::partition
PARTITION_CONTEXT ** partition
Definition: av1_common_int.h:693
CommonContexts::num_planes
int num_planes
Definition: av1_common_int.h:717
CommonContexts::entropy
ENTROPY_CONTEXT ** entropy[3]
Definition: av1_common_int.h:703
CommonContexts::num_tile_rows
int num_tile_rows
Definition: av1_common_int.h:718
CommonContexts::num_mi_cols
int num_mi_cols
Definition: av1_common_int.h:719
CommonContexts::txfm
TXFM_CONTEXT ** txfm
Definition: av1_common_int.h:711
CommonModeInfoParams
Params related to MB_MODE_INFO arrays and related info.
Definition: av1_common_int.h:479
CommonModeInfoParams::mb_cols
int mb_cols
Definition: av1_common_int.h:489
CommonModeInfoParams::mi_alloc
MB_MODE_INFO * mi_alloc
Definition: av1_common_int.h:513
CommonModeInfoParams::mi_rows
int mi_rows
Definition: av1_common_int.h:500
CommonModeInfoParams::setup_mi
void(* setup_mi)(struct CommonModeInfoParams *mi_params)
Definition: av1_common_int.h:568
CommonModeInfoParams::free_mi
void(* free_mi)(struct CommonModeInfoParams *mi_params)
Definition: av1_common_int.h:563
CommonModeInfoParams::mi_cols
int mi_cols
Definition: av1_common_int.h:505
CommonModeInfoParams::mi_alloc_size
int mi_alloc_size
Definition: av1_common_int.h:517
CommonModeInfoParams::MBs
int MBs
Definition: av1_common_int.h:494
CommonModeInfoParams::tx_type_map
TX_TYPE * tx_type_map
Definition: av1_common_int.h:553
CommonModeInfoParams::set_mb_mi
void(* set_mb_mi)(struct CommonModeInfoParams *mi_params, int width, int height)
Definition: av1_common_int.h:575
CommonModeInfoParams::mi_alloc_stride
int mi_alloc_stride
Definition: av1_common_int.h:521
CommonModeInfoParams::mi_grid_size
int mi_grid_size
Definition: av1_common_int.h:541
CommonModeInfoParams::mi_stride
int mi_stride
Definition: av1_common_int.h:545
CommonModeInfoParams::mb_rows
int mb_rows
Definition: av1_common_int.h:484
CommonModeInfoParams::mi_grid_base
MB_MODE_INFO ** mi_grid_base
Definition: av1_common_int.h:537
CommonModeInfoParams::mi_alloc_bsize
BLOCK_SIZE mi_alloc_bsize
Definition: av1_common_int.h:528
CommonQuantParams
Parameters related to quantization at the frame level.
Definition: av1_common_int.h:584
CommonQuantParams::u_ac_delta_q
int u_ac_delta_q
Definition: av1_common_int.h:609
CommonQuantParams::u_iqmatrix
const qm_val_t * u_iqmatrix[8][TX_SIZES_ALL]
Definition: av1_common_int.h:658
CommonQuantParams::qmatrix_level_v
int qmatrix_level_v
Definition: av1_common_int.h:680
CommonQuantParams::giqmatrix
const qm_val_t * giqmatrix[(1<< 4)][3][TX_SIZES_ALL]
Definition: av1_common_int.h:640
CommonQuantParams::u_dequant_QTX
int16_t u_dequant_QTX[8][2]
Definition: av1_common_int.h:629
CommonQuantParams::y_iqmatrix
const qm_val_t * y_iqmatrix[8][TX_SIZES_ALL]
Definition: av1_common_int.h:654
CommonQuantParams::qmatrix_level_y
int qmatrix_level_y
Definition: av1_common_int.h:678
CommonQuantParams::v_ac_delta_q
int v_ac_delta_q
Definition: av1_common_int.h:614
CommonQuantParams::using_qmatrix
bool using_qmatrix
Definition: av1_common_int.h:671
CommonQuantParams::u_dc_delta_q
int u_dc_delta_q
Definition: av1_common_int.h:599
CommonQuantParams::qmatrix_level_u
int qmatrix_level_u
Definition: av1_common_int.h:679
CommonQuantParams::base_qindex
int base_qindex
Definition: av1_common_int.h:588
CommonQuantParams::v_dequant_QTX
int16_t v_dequant_QTX[8][2]
Definition: av1_common_int.h:630
CommonQuantParams::v_iqmatrix
const qm_val_t * v_iqmatrix[8][TX_SIZES_ALL]
Definition: av1_common_int.h:662
CommonQuantParams::y_dequant_QTX
int16_t y_dequant_QTX[8][2]
Definition: av1_common_int.h:628
CommonQuantParams::v_dc_delta_q
int v_dc_delta_q
Definition: av1_common_int.h:603
CommonQuantParams::y_dc_delta_q
int y_dc_delta_q
Definition: av1_common_int.h:594
CommonQuantParams::gqmatrix
const qm_val_t * gqmatrix[(1<< 4)][3][TX_SIZES_ALL]
Definition: av1_common_int.h:644
CommonTileParams
Params related to tiles.
Definition: av1_common_int.h:405
CommonTileParams::uniform_spacing
int uniform_spacing
Definition: av1_common_int.h:421
CommonTileParams::max_width_sb
int max_width_sb
Definition: av1_common_int.h:408
CommonTileParams::log2_rows
int log2_rows
Definition: av1_common_int.h:428
CommonTileParams::min_log2_rows
int min_log2_rows
Definition: av1_common_int.h:440
CommonTileParams::width
int width
Definition: av1_common_int.h:429
CommonTileParams::max_log2_rows
int max_log2_rows
Definition: av1_common_int.h:448
CommonTileParams::row_start_sb
int row_start_sb[MAX_TILE_ROWS+1]
Definition: av1_common_int.h:462
CommonTileParams::cols
int cols
Definition: av1_common_int.h:406
CommonTileParams::max_height_sb
int max_height_sb
Definition: av1_common_int.h:409
CommonTileParams::large_scale
unsigned int large_scale
Definition: av1_common_int.h:466
CommonTileParams::single_tile_decoding
unsigned int single_tile_decoding
Definition: av1_common_int.h:472
CommonTileParams::max_log2_cols
int max_log2_cols
Definition: av1_common_int.h:444
CommonTileParams::log2_cols
int log2_cols
Definition: av1_common_int.h:427
CommonTileParams::min_log2
int min_log2
Definition: av1_common_int.h:452
CommonTileParams::rows
int rows
Definition: av1_common_int.h:407
CommonTileParams::min_inner_width
int min_inner_width
Definition: av1_common_int.h:414
CommonTileParams::min_log2_cols
int min_log2_cols
Definition: av1_common_int.h:436
CommonTileParams::col_start_sb
int col_start_sb[MAX_TILE_COLS+1]
Definition: av1_common_int.h:457
CommonTileParams::height
int height
Definition: av1_common_int.h:430
FeatureFlags
Frame level features.
Definition: av1_common_int.h:336
FeatureFlags::interp_filter
InterpFilter interp_filter
Definition: av1_common_int.h:385
FeatureFlags::allow_ref_frame_mvs
bool allow_ref_frame_mvs
Definition: av1_common_int.h:359
FeatureFlags::allow_warped_motion
bool allow_warped_motion
Definition: av1_common_int.h:355
FeatureFlags::allow_screen_content_tools
bool allow_screen_content_tools
Definition: av1_common_int.h:353
FeatureFlags::switchable_motion_mode
bool switchable_motion_mode
Definition: av1_common_int.h:383
FeatureFlags::tx_mode
TX_MODE tx_mode
Definition: av1_common_int.h:384
FeatureFlags::reduced_tx_set_used
bool reduced_tx_set_used
Definition: av1_common_int.h:372
FeatureFlags::allow_intrabc
bool allow_intrabc
Definition: av1_common_int.h:354
FeatureFlags::byte_alignment
int byte_alignment
Definition: av1_common_int.h:394
FeatureFlags::coded_lossless
bool coded_lossless
Definition: av1_common_int.h:363
FeatureFlags::refresh_frame_context
REFRESH_FRAME_CONTEXT_MODE refresh_frame_context
Definition: av1_common_int.h:399
FeatureFlags::error_resilient_mode
bool error_resilient_mode
Definition: av1_common_int.h:378
FeatureFlags::primary_ref_frame
int primary_ref_frame
Definition: av1_common_int.h:390
FeatureFlags::disable_cdf_update
bool disable_cdf_update
Definition: av1_common_int.h:340
FeatureFlags::allow_high_precision_mv
bool allow_high_precision_mv
Definition: av1_common_int.h:345
FeatureFlags::cur_frame_force_integer_mv
bool cur_frame_force_integer_mv
Definition: av1_common_int.h:349
FeatureFlags::all_lossless
bool all_lossless
Definition: av1_common_int.h:367
MB_MODE_INFO
Stores the prediction/txfm mode of the current coding block.
Definition: blockd.h:216
MB_MODE_INFO::bsize
BLOCK_SIZE bsize
The block size of the current coding block.
Definition: blockd.h:222
RestorationInfo
Parameters related to Restoration Info.
Definition: restoration.h:255
aom_codec_frame_buffer
External frame buffer.
Definition: aom_frame_buffer.h:40
macroblockd
Variables related to current coding block.
Definition: blockd.h:568
macroblockd::left_available
bool left_available
Definition: blockd.h:624
macroblockd::tx_type_map
uint8_t * tx_type_map
Definition: blockd.h:664
macroblockd::mb_to_bottom_edge
int mb_to_bottom_edge
Definition: blockd.h:678
macroblockd::left_txfm_context
TXFM_CONTEXT * left_txfm_context
Definition: blockd.h:738
macroblockd::plane
struct macroblockd_plane plane[3]
Definition: blockd.h:604
macroblockd::mb_to_top_edge
int mb_to_top_edge
Definition: blockd.h:677
macroblockd::mb_to_right_edge
int mb_to_right_edge
Definition: blockd.h:676
macroblockd::up_available
bool up_available
Definition: blockd.h:620
macroblockd::above_mbmi
MB_MODE_INFO * above_mbmi
Definition: blockd.h:643
macroblockd::chroma_up_available
bool chroma_up_available
Definition: blockd.h:628
macroblockd::above_txfm_context
TXFM_CONTEXT * above_txfm_context
Definition: blockd.h:731
macroblockd::chroma_left_available
bool chroma_left_available
Definition: blockd.h:632
macroblockd::above_partition_context
PARTITION_CONTEXT * above_partition_context
Definition: blockd.h:716
macroblockd::chroma_left_mbmi
MB_MODE_INFO * chroma_left_mbmi
Definition: blockd.h:650
macroblockd::left_txfm_context_buffer
TXFM_CONTEXT left_txfm_context_buffer[MAX_MIB_SIZE]
Definition: blockd.h:745
macroblockd::tx_type_map_stride
int tx_type_map_stride
Definition: blockd.h:669
macroblockd::chroma_above_mbmi
MB_MODE_INFO * chroma_above_mbmi
Definition: blockd.h:657
macroblockd::mi_row
int mi_row
Definition: blockd.h:573
macroblockd::mi_stride
int mi_stride
Definition: blockd.h:580
macroblockd::is_last_vertical_rect
bool is_last_vertical_rect
Definition: blockd.h:785
macroblockd::is_first_horizontal_rect
bool is_first_horizontal_rect
Definition: blockd.h:790
macroblockd::width
uint8_t width
Definition: blockd.h:763
macroblockd::error_info
struct aom_internal_error_info * error_info
Definition: blockd.h:836
macroblockd::cfl
CFL_CTX cfl
Definition: blockd.h:892
macroblockd::lossless
int lossless[8]
Definition: blockd.h:815
macroblockd::left_entropy_context
ENTROPY_CONTEXT left_entropy_context[3][MAX_MIB_SIZE]
Definition: blockd.h:708
macroblockd::above_entropy_context
ENTROPY_CONTEXT * above_entropy_context[3]
Definition: blockd.h:701
macroblockd::mi
MB_MODE_INFO ** mi
Definition: blockd.h:615
macroblockd::height
uint8_t height
Definition: blockd.h:764
macroblockd::left_mbmi
MB_MODE_INFO * left_mbmi
Definition: blockd.h:638
macroblockd::left_partition_context
PARTITION_CONTEXT left_partition_context[MAX_MIB_SIZE]
Definition: blockd.h:723
macroblockd::is_chroma_ref
bool is_chroma_ref
Definition: blockd.h:599
macroblockd::mi_col
int mi_col
Definition: blockd.h:574
macroblockd::mb_to_left_edge
int mb_to_left_edge
Definition: blockd.h:675
yv12_buffer_config
YV12 frame buffer data structure.
Definition: yv12config.h:38