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#include "av1/encoder/mcomp_structs.h"
26#if !CONFIG_REALTIME_ONLY
27#include "av1/encoder/partition_cnn_weights.h"
28#endif
29
30#include "av1/encoder/hash_motion.h"
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
37#define MIN_TPL_BSIZE_1D 16
39#define MAX_TPL_BLK_IN_SB (MAX_SB_SIZE / MIN_TPL_BSIZE_1D)
41#define RD_RECORD_BUFFER_LEN 8
42
44#define MAX_TX_TYPE_PROB 1024
45
47#define TOP_INTER_TX_NO_SPLIT_COUNT 4
48
50#define COLOR_SENS_IDX(plane) ((plane) - 1)
51
53#define COLLECT_NONRD_PICK_MODE_STAT 0
54
56#if COLLECT_NONRD_PICK_MODE_STAT
57#include "aom_ports/aom_timer.h"
58
59typedef struct _mode_search_stat_nonrd {
60 int32_t num_blocks[BLOCK_SIZES];
61 int64_t total_block_times[BLOCK_SIZES];
62 int32_t num_searches[BLOCK_SIZES][MB_MODE_COUNT];
63 int32_t num_nonskipped_searches[BLOCK_SIZES][MB_MODE_COUNT];
64 int64_t search_times[BLOCK_SIZES][MB_MODE_COUNT];
65 int64_t nonskipped_search_times[BLOCK_SIZES][MB_MODE_COUNT];
66 int64_t ms_time[BLOCK_SIZES][MB_MODE_COUNT];
67 int64_t ifs_time[BLOCK_SIZES][MB_MODE_COUNT];
68 int64_t model_rd_time[BLOCK_SIZES][MB_MODE_COUNT];
69 int64_t txfm_time[BLOCK_SIZES][MB_MODE_COUNT];
70 struct aom_usec_timer timer1;
71 struct aom_usec_timer timer2;
72 struct aom_usec_timer bsize_timer;
73} mode_search_stat_nonrd;
74#endif // COLLECT_NONRD_PICK_MODE_STAT
76
83 typedef struct {
85 BLOCK_SIZE min_partition_size;
87 BLOCK_SIZE max_partition_size;
88
89
97 int tpl_data_count;
99 int64_t tpl_inter_cost[MAX_TPL_BLK_IN_SB * MAX_TPL_BLK_IN_SB];
101 int64_t tpl_intra_cost[MAX_TPL_BLK_IN_SB * MAX_TPL_BLK_IN_SB];
103 int_mv tpl_mv[MAX_TPL_BLK_IN_SB * MAX_TPL_BLK_IN_SB][INTER_REFS_PER_FRAME];
105 int tpl_stride;
107} SuperBlockEnc;
108
111 typedef struct {
113 MB_MODE_INFO mbmi;
115 RD_STATS rd_cost;
117 int64_t rd;
119 int rate_y;
121 int rate_uv;
123 uint8_t color_index_map[MAX_SB_SQUARE];
125 THR_MODES mode_index;
126} WinnerModeStats;
127
132 typedef struct macroblock_plane {
134 int16_t *src_diff;
136 tran_low_t *dqcoeff;
138 tran_low_t *qcoeff;
140 tran_low_t *coeff;
142 uint16_t *eobs;
144 uint8_t *txb_entropy_ctx;
146 struct buf_2d src;
147
156 const int16_t *quant_fp_QTX;
158 const int16_t *round_fp_QTX;
160 const int16_t *quant_QTX;
162 const int16_t *round_QTX;
164 const int16_t *quant_shift_QTX;
166 const int16_t *zbin_QTX;
168 const int16_t *dequant_QTX;
170} MACROBLOCK_PLANE;
171
176 typedef struct {
178 int txb_skip_cost[TXB_SKIP_CONTEXTS][2];
183 int base_eob_cost[SIG_COEF_CONTEXTS_EOB][3];
188 int base_cost[SIG_COEF_CONTEXTS][8];
193 int eob_extra_cost[EOB_COEF_CONTEXTS][2];
195 int dc_sign_cost[DC_SIGN_CONTEXTS][2];
197 int lps_cost[LEVEL_CONTEXTS][COEFF_BASE_RANGE + 1 + COEFF_BASE_RANGE + 1];
198} LV_MAP_COEFF_COST;
199
202 typedef struct {
204 int eob_cost[2][11];
205} LV_MAP_EOB_COST;
206
209 typedef struct {
211 tran_low_t *tcoeff[MAX_MB_PLANE];
213 uint16_t *eobs[MAX_MB_PLANE];
220 uint8_t *entropy_ctx[MAX_MB_PLANE];
221} CB_COEFF_BUFFER;
222
225 typedef struct {
226 // TODO(angiebird): Reduce the buffer size according to sb_type
228 CANDIDATE_MV ref_mv_stack[MODE_CTX_REF_FRAMES][USABLE_REF_MV_STACK_SIZE];
230 uint16_t weight[MODE_CTX_REF_FRAMES][USABLE_REF_MV_STACK_SIZE];
232 uint8_t ref_mv_count[MODE_CTX_REF_FRAMES];
234 int_mv global_mvs[REF_FRAMES];
236 int16_t mode_context[MODE_CTX_REF_FRAMES];
237} MB_MODE_INFO_EXT;
238
245 typedef struct {
247 CANDIDATE_MV ref_mv_stack[USABLE_REF_MV_STACK_SIZE];
249 uint16_t weight[USABLE_REF_MV_STACK_SIZE];
251 uint8_t ref_mv_count;
252 // TODO(Ravi/Remya): Reduce the buffer size of global_mvs
254 int_mv global_mvs[REF_FRAMES];
256 int16_t mode_context;
258 uint16_t cb_offset[PLANE_TYPES];
259} MB_MODE_INFO_EXT_FRAME;
260
263 typedef struct {
265 TX_SIZE tx_size;
267 TX_SIZE inter_tx_size[INTER_TX_SIZE_BUF_LEN];
269 uint8_t blk_skip[MAX_MIB_SIZE * MAX_MIB_SIZE];
271 uint8_t tx_type_map[MAX_MIB_SIZE * MAX_MIB_SIZE];
273 RD_STATS rd_stats;
275 uint32_t hash_value;
276} MB_RD_INFO;
277
284 typedef struct {
288 MB_RD_INFO mb_rd_info[RD_RECORD_BUFFER_LEN];
290 int index_start;
292 int num;
294 CRC32C crc_calculator;
295} MB_RD_RECORD;
296
298#define MAX_COMP_RD_STATS 64
301 typedef struct {
303 int32_t rate[COMPOUND_TYPES];
305 int64_t dist[COMPOUND_TYPES];
307 int32_t model_rate[COMPOUND_TYPES];
309 int64_t model_dist[COMPOUND_TYPES];
311 int comp_rs2[COMPOUND_TYPES];
313 int_mv mv[2];
315 MV_REFERENCE_FRAME ref_frames[2];
317 PREDICTION_MODE mode;
319 int_interpfilters filter;
321 int ref_mv_idx;
323 int is_global[2];
325 INTERINTER_COMPOUND_DATA interinter_comp;
326} COMP_RD_STATS;
327
332 typedef struct {
337 int32_t *wsrc;
342 int32_t *mask;
347 uint8_t *above_pred;
352 uint8_t *left_pred;
353} OBMCBuffer;
354
357 typedef struct {
359 uint8_t best_palette_color_map[MAX_PALETTE_SQUARE];
361 int16_t kmeans_data_buf[2 * MAX_PALETTE_SQUARE];
362} PALETTE_BUFFER;
363
369 typedef struct {
371 uint8_t *pred0;
373 uint8_t *pred1;
375 int16_t *residual1;
377 int16_t *diff10;
379 uint8_t *tmp_best_mask_buf;
380} CompoundTypeRdBuffers;
381
384// TODO(chiyotsai@google.com): Consolidate this with SIMPLE_MOTION_DATA_TREE
385 typedef struct {
386#if !CONFIG_REALTIME_ONLY
387 // The following 4 parameters are used for cnn-based partitioning on intra
388 // frame.
393 int quad_tree_idx;
395 int cnn_output_valid;
397 float cnn_buffer[CNN_OUT_BUF_SIZE];
399 float log_q;
400#endif
401
415 uint8_t variance_low[105];
416} PartitionSearchInfo;
417
419enum {
423 TX_PRUNE_NONE = 0,
427 TX_PRUNE_LARGEST = 1,
431 TX_PRUNE_SPLIT = 2,
432} UENUM1BYTE(TX_PRUNE_TYPE);
434
439 typedef struct {
445 int use_default_intra_tx_type;
446
450 int use_derived_intra_tx_type_set;
451
453 int default_inter_tx_type_prob_thresh;
454
456 int prune_2d_txfm_mode;
457
462 unsigned int coeff_opt_thresholds[2];
464 unsigned int tx_domain_dist_threshold;
466 TX_SIZE_SEARCH_METHOD tx_size_search_method;
468 unsigned int use_transform_domain_distortion;
470 unsigned int skip_txfm_level;
471
485 TX_MODE tx_mode_search_type;
486
495 unsigned int predict_dc_level;
496
501 int use_qm_dist_metric;
502
507 int mode_eval_type;
508
509#if !CONFIG_REALTIME_ONLY
511 TX_PRUNE_TYPE nn_prune_depths_for_intra_tx;
512
518 bool enable_nn_prune_intra_tx_depths;
519#endif
520} TxfmSearchParams;
521
523#define MAX_NUM_8X8_TXBS ((MAX_MIB_SIZE >> 1) * (MAX_MIB_SIZE >> 1))
524#define MAX_NUM_16X16_TXBS ((MAX_MIB_SIZE >> 2) * (MAX_MIB_SIZE >> 2))
525#define MAX_NUM_32X32_TXBS ((MAX_MIB_SIZE >> 3) * (MAX_MIB_SIZE >> 3))
526#define MAX_NUM_64X64_TXBS ((MAX_MIB_SIZE >> 4) * (MAX_MIB_SIZE >> 4))
528
534 typedef struct {
536 uint8_t skip_txfm;
537
545 uint8_t blk_skip[MAX_MIB_SIZE * MAX_MIB_SIZE];
546
556 uint8_t tx_type_map_[MAX_MIB_SIZE * MAX_MIB_SIZE];
557
559 MB_RD_RECORD *mb_rd_record;
560
569 // TODO(chiyotsai@google.com): Move this to a more appropriate location such
570 // as ThreadData.
571 unsigned int txb_split_count;
572#if CONFIG_SPEED_STATS
574 unsigned int tx_search_count;
575#endif // CONFIG_SPEED_STATS
576} TxfmSearchInfo;
577#undef MAX_NUM_8X8_TXBS
578#undef MAX_NUM_16X16_TXBS
579#undef MAX_NUM_32X32_TXBS
580#undef MAX_NUM_64X64_TXBS
581
587 typedef struct {
588
593 int partition_cost[PARTITION_CONTEXTS][EXT_PARTITION_TYPES];
595
596
601 int mbmode_cost[BLOCK_SIZE_GROUPS][INTRA_MODES];
603 int y_mode_costs[INTRA_MODES][INTRA_MODES][INTRA_MODES];
605 int intra_uv_mode_cost[CFL_ALLOWED_TYPES][INTRA_MODES][UV_INTRA_MODES];
607 int filter_intra_cost[BLOCK_SIZES_ALL][2];
609 int filter_intra_mode_cost[FILTER_INTRA_MODES];
611 int angle_delta_cost[DIRECTIONAL_MODES][2 * MAX_ANGLE_DELTA + 1];
612
614 int cfl_cost[CFL_JOINT_SIGNS][CFL_PRED_PLANES][CFL_ALPHABET_SIZE];
616
617
622 int intrabc_cost[2];
623
625 int palette_y_size_cost[PALATTE_BSIZE_CTXS][PALETTE_SIZES];
627 int palette_uv_size_cost[PALATTE_BSIZE_CTXS][PALETTE_SIZES];
629 int palette_y_color_cost[PALETTE_SIZES][PALETTE_COLOR_INDEX_CONTEXTS]
630 [PALETTE_COLORS];
632 int palette_uv_color_cost[PALETTE_SIZES][PALETTE_COLOR_INDEX_CONTEXTS]
633 [PALETTE_COLORS];
635 int palette_y_mode_cost[PALATTE_BSIZE_CTXS][PALETTE_Y_MODE_CONTEXTS][2];
637 int palette_uv_mode_cost[PALETTE_UV_MODE_CONTEXTS][2];
639
640
645 int skip_mode_cost[SKIP_MODE_CONTEXTS][2];
647 int newmv_mode_cost[NEWMV_MODE_CONTEXTS][2];
649 int zeromv_mode_cost[GLOBALMV_MODE_CONTEXTS][2];
651 int refmv_mode_cost[REFMV_MODE_CONTEXTS][2];
653 int drl_mode_cost0[DRL_MODE_CONTEXTS][2];
655
656
661 int single_ref_cost[REF_CONTEXTS][SINGLE_REFS - 1][2];
663 int comp_inter_cost[COMP_INTER_CONTEXTS][2];
665 int comp_ref_type_cost[COMP_REF_TYPE_CONTEXTS]
666 [CDF_SIZE(COMP_REFERENCE_TYPES)];
668 int uni_comp_ref_cost[UNI_COMP_REF_CONTEXTS][UNIDIR_COMP_REFS - 1]
669 [CDF_SIZE(2)];
674 int comp_ref_cost[REF_CONTEXTS][FWD_REFS - 1][2];
679 int comp_bwdref_cost[REF_CONTEXTS][BWD_REFS - 1][2];
681
682
687 int intra_inter_cost[INTRA_INTER_CONTEXTS][2];
689 int inter_compound_mode_cost[INTER_MODE_CONTEXTS][INTER_COMPOUND_MODES];
691 int compound_type_cost[BLOCK_SIZES_ALL][MASKED_COMPOUND_TYPES];
693 int wedge_idx_cost[BLOCK_SIZES_ALL][16];
695 int interintra_cost[BLOCK_SIZE_GROUPS][2];
697 int wedge_interintra_cost[BLOCK_SIZES_ALL][2];
699 int interintra_mode_cost[BLOCK_SIZE_GROUPS][INTERINTRA_MODES];
701
702
707 int comp_idx_cost[COMP_INDEX_CONTEXTS][2];
709 int comp_group_idx_cost[COMP_GROUP_IDX_CONTEXTS][2];
711
712
717 int motion_mode_cost[BLOCK_SIZES_ALL][MOTION_MODES];
719 int motion_mode_cost1[BLOCK_SIZES_ALL][2];
721 int switchable_interp_costs[SWITCHABLE_FILTER_CONTEXTS][SWITCHABLE_FILTERS];
723
724
729 int skip_txfm_cost[SKIP_CONTEXTS][2];
731 int tx_size_cost[TX_SIZES - 1][TX_SIZE_CONTEXTS][TX_SIZES];
733 int txfm_partition_cost[TXFM_PARTITION_CONTEXTS][2];
735 int inter_tx_type_costs[EXT_TX_SETS_INTER][EXT_TX_SIZES][TX_TYPES];
737 int intra_tx_type_costs[EXT_TX_SETS_INTRA][EXT_TX_SIZES][INTRA_MODES]
738 [TX_TYPES];
740
741
746 int switchable_restore_cost[RESTORE_SWITCHABLE_TYPES];
748 int wiener_restore_cost[2];
750 int sgrproj_restore_cost[2];
752
753
758 int tmp_pred_cost[SEG_TEMPORAL_PRED_CTXS][2];
760 int spatial_pred_cost[SPATIAL_PREDICTION_PROBS][MAX_SEGMENTS];
762} ModeCosts;
763
766 typedef struct {
767
780 int nmv_joint_cost[MV_JOINTS];
781
783 int nmv_cost_alloc[2][MV_VALS];
785 int nmv_cost_hp_alloc[2][MV_VALS];
787 int *nmv_cost[2];
789 int *nmv_cost_hp[2];
791 int **mv_cost_stack;
793} MvCosts;
794
797 typedef struct {
799 int joint_mv[MV_JOINTS];
800
806 int dv_costs_alloc[2][MV_VALS];
807
809 int *dv_costs[2];
810} IntraBCMVCosts;
811
814 typedef struct {
816 LV_MAP_COEFF_COST coeff_costs[TX_SIZES][PLANE_TYPES];
818 LV_MAP_EOB_COST eob_costs[7][2];
819} CoeffCosts;
820
822// 4: NEAREST, NEW, NEAR, GLOBAL
823#define SINGLE_REF_MODES ((REF_FRAMES - 1) * 4)
825struct inter_modes_info;
826
829 typedef struct {
831 int num;
833 int pts[16];
835 int pts_inref[16];
836} WARP_SAMPLE_INFO;
837
839typedef enum {
840 kZeroSad = 0,
841 kVeryLowSad = 1,
842 kLowSad = 2,
843 kMedSad = 3,
844 kHighSad = 4
845} SOURCE_SAD;
846
847typedef struct {
849 SOURCE_SAD source_sad_nonrd;
851 SOURCE_SAD source_sad_rd;
852 int lighting_change;
853 int low_sumdiff;
854} CONTENT_STATE_SB;
855
856// Structure to hold pixel level gradient info.
857typedef struct {
858 uint16_t abs_dx_abs_dy_sum;
859 int8_t hist_bin_idx;
860 bool is_dx_zero;
861} PixelLevelGradientInfo;
862
863// Structure to hold the variance and log(1 + variance) for 4x4 sub-blocks.
864typedef struct {
865 double log_var;
866 int var;
867} Block4x4VarInfo;
868
869#ifndef NDEBUG
870typedef struct SetOffsetsLoc {
871 int mi_row;
872 int mi_col;
873 BLOCK_SIZE bsize;
874} SetOffsetsLoc;
875#endif // NDEBUG
876
878
880#define TOP_COMP_AVG_EST_RD_COUNT 5
881
889 typedef struct macroblock {
890
899 struct macroblock_plane plane[MAX_MB_PLANE];
900
907 MACROBLOCKD e_mbd;
908
914 MB_MODE_INFO_EXT mbmi_ext;
915
921 MB_MODE_INFO_EXT_FRAME *mbmi_ext_frame;
922
924 FRAME_CONTEXT *row_ctx;
933 FRAME_CONTEXT *tile_pb_ctx;
934
943 CB_COEFF_BUFFER *cb_coef_buff;
945 uint16_t cb_offset[PLANE_TYPES];
946
948 OBMCBuffer obmc_buffer;
950 PALETTE_BUFFER *palette_buffer;
952 CompoundTypeRdBuffers comp_rd_buffer;
954 CONV_BUF_TYPE *tmp_conv_dst;
955
965 uint8_t *tmp_pred_bufs[2];
966
970 uint8_t *upsample_pred;
972
973
982 int qindex;
983
989 int delta_qindex;
990
999 int rdmult_delta_qindex;
1000
1004 int rdmult_cur_qindex;
1005
1014 int rdmult;
1015
1017 int intra_sb_rdmult_modifier;
1018
1020 double rb;
1021
1023 int mb_energy;
1025 int sb_energy_level;
1026
1028 ModeCosts mode_costs;
1029
1032 MvCosts *mv_costs;
1033
1037 IntraBCMVCosts *dv_costs;
1038
1040 CoeffCosts coeff_costs;
1042
1043
1048 int errorperbit;
1050 int sadperbit;
1052
1053
1062 int seg_skip_block;
1063
1068 int actual_num_seg1_blocks;
1069
1074 int actual_num_seg2_blocks;
1075
1078 int cnt_zeromv;
1079
1085 int force_zeromv_skip_for_sb;
1086
1089 int force_zeromv_skip_for_blk;
1090
1094 int prev_segment_id;
1096
1097
1102 // TODO(chiyotsai@google.com): Refactor this out of macroblock
1103 SuperBlockEnc sb_enc;
1104
1110 CONTENT_STATE_SB content_state_sb;
1112
1113
1121 int pred_mv_sad[REF_FRAMES];
1127 int best_pred_mv_sad[2];
1129 int pred_mv0_sad[REF_FRAMES];
1131 int pred_mv1_sad[REF_FRAMES];
1132
1139 uint8_t tpl_keep_ref_frame[REF_FRAMES];
1140
1145 WARP_SAMPLE_INFO warp_sample_info[REF_FRAMES];
1146
1153 int picked_ref_frames_mask[MAX_MIB_SIZE * MAX_MIB_SIZE];
1154
1162 int nonrd_prune_ref_frame_search;
1164
1165
1170 PartitionSearchInfo part_search_info;
1171
1179 int must_find_valid_partition;
1181
1182
1192 int skip_mode;
1193
1200 int thresh_freq_fact[BLOCK_SIZES_ALL][MAX_MODES];
1201
1210 WinnerModeStats *winner_mode_stats;
1212 int winner_mode_count;
1213
1226 TXFM_RD_MODEL rd_model;
1227
1237 // TODO(any): try to consolidate this speed feature with winner mode
1238 // processing.
1239 struct inter_modes_info *inter_modes_info;
1240
1242 uint8_t compound_idx;
1243
1245 COMP_RD_STATS comp_rd_stats[MAX_COMP_RD_STATS];
1247 int comp_rd_stats_idx;
1248
1256 int recalc_luma_mc_data;
1257
1262 IntraBCHashInfo intrabc_hash_info;
1263
1265 int use_mb_mode_cache;
1268 const MB_MODE_INFO *mb_mode_cache;
1275 PixelLevelGradientInfo *pixel_gradient_info;
1277 bool is_sb_gradient_cached[PLANE_TYPES];
1278
1280 bool reuse_inter_pred;
1282
1283
1292 unsigned int max_mv_context[REF_FRAMES];
1293
1299 FullMvLimits mv_limits;
1300
1308 search_site_config search_site_cfg_buf[NUM_DISTINCT_SEARCH_METHODS];
1310
1311
1320 TxfmSearchParams txfm_search_params;
1321
1327 TxfmSearchInfo txfm_search_info;
1328
1334 uint8_t color_sensitivity_sb[MAX_MB_PLANE - 1];
1336 uint8_t color_sensitivity_sb_g[MAX_MB_PLANE - 1];
1338 uint8_t color_sensitivity_sb_alt[MAX_MB_PLANE - 1];
1340 uint8_t color_sensitivity[MAX_MB_PLANE - 1];
1342 int64_t min_dist_inter_uv;
1343
1345 int color_palette_thresh;
1346
1348 // should be checked at the coding block level.
1349 int force_color_check_block_level;
1350
1352 // so we can keep dqcoeff of the best tx_type.
1353 tran_low_t *dqcoeff_buf;
1355
1356
1361 unsigned int source_variance;
1363 int block_is_zero_sad;
1365 // good/reliable, and so the superblock MV will be tested in the
1366 // nonrd_pickmode. This is only used for LAST_FRAME.
1367 int sb_me_partition;
1369 // nonrd_pickmode.
1370 int sb_me_block;
1372 int sb_col_scroll;
1374 int sb_row_scroll;
1376 // the variance_partitioning.
1377 int_mv sb_me_mv;
1379 // speed feature rt_sf->use_fast_fixed_part is enabled.
1380 int sb_force_fixed_part;
1382 unsigned int pred_sse[REF_FRAMES];
1384#if CONFIG_RT_ML_PARTITIONING
1385 DECLARE_ALIGNED(16, uint8_t, est_pred[128 * 128]);
1386#endif
1388
1395 int try_merge_partition;
1396
1403 Block4x4VarInfo *src_var_info_of_4x4_sub_blocks;
1404#ifndef NDEBUG
1406 SetOffsetsLoc last_set_offsets_loc;
1407#endif // NDEBUG
1408
1409#if COLLECT_NONRD_PICK_MODE_STAT
1410 mode_search_stat_nonrd ms_stat_nonrd;
1411#endif // COLLECT_NONRD_PICK_MODE_STAT
1412
1416 int palette_pixels;
1417
1419 int64_t top_inter_tx_no_split_rd[MAX_TX_BLOCKS_IN_MAX_SB]
1420 [TOP_INTER_TX_NO_SPLIT_COUNT];
1421
1425 struct SB_FIRST_PASS_STATS *sb_stats_cache;
1426
1430 struct SB_FIRST_PASS_STATS *sb_fp_stats;
1431
1433 int64_t top_comp_avg_est_rd[TOP_COMP_AVG_EST_RD_COUNT];
1434
1435#if CONFIG_PARTITION_SEARCH_ORDER
1439 RD_STATS *rdcost;
1440#endif // CONFIG_PARTITION_SEARCH_ORDER
1441} MACROBLOCK;
1442#undef SINGLE_REF_MODES
1443
1445// Zeroes out 'n_stats' elements in the array x->winner_mode_stats.
1446// It only zeroes out what is necessary in 'color_index_map' (just the block
1447// size, not the whole array).
1448static inline void zero_winner_mode_stats(BLOCK_SIZE bsize, int n_stats,
1449 WinnerModeStats *stats) {
1450 // When winner mode stats are not required, the memory allocation is avoided
1451 // for x->winner_mode_stats. The stats pointer will be NULL in such cases.
1452 if (stats == NULL) return;
1453
1454 const int block_height = block_size_high[bsize];
1455 const int block_width = block_size_wide[bsize];
1456 for (int i = 0; i < n_stats; ++i) {
1457 WinnerModeStats *const stat = &stats[i];
1458 memset(&stat->mbmi, 0, sizeof(stat->mbmi));
1459 memset(&stat->rd_cost, 0, sizeof(stat->rd_cost));
1460 memset(&stat->rd, 0, sizeof(stat->rd));
1461 memset(&stat->rate_y, 0, sizeof(stat->rate_y));
1462 memset(&stat->rate_uv, 0, sizeof(stat->rate_uv));
1463 // Do not reset the whole array as it is CPU intensive.
1464 memset(&stat->color_index_map, 0,
1465 block_width * block_height * sizeof(stat->color_index_map[0]));
1466 memset(&stat->mode_index, 0, sizeof(stat->mode_index));
1467 }
1468}
1469
1470static inline int is_rect_tx_allowed_bsize(BLOCK_SIZE bsize) {
1471 static const char LUT[BLOCK_SIZES_ALL] = {
1472 0, // BLOCK_4X4
1473 1, // BLOCK_4X8
1474 1, // BLOCK_8X4
1475 0, // BLOCK_8X8
1476 1, // BLOCK_8X16
1477 1, // BLOCK_16X8
1478 0, // BLOCK_16X16
1479 1, // BLOCK_16X32
1480 1, // BLOCK_32X16
1481 0, // BLOCK_32X32
1482 1, // BLOCK_32X64
1483 1, // BLOCK_64X32
1484 0, // BLOCK_64X64
1485 0, // BLOCK_64X128
1486 0, // BLOCK_128X64
1487 0, // BLOCK_128X128
1488 1, // BLOCK_4X16
1489 1, // BLOCK_16X4
1490 1, // BLOCK_8X32
1491 1, // BLOCK_32X8
1492 1, // BLOCK_16X64
1493 1, // BLOCK_64X16
1494 };
1495
1496 return LUT[bsize];
1497}
1498
1499static inline int is_rect_tx_allowed(const MACROBLOCKD *xd,
1500 const MB_MODE_INFO *mbmi) {
1501 return is_rect_tx_allowed_bsize(mbmi->bsize) &&
1502 !xd->lossless[mbmi->segment_id];
1503}
1504
1505static inline int tx_size_to_depth(TX_SIZE tx_size, BLOCK_SIZE bsize) {
1506 TX_SIZE ctx_size = max_txsize_rect_lookup[bsize];
1507 int depth = 0;
1508 while (tx_size != ctx_size) {
1509 depth++;
1510 ctx_size = sub_tx_size_map[ctx_size];
1511 assert(depth <= MAX_TX_DEPTH);
1512 }
1513 return depth;
1514}
1515
1516static inline void set_blk_skip(uint8_t txb_skip[], int plane, int blk_idx,
1517 int skip) {
1518 if (skip)
1519 txb_skip[blk_idx] |= 1UL << plane;
1520 else
1521 txb_skip[blk_idx] &= ~(1UL << plane);
1522#ifndef NDEBUG
1523 // Set chroma planes to uninitialized states when luma is set to check if
1524 // it will be set later
1525 if (plane == 0) {
1526 txb_skip[blk_idx] |= 1UL << (1 + 4);
1527 txb_skip[blk_idx] |= 1UL << (2 + 4);
1528 }
1529
1530 // Clear the initialization checking bit
1531 txb_skip[blk_idx] &= ~(1UL << (plane + 4));
1532#endif
1533}
1534
1535static inline int is_blk_skip(uint8_t *txb_skip, int plane, int blk_idx) {
1536#ifndef NDEBUG
1537 // Check if this is initialized
1538 assert(!(txb_skip[blk_idx] & (1UL << (plane + 4))));
1539
1540 // The magic number is 0x77, this is to test if there is garbage data
1541 assert((txb_skip[blk_idx] & 0x88) == 0);
1542#endif
1543 return (txb_skip[blk_idx] >> plane) & 1;
1544}
1545
1547
1548#ifdef __cplusplus
1549} // extern "C"
1550#endif
1551
1552#endif // AOM_AV1_ENCODER_BLOCK_H_
TOP_COMP_AVG_EST_RD_COUNT
#define TOP_COMP_AVG_EST_RD_COUNT
Maximum number of estimated RD Cost records for compound average.
Definition block.h:880
MAX_COMP_RD_STATS
#define MAX_COMP_RD_STATS
Number of compound rd stats.
Definition block.h:298
MAX_TPL_BLK_IN_SB
#define MAX_TPL_BLK_IN_SB
Maximum number of tpl block in a super block.
Definition block.h:39
RD_RECORD_BUFFER_LEN
#define RD_RECORD_BUFFER_LEN
Number of txfm hash records kept for the partition block.
Definition block.h:41
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.
TOP_INTER_TX_NO_SPLIT_COUNT
#define TOP_INTER_TX_NO_SPLIT_COUNT
Definition block.h:47
enums.h
RESTORE_SWITCHABLE_TYPES
@ RESTORE_SWITCHABLE_TYPES
Definition enums.h:614
CB_COEFF_BUFFER
Stores the transforms coefficients for the whole superblock.
Definition block.h:209
CB_COEFF_BUFFER::entropy_ctx
uint8_t * entropy_ctx[3]
Transform block entropy contexts.
Definition block.h:220
CB_COEFF_BUFFER::eobs
uint16_t * eobs[3]
Where the transformed coefficients end.
Definition block.h:213
CB_COEFF_BUFFER::tcoeff
tran_low_t * tcoeff[3]
The transformed coefficients.
Definition block.h:211
COMP_RD_STATS
Rdcost stats in compound mode.
Definition block.h:301
COMP_RD_STATS::model_dist
int64_t model_dist[COMPOUND_TYPES]
Estimated distortion of the compound modes.
Definition block.h:309
COMP_RD_STATS::filter
int_interpfilters filter
Current interpolation filter.
Definition block.h:319
COMP_RD_STATS::comp_rs2
int comp_rs2[COMPOUND_TYPES]
Rate need to send the mask type.
Definition block.h:311
COMP_RD_STATS::interinter_comp
INTERINTER_COMPOUND_DATA interinter_comp
Current parameters for interinter mode.
Definition block.h:325
COMP_RD_STATS::dist
int64_t dist[COMPOUND_TYPES]
Distortion of the compound modes.
Definition block.h:305
COMP_RD_STATS::mode
PREDICTION_MODE mode
Current prediction mode.
Definition block.h:317
COMP_RD_STATS::is_global
int is_global[2]
Whether the predictors are GLOBALMV.
Definition block.h:323
COMP_RD_STATS::rate
int32_t rate[COMPOUND_TYPES]
Rate of the compound modes.
Definition block.h:303
COMP_RD_STATS::mv
int_mv mv[2]
Motion vector for each predictor.
Definition block.h:313
COMP_RD_STATS::ref_frames
MV_REFERENCE_FRAME ref_frames[2]
Ref frame for each predictor.
Definition block.h:315
COMP_RD_STATS::model_rate
int32_t model_rate[COMPOUND_TYPES]
Estimated rate of the compound modes.
Definition block.h:307
COMP_RD_STATS::ref_mv_idx
int ref_mv_idx
Refmv index in the drl.
Definition block.h:321
CoeffCosts
Holds the costs needed to encode the coefficients.
Definition block.h:814
CoeffCosts::eob_costs
LV_MAP_EOB_COST eob_costs[7][2]
Costs for coding the eobs.
Definition block.h:818
CoeffCosts::coeff_costs
LV_MAP_COEFF_COST coeff_costs[TX_SIZES][PLANE_TYPES]
Costs for coding the coefficients.
Definition block.h:816
CompoundTypeRdBuffers
Contains buffers used by av1_compound_type_rd().
Definition block.h:369
CompoundTypeRdBuffers::diff10
int16_t * diff10
Second prediction - first prediction.
Definition block.h:377
CompoundTypeRdBuffers::pred1
uint8_t * pred1
Second prediction.
Definition block.h:373
CompoundTypeRdBuffers::residual1
int16_t * residual1
Source - first prediction.
Definition block.h:375
CompoundTypeRdBuffers::pred0
uint8_t * pred0
First prediction.
Definition block.h:371
CompoundTypeRdBuffers::tmp_best_mask_buf
uint8_t * tmp_best_mask_buf
Backup of the best segmentation mask.
Definition block.h:379
IntraBCMVCosts
Holds mv costs for intrabc.
Definition block.h:797
IntraBCMVCosts::dv_costs
int * dv_costs[2]
Definition block.h:809
IntraBCMVCosts::dv_costs_alloc
int dv_costs_alloc[2][((((1<<(11+1+2)) - 1)<< 1)+1)]
Cost of transmitting the actual motion vector. dv_costs_alloc[0][i] is the cost of motion vector with...
Definition block.h:806
IntraBCMVCosts::joint_mv
int joint_mv[4]
Definition block.h:799
LV_MAP_COEFF_COST
Costs for encoding the coefficients within a level.
Definition block.h:176
LV_MAP_COEFF_COST::base_cost
int base_cost[(26+16)][8]
Cost for encoding the base level of a coefficient.
Definition block.h:188
LV_MAP_COEFF_COST::lps_cost
int lps_cost[21][(4 *((4) - 1))+1+(4 *((4) - 1))+1]
Cost for encoding an increment to the coefficient.
Definition block.h:197
LV_MAP_COEFF_COST::txb_skip_cost
int txb_skip_cost[13][2]
Cost to skip txfm for the current txfm block.
Definition block.h:178
LV_MAP_COEFF_COST::dc_sign_cost
int dc_sign_cost[3][2]
Cost for encoding the dc_sign.
Definition block.h:195
LV_MAP_COEFF_COST::eob_extra_cost
int eob_extra_cost[9][2]
Cost for encoding the last non-zero coefficient.
Definition block.h:193
LV_MAP_COEFF_COST::base_eob_cost
int base_eob_cost[4][3]
Cost for encoding the base_eob of a level.
Definition block.h:183
LV_MAP_EOB_COST
Costs for encoding the eob.
Definition block.h:202
LV_MAP_EOB_COST::eob_cost
int eob_cost[2][11]
eob_cost.
Definition block.h:204
MB_MODE_INFO_EXT_FRAME
Stores best extended mode information at frame level.
Definition block.h:245
MB_MODE_INFO_EXT_FRAME::cb_offset
uint16_t cb_offset[PLANE_TYPES]
Offset of current coding block's coeff buffer relative to the sb.
Definition block.h:258
MB_MODE_INFO_EXT_FRAME::ref_mv_count
uint8_t ref_mv_count
Number of ref mvs in the drl.
Definition block.h:251
MB_MODE_INFO_EXT_FRAME::weight
uint16_t weight[USABLE_REF_MV_STACK_SIZE]
The weights used to compute the ref mvs.
Definition block.h:249
MB_MODE_INFO_EXT_FRAME::ref_mv_stack
CANDIDATE_MV ref_mv_stack[USABLE_REF_MV_STACK_SIZE]
The reference mv list for the current block.
Definition block.h:247
MB_MODE_INFO_EXT_FRAME::mode_context
int16_t mode_context
Context used to encode the current mode.
Definition block.h:256
MB_MODE_INFO_EXT_FRAME::global_mvs
int_mv global_mvs[REF_FRAMES]
Global mvs.
Definition block.h:254
MB_MODE_INFO_EXT
Extended mode info derived from mbmi.
Definition block.h:225
MB_MODE_INFO_EXT::global_mvs
int_mv global_mvs[REF_FRAMES]
Global mvs.
Definition block.h:234
MB_MODE_INFO_EXT::ref_mv_stack
CANDIDATE_MV ref_mv_stack[MODE_CTX_REF_FRAMES][USABLE_REF_MV_STACK_SIZE]
The reference mv list for the current block.
Definition block.h:228
MB_MODE_INFO_EXT::weight
uint16_t weight[MODE_CTX_REF_FRAMES][USABLE_REF_MV_STACK_SIZE]
The weights used to compute the ref mvs.
Definition block.h:230
MB_MODE_INFO_EXT::mode_context
int16_t mode_context[MODE_CTX_REF_FRAMES]
Context used to encode the current mode.
Definition block.h:236
MB_MODE_INFO_EXT::ref_mv_count
uint8_t ref_mv_count[MODE_CTX_REF_FRAMES]
Number of ref mvs in the drl.
Definition block.h:232
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:263
MB_RD_INFO::blk_skip
uint8_t blk_skip[MAX_MIB_SIZE *MAX_MIB_SIZE]
Map showing which txfm block skips the txfm process.
Definition block.h:269
MB_RD_INFO::tx_size
TX_SIZE tx_size
Txfm size used if the current mode is intra mode.
Definition block.h:265
MB_RD_INFO::tx_type_map
uint8_t tx_type_map[MAX_MIB_SIZE *MAX_MIB_SIZE]
Map showing the txfm types for each block.
Definition block.h:271
MB_RD_INFO::hash_value
uint32_t hash_value
Hash value of the current record.
Definition block.h:275
MB_RD_INFO::rd_stats
RD_STATS rd_stats
Rd_stats for the whole partition block.
Definition block.h:273
MB_RD_INFO::inter_tx_size
TX_SIZE inter_tx_size[INTER_TX_SIZE_BUF_LEN]
Txfm sizes used if the current mode is inter mode.
Definition block.h:267
MB_RD_RECORD
Hash records of the inter-mode transform results.
Definition block.h:284
MB_RD_RECORD::mb_rd_info
MB_RD_INFO mb_rd_info[8]
Definition block.h:288
MB_RD_RECORD::index_start
int index_start
Index to insert the newest rd record.
Definition block.h:290
MB_RD_RECORD::num
int num
Number of info stored in this record.
Definition block.h:292
MB_RD_RECORD::crc_calculator
CRC32C crc_calculator
Hash function.
Definition block.h:294
ModeCosts
Holds the entropy costs for various modes sent to the bitstream.
Definition block.h:587
ModeCosts::tx_size_cost
int tx_size_cost[TX_SIZES - 1][3][TX_SIZES]
tx_size_cost
Definition block.h:731
ModeCosts::mbmode_cost
int mbmode_cost[4][INTRA_MODES]
Luma mode cost for inter frame.
Definition block.h:601
ModeCosts::drl_mode_cost0
int drl_mode_cost0[DRL_MODE_CONTEXTS][2]
drl_mode_cost0
Definition block.h:653
ModeCosts::intrabc_cost
int intrabc_cost[2]
intrabc_cost
Definition block.h:622
ModeCosts::palette_uv_mode_cost
int palette_uv_mode_cost[2][2]
palette_uv_mode_cost
Definition block.h:637
ModeCosts::palette_y_color_cost
int palette_y_color_cost[PALETTE_SIZES][5][PALETTE_COLORS]
palette_y_color_cost
Definition block.h:630
ModeCosts::palette_y_size_cost
int palette_y_size_cost[7][PALETTE_SIZES]
palette_y_size_cost
Definition block.h:625
ModeCosts::interintra_cost
int interintra_cost[4][2]
interintra_cost
Definition block.h:695
ModeCosts::palette_uv_size_cost
int palette_uv_size_cost[7][PALETTE_SIZES]
palette_uv_size_cost
Definition block.h:627
ModeCosts::palette_uv_color_cost
int palette_uv_color_cost[PALETTE_SIZES][5][PALETTE_COLORS]
palette_uv_color_cost
Definition block.h:633
ModeCosts::comp_inter_cost
int comp_inter_cost[COMP_INTER_CONTEXTS][2]
comp_inter_cost
Definition block.h:663
ModeCosts::tmp_pred_cost
int tmp_pred_cost[3][2]
tmp_pred_cost
Definition block.h:758
ModeCosts::inter_tx_type_costs
int inter_tx_type_costs[EXT_TX_SETS_INTER][EXT_TX_SIZES][TX_TYPES]
inter_tx_type_costs
Definition block.h:735
ModeCosts::filter_intra_cost
int filter_intra_cost[BLOCK_SIZES_ALL][2]
filter_intra_cost
Definition block.h:607
ModeCosts::txfm_partition_cost
int txfm_partition_cost[TXFM_PARTITION_CONTEXTS][2]
txfm_partition_cost
Definition block.h:733
ModeCosts::spatial_pred_cost
int spatial_pred_cost[3][8]
spatial_pred_cost
Definition block.h:760
ModeCosts::newmv_mode_cost
int newmv_mode_cost[NEWMV_MODE_CONTEXTS][2]
newmv_mode_cost
Definition block.h:647
ModeCosts::wedge_idx_cost
int wedge_idx_cost[BLOCK_SIZES_ALL][16]
wedge_idx_cost
Definition block.h:693
ModeCosts::sgrproj_restore_cost
int sgrproj_restore_cost[2]
sgrproj_restore_cost
Definition block.h:750
ModeCosts::switchable_restore_cost
int switchable_restore_cost[RESTORE_SWITCHABLE_TYPES]
switchable_restore_cost
Definition block.h:746
ModeCosts::intra_inter_cost
int intra_inter_cost[INTRA_INTER_CONTEXTS][2]
intra_inter_cost
Definition block.h:687
ModeCosts::filter_intra_mode_cost
int filter_intra_mode_cost[FILTER_INTRA_MODES]
filter_intra_mode_cost
Definition block.h:609
ModeCosts::skip_txfm_cost
int skip_txfm_cost[SKIP_CONTEXTS][2]
skip_txfm_cost
Definition block.h:729
ModeCosts::refmv_mode_cost
int refmv_mode_cost[REFMV_MODE_CONTEXTS][2]
refmv_mode_cost
Definition block.h:651
ModeCosts::intra_tx_type_costs
int intra_tx_type_costs[EXT_TX_SETS_INTRA][EXT_TX_SIZES][INTRA_MODES][TX_TYPES]
intra_tx_type_costs
Definition block.h:738
ModeCosts::interintra_mode_cost
int interintra_mode_cost[4][INTERINTRA_MODES]
interintra_mode_cost
Definition block.h:699
ModeCosts::comp_bwdref_cost
int comp_bwdref_cost[REF_CONTEXTS][BWD_REFS - 1][2]
Cost for signaling ref_frame[1] in bidir-comp mode.
Definition block.h:679
ModeCosts::comp_group_idx_cost
int comp_group_idx_cost[COMP_GROUP_IDX_CONTEXTS][2]
comp_group_idx_cost
Definition block.h:709
ModeCosts::comp_ref_type_cost
int comp_ref_type_cost[COMP_REF_TYPE_CONTEXTS][((COMP_REFERENCE_TYPES)+1)]
comp_ref_type_cost
Definition block.h:666
ModeCosts::comp_ref_cost
int comp_ref_cost[REF_CONTEXTS][FWD_REFS - 1][2]
Cost for signaling ref_frame[0] in bidir-comp mode.
Definition block.h:674
ModeCosts::switchable_interp_costs
int switchable_interp_costs[((SWITCHABLE_FILTERS+1) *4)][SWITCHABLE_FILTERS]
switchable_interp_costs
Definition block.h:721
ModeCosts::wiener_restore_cost
int wiener_restore_cost[2]
wiener_restore_cost
Definition block.h:748
ModeCosts::single_ref_cost
int single_ref_cost[REF_CONTEXTS][SINGLE_REFS - 1][2]
single_ref_cost
Definition block.h:661
ModeCosts::zeromv_mode_cost
int zeromv_mode_cost[GLOBALMV_MODE_CONTEXTS][2]
zeromv_mode_cost
Definition block.h:649
ModeCosts::uni_comp_ref_cost
int uni_comp_ref_cost[UNI_COMP_REF_CONTEXTS][UNIDIR_COMP_REFS - 1][((2)+1)]
uni_comp_ref_cost
Definition block.h:669
ModeCosts::comp_idx_cost
int comp_idx_cost[COMP_INDEX_CONTEXTS][2]
comp_idx_cost
Definition block.h:707
ModeCosts::angle_delta_cost
int angle_delta_cost[DIRECTIONAL_MODES][2 *MAX_ANGLE_DELTA+1]
angle_delta_cost
Definition block.h:611
ModeCosts::motion_mode_cost1
int motion_mode_cost1[BLOCK_SIZES_ALL][2]
motion_mode_cost1
Definition block.h:719
ModeCosts::palette_y_mode_cost
int palette_y_mode_cost[7][3][2]
palette_y_mode_cost
Definition block.h:635
ModeCosts::compound_type_cost
int compound_type_cost[BLOCK_SIZES_ALL][MASKED_COMPOUND_TYPES]
compound_type_cost
Definition block.h:691
ModeCosts::skip_mode_cost
int skip_mode_cost[SKIP_MODE_CONTEXTS][2]
skip_mode_cost
Definition block.h:645
ModeCosts::inter_compound_mode_cost
int inter_compound_mode_cost[INTER_MODE_CONTEXTS][INTER_COMPOUND_MODES]
inter_compound_mode_cost
Definition block.h:689
ModeCosts::partition_cost
int partition_cost[PARTITION_CONTEXTS][EXT_PARTITION_TYPES]
Cost for coding the partition.
Definition block.h:593
ModeCosts::motion_mode_cost
int motion_mode_cost[BLOCK_SIZES_ALL][MOTION_MODES]
motion_mode_cost
Definition block.h:717
ModeCosts::intra_uv_mode_cost
int intra_uv_mode_cost[CFL_ALLOWED_TYPES][INTRA_MODES][UV_INTRA_MODES]
Chroma mode cost.
Definition block.h:605
ModeCosts::y_mode_costs
int y_mode_costs[INTRA_MODES][INTRA_MODES][INTRA_MODES]
Luma mode cost for intra frame.
Definition block.h:603
ModeCosts::cfl_cost
int cfl_cost[CFL_JOINT_SIGNS][CFL_PRED_PLANES][CFL_ALPHABET_SIZE]
Rate rate associated with each alpha codeword.
Definition block.h:614
ModeCosts::wedge_interintra_cost
int wedge_interintra_cost[BLOCK_SIZES_ALL][2]
wedge_interintra_cost
Definition block.h:697
MvCosts
Holds mv costs for encoding and motion search.
Definition block.h:766
MvCosts::nmv_cost_hp_alloc
int nmv_cost_hp_alloc[2][((((1<<(11+1+2)) - 1)<< 1)+1)]
Allocates memory for 1/8-pel motion vector costs.
Definition block.h:785
MvCosts::nmv_joint_cost
int nmv_joint_cost[4]
Costs for coding the zero components.
Definition block.h:780
MvCosts::mv_cost_stack
int ** mv_cost_stack
Points to the nmv_cost_hp in use.
Definition block.h:791
MvCosts::nmv_cost
int * nmv_cost[2]
Points to the middle of nmv_cost_alloc.
Definition block.h:787
MvCosts::nmv_cost_hp
int * nmv_cost_hp[2]
Points to the middle of nmv_cost_hp_alloc.
Definition block.h:789
MvCosts::nmv_cost_alloc
int nmv_cost_alloc[2][((((1<<(11+1+2)) - 1)<< 1)+1)]
Allocates memory for 1/4-pel motion vector costs.
Definition block.h:783
OBMCBuffer
Contains buffers used to speed up rdopt for obmc.
Definition block.h:332
OBMCBuffer::left_pred
uint8_t * left_pred
Prediction from the up predictor.
Definition block.h:352
OBMCBuffer::wsrc
int32_t * wsrc
A new source weighted with the above and left predictors.
Definition block.h:337
OBMCBuffer::mask
int32_t * mask
A new mask constructed from the original horz/vert mask.
Definition block.h:342
OBMCBuffer::above_pred
uint8_t * above_pred
Prediction from the up predictor.
Definition block.h:347
PALETTE_BUFFER
Contains color maps used in palette mode.
Definition block.h:357
PALETTE_BUFFER::kmeans_data_buf
int16_t kmeans_data_buf[2 *MAX_PALETTE_SQUARE]
A temporary buffer used for k-means clustering.
Definition block.h:361
PALETTE_BUFFER::best_palette_color_map
uint8_t best_palette_color_map[MAX_PALETTE_SQUARE]
The best color map found.
Definition block.h:359
PartitionSearchInfo
Holds some parameters related to partitioning schemes in AV1.
Definition block.h:385
PartitionSearchInfo::cnn_buffer
float cnn_buffer[((((20))+(((4) *2 *2))+(((20) *4 *4))+(((20) *8 *8))))]
A buffer used by our segmentation CNN for intra-frame partitioning.
Definition block.h:397
PartitionSearchInfo::variance_low
uint8_t variance_low[105]
Variance of the subblocks in the superblock.
Definition block.h:415
PartitionSearchInfo::cnn_output_valid
int cnn_output_valid
Whether the CNN buffer contains valid output.
Definition block.h:395
PartitionSearchInfo::log_q
float log_q
log of the quantization parameter of the ancestor BLOCK_64X64.
Definition block.h:399
PartitionSearchInfo::quad_tree_idx
int quad_tree_idx
Current index on the partition block quad tree.
Definition block.h:393
SuperBlockEnc
Superblock level encoder info.
Definition block.h:83
SuperBlockEnc::tpl_mv
int_mv tpl_mv[(MAX_SB_SIZE/16) *(MAX_SB_SIZE/16)][INTER_REFS_PER_FRAME]
Motion vectors found by TPL model for each tpl block.
Definition block.h:103
SuperBlockEnc::min_partition_size
BLOCK_SIZE min_partition_size
Maximum partition size for the sb.
Definition block.h:85
SuperBlockEnc::tpl_inter_cost
int64_t tpl_inter_cost[(MAX_SB_SIZE/16) *(MAX_SB_SIZE/16)]
TPL's estimate of inter cost for each tpl block.
Definition block.h:99
SuperBlockEnc::max_partition_size
BLOCK_SIZE max_partition_size
Minimum partition size for the sb.
Definition block.h:87
SuperBlockEnc::tpl_stride
int tpl_stride
TPL's stride for the arrays in this struct.
Definition block.h:105
SuperBlockEnc::tpl_intra_cost
int64_t tpl_intra_cost[(MAX_SB_SIZE/16) *(MAX_SB_SIZE/16)]
TPL's estimate of tpl cost for each tpl block.
Definition block.h:101
SuperBlockEnc::tpl_data_count
int tpl_data_count
Number of TPL blocks in this superblock.
Definition block.h:97
TxfmSearchInfo
Stores various encoding/search decisions related to txfm search.
Definition block.h:534
TxfmSearchInfo::txb_split_count
unsigned int txb_split_count
Number of txb splits.
Definition block.h:571
TxfmSearchInfo::blk_skip
uint8_t blk_skip[MAX_MIB_SIZE *MAX_MIB_SIZE]
Whether to skip transform and quantization on a txfm block level.
Definition block.h:545
TxfmSearchInfo::mb_rd_record
MB_RD_RECORD * mb_rd_record
Txfm hash records of inter-modes.
Definition block.h:559
TxfmSearchInfo::tx_type_map_
uint8_t tx_type_map_[MAX_MIB_SIZE *MAX_MIB_SIZE]
Transform types inside the partition block.
Definition block.h:556
TxfmSearchInfo::skip_txfm
uint8_t skip_txfm
Whether to skip transform and quantization on a partition block level.
Definition block.h:536
TxfmSearchParams
Defines the parameters used to perform txfm search.
Definition block.h:439
TxfmSearchParams::use_derived_intra_tx_type_set
int use_derived_intra_tx_type_set
Definition block.h:450
TxfmSearchParams::mode_eval_type
int mode_eval_type
Definition block.h:507
TxfmSearchParams::use_qm_dist_metric
int use_qm_dist_metric
Definition block.h:501
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:445
TxfmSearchParams::prune_2d_txfm_mode
int prune_2d_txfm_mode
Whether to prune 2d transforms based on 1d transform results.
Definition block.h:456
TxfmSearchParams::enable_nn_prune_intra_tx_depths
bool enable_nn_prune_intra_tx_depths
Indicates if NN model should be invoked to prune transform depths.
Definition block.h:518
TxfmSearchParams::coeff_opt_thresholds
unsigned int coeff_opt_thresholds[2]
Variable from WinnerModeParams based on current eval mode.
Definition block.h:462
TxfmSearchParams::tx_mode_search_type
TX_MODE tx_mode_search_type
How to search for the optimal tx_size.
Definition block.h:485
TxfmSearchParams::tx_size_search_method
TX_SIZE_SEARCH_METHOD tx_size_search_method
Variable from WinnerModeParams based on current eval mode.
Definition block.h:466
TxfmSearchParams::default_inter_tx_type_prob_thresh
int default_inter_tx_type_prob_thresh
Definition block.h:453
TxfmSearchParams::predict_dc_level
unsigned int predict_dc_level
Definition block.h:495
TxfmSearchParams::tx_domain_dist_threshold
unsigned int tx_domain_dist_threshold
Variable from WinnerModeParams based on current eval mode.
Definition block.h:464
TxfmSearchParams::skip_txfm_level
unsigned int skip_txfm_level
Variable from WinnerModeParams based on current eval mode.
Definition block.h:470
TxfmSearchParams::nn_prune_depths_for_intra_tx
TX_PRUNE_TYPE nn_prune_depths_for_intra_tx
Indicates the transform depths for which RD evaluation is skipped.
Definition block.h:511
TxfmSearchParams::use_transform_domain_distortion
unsigned int use_transform_domain_distortion
Variable from WinnerModeParams based on current eval mode.
Definition block.h:468
WARP_SAMPLE_INFO
Holds the motion samples for warp motion model estimation.
Definition block.h:829
WARP_SAMPLE_INFO::pts
int pts[16]
Sample locations in current frame.
Definition block.h:833
WARP_SAMPLE_INFO::num
int num
Number of samples.
Definition block.h:831
WARP_SAMPLE_INFO::pts_inref
int pts_inref[16]
Sample location in the reference frame.
Definition block.h:835
WinnerModeStats
Stores the best performing modes.
Definition block.h:111
WinnerModeStats::rate_y
int rate_y
Luma rate of the winner mode.
Definition block.h:119
WinnerModeStats::color_index_map
uint8_t color_index_map[MAX_SB_SQUARE]
The color map needed to reconstruct palette mode.
Definition block.h:123
WinnerModeStats::rd_cost
RD_STATS rd_cost
Rdstats of the winner mode.
Definition block.h:115
WinnerModeStats::mbmi
MB_MODE_INFO mbmi
The mbmi used to reconstruct the winner mode.
Definition block.h:113
WinnerModeStats::mode_index
THR_MODES mode_index
The current winner mode.
Definition block.h:125
WinnerModeStats::rate_uv
int rate_uv
Chroma rate of the winner mode.
Definition block.h:121
WinnerModeStats::rd
int64_t rd
Rdcost of the winner mode.
Definition block.h:117
inter_modes_info
Struct used to hold inter mode data for fast tx search.
Definition encoder.h:1281
macroblock_plane
Each source plane of the current macroblock.
Definition block.h:132
macroblock_plane::qcoeff
tran_low_t * qcoeff
Quantized coefficients.
Definition block.h:138
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:164
macroblock_plane::quant_fp_QTX
const int16_t * quant_fp_QTX
Quantization step size used by AV1_XFORM_QUANT_FP.
Definition block.h:156
macroblock_plane::dequant_QTX
const int16_t * dequant_QTX
Dequantizer.
Definition block.h:168
macroblock_plane::dqcoeff
tran_low_t * dqcoeff
Dequantized coefficients.
Definition block.h:136
macroblock_plane::zbin_QTX
const int16_t * zbin_QTX
Size of the quantization bin around 0. Only Used by QUANT_B.
Definition block.h:166
macroblock_plane::quant_QTX
const int16_t * quant_QTX
Quantization step size used by AV1_XFORM_QUANT_B.
Definition block.h:160
macroblock_plane::src
struct buf_2d src
A buffer containing the source frame.
Definition block.h:146
macroblock_plane::eobs
uint16_t * eobs
Location of the end of qcoeff (end of block).
Definition block.h:142
macroblock_plane::coeff
tran_low_t * coeff
Transformed coefficients.
Definition block.h:140
macroblock_plane::src_diff
int16_t * src_diff
Stores source - pred so the txfm can be computed later.
Definition block.h:134
macroblock_plane::txb_entropy_ctx
uint8_t * txb_entropy_ctx
Contexts used to code the transform coefficients.
Definition block.h:144
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:158
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:162
macroblock
Encoder's parameters related to the current coding block.
Definition block.h:889
macroblock::delta_qindex
int delta_qindex
Difference between frame-level qindex and current qindex.
Definition block.h:989
macroblock::warp_sample_info
WARP_SAMPLE_INFO warp_sample_info[REF_FRAMES]
Warp motion samples buffer.
Definition block.h:1145
macroblock::mbmi_ext_frame
MB_MODE_INFO_EXT_FRAME * mbmi_ext_frame
Finalized mbmi_ext for the whole frame.
Definition block.h:921
macroblock::sb_energy_level
int sb_energy_level
Energy in the current source superblock. Used to calculate rdmult.
Definition block.h:1025
macroblock::tmp_pred_bufs
uint8_t * tmp_pred_bufs[2]
Temporary buffer to hold prediction.
Definition block.h:965
macroblock::mb_energy
int mb_energy
Energy in the current source coding block. Used to calculate rdmult.
Definition block.h:1023
macroblock::min_dist_inter_uv
int64_t min_dist_inter_uv
Coding block distortion value for uv/color, minimum over the inter modes.
Definition block.h:1342
macroblock::search_site_cfg_buf
search_site_config search_site_cfg_buf[NUM_DISTINCT_SEARCH_METHODS]
Buffer for storing the search site config.
Definition block.h:1308
macroblock::rdmult_cur_qindex
int rdmult_cur_qindex
Current qindex (before being adjusted by delta_q_res) used to derive rdmult_delta_qindex.
Definition block.h:1004
macroblock::skip_mode
int skip_mode
Inter skip mode.
Definition block.h:1192
macroblock::block_is_zero_sad
int block_is_zero_sad
Flag to indicate coding block is zero sad.
Definition block.h:1363
macroblock::mv_limits
FullMvLimits mv_limits
Limit for the range of motion vectors.
Definition block.h:1299
macroblock::coeff_costs
CoeffCosts coeff_costs
The rate needed to signal the txfm coefficients to the bitstream.
Definition block.h:1040
macroblock::part_search_info
PartitionSearchInfo part_search_info
Stores some partition-search related buffers.
Definition block.h:1170
macroblock::rdmult
int rdmult
Rate-distortion multiplier.
Definition block.h:1014
macroblock::sb_force_fixed_part
int sb_force_fixed_part
Flag to indicate if a fixed partition should be used, only if the.
Definition block.h:1380
macroblock::sb_col_scroll
int sb_col_scroll
Counter for superblock selected column scroll.
Definition block.h:1372
macroblock::rb
double rb
Superblock level distortion propagation factor.
Definition block.h:1020
macroblock::e_mbd
MACROBLOCKD e_mbd
Decoder's view of current coding block.
Definition block.h:907
macroblock::last_set_offsets_loc
SetOffsetsLoc last_set_offsets_loc
A hash to make sure av1_set_offsets is called.
Definition block.h:1406
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:1068
macroblock::source_variance
unsigned int source_variance
Variance of the source frame.
Definition block.h:1361
macroblock::seg_skip_block
int seg_skip_block
Skip mode for the segment.
Definition block.h:1062
macroblock::pred_mv1_sad
int pred_mv1_sad[REF_FRAMES]
The sad of the 2nd mv ref (near).
Definition block.h:1131
macroblock::sb_me_block
int sb_me_block
Flag to indicate to test the superblock MV for the coding block in the.
Definition block.h:1370
macroblock::row_ctx
FRAME_CONTEXT * row_ctx
Entropy context for the current row.
Definition block.h:924
macroblock::winner_mode_stats
WinnerModeStats * winner_mode_stats
Tracks the winner modes in the current coding block.
Definition block.h:1210
macroblock::pred_sse
unsigned int pred_sse[REF_FRAMES]
SSE of the current predictor.
Definition block.h:1382
macroblock::tmp_conv_dst
CONV_BUF_TYPE * tmp_conv_dst
Buffer to store convolution during averaging process in compound mode.
Definition block.h:954
macroblock::mode_costs
ModeCosts mode_costs
The rate needed to signal a mode to the bitstream.
Definition block.h:1028
macroblock::pred_mv0_sad
int pred_mv0_sad[REF_FRAMES]
The sad of the 1st mv ref (nearest).
Definition block.h:1129
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:1247
macroblock::nonrd_prune_ref_frame_search
int nonrd_prune_ref_frame_search
Prune ref frames in real-time mode.
Definition block.h:1162
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:1094
macroblock::try_merge_partition
int try_merge_partition
Prediction for ML based partition.
Definition block.h:1395
macroblock::dqcoeff_buf
tran_low_t * dqcoeff_buf
The buffer used by search_tx_type() to swap dqcoeff in macroblockd_plane.
Definition block.h:1353
macroblock::reuse_inter_pred
bool reuse_inter_pred
Flag to reuse predicted samples of inter block.
Definition block.h:1280
macroblock::pixel_gradient_info
PixelLevelGradientInfo * pixel_gradient_info
Pointer to the buffer which caches gradient information.
Definition block.h:1275
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:1292
macroblock::sadperbit
int sadperbit
A multiplier that converts mv cost to l1 error.
Definition block.h:1050
macroblock::compound_idx
uint8_t compound_idx
How to blend the compound predictions.
Definition block.h:1242
macroblock::top_comp_avg_est_rd
int64_t top_comp_avg_est_rd[5]
Array of best estimated RD Costs of compound average.
Definition block.h:1433
macroblock::intra_sb_rdmult_modifier
int intra_sb_rdmult_modifier
Intra only, per sb rd adjustment.
Definition block.h:1017
macroblock::comp_rd_buffer
CompoundTypeRdBuffers comp_rd_buffer
Buffer used for compound_type_rd().
Definition block.h:952
macroblock::best_pred_mv_sad
int best_pred_mv_sad[2]
The minimum of pred_mv_sad.
Definition block.h:1127
macroblock::thresh_freq_fact
int thresh_freq_fact[BLOCK_SIZES_ALL][MAX_MODES]
Factors used for rd-thresholding.
Definition block.h:1200
macroblock::dv_costs
IntraBCMVCosts * dv_costs
Definition block.h:1037
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:1268
macroblock::color_palette_thresh
int color_palette_thresh
Threshold on the number of colors for testing palette mode.
Definition block.h:1345
macroblock::palette_buffer
PALETTE_BUFFER * palette_buffer
Buffer to store the best palette map.
Definition block.h:950
macroblock::color_sensitivity_sb
uint8_t color_sensitivity_sb[3 - 1]
Whether there is a strong color activity.
Definition block.h:1334
macroblock::content_state_sb
CONTENT_STATE_SB content_state_sb
Characteristics of the current superblock.
Definition block.h:1110
macroblock::force_color_check_block_level
int force_color_check_block_level
Used in REALTIME coding mode: flag to indicate if the color_sensitivity.
Definition block.h:1349
macroblock::plane
struct macroblock_plane plane[3]
Each of the encoding plane.
Definition block.h:899
macroblock::color_sensitivity
uint8_t color_sensitivity[3 - 1]
Color sensitivity flag for the coding block.
Definition block.h:1340
macroblock::recalc_luma_mc_data
int recalc_luma_mc_data
Whether to recompute the luma prediction.
Definition block.h:1256
macroblock::is_sb_gradient_cached
bool is_sb_gradient_cached[PLANE_TYPES]
Flags indicating the availability of cached gradient info.
Definition block.h:1277
macroblock::sb_me_mv
int_mv sb_me_mv
Motion vector from superblock MV derived from int_pro_motion() in.
Definition block.h:1377
macroblock::obmc_buffer
OBMCBuffer obmc_buffer
Modified source and masks used for fast OBMC search.
Definition block.h:948
macroblock::sb_enc
SuperBlockEnc sb_enc
Information on a whole superblock level.
Definition block.h:1103
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:1245
macroblock::force_zeromv_skip_for_blk
int force_zeromv_skip_for_blk
Flag to force zeromv-skip at block level, for nonrd path.
Definition block.h:1089
macroblock::use_mb_mode_cache
int use_mb_mode_cache
Whether to reuse the mode stored in mb_mode_cache.
Definition block.h:1265
macroblock::sb_fp_stats
struct SB_FIRST_PASS_STATS * sb_fp_stats
Pointer to the structure which stores the statistics used by first-pass when superblock is searched t...
Definition block.h:1430
macroblock::cb_coef_buff
CB_COEFF_BUFFER * cb_coef_buff
Buffer of transformed coefficients.
Definition block.h:943
macroblock::qindex
int qindex
Quantization index for the current partition block.
Definition block.h:982
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:1179
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:1074
macroblock::force_zeromv_skip_for_sb
int force_zeromv_skip_for_sb
Flag to force zeromv-skip at superblock level, for nonrd path.
Definition block.h:1085
macroblock::color_sensitivity_sb_alt
uint8_t color_sensitivity_sb_alt[3 - 1]
Color sensitivity flag for the superblock for altref reference.
Definition block.h:1338
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:1153
macroblock::mv_costs
MvCosts * mv_costs
Definition block.h:1032
macroblock::sb_row_scroll
int sb_row_scroll
Counter for superblock selected row scroll.
Definition block.h:1374
macroblock::txfm_search_info
TxfmSearchInfo txfm_search_info
Results of the txfm searches that have been done.
Definition block.h:1327
macroblock::upsample_pred
uint8_t * upsample_pred
Definition block.h:970
macroblock::top_inter_tx_no_split_rd
int64_t top_inter_tx_no_split_rd[MAX_TX_BLOCKS_IN_MAX_SB][4]
Keep records of top no-split RD Costs of transform size search.
Definition block.h:1420
macroblock::pred_mv_sad
int pred_mv_sad[REF_FRAMES]
Sum absolute distortion of the predicted mv for each ref frame.
Definition block.h:1121
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:1403
macroblock::intrabc_hash_info
IntraBCHashInfo intrabc_hash_info
Data structure to speed up intrabc search.
Definition block.h:1262
macroblock::palette_pixels
int palette_pixels
Number of pixels in current thread that choose palette mode in the fast encoding stage for screen con...
Definition block.h:1416
macroblock::errorperbit
int errorperbit
A multiplier that converts mv cost to l2 error.
Definition block.h:1048
macroblock::tile_pb_ctx
FRAME_CONTEXT * tile_pb_ctx
Entropy context for the current tile.
Definition block.h:933
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:1239
macroblock::sb_stats_cache
struct SB_FIRST_PASS_STATS * sb_stats_cache
Pointer to the structure which stores the statistics used by sb-level multi-pass encoding.
Definition block.h:1425
macroblock::cb_offset
uint16_t cb_offset[PLANE_TYPES]
Offset of current coding block's coeff buffer relative to the sb.
Definition block.h:945
macroblock::rdmult_delta_qindex
int rdmult_delta_qindex
Difference between frame-level qindex and qindex used to compute rdmult (lambda).
Definition block.h:999
macroblock::sb_me_partition
int sb_me_partition
Flag to indicate superblock ME in variance partition is determined to be.
Definition block.h:1367
macroblock::color_sensitivity_sb_g
uint8_t color_sensitivity_sb_g[3 - 1]
Color sensitivity flag for the superblock for golden reference.
Definition block.h:1336
macroblock::winner_mode_count
int winner_mode_count
Tracks how many winner modes there are.
Definition block.h:1212
macroblock::cnt_zeromv
int cnt_zeromv
Number of zero motion vectors.
Definition block.h:1078
macroblock::rd_model
TXFM_RD_MODEL rd_model
The model used for rd-estimation to avoid txfm.
Definition block.h:1226
macroblock::txfm_search_params
TxfmSearchParams txfm_search_params
Parameters that control how motion search is done.
Definition block.h:1320
macroblock::tpl_keep_ref_frame
uint8_t tpl_keep_ref_frame[REF_FRAMES]
Disables certain ref frame pruning based on tpl.
Definition block.h:1139
macroblock::mbmi_ext
MB_MODE_INFO_EXT mbmi_ext
Derived coding information.
Definition block.h:914
macroblockd::lossless
int lossless[8]
Definition blockd.h:817