AOMedia AV1 Codec
NonRD Optimized Mode Search

Functions

void av1_nonrd_pick_intra_mode (AV1_COMP *cpi, MACROBLOCK *x, RD_STATS *rd_cost, BLOCK_SIZE bsize, PICK_MODE_CONTEXT *ctx)
 AV1 intra mode selection based on Non-RD optimized model.
 
void av1_nonrd_pick_inter_mode_sb (struct AV1_COMP *cpi, struct TileDataEnc *tile_data, struct macroblock *x, struct RD_STATS *rd_cost, BLOCK_SIZE bsize, PICK_MODE_CONTEXT *ctx)
 AV1 inter mode selection based on Non-RD optimized model.
 
static void find_predictors (AV1_COMP *cpi, MACROBLOCK *x, MV_REFERENCE_FRAME ref_frame, int_mv frame_mv[MB_MODE_COUNT][REF_FRAMES], struct buf_2d yv12_mb[8][3], BLOCK_SIZE bsize, int force_skip_low_temp_var, int skip_pred_mv, bool *use_scaled_ref_frame)
 Finds predicted motion vectors for a block.
 
static int combined_motion_search (AV1_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize, int_mv *tmp_mv, int *rate_mv, int64_t best_rd_sofar, int use_base_mv)
 Runs Motion Estimation for a specific block and specific ref frame.
 
static int search_new_mv (AV1_COMP *cpi, MACROBLOCK *x, int_mv frame_mv[][REF_FRAMES], MV_REFERENCE_FRAME ref_frame, int gf_temporal_ref, BLOCK_SIZE bsize, int mi_row, int mi_col, int *rate_mv, RD_STATS *best_rdc)
 Searches for the best New Motion Vector.
 
static void search_filter_ref (AV1_COMP *cpi, MACROBLOCK *x, RD_STATS *this_rdc, InterPredParams *inter_pred_params_sr, int mi_row, int mi_col, PRED_BUFFER *tmp_buffer, BLOCK_SIZE bsize, int reuse_inter_pred, PRED_BUFFER **this_mode_pred, int *this_early_term, unsigned int *var, int use_model_yrd_large, int64_t best_sse, int is_single_pred)
 Searches for the best interpolation filter.
 

Detailed Description

This module describes NonRD Optimized Mode Search used in Real-Time mode. More details will be added.

Function Documentation

◆ av1_nonrd_pick_intra_mode()

void av1_nonrd_pick_intra_mode ( AV1_COMP * cpi,
MACROBLOCK * x,
RD_STATS * rd_cost,
BLOCK_SIZE bsize,
PICK_MODE_CONTEXT * ctx )

AV1 intra mode selection based on Non-RD optimized model.

Top level function for Non-RD optimized intra mode selection. This finction will loop over subset of intra modes and select the best one based on calculated modelled RD cost. Only 4 intra modes are checked as specified in intra_mode_list. When calculating RD cost Hadamard transform of residual is used to calculate rate. Estmation of RD cost is performed in av1_estimate_block_intra which is called from this function

Parameters
[in]cpiTop-level encoder structure
[in]xPointer to structure holding all the data for the current macroblock
[in]rd_costStruct to keep track of the RD information
[in]bsizeCurrent block size
[in]ctxStructure to hold snapshot of coding context during the mode picking process
Remarks
Nothing is returned. Instead, the MB_MODE_INFO struct inside x is modified to store information about the best mode computed in this function. The rd_cost struct is also updated with the RD stats corresponding to the best mode found.

< Y (Luminance) plane

References macroblockd::above_mbmi, AOM_PLANE_Y, TxfmSearchInfo::blk_skip, AV1_COMP::common, macroblock::e_mbd, macroblockd::left_mbmi, macroblockd::lossless, macroblockd::mi, MB_MODE_INFO::mode, macroblock::mode_costs, MB_MODE_INFO::mv, AV1_COMP::oxcf, AV1EncoderConfig::rc_cfg, macroblock::rdmult, SPEED_FEATURES::rt_sf, MB_MODE_INFO::segment_id, AV1_COMP::sf, TxfmSearchInfo::skip_txfm, ModeCosts::skip_txfm_cost, macroblock::source_variance, TxfmSearchParams::tx_mode_search_type, MB_MODE_INFO::tx_size, macroblock::txfm_search_info, macroblock::txfm_search_params, MB_MODE_INFO::uv_mode, and ModeCosts::y_mode_costs.

