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 #define EARLY_TERMINATION \
00029 if ((min_mcost-pred_SAD)<pred_SAD*betaFourth_2) \
00030 goto fourth_2_step; \
00031 else if((min_mcost-pred_SAD)<pred_SAD*betaFourth_1) \
00032 goto fourth_1_step;
00033
00034 #define SEARCH_ONE_PIXEL \
00035 if(iabs(cand_x - center_x) <=search_range && iabs(cand_y - center_y)<= search_range)\
00036 { \
00037 if(!McostState[cand_y-center_y+search_range][cand_x-center_x+search_range]) \
00038 { \
00039 mcost = MV_COST (lambda_factor, mvshift, cand_x, cand_y, pred_x, pred_y); \
00040 if(mcost<min_mcost) \
00041 { \
00042 mcost += computeUniPred[dist_method](orig_pic, \
00043 blocksize_y,blocksize_x, min_mcost - mcost, \
00044 (cand_x << 2) + IMG_PAD_SIZE_TIMES4, (cand_y << 2) + IMG_PAD_SIZE_TIMES4); \
00045 McostState[cand_y-center_y+search_range][cand_x-center_x+search_range] = 1; \
00046 if (mcost < min_mcost) \
00047 { \
00048 best_x = cand_x; \
00049 best_y = cand_y; \
00050 min_mcost = mcost; \
00051 } \
00052 } \
00053 } \
00054 }
00055
00056 #define SEARCH_ONE_PIXEL_BIPRED \
00057 if(iabs(cand_x - center2_x) <=search_range && iabs(cand_y - center2_y)<= search_range)\
00058 { \
00059 if(!McostState[cand_y-center2_y+search_range][cand_x-center2_x+search_range]) \
00060 { \
00061 mcost = MV_COST (lambda_factor, mvshift, center1_x, center1_y, pred_x1, pred_y1);\
00062 mcost += MV_COST (lambda_factor, mvshift, cand_x, cand_y, pred_x2, pred_y2); \
00063 if(mcost<min_mcost) \
00064 { \
00065 mcost += computeBiPred(cur_pic, blocksize_y, blocksize_x, \
00066 min_mcost - mcost, \
00067 (center1_x << 2) + IMG_PAD_SIZE_TIMES4, \
00068 (center1_y << 2) + IMG_PAD_SIZE_TIMES4, \
00069 (cand_x << 2) + IMG_PAD_SIZE_TIMES4, \
00070 (cand_y << 2) + IMG_PAD_SIZE_TIMES4); \
00071 McostState[cand_y-center2_y+search_range][cand_x-center2_x+search_range] = 1; \
00072 if (mcost < min_mcost) \
00073 { \
00074 best_x = cand_x; \
00075 best_y = cand_y; \
00076 min_mcost = mcost; \
00077 } \
00078 } \
00079 } \
00080 }
00081
00082 byte **McostState;
00083 byte **SearchState;
00084
00085 int ****fastme_ref_cost;
00086 int ***fastme_l0_cost;
00087 int ***fastme_l1_cost;
00088 int ***fastme_l0_cost_bipred;
00089 int ***fastme_l1_cost_bipred;
00090 int bipred_flag;
00091 int **fastme_best_cost;
00092 int pred_SAD;
00093 int pred_MV_ref[2], pred_MV_uplayer[2];
00094
00095 int UMHEX_blocktype;
00096 int predict_point[5][2];
00097 int SAD_a,SAD_b,SAD_c,SAD_d;
00098 int Threshold_DSR_MB[8];
00099
00100 float Bsize[8];
00101 float AlphaFourth_1[8];
00102 float AlphaFourth_2[8];
00103 byte *flag_intra;
00104 int flag_intra_SAD;
00105
00106 void UMHEX_DefineThreshold(void);
00107 void UMHEX_DefineThresholdMB(void);
00108 int UMHEX_get_mem(void);
00109 void UMHEX_free_mem(void);
00110
00111 void UMHEX_decide_intrabk_SAD(void);
00112 void UMHEX_skip_intrabk_SAD(int best_mode, int ref_max);
00113 void UMHEX_setup(short ref, int list, int block_y, int block_x, int blocktype, short ******all_mv);
00114
00115 int
00116 UMHEXIntegerPelBlockMotionSearch (Macroblock *currMB,
00117 imgpel *orig_pic,
00118 short ref,
00119 int list,
00120 char ***refPic,
00121 short ****tmp_mv,
00122 int pic_pix_x,
00123 int pic_pix_y,
00124 int blocktype,
00125 MotionVector *pred,
00126 MotionVector *mv,
00127 int search_range,
00128 int min_mcost,
00129 int lambda_factor,
00130 int apply_weights
00131 );
00132
00133 int
00134 UMHEXSubPelBlockMotionSearch (
00135 imgpel* orig_pic,
00136 short ref,
00137 int list,
00138 int list_offset,
00139 int pic_pix_x,
00140 int pic_pix_y,
00141 int blocktype,
00142 MotionVector *pred,
00143 MotionVector *mv,
00144 int search_pos2,
00145 int search_pos4,
00146 int min_mcost,
00147 int lambda_factor,
00148 int apply_weights
00149 );
00150
00151 extern int UMHEXSubPelBlockME (
00152 imgpel* orig_pic,
00153 short ref,
00154 int list,
00155 int list_offset,
00156 int pic_pix_x,
00157 int pic_pix_y,
00158 int blocktype,
00159 MotionVector *pred,
00160 MotionVector *mv,
00161 int search_pos2,
00162 int search_pos4,
00163 int min_mcost,
00164 int* lambda,
00165 int apply_weights
00166 );
00167
00168
00169 extern int
00170 SubPelBlockMotionSearch (imgpel* orig_pic,
00171 short ref,
00172 int list,
00173 int list_offset,
00174 int pic_pix_x,
00175 int pic_pix_y,
00176 int blocktype,
00177 MotionVector *pred,
00178 MotionVector *mv,
00179 int search_pos2,
00180 int search_pos4,
00181 int min_mcost,
00182 int *lambda_factor,
00183 int apply_weights);
00184
00185 int
00186 UMHEXBipredIntegerPelBlockMotionSearch (Macroblock *currMB,
00187 imgpel* orig_pic,
00188 short ref,
00189 int list,
00190 char ***refPic,
00191 short ****tmp_mv,
00192 int pic_pix_x,
00193 int pic_pix_y,
00194 int blocktype,
00195 MotionVector *pred1,
00196 MotionVector *pred2,
00197 MotionVector *mv1,
00198 MotionVector *mv2,
00199 int search_range,
00200 int min_mcost,
00201 int iteration_no,
00202 int lambda_factor,
00203 int apply_weights
00204 );
00205
00206 void UMHEXSetMotionVectorPredictor (Macroblock *currMB, short pmv[2], char **refPic, short ***tmp_mv,
00207 short ref_frame, int list, int mb_x, int mb_y, int bl_x, int bl_y, int *search_range);
00208
00209 #endif