#include "contributors.h"
#include <math.h>
#include <limits.h>
#include <time.h>
#include <sys/timeb.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_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 | |
| int | BlockMotionSearch (Macroblock *currMB,short ref,int list,int mb_x,int mb_y,int blocktype,int search_range,int *lambda_factor) |
| int | BiPredBlockMotionSearch (Macroblock *currMB,MotionVector *mv,MotionVector *pred_mv,short ref,int list,int mb_x,int mb_y,int blocktype,int search_range,int apply_bi_weights,int *lambda_factor) |
| int | GetSkipCostMB (Macroblock *currMB) |
| 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 (int SearchMode) |
| void | PrepareMEParams (int apply_weights, int ChromaMEEnable, int list, int ref) |
| void | PrepareBiPredMEParams (int apply_weights, int ChromaMEEnable, int list, int list_offset, int ref) |
| void | get_neighbors (Macroblock *currMB, PixelPos *block_a, PixelPos *block_b, PixelPos *block_c, PixelPos *block_d, int mb_x, int mb_y, int blockshape_x) |
| void | GetMotionVectorPredictor (Macroblock *currMB, PixelPos *block_a, PixelPos *block_b, PixelPos *block_c, short pmv[2], char **refPic, short ***tmp_mv, short ref_frame, int mb_x, int mb_y, int blockshape_x, int blockshape_y) |
| void | Init_Motion_Search_Module (void) |
| void | Clear_Motion_Search_Module () |
| static int | mv_bits_cost (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, int 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) |
| 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, int bslice) |
| void | PartitionMotionSearch (Macroblock *currMB, int blocktype, int block8x8, int *lambda_factor) |
| void | Get_Direct_Motion_Vectors (Macroblock *currMB) |
Variables | |
| int | max_mvd |
| short * | spiral_search_x |
| short * | spiral_search_y |
| short * | spiral_hpel_search_x |
| short * | spiral_hpel_search_y |
| SearchWindow | searchrange |
| int * | mvbits |
| int * | refbits |
| int * | byte_abs |
| int **** | motion_cost |
| int | byte_abs_range |
| static int | diff [16] |
| static int | diff64 [64] |
| static imgpel | orig_pic [768] |
| int(* | IntPelME )(Macroblock *, imgpel *, short, int, char ***, short ****, int, int, int, MotionVector *, MotionVector *, int, int, int, int) |
| int(* | BiPredME )(Macroblock *, imgpel *, short, int, char ***, short ****, int, int, int, MotionVector *, MotionVector *, MotionVector *, MotionVector *, int, int, int, int, int) |
| int(* | SubPelBiPredME )(imgpel *orig_pic, short ref, int list, int pic_pix_x, int pic_pix_y, int blocktype, MotionVector *pred_mv1, MotionVector *pred_mv2, MotionVector *mv1, MotionVector *mv2, int search_pos2, int search_pos4, int min_mcost, int *lambda_factor, int apply_weights) |
| int(* | SubPelME )(imgpel *orig_pic, short ref, int list, int list_offset, int pic_pix_x, int pic_pix_y, int blocktype, MotionVector *pred_mv, MotionVector *mv, int search_pos2, int search_pos4, int min_mcost, int *lambda_factor, int apply_weights) |
| ColocatedParams * | Co_located |
| const short | block_type_shift_factor [8] |
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 1117 of file mv-search.c.
References ImageParameters::all_mv, InputParameters::blc_size, distortion4x4(), distortion8x8(), LumaPrediction(), ImageParameters::mb_pred, ImageParameters::opix_x, ImageParameters::opix_y, InputParameters::part_size, pCurImg, and InputParameters::Transform8x8Mode.
Referenced by list_prediction_cost().