Referenced by hybrid_intra_mode_search().

◆ av1_nonrd_pick_inter_mode_sb()

void av1_nonrd_pick_inter_mode_sb ( struct AV1_COMP * cpi,
struct TileDataEnc * tile_data,
struct macroblock * x,
struct RD_STATS * rd_cost,
BLOCK_SIZE bsize,
PICK_MODE_CONTEXT * ctx )

AV1 inter mode selection based on Non-RD optimized model.

Top level function for Non-RD optimized inter mode selection. This finction will loop over subset of inter modes and select the best one based on calculated modelled RD cost. While making decisions which modes to check, this function applies heuristics based on previously checked modes, block residual variance, block size, and other factors to prune certain modes and reference frames. Currently only single reference frame modes are checked. Additional heuristics are applied to decide if intra modes need to be checked.

  • Parameters
    [in]cpiTop-level encoder structure
    [in]tile_dataPointer to struct holding adaptive data/contexts/models for the tile during encoding
    [in]xPointer to structure holding all the data for the current macroblock
    [in]rd_costStruct to keep track of the RD information
    [in]bsizeCurrent block size
    [in]ctxStructure to hold snapshot of coding context during the mode picking process
    Remarks
    Nothing is returned. Instead, the MB_MODE_INFO struct inside x is modified to store information about the best mode computed in this function. The rd_cost struct is also updated with the RD stats corresponding to the best mode found.

< Y (Luminance) plane

< Y (Luminance) plane

< U (Chroma) plane

< U (Chroma) plane

< V (Chroma) plane

< V (Chroma) plane

< U (Chroma) plane

< V (Chroma) plane

References FeatureFlags::allow_screen_content_tools, MB_MODE_INFO::angle_delta, AOM_BITS_8, AOM_PLANE_U, AOM_PLANE_V, AOM_PLANE_Y, macroblockd::bd, InterModeSearchStateNonrd::best_pickmode, InterModeSearchStateNonrd::best_rdc, macroblock::block_is_zero_sad, macroblockd::block_ref_scale_factors, MB_MODE_INFO::bsize, COLOR_SENS_IDX, macroblock::color_sensitivity, macroblock::color_sensitivity_sb_g, AV1_COMP::common, MB_MODE_INFO::comp_group_idx, MB_MODE_INFO::compound_idx, macroblock::content_state_sb, SVC::downsample_filter_phase, macroblock::e_mbd, AV1Common::features, MB_MODE_INFO::filter_intra_mode_info, macroblock::force_zeromv_skip_for_blk, InterModeSearchStateNonrd::frame_mv, InterModeSearchStateNonrd::frame_mv_best, SVC::has_lower_quality_layer, AV1Common::height, SPEED_FEATURES::inter_sf, MB_MODE_INFO::inter_tx_size, MB_MODE_INFO::interinter_comp, MB_MODE_INFO::interp_filters, SPEED_FEATURES::interp_sf, macroblock::mbmi_ext, macroblockd::mi, macroblockd::mi_col, CommonModeInfoParams::mi_cols, AV1Common::mi_params, macroblockd::mi_row, CommonModeInfoParams::mi_rows, macroblock::min_dist_inter_uv, MB_MODE_INFO::mode, MB_MODE_INFO_EXT::mode_context, macroblock::mode_costs, MB_MODE_INFO::motion_mode, AV1_COMP::mt_info, MB_MODE_INFO::mv, MB_MODE_INFO::num_proj_ref, MultiThreadInfo::num_workers, AV1_COMP::oxcf, MB_MODE_INFO::palette_mode_info, macroblockd::plane, AV1_COMP::ppi, macroblock::pred_mv0_sad, macroblock::pred_mv1_sad, macroblock::pred_mv_sad, AV1_COMP::rc, AV1EncoderConfig::rc_cfg, InterModeSearchStateNonrd::ref_costs_single, MB_MODE_INFO::ref_frame, macroblock::reuse_inter_pred, SPEED_FEATURES::rt_sf, macroblock::sb_me_block, macroblock::sb_me_partition, AV1Common::seg, MB_MODE_INFO::segment_id, AV1Common::seq_params, AV1_COMP::sf, InterModeSearchStateNonrd::single_inter_mode_costs, TxfmSearchInfo::skip_txfm, macroblock::source_variance, AV1_COMP::svc, TxfmSearchParams::tx_mode_search_type, MB_MODE_INFO::tx_size, macroblock::txfm_search_info, macroblock::txfm_search_params, InterModeSearchStateNonrd::use_ref_frame_mask, InterModeSearchStateNonrd::use_scaled_ref_frame, AV1_PRIMARY::use_svc, InterModeSearchStateNonrd::vars, AV1Common::width, MB_MODE_INFO::wm_params, and InterModeSearchStateNonrd::yv12_mb.

