#include <limits.h>
#include <math.h>
#include <stdio.h>
#include "config/aom_config.h"
#include "config/aom_dsp_rtcd.h"
#include "aom_dsp/aom_dsp_common.h"
#include "aom_mem/aom_mem.h"
#include "aom_ports/mem.h"
#include "av1/common/av1_common_int.h"
#include "av1/common/common.h"
#include "av1/common/filter.h"
#include "av1/common/mvref_common.h"
#include "av1/common/reconinter.h"
#include "av1/encoder/encoder.h"
#include "av1/encoder/encodemv.h"
#include "av1/encoder/mcomp.h"
#include "av1/encoder/rdopt.h"
#include "av1/encoder/reconinter_enc.h"
static inline void init_mv_cost_params(MV_COST_PARAMS *mv_cost_params,
const MvCosts *mv_costs,
const MV *ref_mv, int errorperbit,
int sadperbit) { … }
static inline void init_ms_buffers(MSBuffers *ms_buffers, const MACROBLOCK *x) { … }
void av1_init_obmc_buffer(OBMCBuffer *obmc_buffer) { … }
void av1_make_default_fullpel_ms_params(
FULLPEL_MOTION_SEARCH_PARAMS *ms_params, const struct AV1_COMP *cpi,
MACROBLOCK *x, BLOCK_SIZE bsize, const MV *ref_mv, FULLPEL_MV start_mv,
const search_site_config search_sites[NUM_DISTINCT_SEARCH_METHODS],
SEARCH_METHODS search_method, int fine_search_interval) { … }
void av1_set_ms_to_intra_mode(FULLPEL_MOTION_SEARCH_PARAMS *ms_params,
const IntraBCMVCosts *dv_costs) { … }
void av1_make_default_subpel_ms_params(SUBPEL_MOTION_SEARCH_PARAMS *ms_params,
const struct AV1_COMP *cpi,
const MACROBLOCK *x, BLOCK_SIZE bsize,
const MV *ref_mv, const int *cost_list) { … }
void av1_set_mv_search_range(FullMvLimits *mv_limits, const MV *mv) { … }
int av1_init_search_range(int size) { … }
#define SSE_LAMBDA_LOWRES …
#define SAD_LAMBDA_LOWRES …
#define SSE_LAMBDA_MIDRES …
#define SAD_LAMBDA_MIDRES …
#define SSE_LAMBDA_HDRES …
#define SAD_LAMBDA_HDRES …
static inline int mv_cost(const MV *mv, const int *joint_cost,
const int *const comp_cost[2]) { … }
#define CONVERT_TO_CONST_MVCOST(ptr) …
int av1_mv_bit_cost(const MV *mv, const MV *ref_mv, const int *mvjcost,
int *const mvcost[2], int weight) { … }
#define PIXEL_TRANSFORM_ERROR_SCALE …
static inline int mv_err_cost(const MV *mv, const MV *ref_mv,
const int *mvjcost, const int *const mvcost[2],
int error_per_bit, MV_COST_TYPE mv_cost_type) { … }
static inline int mv_err_cost_(const MV *mv,
const MV_COST_PARAMS *mv_cost_params) { … }
static inline int mvsad_err_cost(const FULLPEL_MV *mv, const FULLPEL_MV *ref_mv,
const int *mvjcost, const int *const mvcost[2],
int sad_per_bit, MV_COST_TYPE mv_cost_type) { … }
static inline int mvsad_err_cost_(const FULLPEL_MV *mv,
const MV_COST_PARAMS *mv_cost_params) { … }
#define MAX_PATTERN_SCALES …
#define MAX_PATTERN_CANDIDATES …
#define PATTERN_CANDIDATES_REF …
static void init_dsmotion_compensation(search_site_config *cfg, int stride,
int level) { … }
void av1_init_motion_fpf(search_site_config *cfg, int stride) { … }
static void init_motion_compensation_nstep(search_site_config *cfg, int stride,
int level) { … }
static void init_motion_compensation_bigdia(search_site_config *cfg, int stride,
int level) { … }
static void init_motion_compensation_square(search_site_config *cfg, int stride,
int level) { … }
static void init_motion_compensation_hex(search_site_config *cfg, int stride,
int level) { … }
const av1_init_search_site_config
av1_init_motion_compensation[NUM_DISTINCT_SEARCH_METHODS] = …;
static inline int check_bounds(const FullMvLimits *mv_limits, int row, int col,
int range) { … }
static inline int get_mvpred_var_cost(
const FULLPEL_MOTION_SEARCH_PARAMS *ms_params, const FULLPEL_MV *this_mv,
FULLPEL_MV_STATS *mv_stats) { … }
static inline int get_mvpred_sad(const FULLPEL_MOTION_SEARCH_PARAMS *ms_params,
const struct buf_2d *const src,
const uint8_t *const ref_address,
const int ref_stride) { … }
static inline int get_mvpred_compound_var_cost(
const FULLPEL_MOTION_SEARCH_PARAMS *ms_params, const FULLPEL_MV *this_mv,
FULLPEL_MV_STATS *mv_stats) { … }
static inline int get_mvpred_compound_sad(
const FULLPEL_MOTION_SEARCH_PARAMS *ms_params,
const struct buf_2d *const src, const uint8_t *const ref_address,
const int ref_stride) { … }
#define USE_SAD_COSTLIST …
static AOM_FORCE_INLINE void calc_int_cost_list(
const FULLPEL_MV best_mv, const FULLPEL_MOTION_SEARCH_PARAMS *ms_params,
int *cost_list) { … }
static AOM_FORCE_INLINE void calc_int_sad_list(
const FULLPEL_MV best_mv, const FULLPEL_MOTION_SEARCH_PARAMS *ms_params,
int *cost_list, int costlist_has_sad) { … }
static inline int update_mvs_and_sad(const unsigned int this_sad,
const FULLPEL_MV *mv,
const MV_COST_PARAMS *mv_cost_params,
unsigned int *best_sad,
unsigned int *raw_best_sad,
FULLPEL_MV *best_mv,
FULLPEL_MV *second_best_mv) { … }
static inline void calc_sad4_update_bestmv(
const FULLPEL_MOTION_SEARCH_PARAMS *ms_params,
const MV_COST_PARAMS *mv_cost_params, FULLPEL_MV *best_mv,
const FULLPEL_MV center_mv, const uint8_t *center_address,
unsigned int *bestsad, unsigned int *raw_bestsad, int search_step,
int *best_site, int cand_start, int *cost_list) { … }
static inline void calc_sad3_update_bestmv(
const FULLPEL_MOTION_SEARCH_PARAMS *ms_params,
const MV_COST_PARAMS *mv_cost_params, FULLPEL_MV *best_mv,
FULLPEL_MV center_mv, const uint8_t *center_address, unsigned int *bestsad,
unsigned int *raw_bestsad, int search_step, int *best_site,
const int *chkpts_indices, int *cost_list) { … }
static inline void calc_sad_update_bestmv(
const FULLPEL_MOTION_SEARCH_PARAMS *ms_params,
const MV_COST_PARAMS *mv_cost_params, FULLPEL_MV *best_mv,
const FULLPEL_MV center_mv, const uint8_t *center_address,
unsigned int *bestsad, unsigned int *raw_bestsad, int search_step,
int *best_site, const int num_candidates, int cand_start, int *cost_list) { … }
static inline void calc_sad_update_bestmv_with_indices(
const FULLPEL_MOTION_SEARCH_PARAMS *ms_params,
const MV_COST_PARAMS *mv_cost_params, FULLPEL_MV *best_mv,
const FULLPEL_MV center_mv, const uint8_t *center_address,
unsigned int *bestsad, unsigned int *raw_bestsad, int search_step,
int *best_site, const int num_candidates, const int *chkpts_indices,
int *cost_list) { … }
static int pattern_search(FULLPEL_MV start_mv,
const FULLPEL_MOTION_SEARCH_PARAMS *ms_params,
int search_step, const int do_init_search,
int *cost_list, FULLPEL_MV *best_mv,
FULLPEL_MV_STATS *best_mv_stats) { … }
static int hex_search(const FULLPEL_MV start_mv,
const FULLPEL_MOTION_SEARCH_PARAMS *ms_params,
const int search_step, const int do_init_search,
int *cost_list, FULLPEL_MV *best_mv,
FULLPEL_MV_STATS *best_mv_stats) { … }
static int bigdia_search(const FULLPEL_MV start_mv,
const FULLPEL_MOTION_SEARCH_PARAMS *ms_params,
const int search_step, const int do_init_search,
int *cost_list, FULLPEL_MV *best_mv,
FULLPEL_MV_STATS *best_mv_stats) { … }
static int square_search(const FULLPEL_MV start_mv,
const FULLPEL_MOTION_SEARCH_PARAMS *ms_params,
const int search_step, const int do_init_search,
int *cost_list, FULLPEL_MV *best_mv,
FULLPEL_MV_STATS *best_mv_stats) { … }
static int fast_hex_search(const FULLPEL_MV start_mv,
const FULLPEL_MOTION_SEARCH_PARAMS *ms_params,
const int search_step, const int do_init_search,
int *cost_list, FULLPEL_MV *best_mv,
FULLPEL_MV_STATS *best_mv_stats) { … }
static int vfast_dia_search(const FULLPEL_MV start_mv,
const FULLPEL_MOTION_SEARCH_PARAMS *ms_params,
const int search_step, const int do_init_search,
int *cost_list, FULLPEL_MV *best_mv,
FULLPEL_MV_STATS *best_mv_stats) { … }
static int fast_dia_search(const FULLPEL_MV start_mv,
const FULLPEL_MOTION_SEARCH_PARAMS *ms_params,
const int search_step, const int do_init_search,
int *cost_list, FULLPEL_MV *best_mv,
FULLPEL_MV_STATS *best_mv_stats) { … }
static int fast_bigdia_search(const FULLPEL_MV start_mv,
const FULLPEL_MOTION_SEARCH_PARAMS *ms_params,
const int search_step, const int do_init_search,
int *cost_list, FULLPEL_MV *best_mv,
FULLPEL_MV_STATS *best_mv_stats) { … }
static int diamond_search_sad(FULLPEL_MV start_mv, unsigned int start_mv_sad,
const FULLPEL_MOTION_SEARCH_PARAMS *ms_params,
const int search_step, int *num00,
FULLPEL_MV *best_mv, FULLPEL_MV *second_best_mv) { … }
static inline unsigned int get_start_mvpred_sad_cost(
const FULLPEL_MOTION_SEARCH_PARAMS *ms_params, FULLPEL_MV start_mv) { … }
static int full_pixel_diamond(FULLPEL_MV start_mv,
const FULLPEL_MOTION_SEARCH_PARAMS *ms_params,
const int step_param, int *cost_list,
FULLPEL_MV *best_mv,
FULLPEL_MV_STATS *best_mv_stats,
FULLPEL_MV *second_best_mv) { … }
static int exhaustive_mesh_search(FULLPEL_MV start_mv,
const FULLPEL_MOTION_SEARCH_PARAMS *ms_params,
const int range, const int step,
FULLPEL_MV *best_mv,
FULLPEL_MV *second_best_mv) { … }
static int full_pixel_exhaustive(const FULLPEL_MV start_mv,
const FULLPEL_MOTION_SEARCH_PARAMS *ms_params,
const struct MESH_PATTERN *const mesh_patterns,
int *cost_list, FULLPEL_MV *best_mv,
FULLPEL_MV_STATS *mv_stats,
FULLPEL_MV *second_best_mv) { … }
int av1_refining_search_8p_c(const FULLPEL_MOTION_SEARCH_PARAMS *ms_params,
const FULLPEL_MV start_mv, FULLPEL_MV *best_mv) { … }
int av1_full_pixel_search(const FULLPEL_MV start_mv,
const FULLPEL_MOTION_SEARCH_PARAMS *ms_params,
const int step_param, int *cost_list,
FULLPEL_MV *best_mv, FULLPEL_MV_STATS *best_mv_stats,
FULLPEL_MV *second_best_mv) { … }
int av1_intrabc_hash_search(const AV1_COMP *cpi, const MACROBLOCKD *xd,
const FULLPEL_MOTION_SEARCH_PARAMS *ms_params,
IntraBCHashInfo *intrabc_hash_info,
FULLPEL_MV *best_mv) { … }
int av1_vector_match(const int16_t *ref, const int16_t *src, int bwl,
int search_size, int full_search, int *sad) { … }
unsigned int av1_int_pro_motion_estimation(const AV1_COMP *cpi, MACROBLOCK *x,
BLOCK_SIZE bsize, int mi_row,
int mi_col, const MV *ref_mv,
unsigned int *y_sad_zero,
int me_search_size_col,
int me_search_size_row) { … }
static inline int get_obmc_mvpred_var(
const FULLPEL_MOTION_SEARCH_PARAMS *ms_params, const FULLPEL_MV *this_mv) { … }
static int obmc_refining_search_sad(
const FULLPEL_MOTION_SEARCH_PARAMS *ms_params, FULLPEL_MV *best_mv) { … }
static int obmc_diamond_search_sad(
const FULLPEL_MOTION_SEARCH_PARAMS *ms_params, FULLPEL_MV start_mv,
FULLPEL_MV *best_mv, int search_step, int *num00) { … }
static int obmc_full_pixel_diamond(
const FULLPEL_MOTION_SEARCH_PARAMS *ms_params, const FULLPEL_MV start_mv,
int step_param, FULLPEL_MV *best_mv) { … }
int av1_obmc_full_pixel_search(const FULLPEL_MV start_mv,
const FULLPEL_MOTION_SEARCH_PARAMS *ms_params,
const int step_param, FULLPEL_MV *best_mv) { … }
#define INIT_SUBPEL_STEP_SIZE …
static inline int get_subpel_part(int x) { … }
static inline const uint8_t *get_buf_from_mv(const struct buf_2d *buf,
const MV mv) { … }
static inline int estimated_pref_error(
const MV *this_mv, const SUBPEL_SEARCH_VAR_PARAMS *var_params,
unsigned int *sse) { … }
static int upsampled_pref_error(MACROBLOCKD *xd, const AV1_COMMON *cm,
const MV *this_mv,
const SUBPEL_SEARCH_VAR_PARAMS *var_params,
unsigned int *sse) { … }
static inline unsigned int check_better_fast(
MACROBLOCKD *xd, const AV1_COMMON *cm, const MV *this_mv, MV *best_mv,
const SubpelMvLimits *mv_limits, const SUBPEL_SEARCH_VAR_PARAMS *var_params,
const MV_COST_PARAMS *mv_cost_params, unsigned int *besterr,
unsigned int *sse1, int *distortion, int *has_better_mv, int is_scaled) { … }
static AOM_FORCE_INLINE unsigned int check_better(
MACROBLOCKD *xd, const AV1_COMMON *cm, const MV *this_mv, MV *best_mv,
const SubpelMvLimits *mv_limits, const SUBPEL_SEARCH_VAR_PARAMS *var_params,
const MV_COST_PARAMS *mv_cost_params, unsigned int *besterr,
unsigned int *sse1, int *distortion, int *is_better) { … }
static inline MV get_best_diag_step(int step_size, unsigned int left_cost,
unsigned int right_cost,
unsigned int up_cost,
unsigned int down_cost) { … }
static AOM_FORCE_INLINE MV first_level_check_fast(
MACROBLOCKD *xd, const AV1_COMMON *cm, const MV this_mv, MV *best_mv,
int hstep, const SubpelMvLimits *mv_limits,
const SUBPEL_SEARCH_VAR_PARAMS *var_params,
const MV_COST_PARAMS *mv_cost_params, unsigned int *besterr,
unsigned int *sse1, int *distortion, int is_scaled) { … }
static AOM_FORCE_INLINE void second_level_check_fast(
MACROBLOCKD *xd, const AV1_COMMON *cm, const MV this_mv, const MV diag_step,
MV *best_mv, int hstep, const SubpelMvLimits *mv_limits,
const SUBPEL_SEARCH_VAR_PARAMS *var_params,
const MV_COST_PARAMS *mv_cost_params, unsigned int *besterr,
unsigned int *sse1, int *distortion, int is_scaled) { … }
static AOM_FORCE_INLINE void two_level_checks_fast(
MACROBLOCKD *xd, const AV1_COMMON *cm, const MV this_mv, MV *best_mv,
int hstep, const SubpelMvLimits *mv_limits,
const SUBPEL_SEARCH_VAR_PARAMS *var_params,
const MV_COST_PARAMS *mv_cost_params, unsigned int *besterr,
unsigned int *sse1, int *distortion, int iters, int is_scaled) { … }
static AOM_FORCE_INLINE MV
first_level_check(MACROBLOCKD *xd, const AV1_COMMON *const cm, const MV this_mv,
MV *best_mv, const int hstep, const SubpelMvLimits *mv_limits,
const SUBPEL_SEARCH_VAR_PARAMS *var_params,
const MV_COST_PARAMS *mv_cost_params, unsigned int *besterr,
unsigned int *sse1, int *distortion) { … }
static AOM_FORCE_INLINE void second_level_check_v2(
MACROBLOCKD *xd, const AV1_COMMON *const cm, const MV this_mv, MV diag_step,
MV *best_mv, const SubpelMvLimits *mv_limits,
const SUBPEL_SEARCH_VAR_PARAMS *var_params,
const MV_COST_PARAMS *mv_cost_params, unsigned int *besterr,
unsigned int *sse1, int *distortion, int is_scaled) { … }
static unsigned int setup_center_error(
const MACROBLOCKD *xd, const MV *bestmv,
const SUBPEL_SEARCH_VAR_PARAMS *var_params,
const MV_COST_PARAMS *mv_cost_params, unsigned int *sse1, int *distortion) { … }
static unsigned int upsampled_setup_center_error(
MACROBLOCKD *xd, const AV1_COMMON *const cm, const MV *bestmv,
const SUBPEL_SEARCH_VAR_PARAMS *var_params,
const MV_COST_PARAMS *mv_cost_params, unsigned int *sse1, int *distortion) { … }
static inline int divide_and_round(int n, int d) { … }
static inline int is_cost_list_wellbehaved(const int *cost_list) { … }
static inline void get_cost_surf_min(const int *cost_list, int *ir, int *ic,
int bits) { … }
static inline int check_repeated_mv_and_update(int_mv *last_mv_search_list,
const MV current_mv, int iter) { … }
static inline int setup_center_error_facade(
MACROBLOCKD *xd, const AV1_COMMON *cm, const MV *bestmv,
const SUBPEL_SEARCH_VAR_PARAMS *var_params,
const MV_COST_PARAMS *mv_cost_params, unsigned int *sse1, int *distortion,
int is_scaled) { … }
int av1_find_best_sub_pixel_tree_pruned_more(
MACROBLOCKD *xd, const AV1_COMMON *const cm,
const SUBPEL_MOTION_SEARCH_PARAMS *ms_params, MV start_mv,
const FULLPEL_MV_STATS *start_mv_stats, MV *bestmv, int *distortion,
unsigned int *sse1, int_mv *last_mv_search_list) { … }
int av1_find_best_sub_pixel_tree_pruned(
MACROBLOCKD *xd, const AV1_COMMON *const cm,
const SUBPEL_MOTION_SEARCH_PARAMS *ms_params, MV start_mv,
const FULLPEL_MV_STATS *start_mv_stats, MV *bestmv, int *distortion,
unsigned int *sse1, int_mv *last_mv_search_list) { … }
int av1_find_best_sub_pixel_tree(MACROBLOCKD *xd, const AV1_COMMON *const cm,
const SUBPEL_MOTION_SEARCH_PARAMS *ms_params,
MV start_mv,
const FULLPEL_MV_STATS *start_mv_stats,
MV *bestmv, int *distortion,
unsigned int *sse1,
int_mv *last_mv_search_list) { … }
int av1_return_max_sub_pixel_mv(MACROBLOCKD *xd, const AV1_COMMON *const cm,
const SUBPEL_MOTION_SEARCH_PARAMS *ms_params,
MV start_mv,
const FULLPEL_MV_STATS *start_mv_stats,
MV *bestmv, int *distortion, unsigned int *sse1,
int_mv *last_mv_search_list) { … }
int av1_return_min_sub_pixel_mv(MACROBLOCKD *xd, const AV1_COMMON *const cm,
const SUBPEL_MOTION_SEARCH_PARAMS *ms_params,
MV start_mv,
const FULLPEL_MV_STATS *start_mv_stats,
MV *bestmv, int *distortion, unsigned int *sse1,
int_mv *last_mv_search_list) { … }
#if !CONFIG_REALTIME_ONLY
static inline unsigned int compute_motion_cost(
MACROBLOCKD *xd, const AV1_COMMON *const cm,
const SUBPEL_MOTION_SEARCH_PARAMS *ms_params, BLOCK_SIZE bsize,
const MV *this_mv) {
unsigned int mse;
unsigned int sse;
const int mi_row = xd->mi_row;
const int mi_col = xd->mi_col;
av1_enc_build_inter_predictor(cm, xd, mi_row, mi_col, NULL, bsize,
AOM_PLANE_Y, AOM_PLANE_Y);
const SUBPEL_SEARCH_VAR_PARAMS *var_params = &ms_params->var_params;
const MSBuffers *ms_buffers = &var_params->ms_buffers;
const uint8_t *const src = ms_buffers->src->buf;
const int src_stride = ms_buffers->src->stride;
const uint8_t *const dst = xd->plane[0].dst.buf;
const int dst_stride = xd->plane[0].dst.stride;
const aom_variance_fn_ptr_t *vfp = ms_params->var_params.vfp;
mse = vfp->vf(dst, dst_stride, src, src_stride, &sse);
mse += mv_err_cost_(this_mv, &ms_params->mv_cost_params);
return mse;
}
#define NEIGHBOR_MASK_DIA …
#define NEIGHBOR_MASK_SQR …
static const warp_search_config warp_search_info[WARP_SEARCH_METHODS] = {
{
.num_neighbors = 4,
.neighbors = { { 0, -1 }, { 1, 0 }, { 0, 1 }, { -1, 0 } },
.neighbor_mask = {
NEIGHBOR_MASK_DIA(1, 1, 0, 1),
NEIGHBOR_MASK_DIA(1, 1, 1, 0),
NEIGHBOR_MASK_DIA(0, 1, 1, 1),
NEIGHBOR_MASK_DIA(1, 0, 1, 1),
},
},
{
.num_neighbors = 8,
.neighbors = { { 0, -1 }, { 1, 0 }, { 0, 1 }, { -1, 0 },
{ 1, -1 }, { 1, 1 }, { -1, -1 }, { -1, 1 } },
.neighbor_mask = {
NEIGHBOR_MASK_SQR(1, 0, 0, 0, 1, 0, 1, 0),
NEIGHBOR_MASK_SQR(0, 1, 0, 0, 1, 1, 0, 0),
NEIGHBOR_MASK_SQR(0, 0, 1, 0, 0, 1, 0, 1),
NEIGHBOR_MASK_SQR(0, 0, 0, 1, 0, 0, 1, 1),
NEIGHBOR_MASK_SQR(1, 1, 0, 0, 1, 1, 1, 0),
NEIGHBOR_MASK_SQR(0, 1, 1, 0, 1, 1, 0, 1),
NEIGHBOR_MASK_SQR(1, 0, 0, 1, 1, 0, 1, 1),
NEIGHBOR_MASK_SQR(0, 0, 1, 1, 0, 1, 1, 1),
},
},
};
unsigned int av1_refine_warped_mv(MACROBLOCKD *xd, const AV1_COMMON *const cm,
const SUBPEL_MOTION_SEARCH_PARAMS *ms_params,
BLOCK_SIZE bsize, const int *pts0,
const int *pts_inref0, int total_samples,
WARP_SEARCH_METHOD search_method,
int num_iterations) {
MB_MODE_INFO *mbmi = xd->mi[0];
const MV *neighbors = warp_search_info[search_method].neighbors;
const int num_neighbors = warp_search_info[search_method].num_neighbors;
const uint8_t *neighbor_mask = warp_search_info[search_method].neighbor_mask;
MV *best_mv = &mbmi->mv[0].as_mv;
WarpedMotionParams best_wm_params = mbmi->wm_params;
int best_num_proj_ref = mbmi->num_proj_ref;
unsigned int bestmse;
const SubpelMvLimits *mv_limits = &ms_params->mv_limits;
const int mv_shift = ms_params->allow_hp ? 0 : 1;
assert(av1_is_subpelmv_in_range(mv_limits, *best_mv));
bestmse = compute_motion_cost(xd, cm, ms_params, bsize, best_mv);
int pts[SAMPLES_ARRAY_SIZE], pts_inref[SAMPLES_ARRAY_SIZE];
const int mi_row = xd->mi_row;
const int mi_col = xd->mi_col;
uint8_t valid_neighbors = UINT8_MAX;
for (int ite = 0; ite < num_iterations; ++ite) {
int best_idx = -1;
for (int idx = 0; idx < num_neighbors; ++idx) {
if ((valid_neighbors & (1 << idx)) == 0) {
continue;
}
unsigned int thismse;
MV this_mv = { best_mv->row + neighbors[idx].row * (1 << mv_shift),
best_mv->col + neighbors[idx].col * (1 << mv_shift) };
if (av1_is_subpelmv_in_range(mv_limits, this_mv)) {
memcpy(pts, pts0, total_samples * 2 * sizeof(*pts0));
memcpy(pts_inref, pts_inref0, total_samples * 2 * sizeof(*pts_inref0));
if (total_samples > 1) {
mbmi->num_proj_ref =
av1_selectSamples(&this_mv, pts, pts_inref, total_samples, bsize);
}
if (!av1_find_projection(mbmi->num_proj_ref, pts, pts_inref, bsize,
this_mv.row, this_mv.col, &mbmi->wm_params,
mi_row, mi_col)) {
thismse = compute_motion_cost(xd, cm, ms_params, bsize, &this_mv);
if (thismse < bestmse) {
best_idx = idx;
best_wm_params = mbmi->wm_params;
best_num_proj_ref = mbmi->num_proj_ref;
bestmse = thismse;
}
}
}
}
if (best_idx == -1) break;
if (best_idx >= 0) {
best_mv->row += neighbors[best_idx].row * (1 << mv_shift);
best_mv->col += neighbors[best_idx].col * (1 << mv_shift);
valid_neighbors = neighbor_mask[best_idx];
}
}
mbmi->wm_params = best_wm_params;
mbmi->num_proj_ref = best_num_proj_ref;
return bestmse;
}
#endif
static inline int estimate_obmc_pref_error(
const MV *this_mv, const SUBPEL_SEARCH_VAR_PARAMS *var_params,
unsigned int *sse) { … }
static int upsampled_obmc_pref_error(MACROBLOCKD *xd, const AV1_COMMON *cm,
const MV *this_mv,
const SUBPEL_SEARCH_VAR_PARAMS *var_params,
unsigned int *sse) { … }
static unsigned int setup_obmc_center_error(
const MV *this_mv, const SUBPEL_SEARCH_VAR_PARAMS *var_params,
const MV_COST_PARAMS *mv_cost_params, unsigned int *sse1, int *distortion) { … }
static unsigned int upsampled_setup_obmc_center_error(
MACROBLOCKD *xd, const AV1_COMMON *const cm, const MV *this_mv,
const SUBPEL_SEARCH_VAR_PARAMS *var_params,
const MV_COST_PARAMS *mv_cost_params, unsigned int *sse1, int *distortion) { … }
static inline int estimate_obmc_mvcost(const MV *this_mv,
const MV_COST_PARAMS *mv_cost_params) { … }
static inline unsigned int obmc_check_better_fast(
const MV *this_mv, MV *best_mv, const SubpelMvLimits *mv_limits,
const SUBPEL_SEARCH_VAR_PARAMS *var_params,
const MV_COST_PARAMS *mv_cost_params, unsigned int *besterr,
unsigned int *sse1, int *distortion, int *has_better_mv) { … }
static inline unsigned int obmc_check_better(
MACROBLOCKD *xd, const AV1_COMMON *cm, const MV *this_mv, MV *best_mv,
const SubpelMvLimits *mv_limits, const SUBPEL_SEARCH_VAR_PARAMS *var_params,
const MV_COST_PARAMS *mv_cost_params, unsigned int *besterr,
unsigned int *sse1, int *distortion, int *has_better_mv) { … }
static AOM_FORCE_INLINE MV obmc_first_level_check(
MACROBLOCKD *xd, const AV1_COMMON *const cm, const MV this_mv, MV *best_mv,
const int hstep, const SubpelMvLimits *mv_limits,
const SUBPEL_SEARCH_VAR_PARAMS *var_params,
const MV_COST_PARAMS *mv_cost_params, unsigned int *besterr,
unsigned int *sse1, int *distortion) { … }
static AOM_FORCE_INLINE void obmc_second_level_check_v2(
MACROBLOCKD *xd, const AV1_COMMON *const cm, const MV this_mv, MV diag_step,
MV *best_mv, const SubpelMvLimits *mv_limits,
const SUBPEL_SEARCH_VAR_PARAMS *var_params,
const MV_COST_PARAMS *mv_cost_params, unsigned int *besterr,
unsigned int *sse1, int *distortion) { … }
int av1_find_best_obmc_sub_pixel_tree_up(
MACROBLOCKD *xd, const AV1_COMMON *const cm,
const SUBPEL_MOTION_SEARCH_PARAMS *ms_params, MV start_mv,
const FULLPEL_MV_STATS *start_mv_stats, MV *bestmv, int *distortion,
unsigned int *sse1, int_mv *last_mv_search_list) { … }
int av1_get_mvpred_sse(const MV_COST_PARAMS *mv_cost_params,
const FULLPEL_MV best_mv,
const aom_variance_fn_ptr_t *vfp,
const struct buf_2d *src, const struct buf_2d *pre) { … }