AOMedia AV1 Codec: av1/encoder/block.h Source File

| AOMedia AV1 Codec

block.h
Go to the documentation of this file.
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
15#ifndef AOM_AV1_ENCODER_BLOCK_H_
16#define AOM_AV1_ENCODER_BLOCK_H_
17
18#include "av1/common/blockd.h"
19#include "av1/common/entropymv.h"
20#include "av1/common/entropy.h"
21#include "av1/common/enums.h"
22#include "av1/common/mvref_common.h"
23
24#include "av1/encoder/enc_enums.h"
25#if !CONFIG_REALTIME_ONLY
26#include "av1/encoder/partition_cnn_weights.h"
27#endif
28
29#include "av1/encoder/hash_motion.h"
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
36#define MIN_TPL_BSIZE_1D 16
38#define MAX_TPL_BLK_IN_SB (MAX_SB_SIZE / MIN_TPL_BSIZE_1D)
40#define RD_RECORD_BUFFER_LEN 8
41
43#define MAX_TX_TYPE_PROB 1024
50 typedef struct {
52 BLOCK_SIZE min_partition_size;
54 BLOCK_SIZE max_partition_size;
55
56
64 int tpl_data_count;
66 int64_t tpl_inter_cost[MAX_TPL_BLK_IN_SB * MAX_TPL_BLK_IN_SB];
68 int64_t tpl_intra_cost[MAX_TPL_BLK_IN_SB * MAX_TPL_BLK_IN_SB];
70 int_mv tpl_mv[MAX_TPL_BLK_IN_SB * MAX_TPL_BLK_IN_SB][INTER_REFS_PER_FRAME];
72 int tpl_stride;
74} SuperBlockEnc;
75
78 typedef struct {
80 MB_MODE_INFO mbmi;
82 RD_STATS rd_cost;
84 int64_t rd;
86 int rate_y;
88 int rate_uv;
90 uint8_t color_index_map[MAX_SB_SQUARE];
92 THR_MODES mode_index;
93} WinnerModeStats;
94
99 typedef struct macroblock_plane {
101 int16_t *src_diff;
103 tran_low_t *dqcoeff;
105 tran_low_t *qcoeff;
107 tran_low_t *coeff;
109 uint16_t *eobs;
111 uint8_t *txb_entropy_ctx;
113 struct buf_2d src;
114
123 const int16_t *quant_fp_QTX;
125 const int16_t *round_fp_QTX;
127 const int16_t *quant_QTX;
129 const int16_t *round_QTX;
131 const int16_t *quant_shift_QTX;
133 const int16_t *zbin_QTX;
135 const int16_t *dequant_QTX;
137} MACROBLOCK_PLANE;
138
143 typedef struct {
145 int txb_skip_cost[TXB_SKIP_CONTEXTS][2];
150 int base_eob_cost[SIG_COEF_CONTEXTS_EOB][3];
155 int base_cost[SIG_COEF_CONTEXTS][8];
160 int eob_extra_cost[EOB_COEF_CONTEXTS][2];
162 int dc_sign_cost[DC_SIGN_CONTEXTS][2];
164 int lps_cost[LEVEL_CONTEXTS][COEFF_BASE_RANGE + 1 + COEFF_BASE_RANGE + 1];
165} LV_MAP_COEFF_COST;
166
169 typedef struct {
171 int eob_cost[2][11];
172} LV_MAP_EOB_COST;
173
176 typedef struct {
178 tran_low_t *tcoeff[MAX_MB_PLANE];
180 uint16_t *eobs[MAX_MB_PLANE];
187 uint8_t *entropy_ctx[MAX_MB_PLANE];
188} CB_COEFF_BUFFER;
189
192 typedef struct {
193 // TODO(angiebird): Reduce the buffer size according to sb_type
195 CANDIDATE_MV ref_mv_stack[MODE_CTX_REF_FRAMES][USABLE_REF_MV_STACK_SIZE];
197 uint16_t weight[MODE_CTX_REF_FRAMES][USABLE_REF_MV_STACK_SIZE];
199 uint8_t ref_mv_count[MODE_CTX_REF_FRAMES];
201 int_mv global_mvs[REF_FRAMES];
203 int16_t mode_context[MODE_CTX_REF_FRAMES];
204} MB_MODE_INFO_EXT;
205
212 typedef struct {
214 CANDIDATE_MV ref_mv_stack[USABLE_REF_MV_STACK_SIZE];
216 uint16_t weight[USABLE_REF_MV_STACK_SIZE];
218 uint8_t ref_mv_count;
219 // TODO(Ravi/Remya): Reduce the buffer size of global_mvs
221 int_mv global_mvs[REF_FRAMES];
223 int16_t mode_context;
225 uint16_t cb_offset[PLANE_TYPES];
226} MB_MODE_INFO_EXT_FRAME;
227
230 typedef struct {
232 TX_SIZE tx_size;
234 TX_SIZE inter_tx_size[INTER_TX_SIZE_BUF_LEN];
236 uint8_t blk_skip[MAX_MIB_SIZE * MAX_MIB_SIZE];
238 uint8_t tx_type_map[MAX_MIB_SIZE * MAX_MIB_SIZE];
240 RD_STATS rd_stats;
242 uint32_t hash_value;
243} MB_RD_INFO;
244
251 typedef struct {
255 MB_RD_INFO mb_rd_info[RD_RECORD_BUFFER_LEN];
257 int index_start;
259 int num;
261 CRC32C crc_calculator;
262} MB_RD_RECORD;
263
265#define MAX_COMP_RD_STATS 64
268 typedef struct {
270 int32_t rate[COMPOUND_TYPES];
272 int64_t dist[COMPOUND_TYPES];
274 int32_t model_rate[COMPOUND_TYPES];
276 int64_t model_dist[COMPOUND_TYPES];
278 int comp_rs2[COMPOUND_TYPES];
280 int_mv mv[2];
282 MV_REFERENCE_FRAME ref_frames[2];
284 PREDICTION_MODE mode;
286 int_interpfilters filter;
288 int ref_mv_idx;
290 int is_global[2];
292 INTERINTER_COMPOUND_DATA interinter_comp;
293} COMP_RD_STATS;
294
299 typedef struct {
304 int32_t *wsrc;
309 int32_t *mask;
314 uint8_t *above_pred;
319 uint8_t *left_pred;
320} OBMCBuffer;
321
324 typedef struct {
326 uint8_t best_palette_color_map[MAX_PALETTE_SQUARE];
328 int kmeans_data_buf[2 * MAX_PALETTE_SQUARE];
329} PALETTE_BUFFER;
330
336 typedef struct {
338 uint8_t *pred0;
340 uint8_t *pred1;
342 int16_t *residual1;
344 int16_t *diff10;
346 uint8_t *tmp_best_mask_buf;
347} CompoundTypeRdBuffers;
348
351// TODO(chiyotsai@google.com): Consolidate this with SIMPLE_MOTION_DATA_TREE
352 typedef struct {
353#if !CONFIG_REALTIME_ONLY
354 // The following 4 parameters are used for cnn-based partitioning on intra
355 // frame.
360 int quad_tree_idx;
362 int cnn_output_valid;
364 float cnn_buffer[CNN_OUT_BUF_SIZE];
366 float log_q;
367#endif
368
382 uint8_t variance_low[105];
383} PartitionSearchInfo;
384
389 typedef struct {
395 int use_default_intra_tx_type;
396
398 int default_inter_tx_type_prob_thresh;
399
401 int prune_2d_txfm_mode;
402
407 unsigned int coeff_opt_thresholds[2];
409 unsigned int tx_domain_dist_threshold;
411 TX_SIZE_SEARCH_METHOD tx_size_search_method;
413 unsigned int use_transform_domain_distortion;
415 unsigned int skip_txfm_level;
416
430 TX_MODE tx_mode_search_type;
431
435 unsigned int predict_dc_level;
436
441 int use_qm_dist_metric;
442
447 int mode_eval_type;
448} TxfmSearchParams;
449
451#define MAX_NUM_8X8_TXBS ((MAX_MIB_SIZE >> 1) * (MAX_MIB_SIZE >> 1))
452#define MAX_NUM_16X16_TXBS ((MAX_MIB_SIZE >> 2) * (MAX_MIB_SIZE >> 2))
453#define MAX_NUM_32X32_TXBS ((MAX_MIB_SIZE >> 3) * (MAX_MIB_SIZE >> 3))
454#define MAX_NUM_64X64_TXBS ((MAX_MIB_SIZE >> 4) * (MAX_MIB_SIZE >> 4))
462 typedef struct {
464 int skip_txfm;
465
473 uint8_t blk_skip[MAX_MIB_SIZE * MAX_MIB_SIZE];
474
484 uint8_t tx_type_map_[MAX_MIB_SIZE * MAX_MIB_SIZE];
485
487 MB_RD_RECORD *mb_rd_record;
488
497 // TODO(chiyotsai@google.com): Move this to a more appropriate location such
498 // as ThreadData.
499 unsigned int txb_split_count;
500#if CONFIG_SPEED_STATS
502 unsigned int tx_search_count;
503#endif // CONFIG_SPEED_STATS
504} TxfmSearchInfo;
505#undef MAX_NUM_8X8_TXBS
506#undef MAX_NUM_16X16_TXBS
507#undef MAX_NUM_32X32_TXBS
508#undef MAX_NUM_64X64_TXBS
509
515 typedef struct {
516
521 int partition_cost[PARTITION_CONTEXTS][EXT_PARTITION_TYPES];
524
529 int mbmode_cost[BLOCK_SIZE_GROUPS][INTRA_MODES];
531 int y_mode_costs[INTRA_MODES][INTRA_MODES][INTRA_MODES];
533 int intra_uv_mode_cost[CFL_ALLOWED_TYPES][INTRA_MODES][UV_INTRA_MODES];
535 int filter_intra_cost[BLOCK_SIZES_ALL][2];
537 int filter_intra_mode_cost[FILTER_INTRA_MODES];
539 int angle_delta_cost[DIRECTIONAL_MODES][2 * MAX_ANGLE_DELTA + 1];
540
542 int cfl_cost[CFL_JOINT_SIGNS][CFL_PRED_PLANES][CFL_ALPHABET_SIZE];
545
550 int intrabc_cost[2];
551
553 int palette_y_size_cost[PALATTE_BSIZE_CTXS][PALETTE_SIZES];
555 int palette_uv_size_cost[PALATTE_BSIZE_CTXS][PALETTE_SIZES];
557 int palette_y_color_cost[PALETTE_SIZES][PALETTE_COLOR_INDEX_CONTEXTS]
558 [PALETTE_COLORS];
560 int palette_uv_color_cost[PALETTE_SIZES][PALETTE_COLOR_INDEX_CONTEXTS]
561 [PALETTE_COLORS];
563 int palette_y_mode_cost[PALATTE_BSIZE_CTXS][PALETTE_Y_MODE_CONTEXTS][2];
565 int palette_uv_mode_cost[PALETTE_UV_MODE_CONTEXTS][2];
568
573 int skip_mode_cost[SKIP_MODE_CONTEXTS][2];
575 int newmv_mode_cost[NEWMV_MODE_CONTEXTS][2];
577 int zeromv_mode_cost[GLOBALMV_MODE_CONTEXTS][2];
579 int refmv_mode_cost[REFMV_MODE_CONTEXTS][2];
581 int drl_mode_cost0[DRL_MODE_CONTEXTS][2];
584
589 int single_ref_cost[REF_CONTEXTS][SINGLE_REFS - 1][2];
591 int comp_inter_cost[COMP_INTER_CONTEXTS][2];
593 int comp_ref_type_cost[COMP_REF_TYPE_CONTEXTS]
594 [CDF_SIZE(COMP_REFERENCE_TYPES)];
596 int uni_comp_ref_cost[UNI_COMP_REF_CONTEXTS][UNIDIR_COMP_REFS - 1]
597 [CDF_SIZE(2)];
602 int comp_ref_cost[REF_CONTEXTS][FWD_REFS - 1][2];
607 int comp_bwdref_cost[REF_CONTEXTS][BWD_REFS - 1][2];
610
615 int intra_inter_cost[INTRA_INTER_CONTEXTS][2];
617 int inter_compound_mode_cost[INTER_MODE_CONTEXTS][INTER_COMPOUND_MODES];
619 int compound_type_cost[BLOCK_SIZES_ALL][MASKED_COMPOUND_TYPES];
621 int wedge_idx_cost[BLOCK_SIZES_ALL][16];
623 int interintra_cost[BLOCK_SIZE_GROUPS][2];
625 int wedge_interintra_cost[BLOCK_SIZES_ALL][2];
627 int interintra_mode_cost[BLOCK_SIZE_GROUPS][INTERINTRA_MODES];
630
635 int comp_idx_cost[COMP_INDEX_CONTEXTS][2];
637 int comp_group_idx_cost[COMP_GROUP_IDX_CONTEXTS][2];
640
645 int motion_mode_cost[BLOCK_SIZES_ALL][MOTION_MODES];
647 int motion_mode_cost1[BLOCK_SIZES_ALL][2];
649 int switchable_interp_costs[SWITCHABLE_FILTER_CONTEXTS][SWITCHABLE_FILTERS];
652
657 int skip_txfm_cost[SKIP_CONTEXTS][2];
659 int tx_size_cost[TX_SIZES - 1][TX_SIZE_CONTEXTS][TX_SIZES];
661 int txfm_partition_cost[TXFM_PARTITION_CONTEXTS][2];
663 int inter_tx_type_costs[EXT_TX_SETS_INTER][EXT_TX_SIZES][TX_TYPES];
665 int intra_tx_type_costs[EXT_TX_SETS_INTRA][EXT_TX_SIZES][INTRA_MODES]
666 [TX_TYPES];
669
674 int switchable_restore_cost[RESTORE_SWITCHABLE_TYPES];
676 int wiener_restore_cost[2];
678 int sgrproj_restore_cost[2];
681
686 int tmp_pred_cost[SEG_TEMPORAL_PRED_CTXS][2];
688 int spatial_pred_cost[SPATIAL_PREDICTION_PROBS][MAX_SEGMENTS];
690} ModeCosts;
691
694 typedef struct {
695
708 int nmv_joint_cost[MV_JOINTS];
709
711 int nmv_cost_alloc[2][MV_VALS];
713 int nmv_cost_hp_alloc[2][MV_VALS];
715 int *nmv_cost[2];
717 int *nmv_cost_hp[2];
719 int **mv_cost_stack;
721} MvCosts;
722
725 typedef struct {
727 int joint_mv[MV_JOINTS];
728
734 int dv_costs_alloc[2][MV_VALS];
735
737 int *dv_costs[2];
738} IntraBCMVCosts;
739
742 typedef struct {
744 LV_MAP_COEFF_COST coeff_costs[TX_SIZES][PLANE_TYPES];
746 LV_MAP_EOB_COST eob_costs[7][2];
747} CoeffCosts;
748
750// 4: NEAREST, NEW, NEAR, GLOBAL
751#define SINGLE_REF_MODES ((REF_FRAMES - 1) * 4)
753struct inter_modes_info;
754
757 typedef struct {
759 int num;
761 int pts[16];
763 int pts_inref[16];
764} WARP_SAMPLE_INFO;
765
767typedef enum {
768 kZeroSad = 0,
769 kLowSad = 1,
770 kMedSad = 2,
771 kHighSad = 3
772} SOURCE_SAD;
773
774typedef struct {
776 SOURCE_SAD source_sad_nonrd;
778 SOURCE_SAD source_sad_rd;
779 int lighting_change;
780 int low_sumdiff;
781} CONTENT_STATE_SB;
782
783// Structure to hold pixel level gradient info.
784typedef struct {
785 uint16_t abs_dx_abs_dy_sum;
786 int8_t hist_bin_idx;
787 bool is_dx_zero;
788} PixelLevelGradientInfo;
789
790// Structure to hold the variance and log(1 + variance) for 4x4 sub-blocks.
791typedef struct {
792 double log_var;
793 int var;
794} Block4x4VarInfo;
795
796#ifndef NDEBUG
797typedef struct SetOffsetsLoc {
798 int mi_row;
799 int mi_col;
800 BLOCK_SIZE bsize;
801} SetOffsetsLoc;
802#endif // NDEBUG
803
813 typedef struct macroblock {
814
823 struct macroblock_plane plane[MAX_MB_PLANE];
824
831 MACROBLOCKD e_mbd;
832
838 MB_MODE_INFO_EXT mbmi_ext;
839
845 MB_MODE_INFO_EXT_FRAME *mbmi_ext_frame;
846
848 FRAME_CONTEXT *row_ctx;
857 FRAME_CONTEXT *tile_pb_ctx;
858
867 CB_COEFF_BUFFER *cb_coef_buff;
869 uint16_t cb_offset[PLANE_TYPES];
870
872 OBMCBuffer obmc_buffer;
874 PALETTE_BUFFER *palette_buffer;
876 CompoundTypeRdBuffers comp_rd_buffer;
878 CONV_BUF_TYPE *tmp_conv_dst;
879
889 uint8_t *tmp_pred_bufs[2];
892
901 int qindex;
902
908 int delta_qindex;
909
918 int rdmult;
919
921 int intra_sb_rdmult_modifier;
922
924 double rb;
925
927 int mb_energy;
929 int sb_energy_level;
930
932 ModeCosts mode_costs;
933
936 MvCosts *mv_costs;
937
941 IntraBCMVCosts *dv_costs;
942
944 CoeffCosts coeff_costs;
947
952 int errorperbit;
954 int sadperbit;
957
966 int seg_skip_block;
967
972 int actual_num_seg1_blocks;
973
978 int actual_num_seg2_blocks;
979
982 int cnt_zeromv;
983
986 int force_zeromv_skip;
987
991 int prev_segment_id;
994
999 // TODO(chiyotsai@google.com): Refactor this out of macroblock
1000 SuperBlockEnc sb_enc;
1001
1007 CONTENT_STATE_SB content_state_sb;
1010
1018 int pred_mv_sad[REF_FRAMES];
1024 int best_pred_mv_sad[2];
1026 int pred_mv0_sad[REF_FRAMES];
1028 int pred_mv1_sad[REF_FRAMES];
1029
1036 uint8_t tpl_keep_ref_frame[REF_FRAMES];
1037
1042 WARP_SAMPLE_INFO warp_sample_info[REF_FRAMES];
1043
1050 int picked_ref_frames_mask[MAX_MIB_SIZE * MAX_MIB_SIZE];
1051
1059 int nonrd_prune_ref_frame_search;
1062
1067 PartitionSearchInfo part_search_info;
1068
1076 int must_find_valid_partition;
1079
1089 int skip_mode;
1090
1097 int thresh_freq_fact[BLOCK_SIZES_ALL][MAX_MODES];
1098
1107 WinnerModeStats *winner_mode_stats;
1109 int winner_mode_count;
1110
1123 TXFM_RD_MODEL rd_model;
1124
1134 // TODO(any): try to consolidate this speed feature with winner mode
1135 // processing.
1136 struct inter_modes_info *inter_modes_info;
1137
1139 uint8_t compound_idx;
1140
1142 COMP_RD_STATS comp_rd_stats[MAX_COMP_RD_STATS];
1144 int comp_rd_stats_idx;
1145
1153 int recalc_luma_mc_data;
1154
1159 IntraBCHashInfo intrabc_hash_info;
1160
1162 int use_mb_mode_cache;
1165 const MB_MODE_INFO *mb_mode_cache;
1172 PixelLevelGradientInfo *pixel_gradient_info;
1174 bool is_sb_gradient_cached[PLANE_TYPES];
1177
1186 unsigned int max_mv_context[REF_FRAMES];
1187
1193 FullMvLimits mv_limits;
1196
1205 TxfmSearchParams txfm_search_params;
1206
1212 TxfmSearchInfo txfm_search_info;
1213
1219 uint8_t color_sensitivity_sb[2];
1221 uint8_t color_sensitivity[2];
1224
1229 unsigned int source_variance;
1231 unsigned int pred_sse[REF_FRAMES];
1233#if CONFIG_RT_ML_PARTITIONING
1234 DECLARE_ALIGNED(16, uint8_t, est_pred[128 * 128]);
1235#endif
1244 int try_merge_partition;
1245
1252 Block4x4VarInfo *src_var_info_of_4x4_sub_blocks;
1253#ifndef NDEBUG
1255 SetOffsetsLoc last_set_offsets_loc;
1256#endif // NDEBUG
1257} MACROBLOCK;
1258#undef SINGLE_REF_MODES
1259
1261// Zeroes out 'n_stats' elements in the array x->winner_mode_stats.
1262// It only zeroes out what is necessary in 'color_index_map' (just the block
1263// size, not the whole array).
1264static INLINE void zero_winner_mode_stats(BLOCK_SIZE bsize, int n_stats,
1265 WinnerModeStats *stats) {
1266 // When winner mode stats are not required, the memory allocation is avoided
1267 // for x->winner_mode_stats. The stats pointer will be NULL in such cases.
1268 if (stats == NULL) return;
1269
1270 const int block_height = block_size_high[bsize];
1271 const int block_width = block_size_wide[bsize];
1272 for (int i = 0; i < n_stats; ++i) {
1273 WinnerModeStats *const stat = &stats[i];
1274 memset(&stat->mbmi, 0, sizeof(stat->mbmi));
1275 memset(&stat->rd_cost, 0, sizeof(stat->rd_cost));
1276 memset(&stat->rd, 0, sizeof(stat->rd));
1277 memset(&stat->rate_y, 0, sizeof(stat->rate_y));
1278 memset(&stat->rate_uv, 0, sizeof(stat->rate_uv));
1279 // Do not reset the whole array as it is CPU intensive.
1280 memset(&stat->color_index_map, 0,
1281 block_width * block_height * sizeof(stat->color_index_map[0]));
1282 memset(&stat->mode_index, 0, sizeof(stat->mode_index));
1283 }
1284}
1285
1286static INLINE int is_rect_tx_allowed_bsize(BLOCK_SIZE bsize) {
1287 static const char LUT[BLOCK_SIZES_ALL] = {
1288 0, // BLOCK_4X4
1289 1, // BLOCK_4X8
1290 1, // BLOCK_8X4
1291 0, // BLOCK_8X8
1292 1, // BLOCK_8X16
1293 1, // BLOCK_16X8
1294 0, // BLOCK_16X16
1295 1, // BLOCK_16X32
1296 1, // BLOCK_32X16
1297 0, // BLOCK_32X32
1298 1, // BLOCK_32X64
1299 1, // BLOCK_64X32
1300 0, // BLOCK_64X64
1301 0, // BLOCK_64X128
1302 0, // BLOCK_128X64
1303 0, // BLOCK_128X128
1304 1, // BLOCK_4X16
1305 1, // BLOCK_16X4
1306 1, // BLOCK_8X32
1307 1, // BLOCK_32X8
1308 1, // BLOCK_16X64
1309 1, // BLOCK_64X16
1310 };
1311
1312 return LUT[bsize];
1313}
1314
1315static INLINE int is_rect_tx_allowed(const MACROBLOCKD *xd,
1316 const MB_MODE_INFO *mbmi) {
1317 return is_rect_tx_allowed_bsize(mbmi->bsize) &&
1318 !xd->lossless[mbmi->segment_id];
1319}
1320
1321static INLINE int tx_size_to_depth(TX_SIZE tx_size, BLOCK_SIZE bsize) {
1322 TX_SIZE ctx_size = max_txsize_rect_lookup[bsize];
1323 int depth = 0;
1324 while (tx_size != ctx_size) {
1325 depth++;
1326 ctx_size = sub_tx_size_map[ctx_size];
1327 assert(depth <= MAX_TX_DEPTH);
1328 }
1329 return depth;
1330}
1331
1332static INLINE void set_blk_skip(uint8_t txb_skip[], int plane, int blk_idx,
1333 int skip) {
1334 if (skip)
1335 txb_skip[blk_idx] |= 1UL << plane;
1336 else
1337 txb_skip[blk_idx] &= ~(1UL << plane);
1338#ifndef NDEBUG
1339 // Set chroma planes to uninitialized states when luma is set to check if
1340 // it will be set later
1341 if (plane == 0) {
1342 txb_skip[blk_idx] |= 1UL << (1 + 4);
1343 txb_skip[blk_idx] |= 1UL << (2 + 4);
1344 }
1345
1346 // Clear the initialization checking bit
1347 txb_skip[blk_idx] &= ~(1UL << (plane + 4));
1348#endif
1349}
1350
1351static INLINE int is_blk_skip(uint8_t *txb_skip, int plane, int blk_idx) {
1352#ifndef NDEBUG
1353 // Check if this is initialized
1354 assert(!(txb_skip[blk_idx] & (1UL << (plane + 4))));
1355
1356 // The magic number is 0x77, this is to test if there is garbage data
1357 assert((txb_skip[blk_idx] & 0x88) == 0);
1358#endif
1359 return (txb_skip[blk_idx] >> plane) & 1;
1360}
1361
1364#ifdef __cplusplus
1365} // extern "C"
1366#endif
1367
1368#endif // AOM_AV1_ENCODER_BLOCK_H_
MAX_COMP_RD_STATS
#define MAX_COMP_RD_STATS
Number of compound rd stats.
Definition: block.h:265
MAX_TPL_BLK_IN_SB
#define MAX_TPL_BLK_IN_SB
Maximum number of tpl block in a super block.
Definition: block.h:38
RD_RECORD_BUFFER_LEN
#define RD_RECORD_BUFFER_LEN
Number of txfm hash records kept for the partition block.
Definition: block.h:40
MACROBLOCK_PLANE
struct macroblock_plane MACROBLOCK_PLANE
Each source plane of the current macroblock.
MACROBLOCK
struct macroblock MACROBLOCK
Encoder's parameters related to the current coding block.
enums.h
RESTORE_SWITCHABLE_TYPES
@ RESTORE_SWITCHABLE_TYPES
Definition: enums.h:602
CB_COEFF_BUFFER
Stores the transforms coefficients for the whole superblock.
Definition: block.h:176
COMP_RD_STATS
Rdcost stats in compound mode.
Definition: block.h:268
COMP_RD_STATS::filter
int_interpfilters filter
Current interpolation filter.
Definition: block.h:286
COMP_RD_STATS::interinter_comp
INTERINTER_COMPOUND_DATA interinter_comp
Current parameters for interinter mode.
Definition: block.h:292
COMP_RD_STATS::mode
PREDICTION_MODE mode
Current prediction mode.
Definition: block.h:284
COMP_RD_STATS::ref_mv_idx
int ref_mv_idx
Refmv index in the drl.
Definition: block.h:288
CoeffCosts
Holds the costs needed to encode the coefficients.
Definition: block.h:742
CompoundTypeRdBuffers
Contains buffers used by av1_compound_type_rd()
Definition: block.h:336
CompoundTypeRdBuffers::diff10
int16_t * diff10
Second prediction - first prediction.
Definition: block.h:344
CompoundTypeRdBuffers::pred1
uint8_t * pred1
Second prediction.
Definition: block.h:340
CompoundTypeRdBuffers::residual1
int16_t * residual1
Source - first prediction.
Definition: block.h:342
CompoundTypeRdBuffers::pred0
uint8_t * pred0
First prediction.
Definition: block.h:338
CompoundTypeRdBuffers::tmp_best_mask_buf
uint8_t * tmp_best_mask_buf
Backup of the best segmentation mask.
Definition: block.h:346
IntraBCMVCosts
Holds mv costs for intrabc.
Definition: block.h:725
LV_MAP_COEFF_COST
Costs for encoding the coefficients within a level.
Definition: block.h:143
LV_MAP_EOB_COST
Costs for encoding the eob.
Definition: block.h:169
MB_MODE_INFO_EXT_FRAME
Stores best extended mode information at frame level.
Definition: block.h:212
MB_MODE_INFO_EXT_FRAME::ref_mv_count
uint8_t ref_mv_count
Number of ref mvs in the drl.
Definition: block.h:218
MB_MODE_INFO_EXT_FRAME::mode_context
int16_t mode_context
Context used to encode the current mode.
Definition: block.h:223
MB_MODE_INFO_EXT
Extended mode info derived from mbmi.
Definition: block.h:192
MB_MODE_INFO
Stores the prediction/txfm mode of the current coding block.
Definition: blockd.h:222
MB_MODE_INFO::segment_id
uint8_t segment_id
The segment id.
Definition: blockd.h:310
MB_MODE_INFO::bsize
BLOCK_SIZE bsize
The block size of the current coding block.
Definition: blockd.h:228
MB_RD_INFO
Inter-mode txfm results for a partition block.
Definition: block.h:230
MB_RD_INFO::tx_size
TX_SIZE tx_size
Txfm size used if the current mode is intra mode.
Definition: block.h:232
MB_RD_INFO::hash_value
uint32_t hash_value
Hash value of the current record.
Definition: block.h:242
MB_RD_INFO::rd_stats
RD_STATS rd_stats
Rd_stats for the whole partition block.
Definition: block.h:240
MB_RD_RECORD
Hash records of the inter-mode transform results.
Definition: block.h:251
MB_RD_RECORD::index_start
int index_start
Index to insert the newest rd record.
Definition: block.h:257
MB_RD_RECORD::num
int num
Number of info stored in this record.
Definition: block.h:259
MB_RD_RECORD::crc_calculator
CRC32C crc_calculator
Hash function.
Definition: block.h:261
ModeCosts
Holds the entropy costs for various modes sent to the bitstream.
Definition: block.h:515
MvCosts
Holds mv costs for encoding and motion search.
Definition: block.h:694
MvCosts::mv_cost_stack
int ** mv_cost_stack
Points to the nmv_cost_hp in use.
Definition: block.h:719
OBMCBuffer
Contains buffers used to speed up rdopt for obmc.
Definition: block.h:299
OBMCBuffer::left_pred
uint8_t * left_pred
Prediction from the up predictor.
Definition: block.h:319
OBMCBuffer::wsrc
int32_t * wsrc
A new source weighted with the above and left predictors.
Definition: block.h:304
OBMCBuffer::mask
int32_t * mask
A new mask constructed from the original horz/vert mask.
Definition: block.h:309
OBMCBuffer::above_pred
uint8_t * above_pred
Prediction from the up predictor.
Definition: block.h:314
PALETTE_BUFFER
Contains color maps used in palette mode.
Definition: block.h:324
PartitionSearchInfo
Holds some parameters related to partitioning schemes in AV1.
Definition: block.h:352
PartitionSearchInfo::cnn_output_valid
int cnn_output_valid
Whether the CNN buffer contains valid output.
Definition: block.h:362
PartitionSearchInfo::log_q
float log_q
log of the quantization parameter of the ancestor BLOCK_64X64.
Definition: block.h:366
PartitionSearchInfo::quad_tree_idx
int quad_tree_idx
Current index on the partition block quad tree.
Definition: block.h:360
SuperBlockEnc
Superblock level encoder info.
Definition: block.h:50
SuperBlockEnc::min_partition_size
BLOCK_SIZE min_partition_size
Maximum partition size for the sb.
Definition: block.h:52
SuperBlockEnc::max_partition_size
BLOCK_SIZE max_partition_size
Minimum partition size for the sb.
Definition: block.h:54
SuperBlockEnc::tpl_stride
int tpl_stride
TPL's stride for the arrays in this struct.
Definition: block.h:72
SuperBlockEnc::tpl_data_count
int tpl_data_count
Number of TPL blocks in this superblock.
Definition: block.h:64
TxfmSearchInfo
Stores various encoding/search decisions related to txfm search.
Definition: block.h:462
TxfmSearchInfo::skip_txfm
int skip_txfm
Whether to skip transform and quantization on a partition block level.
Definition: block.h:464
TxfmSearchInfo::txb_split_count
unsigned int txb_split_count
Number of txb splits.
Definition: block.h:499
TxfmSearchInfo::mb_rd_record
MB_RD_RECORD * mb_rd_record
Txfm hash records of inter-modes.
Definition: block.h:487
TxfmSearchParams
Defines the parameters used to perform txfm search.
Definition: block.h:389
TxfmSearchParams::mode_eval_type
int mode_eval_type
Definition: block.h:447
TxfmSearchParams::use_qm_dist_metric
int use_qm_dist_metric
Definition: block.h:441
TxfmSearchParams::use_default_intra_tx_type
int use_default_intra_tx_type
Whether to limit the intra txfm search type to the default txfm.
Definition: block.h:395
TxfmSearchParams::prune_2d_txfm_mode
int prune_2d_txfm_mode
Whether to prune 2d transforms based on 1d transform results.
Definition: block.h:401
TxfmSearchParams::tx_mode_search_type
TX_MODE tx_mode_search_type
How to search for the optimal tx_size.
Definition: block.h:430
TxfmSearchParams::tx_size_search_method
TX_SIZE_SEARCH_METHOD tx_size_search_method
Variable from WinnerModeParams based on current eval mode.
Definition: block.h:411
TxfmSearchParams::default_inter_tx_type_prob_thresh
int default_inter_tx_type_prob_thresh
Definition: block.h:398
TxfmSearchParams::predict_dc_level
unsigned int predict_dc_level
Definition: block.h:435
TxfmSearchParams::tx_domain_dist_threshold
unsigned int tx_domain_dist_threshold
Variable from WinnerModeParams based on current eval mode.
Definition: block.h:409
TxfmSearchParams::skip_txfm_level
unsigned int skip_txfm_level
Variable from WinnerModeParams based on current eval mode.
Definition: block.h:415
TxfmSearchParams::use_transform_domain_distortion
unsigned int use_transform_domain_distortion
Variable from WinnerModeParams based on current eval mode.
Definition: block.h:413
WARP_SAMPLE_INFO
Holds the motion samples for warp motion model estimation.
Definition: block.h:757
WARP_SAMPLE_INFO::num
int num
Number of samples.
Definition: block.h:759
WinnerModeStats
Stores the best performing modes.
Definition: block.h:78
WinnerModeStats::rate_y
int rate_y
Luma rate of the winner mode.
Definition: block.h:86
WinnerModeStats::color_index_map
uint8_t color_index_map[MAX_SB_SQUARE]
The color map needed to reconstruct palette mode.
Definition: block.h:90
WinnerModeStats::rd_cost
RD_STATS rd_cost
Rdstats of the winner mode.
Definition: block.h:82
WinnerModeStats::mbmi
MB_MODE_INFO mbmi
The mbmi used to reconstruct the winner mode.
Definition: block.h:80
WinnerModeStats::mode_index
THR_MODES mode_index
The current winner mode.
Definition: block.h:92
WinnerModeStats::rate_uv
int rate_uv
Chroma rate of the winner mode.
Definition: block.h:88
WinnerModeStats::rd
int64_t rd
Rdcost of the winner mode.
Definition: block.h:84
macroblock_plane
Each source plane of the current macroblock.
Definition: block.h:99
macroblock_plane::qcoeff
tran_low_t * qcoeff
Quantized coefficients.
Definition: block.h:105
macroblock_plane::quant_shift_QTX
const int16_t * quant_shift_QTX
Scale factor to shift coefficients toward zero. Only used by QUANT_B.
Definition: block.h:131
macroblock_plane::quant_fp_QTX
const int16_t * quant_fp_QTX
Quantization step size used by AV1_XFORM_QUANT_FP.
Definition: block.h:123
macroblock_plane::dequant_QTX
const int16_t * dequant_QTX
Dequantizer.
Definition: block.h:135
macroblock_plane::dqcoeff
tran_low_t * dqcoeff
Dequantized coefficients.
Definition: block.h:103
macroblock_plane::zbin_QTX
const int16_t * zbin_QTX
Size of the quantization bin around 0. Only Used by QUANT_B.
Definition: block.h:133
macroblock_plane::quant_QTX
const int16_t * quant_QTX
Quantization step size used by AV1_XFORM_QUANT_B.
Definition: block.h:127
macroblock_plane::src
struct buf_2d src
A buffer containing the source frame.
Definition: block.h:113
macroblock_plane::eobs
uint16_t * eobs
Location of the end of qcoeff (end of block).
Definition: block.h:109
macroblock_plane::coeff
tran_low_t * coeff
Transformed coefficients.
Definition: block.h:107
macroblock_plane::src_diff
int16_t * src_diff
Stores source - pred so the txfm can be computed later.
Definition: block.h:101
macroblock_plane::txb_entropy_ctx
uint8_t * txb_entropy_ctx
Contexts used to code the transform coefficients.
Definition: block.h:111
macroblock_plane::round_fp_QTX
const int16_t * round_fp_QTX
Offset used for rounding in the quantizer process by AV1_XFORM_QUANT_FP.
Definition: block.h:125
macroblock_plane::round_QTX
const int16_t * round_QTX
Offset used for rounding in the quantizer process by AV1_XFORM_QUANT_B.
Definition: block.h:129
macroblock
Encoder's parameters related to the current coding block.
Definition: block.h:813
macroblock::delta_qindex
int delta_qindex
Difference between frame-level qindex and current qindex.
Definition: block.h:908
macroblock::warp_sample_info
WARP_SAMPLE_INFO warp_sample_info[REF_FRAMES]
Warp motion samples buffer.
Definition: block.h:1042
macroblock::mbmi_ext_frame
MB_MODE_INFO_EXT_FRAME * mbmi_ext_frame
Finalized mbmi_ext for the whole frame.
Definition: block.h:845
macroblock::sb_energy_level
int sb_energy_level
Energy in the current source superblock. Used to calculate rdmult.
Definition: block.h:929
macroblock::tmp_pred_bufs
uint8_t * tmp_pred_bufs[2]
Temporary buffer to hold prediction.
Definition: block.h:889
macroblock::mb_energy
int mb_energy
Energy in the current source coding block. Used to calculate rdmult.
Definition: block.h:927
macroblock::skip_mode
int skip_mode
Inter skip mode.
Definition: block.h:1089
macroblock::mv_limits
FullMvLimits mv_limits
Limit for the range of motion vectors.
Definition: block.h:1193
macroblock::coeff_costs
CoeffCosts coeff_costs
The rate needed to signal the txfm coefficients to the bitstream.
Definition: block.h:944
macroblock::part_search_info
PartitionSearchInfo part_search_info
Stores some partition-search related buffers.
Definition: block.h:1067
macroblock::rdmult
int rdmult
Rate-distortion multiplier.
Definition: block.h:918
macroblock::rb
double rb
Superblock level distortion propagation factor.
Definition: block.h:924
macroblock::e_mbd
MACROBLOCKD e_mbd
Decoder's view of current coding block.
Definition: block.h:831
macroblock::last_set_offsets_loc
SetOffsetsLoc last_set_offsets_loc
A hash to make sure av1_set_offsets is called.
Definition: block.h:1255
macroblock::actual_num_seg1_blocks
int actual_num_seg1_blocks
Number of segment 1 blocks Actual number of (4x4) blocks that were applied delta-q,...
Definition: block.h:972
macroblock::source_variance
unsigned int source_variance
Variance of the source frame.
Definition: block.h:1229
macroblock::seg_skip_block
int seg_skip_block
Skip mode for the segment.
Definition: block.h:966
macroblock::pred_mv1_sad
int pred_mv1_sad[REF_FRAMES]
The sad of the 2nd mv ref (near).
Definition: block.h:1028
macroblock::row_ctx
FRAME_CONTEXT * row_ctx
Entropy context for the current row.
Definition: block.h:848
macroblock::color_sensitivity_sb
uint8_t color_sensitivity_sb[2]
Whether there is a strong color activity.
Definition: block.h:1219
macroblock::winner_mode_stats
WinnerModeStats * winner_mode_stats
Tracks the winner modes in the current coding block.
Definition: block.h:1107
macroblock::pred_sse
unsigned int pred_sse[REF_FRAMES]
SSE of the current predictor.
Definition: block.h:1231
macroblock::tmp_conv_dst
CONV_BUF_TYPE * tmp_conv_dst
Buffer to store convolution during averaging process in compound mode.
Definition: block.h:878
macroblock::mode_costs
ModeCosts mode_costs
The rate needed to signal a mode to the bitstream.
Definition: block.h:932
macroblock::pred_mv0_sad
int pred_mv0_sad[REF_FRAMES]
The sad of the 1st mv ref (nearest).
Definition: block.h:1026
macroblock::comp_rd_stats_idx
int comp_rd_stats_idx
The idx for the latest compound mode in the cache comp_rd_stats.
Definition: block.h:1144
macroblock::nonrd_prune_ref_frame_search
int nonrd_prune_ref_frame_search
Prune ref frames in real-time mode.
Definition: block.h:1059
macroblock::prev_segment_id
int prev_segment_id
Previous segment id for which qmatrices were updated. This is used to bypass setting of qmatrices if ...
Definition: block.h:991
macroblock::try_merge_partition
int try_merge_partition
Prediction for ML based partition.
Definition: block.h:1244
macroblock::pixel_gradient_info
PixelLevelGradientInfo * pixel_gradient_info
Pointer to the buffer which caches gradient information.
Definition: block.h:1172
macroblock::max_mv_context
unsigned int max_mv_context[REF_FRAMES]
Context used to determine the initial step size in motion search.
Definition: block.h:1186
macroblock::sadperbit
int sadperbit
A multiplier that converts mv cost to l1 error.
Definition: block.h:954
macroblock::compound_idx
uint8_t compound_idx
How to blend the compound predictions.
Definition: block.h:1139
macroblock::intra_sb_rdmult_modifier
int intra_sb_rdmult_modifier
Intra only, per sb rd adjustment.
Definition: block.h:921
macroblock::comp_rd_buffer
CompoundTypeRdBuffers comp_rd_buffer
Buffer used for compound_type_rd().
Definition: block.h:876
macroblock::best_pred_mv_sad
int best_pred_mv_sad[2]
The minimum of pred_mv_sad.
Definition: block.h:1024
macroblock::thresh_freq_fact
int thresh_freq_fact[BLOCK_SIZES_ALL][MAX_MODES]
Factors used for rd-thresholding.
Definition: block.h:1097
macroblock::dv_costs
IntraBCMVCosts * dv_costs
Definition: block.h:941
macroblock::mb_mode_cache
const MB_MODE_INFO * mb_mode_cache
The mode to reuse during av1_rd_pick_intra_mode_sb and av1_rd_pick_inter_mode.
Definition: block.h:1165
macroblock::palette_buffer
PALETTE_BUFFER * palette_buffer
Buffer to store the best palette map.
Definition: block.h:874
macroblock::content_state_sb
CONTENT_STATE_SB content_state_sb
Characteristics of the current superblock.
Definition: block.h:1007
macroblock::plane
struct macroblock_plane plane[3]
Each of the encoding plane.
Definition: block.h:823
macroblock::recalc_luma_mc_data
int recalc_luma_mc_data
Whether to recompute the luma prediction.
Definition: block.h:1153
macroblock::is_sb_gradient_cached
bool is_sb_gradient_cached[PLANE_TYPES]
Flags indicating the availability of cached gradient info.
Definition: block.h:1174
macroblock::obmc_buffer
OBMCBuffer obmc_buffer
Modified source and masks used for fast OBMC search.
Definition: block.h:872
macroblock::sb_enc
SuperBlockEnc sb_enc
Information on a whole superblock level.
Definition: block.h:1000
macroblock::comp_rd_stats
COMP_RD_STATS comp_rd_stats[64]
A caches of results of compound type search so they can be reused later.
Definition: block.h:1142
macroblock::use_mb_mode_cache
int use_mb_mode_cache
Whether to reuse the mode stored in mb_mode_cache.
Definition: block.h:1162
macroblock::cb_coef_buff
CB_COEFF_BUFFER * cb_coef_buff
Buffer of transformed coefficients.
Definition: block.h:867
macroblock::color_sensitivity
uint8_t color_sensitivity[2]
Color sensitivity flag for the coding block.
Definition: block.h:1221
macroblock::qindex
int qindex
Quantization index for the current partition block.
Definition: block.h:901
macroblock::must_find_valid_partition
int must_find_valid_partition
Whether to disable some features to force a mode in current block.
Definition: block.h:1076
macroblock::force_zeromv_skip
int force_zeromv_skip
Flag to force zeromv-skip block, for nonrd path.
Definition: block.h:986
macroblock::actual_num_seg2_blocks
int actual_num_seg2_blocks
Number of segment 2 blocks Actual number of (4x4) blocks that were applied delta-q,...
Definition: block.h:978
macroblock::picked_ref_frames_mask
int picked_ref_frames_mask[MAX_MIB_SIZE *MAX_MIB_SIZE]
Reference frames picked by the square subblocks in a superblock.
Definition: block.h:1050
macroblock::mv_costs
MvCosts * mv_costs
Definition: block.h:936
macroblock::txfm_search_info
TxfmSearchInfo txfm_search_info
Results of the txfm searches that have been done.
Definition: block.h:1212
macroblock::pred_mv_sad
int pred_mv_sad[REF_FRAMES]
Sum absolute distortion of the predicted mv for each ref frame.
Definition: block.h:1018
macroblock::src_var_info_of_4x4_sub_blocks
Block4x4VarInfo * src_var_info_of_4x4_sub_blocks
Pointer to buffer which caches sub-block variances in a superblock.
Definition: block.h:1252
macroblock::intrabc_hash_info
IntraBCHashInfo intrabc_hash_info
Data structure to speed up intrabc search.
Definition: block.h:1159
macroblock::errorperbit
int errorperbit
A multiplier that converts mv cost to l2 error.
Definition: block.h:952
macroblock::tile_pb_ctx
FRAME_CONTEXT * tile_pb_ctx
Entropy context for the current tile.
Definition: block.h:857
macroblock::inter_modes_info
struct inter_modes_info * inter_modes_info
Stores the inter mode information needed to build an rd model.
Definition: block.h:1136
macroblock::cb_offset
uint16_t cb_offset[PLANE_TYPES]
Offset of current coding block's coeff buffer relative to the sb.
Definition: block.h:869
macroblock::winner_mode_count
int winner_mode_count
Tracks how many winner modes there are.
Definition: block.h:1109
macroblock::cnt_zeromv
int cnt_zeromv
Number of zero motion vectors.
Definition: block.h:982
macroblock::rd_model
TXFM_RD_MODEL rd_model
The model used for rd-estimation to avoid txfm.
Definition: block.h:1123
macroblock::txfm_search_params
TxfmSearchParams txfm_search_params
Parameters that control how motion search is done.
Definition: block.h:1205
macroblock::tpl_keep_ref_frame
uint8_t tpl_keep_ref_frame[REF_FRAMES]
Disables certain ref frame pruning based on tpl.
Definition: block.h:1036
macroblock::mbmi_ext
MB_MODE_INFO_EXT mbmi_ext
Derived coding information.
Definition: block.h:838
macroblockd
Variables related to current coding block.
Definition: blockd.h:577
macroblockd::lossless
int lossless[8]
Definition: blockd.h:824