#include "av1/common/pred_common.h"
#include "av1/encoder/compound_type.h"
#include "av1/encoder/encoder_alloc.h"
#include "av1/encoder/model_rd.h"
#include "av1/encoder/motion_search_facade.h"
#include "av1/encoder/rdopt_utils.h"
#include "av1/encoder/reconinter_enc.h"
#include "av1/encoder/tx_search.h"
pick_interinter_mask_type;
static inline int is_comp_rd_match(const AV1_COMP *const cpi,
const MACROBLOCK *const x,
const COMP_RD_STATS *st,
const MB_MODE_INFO *const mi,
int32_t *comp_rate, int64_t *comp_dist,
int32_t *comp_model_rate,
int64_t *comp_model_dist, int *comp_rs2) { … }
static inline int find_comp_rd_in_stats(const AV1_COMP *const cpi,
const MACROBLOCK *x,
const MB_MODE_INFO *const mbmi,
int32_t *comp_rate, int64_t *comp_dist,
int32_t *comp_model_rate,
int64_t *comp_model_dist, int *comp_rs2,
int *match_index) { … }
static inline bool enable_wedge_search(
MACROBLOCK *const x, const unsigned int disable_wedge_var_thresh) { … }
static inline bool enable_wedge_interinter_search(MACROBLOCK *const x,
const AV1_COMP *const cpi) { … }
static inline bool enable_wedge_interintra_search(MACROBLOCK *const x,
const AV1_COMP *const cpi) { … }
static int8_t estimate_wedge_sign(const AV1_COMP *cpi, const MACROBLOCK *x,
const BLOCK_SIZE bsize, const uint8_t *pred0,
int stride0, const uint8_t *pred1,
int stride1) { … }
static int64_t pick_wedge(const AV1_COMP *const cpi, const MACROBLOCK *const x,
const BLOCK_SIZE bsize, const uint8_t *const p0,
const int16_t *const residual1,
const int16_t *const diff10,
int8_t *const best_wedge_sign,
int8_t *const best_wedge_index, uint64_t *best_sse) { … }
static int64_t pick_wedge_fixed_sign(
const AV1_COMP *const cpi, const MACROBLOCK *const x,
const BLOCK_SIZE bsize, const int16_t *const residual1,
const int16_t *const diff10, const int8_t wedge_sign,
int8_t *const best_wedge_index, uint64_t *best_sse) { … }
static int64_t pick_interinter_wedge(
const AV1_COMP *const cpi, MACROBLOCK *const x, const BLOCK_SIZE bsize,
const uint8_t *const p0, const uint8_t *const p1,
const int16_t *const residual1, const int16_t *const diff10,
uint64_t *best_sse) { … }
static int64_t pick_interinter_seg(const AV1_COMP *const cpi,
MACROBLOCK *const x, const BLOCK_SIZE bsize,
const uint8_t *const p0,
const uint8_t *const p1,
const int16_t *const residual1,
const int16_t *const diff10,
uint64_t *best_sse) { … }
static int64_t pick_interintra_wedge(const AV1_COMP *const cpi,
const MACROBLOCK *const x,
const BLOCK_SIZE bsize,
const uint8_t *const p0,
const uint8_t *const p1) { … }
static inline void get_inter_predictors_masked_compound(
MACROBLOCK *x, const BLOCK_SIZE bsize, uint8_t **preds0, uint8_t **preds1,
int16_t *residual1, int16_t *diff10, int *strides) { … }
static inline void compute_best_interintra_mode(
const AV1_COMP *const cpi, MB_MODE_INFO *mbmi, MACROBLOCKD *xd,
MACROBLOCK *const x, const int *const interintra_mode_cost,
const BUFFER_SET *orig_dst, uint8_t *intrapred, const uint8_t *tmp_buf,
INTERINTRA_MODE *best_interintra_mode, int64_t *best_interintra_rd,
INTERINTRA_MODE interintra_mode, BLOCK_SIZE bsize) { … }
static int64_t estimate_yrd_for_sb(const AV1_COMP *const cpi, BLOCK_SIZE bs,
MACROBLOCK *x, int64_t ref_best_rd,
RD_STATS *rd_stats) { … }
static inline int64_t compute_rd_thresh(MACROBLOCK *const x,
int total_mode_rate,
int64_t ref_best_rd) { … }
static inline int64_t compute_best_wedge_interintra(
const AV1_COMP *const cpi, MB_MODE_INFO *mbmi, MACROBLOCKD *xd,
MACROBLOCK *const x, const int *const interintra_mode_cost,
const BUFFER_SET *orig_dst, uint8_t *intrapred_, uint8_t *tmp_buf_,
int *best_mode, int *best_wedge_index, BLOCK_SIZE bsize) { … }
static int handle_smooth_inter_intra_mode(
const AV1_COMP *const cpi, MACROBLOCK *const x, BLOCK_SIZE bsize,
MB_MODE_INFO *mbmi, int64_t ref_best_rd, int *rate_mv,
INTERINTRA_MODE *best_interintra_mode, int64_t *best_rd,
int *best_mode_rate, const BUFFER_SET *orig_dst, uint8_t *tmp_buf,
uint8_t *intrapred, HandleInterModeArgs *args) { … }
static int handle_wedge_inter_intra_mode(
const AV1_COMP *const cpi, MACROBLOCK *const x, BLOCK_SIZE bsize,
MB_MODE_INFO *mbmi, int *rate_mv, INTERINTRA_MODE *best_interintra_mode,
int64_t *best_rd, const BUFFER_SET *orig_dst, uint8_t *tmp_buf_,
uint8_t *tmp_buf, uint8_t *intrapred_, uint8_t *intrapred,
HandleInterModeArgs *args, int *tmp_rate_mv, int *rate_overhead,
int_mv *tmp_mv, int64_t best_rd_no_wedge) { … }
int av1_handle_inter_intra_mode(const AV1_COMP *const cpi, MACROBLOCK *const x,
BLOCK_SIZE bsize, MB_MODE_INFO *mbmi,
HandleInterModeArgs *args, int64_t ref_best_rd,
int *rate_mv, int *tmp_rate2,
const BUFFER_SET *orig_dst) { … }
static inline int compute_valid_comp_types(MACROBLOCK *x,
const AV1_COMP *const cpi,
BLOCK_SIZE bsize,
int masked_compound_used,
int mode_search_mask,
COMPOUND_TYPE *valid_comp_types) { … }
static inline void calc_masked_type_cost(
const ModeCosts *mode_costs, BLOCK_SIZE bsize, int comp_group_idx_ctx,
int comp_index_ctx, int masked_compound_used, int *masked_type_cost) { … }
static inline void update_mbmi_for_compound_type(MB_MODE_INFO *mbmi,
COMPOUND_TYPE cur_type) { … }
static inline int populate_reuse_comp_type_data(
const MACROBLOCK *x, MB_MODE_INFO *mbmi,
BEST_COMP_TYPE_STATS *best_type_stats, int_mv *cur_mv, int32_t *comp_rate,
int64_t *comp_dist, int *comp_rs2, int *rate_mv, int64_t *rd,
int match_index) { … }
static inline void update_best_info(const MB_MODE_INFO *const mbmi, int64_t *rd,
BEST_COMP_TYPE_STATS *best_type_stats,
int64_t best_rd_cur,
int64_t comp_model_rd_cur, int rs2) { … }
static inline void update_mask_best_mv(const MB_MODE_INFO *const mbmi,
int_mv *best_mv, int *best_tmp_rate_mv,
int tmp_rate_mv) { … }
static inline void save_comp_rd_search_stat(
MACROBLOCK *x, const MB_MODE_INFO *const mbmi, const int32_t *comp_rate,
const int64_t *comp_dist, const int32_t *comp_model_rate,
const int64_t *comp_model_dist, const int_mv *cur_mv, const int *comp_rs2) { … }
static inline int get_interinter_compound_mask_rate(
const ModeCosts *const mode_costs, const MB_MODE_INFO *const mbmi) { … }
static inline void backup_stats(COMPOUND_TYPE cur_type, int32_t *comp_rate,
int64_t *comp_dist, int32_t *comp_model_rate,
int64_t *comp_model_dist, int rate_sum,
int64_t dist_sum, RD_STATS *rd_stats,
int *comp_rs2, int rs2) { … }
static inline int save_mask_search_results(const PREDICTION_MODE this_mode,
const int reuse_level) { … }
static inline int prune_mode_by_skip_rd(const AV1_COMP *const cpi,
MACROBLOCK *x, MACROBLOCKD *xd,
const BLOCK_SIZE bsize,
int64_t ref_skip_rd, int mode_rate) { … }
static int64_t masked_compound_type_rd(
const AV1_COMP *const cpi, MACROBLOCK *x, const int_mv *const cur_mv,
const BLOCK_SIZE bsize, const PREDICTION_MODE this_mode, int *rs2,
int rate_mv, const BUFFER_SET *ctx, int *out_rate_mv, uint8_t **preds0,
uint8_t **preds1, int16_t *residual1, int16_t *diff10, int *strides,
int mode_rate, int64_t rd_thresh, int *calc_pred_masked_compound,
int32_t *comp_rate, int64_t *comp_dist, int32_t *comp_model_rate,
int64_t *comp_model_dist, const int64_t comp_best_model_rd,
int64_t *const comp_model_rd_cur, int *comp_rs2, int64_t ref_skip_rd) { … }
static int comp_type_rd_threshold_mul[3] = …;
static int comp_type_rd_threshold_div[3] = …;
int av1_compound_type_rd(const AV1_COMP *const cpi, MACROBLOCK *x,
HandleInterModeArgs *args, BLOCK_SIZE bsize,
int_mv *cur_mv, int mode_search_mask,
int masked_compound_used, const BUFFER_SET *orig_dst,
const BUFFER_SET *tmp_dst,
const CompoundTypeRdBuffers *buffers, int *rate_mv,
int64_t *rd, RD_STATS *rd_stats, int64_t ref_best_rd,
int64_t ref_skip_rd, int *is_luma_interp_done,
int64_t rd_thresh) { … }