#include <assert.h>
#include <math.h>
#include <stdbool.h>
#include "config/aom_config.h"
#include "config/aom_dsp_rtcd.h"
#include "config/av1_rtcd.h"
#include "aom_dsp/aom_dsp_common.h"
#include "aom_dsp/blend.h"
#include "aom_mem/aom_mem.h"
#include "aom_ports/aom_timer.h"
#include "aom_ports/mem.h"
#include "av1/common/av1_common_int.h"
#include "av1/common/cfl.h"
#include "av1/common/blockd.h"
#include "av1/common/common.h"
#include "av1/common/common_data.h"
#include "av1/common/entropy.h"
#include "av1/common/entropymode.h"
#include "av1/common/idct.h"
#include "av1/common/mvref_common.h"
#include "av1/common/obmc.h"
#include "av1/common/pred_common.h"
#include "av1/common/quant_common.h"
#include "av1/common/reconinter.h"
#include "av1/common/reconintra.h"
#include "av1/common/scan.h"
#include "av1/common/seg_common.h"
#include "av1/common/txb_common.h"
#include "av1/common/warped_motion.h"
#include "av1/encoder/aq_variance.h"
#include "av1/encoder/av1_quantize.h"
#include "av1/encoder/cost.h"
#include "av1/encoder/compound_type.h"
#include "av1/encoder/encodemb.h"
#include "av1/encoder/encodemv.h"
#include "av1/encoder/encoder.h"
#include "av1/encoder/encodetxb.h"
#include "av1/encoder/hybrid_fwd_txfm.h"
#include "av1/encoder/interp_search.h"
#include "av1/encoder/intra_mode_search.h"
#include "av1/encoder/intra_mode_search_utils.h"
#include "av1/encoder/mcomp.h"
#include "av1/encoder/ml.h"
#include "av1/encoder/mode_prune_model_weights.h"
#include "av1/encoder/model_rd.h"
#include "av1/encoder/motion_search_facade.h"
#include "av1/encoder/palette.h"
#include "av1/encoder/pustats.h"
#include "av1/encoder/random.h"
#include "av1/encoder/ratectrl.h"
#include "av1/encoder/rd.h"
#include "av1/encoder/rdopt.h"
#include "av1/encoder/reconinter_enc.h"
#include "av1/encoder/tokenize.h"
#include "av1/encoder/tpl_model.h"
#include "av1/encoder/tx_search.h"
#include "av1/encoder/var_based_part.h"
#define LAST_NEW_MV_INDEX …
#define MODE_THRESH_QBITS …
static const int mode_threshold_mul_factor[QINDEX_RANGE] = …;
static const THR_MODES av1_default_mode_order[MAX_MODES] = …;
SingleInterModeState;
InterModeSearchState;
void av1_inter_mode_data_init(TileDataEnc *tile_data) { … }
static int get_est_rate_dist(const TileDataEnc *tile_data, BLOCK_SIZE bsize,
int64_t sse, int *est_residue_cost,
int64_t *est_dist) { … }
void av1_inter_mode_data_fit(TileDataEnc *tile_data, int rdmult) { … }
static inline void inter_mode_data_push(TileDataEnc *tile_data,
BLOCK_SIZE bsize, int64_t sse,
int64_t dist, int residue_cost) { … }
static inline void inter_modes_info_push(InterModesInfo *inter_modes_info,
int mode_rate, int64_t sse, int64_t rd,
RD_STATS *rd_cost, RD_STATS *rd_cost_y,
RD_STATS *rd_cost_uv,
const MB_MODE_INFO *mbmi) { … }
static int compare_rd_idx_pair(const void *a, const void *b) { … }
static inline void inter_modes_info_sort(const InterModesInfo *inter_modes_info,
RdIdxPair *rd_idx_pair_arr) { … }
void av1_get_horver_correlation_full_c(const int16_t *diff, int stride,
int width, int height, float *hcorr,
float *vcorr) { … }
static int64_t get_sse(const AV1_COMP *cpi, const MACROBLOCK *x,
int64_t *sse_y) { … }
int64_t av1_block_error_c(const tran_low_t *coeff, const tran_low_t *dqcoeff,
intptr_t block_size, int64_t *ssz) { … }
int64_t av1_block_error_lp_c(const int16_t *coeff, const int16_t *dqcoeff,
intptr_t block_size) { … }
#if CONFIG_AV1_HIGHBITDEPTH
int64_t av1_highbd_block_error_c(const tran_low_t *coeff,
const tran_low_t *dqcoeff, intptr_t block_size,
int64_t *ssz, int bd) {
int i;
int64_t error = 0, sqcoeff = 0;
int shift = 2 * (bd - 8);
int rounding = shift > 0 ? 1 << (shift - 1) : 0;
for (i = 0; i < block_size; i++) {
const int64_t diff = coeff[i] - dqcoeff[i];
error += diff * diff;
sqcoeff += (int64_t)coeff[i] * (int64_t)coeff[i];
}
assert(error >= 0 && sqcoeff >= 0);
error = (error + rounding) >> shift;
sqcoeff = (sqcoeff + rounding) >> shift;
*ssz = sqcoeff;
return error;
}
#endif
static int conditional_skipintra(PREDICTION_MODE mode,
PREDICTION_MODE best_intra_mode) { … }
static int cost_mv_ref(const ModeCosts *const mode_costs, PREDICTION_MODE mode,
int16_t mode_context) { … }
static inline PREDICTION_MODE get_single_mode(PREDICTION_MODE this_mode,
int ref_idx) { … }
static inline void estimate_ref_frame_costs(
const AV1_COMMON *cm, const MACROBLOCKD *xd, const ModeCosts *mode_costs,
int segment_id, unsigned int *ref_costs_single,
unsigned int (*ref_costs_comp)[REF_FRAMES]) { … }
static inline void store_coding_context(
#if CONFIG_INTERNAL_STATS
MACROBLOCK *x, PICK_MODE_CONTEXT *ctx, int mode_index,
#else
MACROBLOCK *x, PICK_MODE_CONTEXT *ctx,
#endif
int skippable) { … }
static inline void setup_buffer_ref_mvs_inter(
const AV1_COMP *const cpi, MACROBLOCK *x, MV_REFERENCE_FRAME ref_frame,
BLOCK_SIZE block_size, struct buf_2d yv12_mb[REF_FRAMES][MAX_MB_PLANE]) { … }
#define LEFT_TOP_MARGIN …
#define RIGHT_BOTTOM_MARGIN …
static inline void clamp_mv2(MV *mv, const MACROBLOCKD *xd) { … }
static int skip_repeated_mv(const AV1_COMMON *const cm,
const MACROBLOCK *const x,
PREDICTION_MODE this_mode,
const MV_REFERENCE_FRAME ref_frames[2],
InterModeSearchState *search_state) { … }
static inline int clamp_and_check_mv(int_mv *out_mv, int_mv in_mv,
const AV1_COMMON *cm,
const MACROBLOCK *x) { … }
static inline void clamp_mv_in_range(MACROBLOCK *const x, int_mv *mv,
int ref_idx) { … }
static int64_t handle_newmv(const AV1_COMP *const cpi, MACROBLOCK *const x,
const BLOCK_SIZE bsize, int_mv *cur_mv,
int *const rate_mv, HandleInterModeArgs *const args,
inter_mode_info *mode_info) { … }
static inline void update_mode_start_end_index(
const AV1_COMP *const cpi, const MB_MODE_INFO *const mbmi,
int *mode_index_start, int *mode_index_end, int last_motion_mode_allowed,
int interintra_allowed, int eval_motion_mode) { … }
static int64_t motion_mode_rd(
const AV1_COMP *const cpi, TileDataEnc *tile_data, MACROBLOCK *const x,
BLOCK_SIZE bsize, RD_STATS *rd_stats, RD_STATS *rd_stats_y,
RD_STATS *rd_stats_uv, HandleInterModeArgs *const args, int64_t ref_best_rd,
int64_t *ref_skip_rd, int *rate_mv, const BUFFER_SET *orig_dst,
int64_t *best_est_rd, int do_tx_search, InterModesInfo *inter_modes_info,
int eval_motion_mode, int64_t *yrd) { … }
static int64_t skip_mode_rd(RD_STATS *rd_stats, const AV1_COMP *const cpi,
MACROBLOCK *const x, BLOCK_SIZE bsize,
const BUFFER_SET *const orig_dst, int64_t best_rd) { … }
static inline int check_repeat_ref_mv(const MB_MODE_INFO_EXT *mbmi_ext,
int ref_idx,
const MV_REFERENCE_FRAME *ref_frame,
PREDICTION_MODE single_mode) { … }
static inline int get_this_mv(int_mv *this_mv, PREDICTION_MODE this_mode,
int ref_idx, int ref_mv_idx,
int skip_repeated_ref_mv,
const MV_REFERENCE_FRAME *ref_frame,
const MB_MODE_INFO_EXT *mbmi_ext) { … }
static inline int skip_nearest_near_mv_using_refmv_weight(
const MACROBLOCK *const x, const PREDICTION_MODE this_mode,
const int8_t ref_frame_type, PREDICTION_MODE best_mode) { … }
static inline int build_cur_mv(int_mv *cur_mv, PREDICTION_MODE this_mode,
const AV1_COMMON *cm, const MACROBLOCK *x,
int skip_repeated_ref_mv) { … }
static inline int get_drl_cost(const MB_MODE_INFO *mbmi,
const MB_MODE_INFO_EXT *mbmi_ext,
const int (*const drl_mode_cost0)[2],
int8_t ref_frame_type) { … }
static inline int is_single_newmv_valid(const HandleInterModeArgs *const args,
const MB_MODE_INFO *const mbmi,
PREDICTION_MODE this_mode) { … }
static int get_drl_refmv_count(const MACROBLOCK *const x,
const MV_REFERENCE_FRAME *ref_frame,
PREDICTION_MODE mode) { … }
static int prune_ref_mv_idx_using_qindex(const int reduce_inter_modes,
const int qindex,
const int ref_mv_idx) { … }
static bool ref_mv_idx_early_breakout(
const SPEED_FEATURES *const sf,
const RefFrameDistanceInfo *const ref_frame_dist_info, MACROBLOCK *x,
const HandleInterModeArgs *const args, int64_t ref_best_rd,
int ref_mv_idx) { … }
static int64_t simple_translation_pred_rd(AV1_COMP *const cpi, MACROBLOCK *x,
RD_STATS *rd_stats,
HandleInterModeArgs *args,
int ref_mv_idx, int64_t ref_best_rd,
BLOCK_SIZE bsize) { … }
static inline void mask_set_bit(int *mask, int index) { … }
static inline bool mask_check_bit(int mask, int index) { … }
static int ref_mv_idx_to_search(AV1_COMP *const cpi, MACROBLOCK *x,
RD_STATS *rd_stats,
HandleInterModeArgs *const args,
int64_t ref_best_rd, BLOCK_SIZE bsize,
const int ref_set) { … }
motion_mode_candidate;
motion_mode_best_st_candidate;
static inline int ref_match_found_in_nb_blocks(MB_MODE_INFO *cur_mbmi,
MB_MODE_INFO *nb_mbmi) { … }
static inline int find_ref_match_in_above_nbs(const int total_mi_cols,
MACROBLOCKD *xd) { … }
static inline int find_ref_match_in_left_nbs(const int total_mi_rows,
MACROBLOCKD *xd) { … }
PruneInfoFromTpl;
#if !CONFIG_REALTIME_ONLY
static inline void get_block_level_tpl_stats(
AV1_COMP *cpi, BLOCK_SIZE bsize, int mi_row, int mi_col, int *valid_refs,
PruneInfoFromTpl *inter_cost_info_from_tpl) {
AV1_COMMON *const cm = &cpi->common;
assert(IMPLIES(cpi->ppi->gf_group.size > 0,
cpi->gf_frame_index < cpi->ppi->gf_group.size));
const int tpl_idx = cpi->gf_frame_index;
TplParams *const tpl_data = &cpi->ppi->tpl_data;
if (!av1_tpl_stats_ready(tpl_data, tpl_idx)) return;
const TplDepFrame *tpl_frame = &tpl_data->tpl_frame[tpl_idx];
const TplDepStats *tpl_stats = tpl_frame->tpl_stats_ptr;
const int mi_wide = mi_size_wide[bsize];
const int mi_high = mi_size_high[bsize];
const int tpl_stride = tpl_frame->stride;
const int step = 1 << tpl_data->tpl_stats_block_mis_log2;
const int mi_col_sr =
coded_to_superres_mi(mi_col, cm->superres_scale_denominator);
const int mi_col_end_sr =
coded_to_superres_mi(mi_col + mi_wide, cm->superres_scale_denominator);
const int mi_cols_sr = av1_pixels_to_mi(cm->superres_upscaled_width);
const int row_step = step;
const int col_step_sr =
coded_to_superres_mi(step, cm->superres_scale_denominator);
for (int row = mi_row; row < AOMMIN(mi_row + mi_high, cm->mi_params.mi_rows);
row += row_step) {
for (int col = mi_col_sr; col < AOMMIN(mi_col_end_sr, mi_cols_sr);
col += col_step_sr) {
const TplDepStats *this_stats = &tpl_stats[av1_tpl_ptr_pos(
row, col, tpl_stride, tpl_data->tpl_stats_block_mis_log2)];
for (int ref_idx = 0; ref_idx < INTER_REFS_PER_FRAME; ref_idx++) {
inter_cost_info_from_tpl->ref_inter_cost[ref_idx] +=
this_stats->pred_error[ref_idx];
}
}
}
int64_t best_inter_cost = INT64_MAX;
for (int ref_idx = 0; ref_idx < INTER_REFS_PER_FRAME; ref_idx++) {
const int64_t cur_inter_cost =
inter_cost_info_from_tpl->ref_inter_cost[ref_idx];
if (cur_inter_cost != 0 && (cur_inter_cost < best_inter_cost) &&
valid_refs[ref_idx])
best_inter_cost = cur_inter_cost;
}
inter_cost_info_from_tpl->best_inter_cost = best_inter_cost;
}
#endif
static inline int prune_modes_based_on_tpl_stats(
PruneInfoFromTpl *inter_cost_info_from_tpl, const int *refs, int ref_mv_idx,
const PREDICTION_MODE this_mode, int prune_mode_level) { … }
static int process_compound_inter_mode(
AV1_COMP *const cpi, MACROBLOCK *x, HandleInterModeArgs *args,
int64_t ref_best_rd, int_mv *cur_mv, BLOCK_SIZE bsize,
int *compmode_interinter_cost, const CompoundTypeRdBuffers *rd_buffers,
const BUFFER_SET *orig_dst, const BUFFER_SET *tmp_dst, int *rate_mv,
RD_STATS *rd_stats, int64_t *skip_rd, int *skip_build_pred) { … }
static int prune_ref_mv_idx_search(int ref_mv_idx, int best_ref_mv_idx,
int_mv save_mv[MAX_REF_MV_SEARCH - 1][2],
MB_MODE_INFO *mbmi, int pruning_factor) { … }
static inline int prune_zero_mv_with_sse(const aom_variance_fn_ptr_t *fn_ptr,
const MACROBLOCK *x, BLOCK_SIZE bsize,
const HandleInterModeArgs *args,
int prune_zero_mv_with_sse) { … }
static inline bool fast_interp_search(const AV1_COMP *cpi, MACROBLOCK *x,
int mi_row, int mi_col,
BLOCK_SIZE bsize) { … }
static int64_t handle_inter_mode(
AV1_COMP *const cpi, TileDataEnc *tile_data, MACROBLOCK *x,
BLOCK_SIZE bsize, RD_STATS *rd_stats, RD_STATS *rd_stats_y,
RD_STATS *rd_stats_uv, HandleInterModeArgs *args, int64_t ref_best_rd,
uint8_t *const tmp_buf, const CompoundTypeRdBuffers *rd_buffers,
int64_t *best_est_rd, const int do_tx_search,
InterModesInfo *inter_modes_info, motion_mode_candidate *motion_mode_cand,
int64_t *skip_rd, PruneInfoFromTpl *inter_cost_info_from_tpl,
int64_t *yrd) { … }
static int64_t rd_pick_intrabc_mode_sb(const AV1_COMP *cpi, MACROBLOCK *x,
PICK_MODE_CONTEXT *ctx,
RD_STATS *rd_stats, BLOCK_SIZE bsize,
int64_t best_rd) { … }
void av1_rd_pick_intra_mode_sb(const struct AV1_COMP *cpi, struct macroblock *x,
struct RD_STATS *rd_cost, BLOCK_SIZE bsize,
PICK_MODE_CONTEXT *ctx, int64_t best_rd) { … }
static inline void calc_target_weighted_pred(
const AV1_COMMON *cm, const MACROBLOCK *x, const MACROBLOCKD *xd,
const uint8_t *above, int above_stride, const uint8_t *left,
int left_stride);
static inline void rd_pick_skip_mode(
RD_STATS *rd_cost, InterModeSearchState *search_state,
const AV1_COMP *const cpi, MACROBLOCK *const x, BLOCK_SIZE bsize,
struct buf_2d yv12_mb[REF_FRAMES][MAX_MB_PLANE]) { … }
static inline MB_MODE_INFO *get_winner_mode_stats(
MACROBLOCK *x, MB_MODE_INFO *best_mbmode, RD_STATS *best_rd_cost,
int best_rate_y, int best_rate_uv, THR_MODES *best_mode_index,
RD_STATS **winner_rd_cost, int *winner_rate_y, int *winner_rate_uv,
THR_MODES *winner_mode_index, MULTI_WINNER_MODE_TYPE multi_winner_mode_type,
int mode_idx) { … }
static inline void refine_winner_mode_tx(
const AV1_COMP *cpi, MACROBLOCK *x, RD_STATS *rd_cost, BLOCK_SIZE bsize,
PICK_MODE_CONTEXT *ctx, THR_MODES *best_mode_index,
MB_MODE_INFO *best_mbmode, struct buf_2d yv12_mb[REF_FRAMES][MAX_MB_PLANE],
int best_rate_y, int best_rate_uv, int *best_skip2, int winner_mode_count) { … }
mode_skip_mask_t;
static inline void disable_reference(
MV_REFERENCE_FRAME ref, bool ref_combo[REF_FRAMES][REF_FRAMES + 1]) { … }
static inline void disable_inter_references_except_altref(
bool ref_combo[REF_FRAMES][REF_FRAMES + 1]) { … }
static const MV_REFERENCE_FRAME reduced_ref_combos[][2] = …;
REF_SET;
static inline void default_skip_mask(mode_skip_mask_t *mask, REF_SET ref_set) { … }
static inline void init_mode_skip_mask(mode_skip_mask_t *mask,
const AV1_COMP *cpi, MACROBLOCK *x,
BLOCK_SIZE bsize) { … }
static inline void init_neighbor_pred_buf(const OBMCBuffer *const obmc_buffer,
HandleInterModeArgs *const args,
int is_hbd) { … }
static inline int prune_ref_frame(const AV1_COMP *cpi, const MACROBLOCK *x,
MV_REFERENCE_FRAME ref_frame) { … }
static inline int is_ref_frame_used_by_compound_ref(int ref_frame,
int skip_ref_frame_mask) { … }
static inline int is_ref_frame_used_in_cache(MV_REFERENCE_FRAME ref_frame,
const MB_MODE_INFO *mi_cache) { … }
static inline void set_params_rd_pick_inter_mode(
const AV1_COMP *cpi, MACROBLOCK *x, HandleInterModeArgs *args,
BLOCK_SIZE bsize, mode_skip_mask_t *mode_skip_mask, int skip_ref_frame_mask,
unsigned int *ref_costs_single, unsigned int (*ref_costs_comp)[REF_FRAMES],
struct buf_2d (*yv12_mb)[MAX_MB_PLANE]) { … }
static inline void init_single_inter_mode_search_state(
InterModeSearchState *search_state) { … }
static inline void init_inter_mode_search_state(
InterModeSearchState *search_state, const AV1_COMP *cpi,
const MACROBLOCK *x, BLOCK_SIZE bsize, int64_t best_rd_so_far) { … }
static bool mask_says_skip(const mode_skip_mask_t *mode_skip_mask,
const MV_REFERENCE_FRAME *ref_frame,
const PREDICTION_MODE this_mode) { … }
static int inter_mode_compatible_skip(const AV1_COMP *cpi, const MACROBLOCK *x,
BLOCK_SIZE bsize,
PREDICTION_MODE curr_mode,
const MV_REFERENCE_FRAME *ref_frames) { … }
static int fetch_picked_ref_frames_mask(const MACROBLOCK *const x,
BLOCK_SIZE bsize, int mib_size) { … }
static inline int match_ref_frame_pair(const MB_MODE_INFO *mbmi,
const MV_REFERENCE_FRAME *ref_frames) { … }
static int inter_mode_search_order_independent_skip(
const AV1_COMP *cpi, const MACROBLOCK *x, mode_skip_mask_t *mode_skip_mask,
InterModeSearchState *search_state, int skip_ref_frame_mask,
PREDICTION_MODE mode, const MV_REFERENCE_FRAME *ref_frame) { … }
static inline void init_mbmi(MB_MODE_INFO *mbmi, PREDICTION_MODE curr_mode,
const MV_REFERENCE_FRAME *ref_frames,
const AV1_COMMON *cm) { … }
static inline void collect_single_states(MACROBLOCK *x,
InterModeSearchState *search_state,
const MB_MODE_INFO *const mbmi) { … }
static inline void analyze_single_states(const AV1_COMP *cpi,
InterModeSearchState *search_state) { … }
static int compound_skip_get_candidates(
const AV1_COMP *cpi, const InterModeSearchState *search_state,
const int dir, const PREDICTION_MODE mode) { … }
static int compound_skip_by_single_states(
const AV1_COMP *cpi, const InterModeSearchState *search_state,
const PREDICTION_MODE this_mode, const MV_REFERENCE_FRAME ref_frame,
const MV_REFERENCE_FRAME second_ref_frame, const MACROBLOCK *x) { … }
static inline void match_ref_frame(const MB_MODE_INFO *const mbmi,
const MV_REFERENCE_FRAME *ref_frames,
int *const is_ref_match) { … }
static inline int compound_skip_using_neighbor_refs(
MACROBLOCKD *const xd, const PREDICTION_MODE this_mode,
const MV_REFERENCE_FRAME *ref_frames, int prune_ext_comp_using_neighbors) { … }
static inline void update_best_single_mode(InterModeSearchState *search_state,
const PREDICTION_MODE this_mode,
const MV_REFERENCE_FRAME ref_frame,
int64_t this_rd) { … }
static inline int skip_compound_using_best_single_mode_ref(
const PREDICTION_MODE this_mode, const MV_REFERENCE_FRAME *ref_frames,
const PREDICTION_MODE *best_single_mode,
int prune_comp_using_best_single_mode_ref) { … }
static int compare_int64(const void *a, const void *b) { … }
static inline void update_search_state(
InterModeSearchState *search_state, RD_STATS *best_rd_stats_dst,
PICK_MODE_CONTEXT *ctx, const RD_STATS *new_best_rd_stats,
const RD_STATS *new_best_rd_stats_y, const RD_STATS *new_best_rd_stats_uv,
THR_MODES new_best_mode, const MACROBLOCK *x, int txfm_search_done) { … }
static inline void find_top_ref(int64_t ref_frame_rd[REF_FRAMES]) { … }
static inline bool in_single_ref_cutoff(int64_t ref_frame_rd[REF_FRAMES],
MV_REFERENCE_FRAME frame1,
MV_REFERENCE_FRAME frame2) { … }
static inline void evaluate_motion_mode_for_winner_candidates(
const AV1_COMP *const cpi, MACROBLOCK *const x, RD_STATS *const rd_cost,
HandleInterModeArgs *const args, TileDataEnc *const tile_data,
PICK_MODE_CONTEXT *const ctx,
struct buf_2d yv12_mb[REF_FRAMES][MAX_MB_PLANE],
const motion_mode_best_st_candidate *const best_motion_mode_cands,
int do_tx_search, const BLOCK_SIZE bsize, int64_t *const best_est_rd,
InterModeSearchState *const search_state, int64_t *yrd) { … }
InterModeSFArgs;
static int skip_inter_mode(AV1_COMP *cpi, MACROBLOCK *x, const BLOCK_SIZE bsize,
int64_t *ref_frame_rd, int midx,
InterModeSFArgs *args, int is_low_temp_var) { … }
static void record_best_compound(REFERENCE_MODE reference_mode,
RD_STATS *rd_stats, int comp_pred, int rdmult,
InterModeSearchState *search_state,
int compmode_cost) { … }
static void tx_search_best_inter_candidates(
AV1_COMP *cpi, TileDataEnc *tile_data, MACROBLOCK *x,
int64_t best_rd_so_far, BLOCK_SIZE bsize,
struct buf_2d yv12_mb[REF_FRAMES][MAX_MB_PLANE], int mi_row, int mi_col,
InterModeSearchState *search_state, RD_STATS *rd_cost,
PICK_MODE_CONTEXT *ctx, int64_t *yrd) { … }
static const unsigned int num_winner_motion_modes[3] = …;
static void handle_winner_cand(
MB_MODE_INFO *const mbmi,
motion_mode_best_st_candidate *best_motion_mode_cands,
int max_winner_motion_mode_cand, int64_t this_rd,
motion_mode_candidate *motion_mode_cand, int skip_motion_mode) { … }
static inline void search_intra_modes_in_interframe(
InterModeSearchState *search_state, const AV1_COMP *cpi, MACROBLOCK *x,
RD_STATS *rd_cost, BLOCK_SIZE bsize, PICK_MODE_CONTEXT *ctx,
const InterModeSFArgs *sf_args, unsigned int intra_ref_frame_cost,
int64_t yrd_threshold) { … }
#if !CONFIG_REALTIME_ONLY
static inline void calculate_cost_from_tpl_data(const AV1_COMP *cpi,
MACROBLOCK *x, BLOCK_SIZE bsize,
int mi_row, int mi_col,
int64_t *inter_cost,
int64_t *intra_cost) {
const AV1_COMMON *const cm = &cpi->common;
const BLOCK_SIZE sb_size = cm->seq_params->sb_size;
const int tpl_bsize_1d = cpi->ppi->tpl_data.tpl_bsize_1d;
const int len = (block_size_wide[sb_size] / tpl_bsize_1d) *
(block_size_high[sb_size] / tpl_bsize_1d);
SuperBlockEnc *sb_enc = &x->sb_enc;
if (sb_enc->tpl_data_count == len) {
const BLOCK_SIZE tpl_bsize = convert_length_to_bsize(tpl_bsize_1d);
const int tpl_stride = sb_enc->tpl_stride;
const int tplw = mi_size_wide[tpl_bsize];
const int tplh = mi_size_high[tpl_bsize];
const int nw = mi_size_wide[bsize] / tplw;
const int nh = mi_size_high[bsize] / tplh;
if (nw >= 1 && nh >= 1) {
const int of_h = mi_row % mi_size_high[sb_size];
const int of_w = mi_col % mi_size_wide[sb_size];
const int start = of_h / tplh * tpl_stride + of_w / tplw;
for (int k = 0; k < nh; k++) {
for (int l = 0; l < nw; l++) {
*inter_cost += sb_enc->tpl_inter_cost[start + k * tpl_stride + l];
*intra_cost += sb_enc->tpl_intra_cost[start + k * tpl_stride + l];
}
}
*inter_cost /= nw * nh;
*intra_cost /= nw * nh;
}
}
}
#endif
static inline void skip_intra_modes_in_interframe(
AV1_COMMON *const cm, struct macroblock *x, BLOCK_SIZE bsize,
InterModeSearchState *search_state, const SPEED_FEATURES *const sf,
int64_t inter_cost, int64_t intra_cost) { … }
static inline bool skip_interp_filter_search(const AV1_COMP *cpi,
int is_single_pred) { … }
static inline int get_block_temp_var(const AV1_COMP *cpi, const MACROBLOCK *x,
BLOCK_SIZE bsize) { … }
void av1_rd_pick_inter_mode(struct AV1_COMP *cpi, struct TileDataEnc *tile_data,
struct macroblock *x, struct RD_STATS *rd_cost,
BLOCK_SIZE bsize, PICK_MODE_CONTEXT *ctx,
int64_t best_rd_so_far) { … }
void av1_rd_pick_inter_mode_sb_seg_skip(const AV1_COMP *cpi,
TileDataEnc *tile_data, MACROBLOCK *x,
int mi_row, int mi_col,
RD_STATS *rd_cost, BLOCK_SIZE bsize,
PICK_MODE_CONTEXT *ctx,
int64_t best_rd_so_far) { … }
struct calc_target_weighted_pred_ctxt { … };
static inline void calc_target_weighted_pred_above(
MACROBLOCKD *xd, int rel_mi_row, int rel_mi_col, uint8_t op_mi_size,
int dir, MB_MODE_INFO *nb_mi, void *fun_ctxt, const int num_planes) { … }
static inline void calc_target_weighted_pred_left(
MACROBLOCKD *xd, int rel_mi_row, int rel_mi_col, uint8_t op_mi_size,
int dir, MB_MODE_INFO *nb_mi, void *fun_ctxt, const int num_planes) { … }
static inline void calc_target_weighted_pred(
const AV1_COMMON *cm, const MACROBLOCK *x, const MACROBLOCKD *xd,
const uint8_t *above, int above_stride, const uint8_t *left,
int left_stride) { … }