#ifndef AOM_AV1_ENCODER_PARTITION_STRATEGY_H_
#define AOM_AV1_ENCODER_PARTITION_STRATEGY_H_
#include "av1/encoder/encodeframe.h"
#include "av1/encoder/encodeframe_utils.h"
#include "av1/encoder/encodemb.h"
#include "av1/encoder/encoder.h"
#if !CONFIG_REALTIME_ONLY
void av1_simple_motion_search_early_term_none(AV1_COMP *const cpi,
MACROBLOCK *x,
SIMPLE_MOTION_DATA_TREE *sms_tree,
const RD_STATS *none_rdc,
PartitionSearchState *part_state);
void av1_get_max_min_partition_features(AV1_COMP *const cpi, MACROBLOCK *x,
int mi_row, int mi_col,
float *features);
BLOCK_SIZE av1_predict_max_partition(const AV1_COMP *const cpi,
const MACROBLOCK *const x,
const float *features);
void av1_ml_early_term_after_split(AV1_COMP *const cpi, MACROBLOCK *const x,
SIMPLE_MOTION_DATA_TREE *const sms_tree,
int64_t best_rd, int64_t part_none_rd,
int64_t part_split_rd,
int64_t *split_block_rd,
PartitionSearchState *part_state);
void av1_ml_prune_rect_partition(AV1_COMP *const cpi, const MACROBLOCK *const x,
int64_t best_rd, int64_t none_rd,
const int64_t *split_rd,
PartitionSearchState *part_state);
void av1_ml_prune_4_partition(AV1_COMP *const cpi, MACROBLOCK *const x,
int part_ctx, int64_t best_rd,
PartitionSearchState *part_state,
int *part4_allowed,
unsigned int pb_source_variance);
void av1_ml_predict_breakout(AV1_COMP *const cpi, const MACROBLOCK *const x,
const RD_STATS *const rd_stats,
unsigned int pb_source_variance, int bit_depth,
PartitionSearchState *part_state);
void av1_prune_partitions_before_search(AV1_COMP *const cpi,
MACROBLOCK *const x,
SIMPLE_MOTION_DATA_TREE *const sms_tree,
PartitionSearchState *part_state);
void av1_prune_partitions_by_max_min_bsize(SuperBlockEnc *sb_enc,
PartitionSearchState *part_state);
void av1_prune_ab_partitions(AV1_COMP *cpi, const MACROBLOCK *x,
const PC_TREE *pc_tree, int pb_source_variance,
int64_t best_rdcost,
const RD_RECT_PART_WIN_INFO *rect_part_win_info,
bool ext_partition_allowed,
PartitionSearchState *part_state,
int *ab_partitions_allowed);
void av1_collect_motion_search_features_sb(AV1_COMP *const cpi, ThreadData *td,
TileDataEnc *tile_data,
const int mi_row, const int mi_col,
const BLOCK_SIZE bsize,
aom_partition_features_t *features);
void av1_prepare_motion_search_features_block(
AV1_COMP *const cpi, ThreadData *td, TileDataEnc *tile_data,
const int mi_row, const int mi_col, const BLOCK_SIZE bsize,
const int valid_partition_types, unsigned int *block_sse,
unsigned int *block_var, unsigned int sub_block_sse[4],
unsigned int sub_block_var[4], unsigned int horz_block_sse[2],
unsigned int horz_block_var[2], unsigned int vert_block_sse[2],
unsigned int vert_block_var[2]);
#endif
static inline void set_offsets_for_motion_search(const AV1_COMP *const cpi,
MACROBLOCK *const x,
int mi_row, int mi_col,
BLOCK_SIZE bsize) { … }
void av1_init_simple_motion_search_mvs_for_sb(const AV1_COMP *cpi,
const TileInfo *tile_info,
MACROBLOCK *x,
SIMPLE_MOTION_DATA_TREE *sms_root,
int mi_row, int mi_col);
static inline int is_full_sb(const CommonModeInfoParams *const mi_params,
int mi_row, int mi_col, BLOCK_SIZE sb_size) { … }
#if !CONFIG_REALTIME_ONLY
static inline int use_auto_max_partition(const AV1_COMP *const cpi,
BLOCK_SIZE sb_size, int mi_row,
int mi_col) {
assert(IMPLIES(cpi->ppi->gf_group.size > 0,
cpi->gf_frame_index < cpi->ppi->gf_group.size));
const AV1_COMMON *const cm = &cpi->common;
return !frame_is_intra_only(cm) && !cpi->use_screen_content_tools &&
cpi->sf.part_sf.auto_max_partition_based_on_simple_motion !=
NOT_IN_USE &&
sb_size == BLOCK_128X128 &&
is_full_sb(&cm->mi_params, mi_row, mi_col, sb_size) &&
cpi->ppi->gf_group.update_type[cpi->gf_frame_index] !=
OVERLAY_UPDATE &&
cpi->ppi->gf_group.update_type[cpi->gf_frame_index] !=
INTNL_OVERLAY_UPDATE;
}
static BLOCK_SIZE dim_to_size(int dim) {
switch (dim) {
case 4: return BLOCK_4X4;
case 8: return BLOCK_8X8;
case 16: return BLOCK_16X16;
case 32: return BLOCK_32X32;
case 64: return BLOCK_64X64;
case 128: return BLOCK_128X128;
default: assert(0); return 0;
}
}
static inline void set_max_min_partition_size(SuperBlockEnc *sb_enc,
AV1_COMP *cpi, MACROBLOCK *x,
const SPEED_FEATURES *sf,
BLOCK_SIZE sb_size, int mi_row,
int mi_col) {
const AV1_COMMON *cm = &cpi->common;
sb_enc->max_partition_size =
AOMMIN(sf->part_sf.default_max_partition_size,
dim_to_size(cpi->oxcf.part_cfg.max_partition_size));
sb_enc->min_partition_size =
AOMMAX(sf->part_sf.default_min_partition_size,
dim_to_size(cpi->oxcf.part_cfg.min_partition_size));
sb_enc->max_partition_size =
AOMMIN(sb_enc->max_partition_size, cm->seq_params->sb_size);
sb_enc->min_partition_size =
AOMMIN(sb_enc->min_partition_size, cm->seq_params->sb_size);
if (use_auto_max_partition(cpi, sb_size, mi_row, mi_col)) {
float features[FEATURE_SIZE_MAX_MIN_PART_PRED] = { 0.0f };
av1_get_max_min_partition_features(cpi, x, mi_row, mi_col, features);
sb_enc->max_partition_size =
AOMMAX(AOMMIN(av1_predict_max_partition(cpi, x, features),
sb_enc->max_partition_size),
sb_enc->min_partition_size);
}
}
#endif
#endif