AOMedia AV1 Codec
NonRD Optimized Mode Search
Collaboration diagram for 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. More...
 
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. More...
 
static void find_predictors (AV1_COMP *cpi, MACROBLOCK *x, MV_REFERENCE_FRAME ref_frame, int_mv frame_mv[MB_MODE_COUNT][REF_FRAMES], TileDataEnc *tile_data, struct buf_2d yv12_mb[8][3], BLOCK_SIZE bsize, int force_skip_low_temp_var, int skip_pred_mv)
 Finds predicted motion vectors for a block. More...
 
static int combined_motion_search (AV1_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize, int mi_row, int mi_col, 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. More...
 
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. More...
 
void av1_block_yrd (const AV1_COMP *const cpi, MACROBLOCK *x, int mi_row, int mi_col, RD_STATS *this_rdc, int *skippable, BLOCK_SIZE bsize, TX_SIZE tx_size, TX_TYPE tx_type, int is_inter_mode)
 Calculates RD Cost using Hadamard transform. More...
 
static void estimate_block_intra (int plane, int block, int row, int col, BLOCK_SIZE plane_bsize, TX_SIZE tx_size, void *arg)
 Estimation of RD cost of an intra mode for Non-RD optimized case. More...
 
static void search_filter_ref (AV1_COMP *cpi, MACROBLOCK *x, RD_STATS *this_rdc, int mi_row, int mi_col, PRED_BUFFER *tmp, BLOCK_SIZE bsize, int reuse_inter_pred, PRED_BUFFER **this_mode_pred, int *this_early_term, int use_model_yrd_large, int64_t best_sse)
 Searches for the best intrpolation filter. More...
 
static void estimate_intra_mode (AV1_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize, int use_modeled_non_rd_cost, int best_early_term, unsigned int ref_cost_intra, int reuse_prediction, struct buf_2d *orig_dst, PRED_BUFFER *tmp_buffers, PRED_BUFFER **this_mode_pred, RD_STATS *best_rdc, BEST_PICKMODE *best_pickmode, PICK_MODE_CONTEXT *ctx)
 Estimates best intra mode for inter mode search. More...
 

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 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
Returns
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.

References macroblockd::above_mbmi, TxfmSearchInfo::blk_skip, AV1_COMP::common, macroblock::e_mbd, estimate_block_intra(), macroblockd::left_mbmi, macroblockd::mi, MB_MODE_INFO::mode, macroblock::mode_costs, MB_MODE_INFO::mv, macroblock::rdmult, ModeCosts::skip_txfm_cost, 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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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
    Returns
    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.

< U (Chroma) plane

< U (Chroma) plane

< V (Chroma) plane

< V (Chroma) plane

References AV1_COMP::common, macroblock::e_mbd, AV1Common::features, FeatureFlags::interp_filter, macroblockd::mi, AV1_COMP::oxcf, macroblockd::plane, AV1_COMP::rd, MB_MODE_INFO::segment_id, AV1_COMP::svc, and macroblock::thresh_freq_fact.

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],
TileDataEnc *  tile_data,
struct buf_2d  yv12_mb[8][3],
BLOCK_SIZE  bsize,
int  force_skip_low_temp_var,
int  skip_pred_mv 
)
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
[in]frame_mvPredicted MVs for a block
[in]tile_dataPointer to struct holding adaptive data/contexts/models for the tile during encoding
[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
Returns
Nothing is returned. Instead, predicted MVs are placed into frame_mv array

References FeatureFlags::allow_high_precision_mv, AV1_COMP::common, macroblock::e_mbd, AV1Common::features, MB_MODE_INFO_EXT::global_mvs, 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, and macroblockd::weight.

◆ combined_motion_search()

static int combined_motion_search ( AV1_COMP cpi,
MACROBLOCK x,
BLOCK_SIZE  bsize,
int  mi_row,
int  mi_col,
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]mi_rowRow index in 4x4 units
[in]mi_colColumn index in 4x4 units
[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, macroblockd::plane, macroblock::pred_sse, macroblock::rdmult, MB_MODE_INFO::ref_frame, MB_MODE_INFO::ref_mv_idx, SPEED_FEATURES::rt_sf, MotionVectorSearchParams::search_site_cfg, and AV1_COMP::sf.

Referenced by search_new_mv().

Here is the caller graph for this function:

◆ 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, SPEED_FEATURES::mv_sf, 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.

Here is the call graph for this function:

◆ av1_block_yrd()

void av1_block_yrd ( const AV1_COMP *const  cpi,
MACROBLOCK x,
int  mi_row,
int  mi_col,
RD_STATS *  this_rdc,
int *  skippable,
BLOCK_SIZE  bsize,
TX_SIZE  tx_size,
TX_TYPE  tx_type,
int  is_inter_mode 
)

Calculates RD Cost using Hadamard transform.

Calculates RD Cost using Hadamard transform. For low bit depth this function uses low-precision set of functions (16-bit) and 32 bit for high bit depth

Parameters
[in]cpiTop-level encoder structure
[in]xPointer to structure holding all the data for the current macroblock
[in]mi_rowRow index in 4x4 units
[in]mi_colColumn index in 4x4 units
[in]this_rdcPointer to calculated RD Cost
[in]skippablePointer to a flag indicating possible tx skip
[in]bsizeCurrent block size
[in]tx_sizeTransform size
[in]tx_typeTransform kernel type
[in]is_inter_modeFlag to indicate inter mode
Returns
Nothing is returned. Instead, calculated RD cost is placed to this_rdc. skippable flag is set if there is no non-zero quantized coefficients for Hadamard transform

References macroblockd::above_mbmi, macroblock_plane::coeff, macroblock::color_sensitivity, macroblock_plane::dequant_QTX, macroblock_plane::dqcoeff, macroblock::e_mbd, AV1Common::features, MB_MODE_INFO::filter_intra_mode_info, AV1_PRIMARY::fn_ptr, ModeCosts::inter_compound_mode_cost, MB_MODE_INFO::interintra_mode, FeatureFlags::interp_filter, macroblockd::left_mbmi, macroblockd::mb_to_bottom_edge, macroblockd::mb_to_right_edge, macroblock::mbmi_ext, macroblockd::mi, MB_MODE_INFO::mode, MB_MODE_INFO::motion_mode, MB_MODE_INFO::mv, ModeCosts::newmv_mode_cost, MB_MODE_INFO::num_proj_ref, MB_MODE_INFO::palette_mode_info, macroblockd::plane, macroblock::plane, AV1_COMP::ppi, macroblock_plane::qcoeff, macroblock_plane::quant_fp_QTX, macroblock_plane::quant_shift_QTX, macroblock::rdmult, MB_MODE_INFO::ref_frame, MB_MODE_INFO::ref_mv_idx, ModeCosts::refmv_mode_cost, macroblock_plane::round_fp_QTX, TxfmSearchInfo::skip_txfm, macroblock_plane::src, macroblock_plane::src_diff, macroblock::txfm_search_info, MB_MODE_INFO::uv_mode, macroblock_plane::zbin_QTX, and ModeCosts::zeromv_mode_cost.

Referenced by estimate_block_intra().

Here is the caller graph for this function:

◆ estimate_block_intra()

static void estimate_block_intra ( int  plane,
int  block,
int  row,
int  col,
BLOCK_SIZE  plane_bsize,
TX_SIZE  tx_size,
void *  arg 
)
static

Estimation of RD cost of an intra mode for Non-RD optimized case.

Calculates RD Cost for an intra mode for a single TX block using Hadamard transform.

Parameters
[in]planeColor plane
[in]blockIndex of a TX block in a prediction block
[in]rowRow of a current TX block
[in]colColumn of a current TX block
[in]plane_bsizeBlock size of a current prediction block
[in]tx_sizeTransform size
[in]argPointer to a structure that holds paramaters for intra mode search
Returns
Nothing is returned. Instead, best mode and RD Cost of the best mode are set in args->rdc and args->mode

References av1_block_yrd(), AV1_COMP::common, macroblock::e_mbd, macroblockd::plane, macroblock::plane, and macroblock_plane::src.

Referenced by av1_nonrd_pick_intra_mode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ search_filter_ref()

static void search_filter_ref ( AV1_COMP cpi,
MACROBLOCK x,
RD_STATS *  this_rdc,
int  mi_row,
int  mi_col,
PRED_BUFFER *  tmp,
BLOCK_SIZE  bsize,
int  reuse_inter_pred,
PRED_BUFFER **  this_mode_pred,
int *  this_early_term,
int  use_model_yrd_large,
int64_t  best_sse 
)
static

Searches for the best intrpolation 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]mi_rowRow index in 4x4 units
[in]mi_colColumn index in 4x4 units
[in]tmpPointer 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
[in]use_model_yrd_largeFlag, indicating special logic to handle large blocks
[in]best_sseBest sse so far.
Returns
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 ouputs this_mode_pred. Also this_early_temp is set if transform can be skipped

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

◆ estimate_intra_mode()

static void estimate_intra_mode ( AV1_COMP cpi,
MACROBLOCK x,
BLOCK_SIZE  bsize,
int  use_modeled_non_rd_cost,
int  best_early_term,
unsigned int  ref_cost_intra,
int  reuse_prediction,
struct buf_2d *  orig_dst,
PRED_BUFFER *  tmp_buffers,
PRED_BUFFER **  this_mode_pred,
RD_STATS *  best_rdc,
BEST_PICKMODE *  best_pickmode,
PICK_MODE_CONTEXT *  ctx 
)
static

Estimates best intra mode for inter mode search.

Using heuristics based on best inter mode, block size, and other decides whether to check intra modes. If so, estimates and selects best intra mode from the reduced set of intra modes (max 4 intra modes checked)

Parameters
[in]cpiTop-level encoder structure
[in]xPointer to structure holding all the data for the current macroblock
[in]bsizeCurrent block size
[in]use_modeled_non_rd_costFlag, indicating usage of curvfit model for RD cost
[in]best_early_termFlag, indicating that TX for the best inter mode was skipped
[in]ref_cost_intraCost of signalling intra mode
[in]reuse_predictionFlag, indicating prediction re-use
[in]orig_dstOriginal destination buffer
[in]tmp_buffersPointer to a temporary buffers for prediction re-use
[out]this_mode_predPointer to store prediction buffer for prediction re-use
[in]best_rdcPointer to RD cost for the best selected intra mode
[in]best_pickmodePointer to a structure containing best mode picked so far
[in]ctxPointer to structure holding coding contexts and modes for the block
Returns
Nothing is returned. Instead, calculated RD cost is placed to best_rdc and best selected mode is placed to best_pickmode

References CommonQuantParams::base_qindex, AV1_COMP::common, macroblock::content_state_sb, macroblock::e_mbd, LAYER_CONTEXT::is_key_frame, SVC::layer_context, macroblockd::mi, macroblockd::mi_col, macroblockd::mi_row, MB_MODE_INFO::mv, AV1_COMP::oxcf, macroblockd::plane, AV1_COMP::ppi, AV1Common::quant_params, AV1_COMP::rd, macroblock::rdmult, SPEED_FEATURES::rt_sf, MB_MODE_INFO::segment_id, AV1Common::seq_params, AV1_COMP::sf, macroblock::source_variance, AV1_COMP::svc, macroblock::thresh_freq_fact, TxfmSearchParams::tx_mode_search_type, macroblock::txfm_search_params, AV1_PRIMARY::use_svc, and CommonQuantParams::y_dc_delta_q.