| int BiPredBlockMotionSearch | ( | Macroblock * | currMB, | |
| MotionVector * | mv, | |||
| MotionVector * | pred_mv, | |||
| short | ref, | |||
| int | list, | |||
| int | mb_x, | |||
| int | mb_y, | |||
| int | blocktype, | |||
| int | search_range, | |||
| int | apply_bi_weights, | |||
| int * | lambda_factor | |||
| ) |
Bi-predictive motion search.
| currMB | Current Macroblock |
| mv | current list motion vector |
| pred_mv | current list motion vector predictor |
| ref | reference idx |
| list | reference picture list |
| mb_x | x-coordinate inside macroblock |
| mb_y | y-coordinate inside macroblock |
| blocktype | block type (1-16x16 ... 7-4x4) |
| search_range | 1-d search range for integer-position search |
| apply_bi_weights | apply bipred weights |
| lambda_factor | lagrangian parameter for determining motion cost |
Definition at line 977 of file mv-search.c.
References bipred_flag, ImageParameters::bipred_mv, InputParameters::BiPredMERefinements, InputParameters::BiPredMESearchRange, InputParameters::BiPredMESubPel, InputParameters::blc_size, clip_mv_range(), InputParameters::DisableSubpelME, InputParameters::EPZSGrid, InputParameters::EPZSSubPelGrid, F_PEL, get_neighbors(), GetMotionVectorPredictor(), macroblock::list_offset, storable_picture::motion, pic_motion_params::mv, ImageParameters::opix_x, ImageParameters::opix_y, PrepareBiPredMEParams(), Q_PEL, pic_motion_params::ref_idx, InputParameters::SearchMode, and UMHEXSetMotionVectorPredictor().
Referenced by BlockMotionSearch().

| int BlockMotionSearch | ( | Macroblock * | currMB, | |
| short | ref, | |||
| int | list, | |||
| int | mb_x, | |||
| int | mb_y, | |||
| int | blocktype, | |||
| int | search_range, | |||
| int * | lambda_factor | |||
| ) |
Block motion search.
< minimum motion cost after search
| currMB | Current Macroblock |
| ref | reference idx |
| list | reference picture list |
| mb_x | x-coordinate inside macroblock |
| mb_y | y-coordinate inside macroblock |
| blocktype | block type (1-16x16 ... 7-4x4) |
| search_range | 1-d search range for integer-position search |
| lambda_factor | lagrangian parameter for determining motion cost |
Definition at line 772 of file mv-search.c.
References ImageParameters::all_mv, bipred_flag, BiPredBlockMotionSearch(), InputParameters::blc_size, InputParameters::ChromaMEEnable, clip_mv_range(), InputParameters::DisableSubpelME, EPZSDistortion, InputParameters::EPZSGrid, InputParameters::EPZSSubPelGrid, F_PEL, FindSkipModeMotionVector(), get_neighbors(), GetMotionVectorPredictor(), GetSkipCostMB(), is_bipred_enabled(), macroblock::list_offset, storable_picture::motion, pic_motion_params::mv, ImageParameters::opix_x, ImageParameters::opix_y, pCurImg, PrepareMEParams(), Q_PEL, InputParameters::rdopt, pic_motion_params::ref_idx, InputParameters::SearchMode, smpUMHEX_setup(), ImageParameters::structure, ImageParameters::type, UMHEX_blocktype, UMHEXSetMotionVectorPredictor(), and InputParameters::UseWeightedReferenceME.
Referenced by PartitionMotionSearch().

| 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 689 of file mv-search.c.
References ImageParameters::bipred_mv, InputParameters::blc_size, distortion4x4(), distortion8x8(), LumaPredictionBi(), ImageParameters::mb_pred, ImageParameters::opix_x, ImageParameters::opix_y, InputParameters::part_size, pCurImg, and InputParameters::Transform8x8Mode.
Referenced by list_prediction_cost().

| void Clear_Motion_Search_Module | ( | void | ) |
Free memory used by motion search.
Definition at line 623 of file mv-search.c.
References ClearFastFullIntegerSearch(), free_mem4Dint(), InputParameters::IntraProfile, and InputParameters::SearchMode.
Referenced by free_encoder_memory().