Referenced by pick_sb_modes_nonrd().

◆ find_predictors()

static void find_predictors ( AV1_COMP * cpi,
MACROBLOCK * x,
MV_REFERENCE_FRAME ref_frame,
int_mv frame_mv[MB_MODE_COUNT][REF_FRAMES],
struct buf_2d yv12_mb[8][3],
BLOCK_SIZE bsize,
int force_skip_low_temp_var,
int skip_pred_mv,
bool * use_scaled_ref_frame )
inlinestatic

Finds predicted motion vectors for a block.

Finds predicted motion vectors for a block from a certain reference frame. First, it fills reference MV stack, then picks the test from the stack and predicts the final MV for a block for each mode.

Parameters
[in]cpiTop-level encoder structure
[in]xPointer to structure holding all the data for the current macroblock
[in]ref_frameReference frame for which to find ref MVs
[out]frame_mvPredicted MVs for a block
[in]yv12_mbBuffer to hold predicted block
[in]bsizeCurrent block size
[in]force_skip_low_temp_varFlag indicating possible mode search prune for low temporal variance block
[in]skip_pred_mvFlag indicating to skip av1_mv_pred
[out]use_scaled_ref_frameFlag to indicate if scaled reference frame is used.
Remarks
Nothing is returned. Instead, predicted MVs are placed into frame_mv array, and use_scaled_ref_frame is set.

References FeatureFlags::allow_high_precision_mv, AV1_COMP::common, macroblock::e_mbd, AV1Common::features, MB_MODE_INFO_EXT::global_mvs, AV1Common::height, macroblock::mbmi_ext, macroblockd::mi, MB_MODE_INFO_EXT::mode_context, MB_MODE_INFO::num_proj_ref, macroblock::pred_mv0_sad, macroblock::pred_mv1_sad, macroblock::pred_mv_sad, MB_MODE_INFO_EXT::ref_mv_count, macroblockd::ref_mv_stack, FeatureFlags::switchable_motion_mode, macroblockd::weight, and AV1Common::width.

◆ combined_motion_search()

static int combined_motion_search ( AV1_COMP * cpi,
MACROBLOCK * x,
BLOCK_SIZE bsize,
int_mv * tmp_mv,
int * rate_mv,
int64_t best_rd_sofar,
int use_base_mv )
static

Runs Motion Estimation for a specific block and specific ref frame.

Finds the best Motion Vector by running Motion Estimation for a specific block and a specific reference frame. Exits early if RDCost of Full Pel part exceeds best RD Cost fund so far

Parameters
[in]cpiTop-level encoder structure
[in]xPointer to structure holding all the data for the current macroblock
[in]bsizeCurrent block size
[in]tmp_mvPointer to best found New MV
[in]rate_mvPointer to Rate of the best new MV
[in]best_rd_sofarRD Cost of the best mode found so far
[in]use_base_mvFlag, indicating that tmp_mv holds specific MV to start the search with
Returns
Returns 0 if ME was terminated after Full Pel Search because too high RD Cost. Otherwise returns 1. Best New MV is placed into tmp_mv. Rate estimation for this vector is placed to rate_mv

References AV1_COMP::common, macroblock::e_mbd, MotionVectorSearchParams::find_fractional_mv_step, macroblockd::mi, MvCosts::mv_cost_stack, macroblock::mv_costs, AV1_COMP::mv_search_params, SPEED_FEATURES::mv_sf, MotionVectorSearchParams::mv_step_param, MvCosts::nmv_joint_cost, macroblock::pred_sse, macroblock::rdmult, MB_MODE_INFO::ref_frame, MB_MODE_INFO::ref_mv_idx, SPEED_FEATURES::rt_sf, and AV1_COMP::sf.

Referenced by search_new_mv().

◆ search_new_mv()

static int search_new_mv ( AV1_COMP * cpi,
MACROBLOCK * x,
int_mv frame_mv[][REF_FRAMES],
MV_REFERENCE_FRAME ref_frame,
int gf_temporal_ref,
BLOCK_SIZE bsize,
int mi_row,
int mi_col,
int * rate_mv,
RD_STATS * best_rdc )
static

