1 2 /*! 3 ************************************************************************ 4 * 5 * \file me_umhex.h 6 * 7 * \brief 8 * Macro definitions and global variables for UMHEX fast 9 * integer pel motion estimation and fractional pel motion estimation 10 * 11 * \author 12 * Main contributors: (see contributors.h for copyright, address and affiliation details) 13 * - Zhibo Chen <chenzhibo@tsinghua.org.cn> 14 * - JianFeng Xu <fenax@video.mdc.tsinghua.edu.cn> 15 * - Wenfang Fu <fwf@video.mdc.tsinghua.edu.cn> 16 * - Xiaozhong Xu <xxz@video.mdc.tsinghua.edu.cn> 17 * 18 * \date 19 * 2006.1 20 ************************************************************************ 21 */ 22 23 #ifndef _ME_UMHEX_H_ 24 #define _ME_UMHEX_H_ 25 26 #include "mbuffer.h" 27 28 struct umhex_struct { 29 float AlphaFourth_1[8]; 30 float AlphaFourth_2[8]; 31 // for bipred mode 32 int pred_MV_ref_flag; 33 int BlockType_LUT[4][4]; 34 distblk Median_Pred_Thd_MB[8]; 35 distblk Big_Hexagon_Thd_MB[8]; 36 distblk Multi_Ref_Thd_MB[8]; 37 distblk Threshold_DSR_MB[8]; //!< Threshold for usage of DSR. DSR refer to JVT-Q088 38 byte **McostState; //!< state for integer pel search 39 byte **SearchState; //!< state for fractional pel search 40 distblk ****fastme_ref_cost; //!< store SAD information needed for forward ref-frame prediction 41 distblk ***fastme_l0_cost; //!< store SAD information needed for forward median and uplayer prediction 42 distblk ***fastme_l1_cost; //!< store SAD information needed for backward median and uplayer prediction 43 distblk **fastme_best_cost; //!< for multi ref early termination threshold 44 distblk ***fastme_l0_cost_bipred; //!< store SAD information for bipred mode 45 distblk ***fastme_l1_cost_bipred; //!< store SAD information for bipred mode 46 distblk pred_SAD; //!< SAD prediction in use. 47 distblk SAD_a,SAD_b,SAD_c,SAD_d; 48 int bipred_flag; //!< flag for bipred 49 int pred_MV_ref[2], pred_MV_uplayer[2]; //!< pred motion vector by space or temporal correlation,Median is provided 50 51 int UMHEX_blocktype; //!< blocktype for UMHEX SetMotionVectorPredictor 52 int predict_point[5][2]; 53 //for early termination 54 float Bsize[8]; 55 56 byte *flag_intra; 57 int flag_intra_SAD; 58 }; 59 60 typedef struct umhex_struct UMHexStruct; 61 62 #define EARLY_TERMINATION \ 63 if ((min_mcost - p_UMHex->pred_SAD)<p_UMHex->pred_SAD * betaFourth_2) \ 64 goto fourth_2_step; \ 65 else if((min_mcost - p_UMHex->pred_SAD) < p_UMHex->pred_SAD * betaFourth_1) \ 66 goto fourth_1_step; 67 68 #define SEARCH_ONE_PIXEL \ 69 if((iabs(cand.mv_x - center.mv_x)>>2) < search_range && (iabs(cand.mv_y - center.mv_y)>>2)< search_range)\ 70 { \ 71 if(!p_UMHex->McostState[((cand.mv_y - center.mv_y) >> 2)+ search_range][((cand.mv_x-center.mv_x)>>2)+search_range]) \ 72 { \ 73 mcost = mv_cost (p_Vid, lambda_factor, &cand, &pred); \ 74 if(mcost<min_mcost) \ 75 { \ 76 mcost += mv_block->computePredFPel(ref_picture, mv_block, \ 77 min_mcost - mcost, &cand); \ 78 p_UMHex->McostState[((cand.mv_y - center.mv_y) >> 2) + search_range][((cand.mv_x - center.mv_x) >> 2) + search_range] = 1; \ 79 if (mcost < min_mcost) \ 80 { \ 81 best = cand; \ 82 min_mcost = mcost; \ 83 } \ 84 } \ 85 } \ 86 } 87 88 #define SEARCH_ONE_PIXEL_BIPRED \ 89 if((iabs(cand.mv_x - center2.mv_x) >> 2) < search_range && (iabs(cand.mv_y - center2.mv_y) >> 2) < search_range) \ 90 { \ 91 if(!p_UMHex->McostState[((cand.mv_y - center2.mv_y) >> 2) + search_range][((cand.mv_x-center2.mv_x) >> 2)+search_range]) \ 92 { \ 93 mcost = mv_cost (p_Vid, lambda_factor, ¢er1, &pred1); \ 94 mcost += mv_cost (p_Vid, lambda_factor, &cand, &pred2); \ 95 if(mcost<min_mcost) \ 96 { \ 97 mcost += mv_block->computeBiPredFPel(ref_picture1, ref_picture2, \ 98 mv_block, min_mcost - mcost, ¢er1, &cand); \ 99 p_UMHex->McostState[((cand.mv_y - center2.mv_y) >> 2) + search_range][((cand.mv_x - center2.mv_x) >> 2) + search_range] = 1; \ 100 if (mcost < min_mcost) \ 101 { \ 102 best = cand; \ 103 min_mcost = mcost; \ 104 } \ 105 } \ 106 } \ 107 } \ 108 109 110 extern void UMHEX_DefineThreshold (VideoParameters *p_Vid); 111 extern void UMHEX_DefineThresholdMB(VideoParameters *p_Vid, InputParameters *p_Inp); 112 extern int UMHEX_get_mem (VideoParameters *p_Vid, InputParameters *p_Inp); 113 extern void UMHEX_free_mem (VideoParameters *p_Vid, InputParameters *p_Inp); 114 115 extern void UMHEX_decide_intrabk_SAD(Macroblock *currMB); 116 extern void UMHEX_skip_intrabk_SAD (Macroblock *currMB, int ref_max); 117 extern void UMHEX_setup (Macroblock *currMB, short ref, int list, int block_y, int block_x, int blocktype, MotionVector *****all_mv); 118 119 extern distblk // ==> minimum motion cost after search 120 UMHEXIntegerPelBlockMotionSearch (Macroblock *currMB, // <-- current Macroblock 121 MotionVector *pred, // <-- motion vector predictor (x) in sub-pel units 122 MEBlock *mv_block, 123 distblk min_mcost, // <-- minimum motion cost (cost for center or huge value) 124 int lambda_factor // <-- lagrangian parameter for determining motion cost 125 ); 126 extern distblk UMHEXSubPelBlockME ( // ==> minimum motion cost after search 127 Macroblock *currMB, // <-- Current Macroblock 128 MotionVector *pred, // <-- motion vector predictor (x) in sub-pel units 129 MEBlock *mv_block, 130 distblk min_mcost, // <-- minimum motion cost (cost for center or huge value) 131 int* lambda // <-- lagrangian parameter for determining motion cost 132 ); 133 extern distblk UMHEXSubPelBlockMotionSearch ( // ==> minimum motion cost after search 134 Macroblock *currMB, // <-- current Macroblock 135 MotionVector *pred_mv, // < <-- motion vector predictor (x|y) in sub-pel units 136 MEBlock *mv_block, 137 distblk min_mcost, // <-- minimum motion cost (cost for center or huge value) 138 int lambda_factor // <-- lagrangian parameter for determining motion cost 139 ); 140 extern distblk UMHEXBipredIntegerPelBlockMotionSearch (Macroblock *, int, 141 MotionVector *, MotionVector *, MotionVector *, MotionVector *, 142 MEBlock *, int, distblk, int); 143 144 extern void UMHEXSetMotionVectorPredictor (Macroblock *currMB, MotionVector *pmv, struct pic_motion_params **mv_info, 145 short ref_frame, int list, int mb_x, int mb_y, int bl_x, int bl_y, MEBlock *mv_block); 146 147 #endif 148