| void FindSkipModeMotionVector | ( | Macroblock * | currMB | ) |
Find motion vector for the Skip mode.
Definition at line 1254 of file mv-search.c.
References ImageParameters::all_mv, pix_pos::available, get_neighbors(), GetMotionVectorPredictor(), pix_pos::mb_addr, ImageParameters::mb_data, macroblock::mb_field, storable_picture::motion, pic_motion_params::mv, pix_pos::pos_x, pix_pos::pos_y, 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 Get_Direct_Motion_Vectors | ( | Macroblock * | currMB | ) |
Calculate Direct Motion Vectors *****.
invalid index. Default to zero even though this case should not happen
Definition at line 1547 of file mv-search.c.
References ImageParameters::all_mv, pix_pos::available, colocated_params::bottom, ImageParameters::current_mb_nr, direct_pdir, direct_ref_idx, ImageParameters::direct_spatial_mv_pred_flag, colocated_params::frame, get_neighbors(), GetMotionVectorPredictor(), macroblock::list_offset, pix_pos::mb_addr, ImageParameters::mb_data, macroblock::mb_field, ImageParameters::MbaffFrameFlag, storable_picture::motion, motion_params::moving_block, motion_params::mv, pic_motion_params::mv, ImageParameters::mvscale, ImageParameters::num_ref_idx_l0_active, ImageParameters::opix_x, ImageParameters::opix_y, out_of_bounds_mvs(), ImageParameters::pix_x, ImageParameters::pix_y, pix_pos::pos_x, pix_pos::pos_y, motion_params::ref_idx, pic_motion_params::ref_idx, motion_params::ref_pic_id, storable_picture::ref_pic_num, colocated_params::top, and YUV400.
Referenced by encode_one_macroblock_high(), encode_one_macroblock_highfast(), encode_one_macroblock_highloss(), and encode_one_macroblock_low().

| void get_neighbors | ( | Macroblock * | currMB, | |
| PixelPos * | block_a, | |||
| PixelPos * | block_b, | |||
| PixelPos * | block_c, | |||
| PixelPos * | block_d, | |||
| int | mb_x, | |||
| int | mb_y, | |||
| int | blockshape_x | |||
| ) |
Get current block spatial neighbors.
Definition at line 247 of file mv-search.c.
References pix_pos::available, get4x4Neighbour(), and ImageParameters::mb_size.
Referenced by BiPredBlockMotionSearch(), BlockMotionSearch(), EPZSBiPredBlockMotionSearch(), EPZSPelBlockMotionSearch(), FindSkipModeMotionVector(), Get_Direct_Motion_Vectors(), and writeMotionVector8x8().

| int GetDirectCost8x8 | ( | Macroblock * | currMB, | |
| int | block, | |||
| int * | cost8x8 | |||
| ) |
Get cost for direct mode for an 8x8 block.
Definition at line 1333 of file mv-search.c.
References direct_pdir, direct_ref_idx, distortion4x4(), distortion8x8(), LumaPrediction(), ImageParameters::mb_pred, ImageParameters::opix_x, ImageParameters::opix_y, pCurImg, InputParameters::rdopt, and InputParameters::Transform8x8Mode.
Referenced by GetDirectCostMB(), and submacroblock_mode_decision_low().

| int GetDirectCostMB | ( | Macroblock * | currMB, | |
| int | bslice | |||
| ) |
Get cost for direct mode for an macroblock.
Definition at line 1396 of file mv-search.c.
References GetDirectCost8x8(), InputParameters::InterSearch, and InputParameters::Transform8x8Mode.
Referenced by encode_one_macroblock_low().

| void GetMotionVectorPredictor | ( | Macroblock * | currMB, | |
| PixelPos * | block_a, | |||
| PixelPos * | block_b, | |||
| PixelPos * | block_c, | |||
| short | pmv[2], | |||
| char ** | refPic, | |||
| short *** | tmp_mv, | |||
| short | ref_frame, | |||
| int | mb_x, | |||
| int | mb_y, | |||
| int | blockshape_x, | |||
| int | blockshape_y | |||
| ) |
Get motion vector predictor.
Definition at line 296 of file mv-search.c.
References pix_pos::available, pix_pos::mb_addr, ImageParameters::mb_data, macroblock::mb_field, ImageParameters::MbaffFrameFlag, pix_pos::pos_x, and pix_pos::pos_y.
Referenced by BiPredBlockMotionSearch(), BlockMotionSearch(), FindSkipModeMotionVector(), Get_Direct_Motion_Vectors(), and writeMotionVector8x8().
| int GetSkipCostMB | ( | Macroblock * | currMB | ) |
Get cost for skip mode for an macroblock.
Definition at line 1199 of file mv-search.c.
References distortion4x4(), distortion8x8(), LumaPrediction(), ImageParameters::mb_pred, ImageParameters::opix_x, ImageParameters::opix_y, pCurImg, InputParameters::rdopt, and InputParameters::Transform8x8Mode.
Referenced by BlockMotionSearch().

