00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _ME_UMHEX_H_
00024 #define _ME_UMHEX_H_
00025
00026 #include "mbuffer.h"
00027
00028 struct umhex_struct {
00029 float AlphaFourth_1[8];
00030 float AlphaFourth_2[8];
00031
00032 int pred_MV_ref_flag;
00033 int BlockType_LUT[4][4];
00034 int Median_Pred_Thd_MB[8];
00035 int Big_Hexagon_Thd_MB[8];
00036 int Multi_Ref_Thd_MB[8];
00037
00038 byte **McostState;
00039 byte **SearchState;
00040
00041 int ****fastme_ref_cost;
00042 int ***fastme_l0_cost;
00043 int ***fastme_l1_cost;
00044 int ***fastme_l0_cost_bipred;
00045 int ***fastme_l1_cost_bipred;
00046 int bipred_flag;
00047 int **fastme_best_cost;
00048 int pred_SAD;
00049 int pred_MV_ref[2], pred_MV_uplayer[2];
00050
00051 int UMHEX_blocktype;
00052 int predict_point[5][2];
00053 int SAD_a,SAD_b,SAD_c,SAD_d;
00054 int Threshold_DSR_MB[8];
00055
00056 float Bsize[8];
00057
00058 byte *flag_intra;
00059 int flag_intra_SAD;
00060 };
00061
00062 typedef struct umhex_struct UMHexStruct;
00063
00064 #define EARLY_TERMINATION \
00065 if ((min_mcost - p_UMHex->pred_SAD)<p_UMHex->pred_SAD * betaFourth_2) \
00066 goto fourth_2_step; \
00067 else if((min_mcost - p_UMHex->pred_SAD) < p_UMHex->pred_SAD * betaFourth_1) \
00068 goto fourth_1_step;
00069
00070 #define SEARCH_ONE_PIXEL \
00071 if((iabs(cand.mv_x - center.mv_x)>>2) < search_range && (iabs(cand.mv_y - center.mv_y)>>2)< search_range)\
00072 { \
00073 if(!p_UMHex->McostState[((cand.mv_y - center.mv_y) >> 2)+ search_range][((cand.mv_x-center.mv_x)>>2)+search_range]) \
00074 { \
00075 mcost = mv_cost (p_Img, lambda_factor, &cand, &pred); \
00076 if(mcost<min_mcost) \
00077 { \
00078 mcost += mv_block->computePredFPel(ref_picture, mv_block, \
00079 min_mcost - mcost, &cand); \
00080 p_UMHex->McostState[((cand.mv_y - center.mv_y) >> 2) + search_range][((cand.mv_x - center.mv_x) >> 2) + search_range] = 1; \
00081 if (mcost < min_mcost) \
00082 { \
00083 best = cand; \
00084 min_mcost = mcost; \
00085 } \
00086 } \
00087 } \
00088 }
00089
00090 #define SEARCH_ONE_PIXEL_BIPRED \
00091 if((iabs(cand.mv_x - center2.mv_x) >> 2) < search_range && (iabs(cand.mv_y - center2.mv_y) >> 2) < search_range) \
00092 { \
00093 if(!p_UMHex->McostState[((cand.mv_y - center2.mv_y) >> 2) + search_range][((cand.mv_x-center2.mv_x) >> 2)+search_range]) \
00094 { \
00095 mcost = mv_cost (p_Img, lambda_factor, ¢er1, &pred1); \
00096 mcost += mv_cost (p_Img, lambda_factor, &cand, &pred2); \
00097 if(mcost<min_mcost) \
00098 { \
00099 mcost += mv_block->computeBiPredFPel(ref_picture1, ref_picture2, \
00100 mv_block, min_mcost - mcost, ¢er1, &cand); \
00101 p_UMHex->McostState[((cand.mv_y - center2.mv_y) >> 2) + search_range][((cand.mv_x - center2.mv_x) >> 2) + search_range] = 1; \
00102 if (mcost < min_mcost) \
00103 { \
00104 best = cand; \
00105 min_mcost = mcost; \
00106 } \
00107 } \
00108 } \
00109 } \
00110
00111
00112 extern void UMHEX_DefineThreshold (ImageParameters *p_Img);
00113 extern void UMHEX_DefineThresholdMB(ImageParameters *p_Img, InputParameters *p_Inp);
00114 extern int UMHEX_get_mem (ImageParameters *p_Img, InputParameters *p_Inp);
00115 extern void UMHEX_free_mem (ImageParameters *p_Img, InputParameters *p_Inp);
00116
00117 extern void UMHEX_decide_intrabk_SAD(Macroblock *currMB);
00118 extern void UMHEX_skip_intrabk_SAD (Macroblock *currMB, int ref_max);
00119 extern void UMHEX_setup (Macroblock *currMB, short ref, int list, int block_y, int block_x, int blocktype, short ******all_mv);
00120
00121 extern int
00122 UMHEXIntegerPelBlockMotionSearch (Macroblock *currMB,
00123 MotionVector *pred,
00124 MEBlock *mv_block,
00125 int min_mcost,
00126 int lambda_factor
00127 );
00128
00129 extern int UMHEXSubPelBlockMotionSearch (
00130 Macroblock *currMB,
00131 MotionVector *pred_mv,
00132 MEBlock *mv_block,
00133 int min_mcost,
00134 int lambda_factor
00135 );
00136
00137 extern int UMHEXSubPelBlockME (
00138 Macroblock *currMB,
00139 MotionVector *pred,
00140 MEBlock *mv_block,
00141 int min_mcost,
00142 int* lambda
00143 );
00144
00145
00146
00147 extern int UMHEXBipredIntegerPelBlockMotionSearch (Macroblock *, int,
00148 MotionVector *, MotionVector *, MotionVector *, MotionVector *,
00149 MEBlock *, int, int, int);
00150
00151 extern void UMHEXSetMotionVectorPredictor (Macroblock *currMB, short pmv[2], char **refPic, short ***tmp_mv,
00152 short ref_frame, int list, int mb_x, int mb_y, int bl_x, int bl_y, MEBlock *mv_block);
00153
00154 #endif