Searches for the best New Motion Vector.

Finds the best Motion Vector by doing Motion Estimation. Uses reduced complexity ME for non-LAST frames or calls combined_motion_search for LAST reference frame

Parameters
[in]cpiTop-level encoder structure
[in]xPointer to structure holding all the data for the current macroblock
[in]frame_mvArray that holds MVs for all modes and ref frames
[in]ref_frameReference frame for which to find the best New MVs
[in]gf_temporal_refFlag, indicating temporal reference for GOLDEN frame
[in]bsizeCurrent block size
[in]mi_rowRow index in 4x4 units
[in]mi_colColumn index in 4x4 units
[in]rate_mvPointer to Rate of the best new MV
[in]best_rdcPointer to the RD Cost for the best mode found so far
Returns
Returns -1 if the search was not done, otherwise returns 0. Best New MV is placed into frame_mv array, Rate estimation for this vector is placed to rate_mv

References AOM_CBR, combined_motion_search(), AV1_COMP::common, macroblock::e_mbd, MotionVectorSearchParams::find_fractional_mv_step, macroblock::mbmi_ext, macroblockd::mi, RateControlCfg::mode, MB_MODE_INFO::mv, MvCosts::mv_cost_stack, macroblock::mv_costs, AV1_COMP::mv_search_params, MvCosts::nmv_joint_cost, AV1_COMP::oxcf, macroblock::pred_mv_sad, macroblock::pred_sse, AV1EncoderConfig::rc_cfg, MB_MODE_INFO_EXT::ref_mv_stack, SPEED_FEATURES::rt_sf, and AV1_COMP::sf.

◆ search_filter_ref()

static void search_filter_ref ( AV1_COMP * cpi,
MACROBLOCK * x,
RD_STATS * this_rdc,
InterPredParams * inter_pred_params_sr,
int mi_row,
int mi_col,
PRED_BUFFER * tmp_buffer,
BLOCK_SIZE bsize,
int reuse_inter_pred,
PRED_BUFFER ** this_mode_pred,
int * this_early_term,
unsigned int * var,
int use_model_yrd_large,
int64_t best_sse,
int is_single_pred )
static

Searches for the best interpolation filter.

Iterates through subset of possible interpolation filters (EIGHTTAP_REGULAR, EIGTHTAP_SMOOTH, MULTITAP_SHARP, depending on FILTER_SEARCH_SIZE) and selects the one that gives lowest RD cost. RD cost is calculated using curvfit model. Support for dual filters (different filters in the x & y directions) is allowed if sf.interp_sf.disable_dual_filter = 0.

Parameters
[in]cpiTop-level encoder structure
[in]xPointer to structure holding all the data for the current macroblock
[in]this_rdcPointer to calculated RD Cost
[in]inter_pred_params_srPointer to structure holding parameters of inter prediction for single reference
[in]mi_rowRow index in 4x4 units
[in]mi_colColumn index in 4x4 units
[in]tmp_bufferPointer to a temporary buffer for prediction re-use
[in]bsizeCurrent block size
[in]reuse_inter_predFlag, indicating prediction re-use
[out]this_mode_predPointer to store prediction buffer for prediction re-use
[out]this_early_termFlag, indicating that transform can be skipped
[out]varThe residue variance of the current predictor.
[in]use_model_yrd_largeFlag, indicating special logic to handle large blocks
[in]best_sseBest sse so far.
[in]is_single_predFlag, indicating single mode.
Remarks
Nothing is returned. Instead, calculated RD cost is placed to this_rdc and best filter is placed to mi->interp_filters. In case reuse_inter_pred flag is set, this function also outputs this_mode_pred. Also this_early_temp is set if transform can be skipped

< Y (Luminance) plane

< Y (Luminance) plane

< Y (Luminance) plane

< Y (Luminance) plane

< Y (Luminance) plane

References AOM_PLANE_Y, macroblockd::block_ref_scale_factors, AV1_COMP::common, macroblock::e_mbd, AV1Common::features, FeatureFlags::interp_filter, MB_MODE_INFO::interp_filters, SPEED_FEATURES::interp_sf, macroblockd::mi, MB_MODE_INFO::mv, macroblockd::plane, macroblock::rdmult, AV1Common::seq_params, AV1_COMP::sf, and MB_MODE_INFO::tx_size.