#include "contributors.h"
#include <math.h>
#include <limits.h>
#include <time.h>
#include "global.h"
#include "image.h"
#include "mv_search.h"
#include "refbuf.h"
#include "memalloc.h"
#include "mb_access.h"
#include "macroblock.h"
#include "mc_prediction.h"
#include "conformance.h"
#include "me_distortion.h"
#include "me_epzs.h"
#include "me_epzs_int.h"
#include "me_fullfast.h"
#include "me_fullsearch.h"
#include "me_umhex.h"
#include "me_umhexsmp.h"
#include "rdoq.h"
Go to the source code of this file.
Functions | |
static int | GetSkipCostMB (Macroblock *currMB) |
static int | BiPredBlockMotionSearch (Macroblock *currMB,MEBlock *mv_block,MotionVector *pred_mv,int mb_x,int mb_y,int *lambda_factor) |
void | get_search_range (MEBlock *mv_block, InputParameters *p_Inp, short ref, int blocktype) |
static void | set_me_parameters (char **ref_array, short ***mv_array, short *all_mv, short ref, int step_h, int step_v, int pic_block_x) |
void | set_access_method (int *access_method, MotionVector *blk, int min_x, int min_y, int max_x, int max_y) |
void | init_ME_engine (Macroblock *currMB) |
void | PrepareMEParams (Slice *currSlice, MEBlock *mv_block, int ChromaMEEnable, int list, int ref) |
void | PrepareBiPredMEParams (Slice *currSlice, MEBlock *mv_block, int ChromaMEEnable, int list, int list_offset, int ref) |
void | get_neighbors (Macroblock *currMB, PixelPos *block, int mb_x, int mb_y, int blockshape_x) |
void | Init_Motion_Search_Module (ImageParameters *p_Img, InputParameters *p_Inp) |
void | Clear_Motion_Search_Module (ImageParameters *p_Img, InputParameters *p_Inp) |
static int | mv_bits_cost (ImageParameters *p_Img, short ***all_mv, short ***p_mv, int by, int bx, int step_v0, int step_v, int step_h0, int step_h, int mvd_bits) |
static int | mv_bit_cost (Macroblock *currMB, short ***all_mv, int cur_list, short cur_ref, int by, int bx, int step_v0, int step_v, int step_h0, int step_h, int mvd_bits) |
int | BPredPartitionCost (Macroblock *currMB, int blocktype, int block8x8, short ref_l0, short ref_l1, int lambda_factor, int list) |
void | update_mv_block (Macroblock *currMB, MEBlock *mv_block, int h, int v) |
void | init_mv_block (Macroblock *currMB, MEBlock *mv_block, short blocktype, int list, char ref_idx, short mb_x, short mb_y) |
void | free_mv_block (InputParameters *p_Inp, MEBlock *mv_block) |
void | get_original_block (ImageParameters *p_Img, InputParameters *p_Inp, MEBlock *mv_block) |
int | BlockMotionSearch (Macroblock *currMB, MEBlock *mv_block, int mb_x, int mb_y, int *lambda_factor) |
int | BIDPartitionCost (Macroblock *currMB, int blocktype, int block8x8, char cur_ref[2], int lambda_factor) |
void | FindSkipModeMotionVector (Macroblock *currMB) |
int | GetDirectCost8x8 (Macroblock *currMB, int block, int *cost8x8) |
int | GetDirectCostMB (Macroblock *currMB) |
void | PartitionMotionSearch (Macroblock *currMB, int blocktype, int block8x8, int *lambda_factor) |
void | SubPartitionMotionSearch (Macroblock *currMB, int blocktype, int block8x8, int *lambda_factor) |
void | Get_Direct_MV_Temporal (Macroblock *currMB) |
void | Get_Direct_MV_Spatial_Normal (Macroblock *currMB) |
void | Get_Direct_MV_Spatial_MBAFF (Macroblock *currMB) |
Variables | |
static const short | bx0 [5][4] = {{0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,2,0,0}, {0,2,0,2}} |
static const short | by0 [5][4] = {{0,0,0,0}, {0,0,0,0}, {0,2,0,0}, {0,0,0,0}, {0,0,2,2}} |
Definition in file mv_search.c.
int BIDPartitionCost | ( | Macroblock * | currMB, | |
int | blocktype, | |||
int | block8x8, | |||
char | cur_ref[2], | |||
int | lambda_factor | |||
) |
Motion Cost for Bidirectional modes.
Definition at line 1138 of file mv_search.c.
References slice::all_mv, luma_prediction(), slice::mb_pred, macroblock::opix_y, macroblock::p_Img, macroblock::p_slice, img_par::pCurImg, and macroblock::pix_x.
Referenced by list_prediction_cost().
static int BiPredBlockMotionSearch | ( | Macroblock * | currMB, | |
MEBlock * | mv_block, | |||
MotionVector * | pred_mv, | |||
int | mb_x, | |||
int | mb_y, | |||
int * | lambda_factor | |||
) | [static] |
Bi-predictive motion search.
currMB | Current Macroblock | |
mv_block | motion vector information | |
pred_mv | current list motion vector predictor | |
mb_x | x-coordinate inside macroblock | |
mb_y | y-coordinate inside macroblock | |
lambda_factor | lagrangian parameter for determining motion cost |
Definition at line 1009 of file mv_search.c.
References slice::bipred_mv, inp_par_enc::BiPredMERefinements, inp_par_enc::BiPredMESearchRange, inp_par_enc::BiPredMESubPel, clip_mv_range(), inp_par_enc::DisableSubpelME, F_PEL, storable_picture::motion, pic_motion_params::mv, macroblock::p_Img, macroblock::p_slice, PrepareBiPredMEParams(), Q_PEL, pic_motion_params::ref_idx, and UMHEXSetMotionVectorPredictor().
Referenced by BlockMotionSearch().
int BlockMotionSearch | ( | Macroblock * | currMB, | |
MEBlock * | mv_block, | |||
int | mb_x, | |||
int | mb_y, | |||
int * | lambda_factor | |||
) |
Block motion search.
< minimum motion cost after search
currMB | Current Macroblock | |
mv_block | Motion estimation information block | |
mb_x | x-coordinate inside macroblock | |
mb_y | y-coordinate inside macroblock | |
lambda_factor | lagrangian parameter for determining motion cost |
Definition at line 835 of file mv_search.c.
References slice::all_mv, BiPredBlockMotionSearch(), clip_mv_range(), inp_par_enc::DisableSubpelME, F_PEL, FindSkipModeMotionVector(), get_neighbors(), GetSkipCostMB(), is_bipred_enabled(), storable_picture::motion, pic_motion_params::mv, macroblock::p_Img, macroblock::p_slice, macroblock::pix_x, PrepareMEParams(), Q_PEL, pic_motion_params::ref_idx, slice::slice_type, smpUMHEX_setup(), img_par::start_me_refinement_hp, and UMHEXSetMotionVectorPredictor().
Referenced by PartitionMotionSearch(), and SubPartitionMotionSearch().
int BPredPartitionCost | ( | Macroblock * | currMB, | |
int | blocktype, | |||
int | block8x8, | |||
short | ref_l0, | |||
short | ref_l1, | |||
int | lambda_factor, | |||
int | list | |||
) |
Motion Cost for Bidirectional modes.
Definition at line 581 of file mv_search.c.
References slice::bipred_mv, luma_prediction_bi(), slice::mb_pred, macroblock::opix_y, macroblock::p_Img, macroblock::p_slice, img_par::pCurImg, and macroblock::pix_x.
Referenced by list_prediction_cost().
void Clear_Motion_Search_Module | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp | |||
) |
Free memory used by motion search.
Definition at line 503 of file mv_search.c.
References ClearFastFullIntegerSearch(), free_mem4Dint(), inp_par_enc::IntraProfile, and inp_par_enc::search_range.
Referenced by free_encoder_memory().
void FindSkipModeMotionVector | ( | Macroblock * | currMB | ) |
Find motion vector for the Skip mode.
Definition at line 1307 of file mv_search.c.
References slice::all_mv, get_neighbors(), img_par::mb_data, storable_picture::motion, pic_motion_params::mv, macroblock::p_Img, macroblock::p_slice, and pic_motion_params::ref_idx.
Referenced by BlockMotionSearch(), encode_one_macroblock_high(), encode_one_macroblock_highfast(), encode_one_macroblock_highloss(), and encode_one_macroblock_low().
void free_mv_block | ( | InputParameters * | p_Inp, | |
MEBlock * | mv_block | |||
) |
free motion vector block
Definition at line 777 of file mv_search.c.
References free_mem1Dpel().
Referenced by PartitionMotionSearch(), and SubPartitionMotionSearch().
void Get_Direct_MV_Spatial_MBAFF | ( | Macroblock * | currMB | ) |
Calculate Spatial Direct Mode Motion Vectors.
Definition at line 2072 of file mv_search.c.
References slice::all_mv, macroblock::block_x, macroblock::block_y, slice::direct_pdir, slice::direct_ref_idx, get_neighbors(), img_par::mb_data, macroblock::mbAddrX, storable_picture::motion, pic_motion_params::mv, macroblock::opix_y, out_of_bounds_mvs(), macroblock::p_Img, macroblock::p_slice, macroblock::pix_x, pic_motion_params::ref_idx, slice::wbp_weight, and YUV400.
Referenced by init_slice().
void Get_Direct_MV_Spatial_Normal | ( | Macroblock * | currMB | ) |
Calculate Spatial Direct Mode Motion Vectors.
Definition at line 1917 of file mv_search.c.
References slice::all_mv, macroblock::block_x, macroblock::block_y, slice::direct_pdir, slice::direct_ref_idx, get_neighbors(), macroblock::mbAddrX, storable_picture::motion, pic_motion_params::mv, macroblock::opix_y, macroblock::p_Img, macroblock::p_slice, macroblock::pix_x, pic_motion_params::ref_idx, slice::wbp_weight, and YUV400.
Referenced by init_slice().
void Get_Direct_MV_Temporal | ( | Macroblock * | currMB | ) |
Calculate Temporal Direct Mode Motion Vectors.
invalid index. Default to zero even though this case should not happen
Definition at line 1775 of file mv_search.c.
References slice::all_mv, macroblock::block_x, macroblock::block_y, slice::direct_pdir, slice::direct_ref_idx, macroblock::mbAddrX, motion_params::mv, macroblock::opix_y, out_of_bounds_mvs(), macroblock::p_Img, macroblock::p_slice, macroblock::pix_x, motion_params::ref_idx, motion_params::ref_pic_id, slice::wbp_weight, and YUV400.
Referenced by init_slice().
void get_neighbors | ( | Macroblock * | currMB, | |
PixelPos * | block, | |||
int | mb_x, | |||
int | mb_y, | |||
int | blockshape_x | |||
) |
Get current block spatial neighbors.
Definition at line 280 of file mv_search.c.
References get4x4Neighbour(), and macroblock::p_Img.
Referenced by BlockMotionSearch(), FindSkipModeMotionVector(), Get_Direct_MV_Spatial_MBAFF(), Get_Direct_MV_Spatial_Normal(), SetupFastFullPelSearch(), and writeMotionVector8x8().
void get_search_range | ( | MEBlock * | mv_block, | |
InputParameters * | p_Inp, | |||
short | ref, | |||
int | blocktype | |||
) |
Set search range. This needs to be changed to provide 2D support.
Definition at line 68 of file mv_search.c.
Referenced by PartitionMotionSearch(), and SubPartitionMotionSearch().
int GetDirectCost8x8 | ( | Macroblock * | currMB, | |
int | block, | |||
int * | cost8x8 | |||
) |
Get cost for direct mode for an 8x8 block.
Definition at line 1389 of file mv_search.c.
References slice::direct_pdir, slice::direct_ref_idx, luma_prediction(), slice::mb_pred, macroblock::opix_y, macroblock::p_Img, macroblock::p_slice, img_par::pCurImg, and macroblock::pix_x.
Referenced by GetDirectCostMB(), and submacroblock_mode_decision_low().
int GetDirectCostMB | ( | Macroblock * | currMB | ) |
Get cost for direct mode for an macroblock.
Definition at line 1458 of file mv_search.c.
References GetDirectCost8x8(), macroblock::p_slice, and slice::slice_type.
Referenced by encode_one_macroblock_low().
static int GetSkipCostMB | ( | Macroblock * | currMB | ) | [static] |
Get cost for skip mode for an macroblock.
Definition at line 1245 of file mv_search.c.
References luma_prediction(), slice::mb_pred, macroblock::opix_y, macroblock::p_Img, macroblock::p_slice, img_par::pCurImg, and macroblock::pix_x.
Referenced by BlockMotionSearch().
void init_ME_engine | ( | Macroblock * | currMB | ) |
Initialize ME engine.
Definition at line 140 of file mv_search.c.
References EPZSBiPredBlockMotionSearch(), EPZSIntBiPredBlockMotionSearch(), EPZSIntPelBlockMotionSearch(), EPZSPelBlockMotionSearch(), EPZSSubPelBlockMotionSearch(), EPZSSubPelBlockSearchBiPred(), FastFullPelBlockMotionSearch(), FullPelBlockMotionBiPred(), FullPelBlockMotionSearch(), smpUMHEXBipredIntegerPelBlockMotionSearch(), smpUMHEXIntegerPelBlockMotionSearch(), SubPelBlockMotionSearch(), SubPelBlockSearchBiPred(), UMHEXBipredIntegerPelBlockMotionSearch(), and UMHEXIntegerPelBlockMotionSearch().
Referenced by start_macroblock().
void Init_Motion_Search_Module | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp | |||
) |
Initialize the motion search.
Definition at line 327 of file mv_search.c.
References computeBiPredSAD1(), computeBiPredSAD2(), computeBiPredSATD1(), computeBiPredSATD2(), computeBiPredSSE1(), computeBiPredSSE2(), computeSAD(), computeSADWP(), computeSATD(), computeSATDWP(), computeSSE(), computeSSEWP(), F_PEL, get_mem4Dint(), H_PEL, InitializeFastFullIntegerSearch(), inp_par_enc::IntraProfile, img_par::max_num_references, img_par::max_pel_value_comp, no_mem_exit(), Q_PEL, inp_par_enc::search_range, img_par::start_me_refinement_hp, and img_par::start_me_refinement_qp.
Referenced by init_encoder().
void init_mv_block | ( | Macroblock * | currMB, | |
MEBlock * | mv_block, | |||
short | blocktype, | |||
int | list, | |||
char | ref_idx, | |||
short | mb_x, | |||
short | mb_y | |||
) |
Init motion vector block.
Definition at line 706 of file mv_search.c.
References F_PEL, get_mem1Dpel(), H_PEL, no_mem_exit(), macroblock::p_Img, macroblock::p_slice, Q_PEL, slice::slice_type, inp_par_enc::UseWeightedReferenceME, and slice::weighted_prediction.
Referenced by PartitionMotionSearch(), and SubPartitionMotionSearch().
void PartitionMotionSearch | ( | Macroblock * | currMB, | |
int | blocktype, | |||
int | block8x8, | |||
int * | lambda_factor | |||
) |
Motion search for a macroblock partition.
Definition at line 1502 of file mv_search.c.
References slice::all_mv, macroblock::block_x, macroblock::block_y, BlockMotionSearch(), EPZSIntPelBlockMotionSearch(), EPZSPelBlockMotionSearch(), free_mv_block(), get_search_range(), init_mv_block(), storable_picture::motion, pic_motion_params::mv, macroblock::p_Img, macroblock::p_slice, pic_motion_params::ref_idx, set_me_parameters(), and slice::slice_type.
Referenced by encode_one_macroblock_high(), encode_one_macroblock_highfast(), encode_one_macroblock_highloss(), and encode_one_macroblock_low().
void PrepareBiPredMEParams | ( | Slice * | currSlice, | |
MEBlock * | mv_block, | |||
int | ChromaMEEnable, | |||
int | list, | |||
int | list_offset, | |||
int | ref | |||
) |
Prepare Motion Estimation parameters for bipred list ME.
Definition at line 218 of file mv_search.c.
References slice::wbp_weight, and slice::wp_offset.
Referenced by BiPredBlockMotionSearch().
void PrepareMEParams | ( | Slice * | currSlice, | |
MEBlock * | mv_block, | |||
int | ChromaMEEnable, | |||
int | list, | |||
int | ref | |||
) |
Prepare Motion Estimation parameters for single list ME.
Definition at line 195 of file mv_search.c.
References slice::wp_offset, and slice::wp_weight.
Referenced by BlockMotionSearch().
void set_access_method | ( | int * | access_method, | |
MotionVector * | blk, | |||
int | min_x, | |||
int | min_y, | |||
int | max_x, | |||
int | max_y | |||
) |
Set ME access method.
Definition at line 122 of file mv_search.c.
References FAST_ACCESS, and UMV_ACCESS.
static void set_me_parameters | ( | char ** | ref_array, | |
short *** | mv_array, | |||
short * | all_mv, | |||
short | ref, | |||
int | step_h, | |||
int | step_v, | |||
int | pic_block_x | |||
) | [inline, static] |
Set search range. This needs to be changed to provide 2D support.
Definition at line 96 of file mv_search.c.
Referenced by PartitionMotionSearch(), and SubPartitionMotionSearch().
void SubPartitionMotionSearch | ( | Macroblock * | currMB, | |
int | blocktype, | |||
int | block8x8, | |||
int * | lambda_factor | |||
) |
Motion search for a submacroblock partition.
Definition at line 1613 of file mv_search.c.
References slice::all_mv, macroblock::block_x, macroblock::block_y, BlockMotionSearch(), EPZSIntPelBlockMotionSearch(), EPZSIntPelBlockMotionSearchSubMB(), EPZSPelBlockMotionSearch(), EPZSPelBlockMotionSearchSubMB(), free_mv_block(), get_search_range(), init_mv_block(), storable_picture::motion, pic_motion_params::mv, macroblock::p_slice, pic_motion_params::ref_idx, set_me_parameters(), and slice::slice_type.
Referenced by submacroblock_mode_decision(), and submacroblock_mode_decision_low().