| void init_ME_engine | ( | int | SearchMode | ) |
Initialize ME engine.
Definition at line 118 of file mv-search.c.
References EPZSBiPredBlockMotionSearch(), EPZSPelBlockMotionSearch(), EPZSSubPelBlockMotionSearch(), EPZSSubPelBlockSearchBiPred(), InputParameters::EPZSSubPelME, InputParameters::EPZSSubPelMEBiPred, FastFullPelBlockMotionSearch(), FullPelBlockMotionBiPred(), FullPelBlockMotionSearch(), smpUMHEXBipredIntegerPelBlockMotionSearch(), smpUMHEXIntegerPelBlockMotionSearch(), SubPelBlockMotionSearch(), SubPelBlockSearchBiPred(), UMHEXBipredIntegerPelBlockMotionSearch(), and UMHEXIntegerPelBlockMotionSearch().
Referenced by Init_Motion_Search_Module().

| void Init_Motion_Search_Module | ( | void | ) |
Initialize the motion search.
Definition at line 469 of file mv-search.c.
References InputParameters::ChromaMEEnable, computeBiPredSAD1(), computeBiPredSAD2(), computeBiPredSATD1(), computeBiPredSATD2(), computeBiPredSSE1(), computeBiPredSSE2(), computeSAD(), computeSADWP(), computeSATD(), computeSATDWP(), computeSSE(), computeSSEWP(), F_PEL, get_mem4Dint(), H_PEL, init_ME_engine(), InitializeFastFullIntegerSearch(), InputParameters::IntraProfile, ImageParameters::max_imgpel_value_comp, ImageParameters::max_num_references, InputParameters::MEErrorMetric, no_mem_exit(), Q_PEL, InputParameters::search_range, and InputParameters::SearchMode.
Referenced by init_encoder().

| void PartitionMotionSearch | ( | Macroblock * | currMB, | |
| int | blocktype, | |||
| int | block8x8, | |||
| int * | lambda_factor | |||
| ) |
Motion search for a partition.
Definition at line 1438 of file mv-search.c.
References ImageParameters::all_mv, ImageParameters::block_x, ImageParameters::block_y, BlockMotionSearch(), InputParameters::full_search, macroblock::list_offset, macroblock::luma_transform_size_8x8_flag, storable_picture::motion, pic_motion_params::mv, InputParameters::part_size, InputParameters::RDOQ_CP_MV, pic_motion_params::ref_idx, InputParameters::search_range, InputParameters::Transform8x8Mode, and ImageParameters::type.
Referenced by encode_one_macroblock_high(), encode_one_macroblock_highfast(), encode_one_macroblock_highloss(), encode_one_macroblock_low(), submacroblock_mode_decision(), and submacroblock_mode_decision_low().

| void PrepareBiPredMEParams | ( | int | apply_weights, | |
| int | ChromaMEEnable, | |||
| int | list, | |||
| int | list_offset, | |||
| int | ref | |||
| ) |
Prepare Motion Estimation parameters for bipred list ME.
Definition at line 185 of file mv-search.c.
Referenced by BiPredBlockMotionSearch().
| void PrepareMEParams | ( | int | apply_weights, | |
| int | ChromaMEEnable, | |||
| int | list, | |||
| int | ref | |||
| ) |
Prepare Motion Estimation parameters for single list ME.
Definition at line 162 of file mv-search.c.
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 100 of file mv-search.c.
References FAST_ACCESS, and UMV_ACCESS.