00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef _MV_SEARCH_H_
00017 #define _MV_SEARCH_H_
00018
00019
00020 extern void get_neighbors(Macroblock *currMB, PixelPos *block, int mb_x, int mb_y, int blockshape_x);
00021 extern void set_access_method(int *access_method, MotionVector *blk, int min_x, int min_y, int max_x, int max_y);
00022
00023 extern void PrepareMEParams (Slice *currSlice, MEBlock *mv_block, int ChromaMEEnable, int list, int ref);
00024 extern void PrepareBiPredMEParams(Slice *currSlice, MEBlock *mv_block, int ChromaMEEnable, int list, int list_offset, int ref);
00025
00026 extern void Init_Motion_Search_Module (ImageParameters *p_Img, InputParameters *p_Inp);
00027 extern void Clear_Motion_Search_Module (ImageParameters *p_Img, InputParameters *p_Inp);
00028
00029 extern void PartitionMotionSearch (Macroblock *currMB, int, int, int*);
00030 extern void SubPartitionMotionSearch (Macroblock *currMB, int, int, int*);
00031
00032 extern void Get_Direct_MV_Spatial_MBAFF (Macroblock *currMB);
00033 extern void Get_Direct_MV_Spatial_Normal (Macroblock *currMB);
00034 extern void Get_Direct_MV_Temporal (Macroblock *currMB);
00035
00036 extern void FindSkipModeMotionVector (Macroblock *currMB);
00037
00038 extern void init_ME_engine (Macroblock *currMB);
00039 extern int BlockMotionSearch (Macroblock *currMB, MEBlock *mv_block, int,int, int*);
00040 extern void init_mv_block (Macroblock *currMB, MEBlock *mv_block, short blocktype, int list, char ref_idx, short mb_x, short mb_y);
00041 extern void get_original_block(ImageParameters *p_Img, InputParameters *p_Inp, MEBlock *mv_block);
00042 extern void free_mv_block (InputParameters *p_Inp, MEBlock *mv_block);
00043 extern void update_mv_block (Macroblock *currMB, MEBlock *mv_block, int h, int v);
00044 extern void get_search_range(MEBlock *mv_block, InputParameters *p_Inp, short ref, int blocktype);
00045
00046 static inline void add_mvs(MotionVector *mv0, const MotionVector *mv1)
00047 {
00048 mv0->mv_x = (short) (mv0->mv_x + mv1->mv_x);
00049 mv0->mv_y = (short) (mv0->mv_y + mv1->mv_y);
00050 }
00051
00052 static inline MotionVector add_MVs(MotionVector mv0, const MotionVector *mv1)
00053 {
00054 mv0.mv_x = (short) (mv0.mv_x + mv1->mv_x);
00055 mv0.mv_y = (short) (mv0.mv_y + mv1->mv_y);
00056
00057 return (mv0);
00058 }
00059
00060 static inline MotionVector pad_MVs(MotionVector mv0, MEBlock *mv_block)
00061 {
00062 mv0.mv_x = (short) (mv0.mv_x + mv_block->pos_x_padded);
00063 mv0.mv_y = (short) (mv0.mv_y + mv_block->pos_y_padded);
00064
00065 return (mv0);
00066 }
00067
00068 static inline int weight_cost(int lambda, int bits)
00069 {
00070 #if (USE_RND_COST)
00071 return (rshift_rnd_sf((lambda) * (bits), LAMBDA_ACCURACY_BITS));
00072 #else
00073 return (((lambda) * (bits)) >> LAMBDA_ACCURACY_BITS);
00074 #endif
00075 }
00076
00077 static inline int mv_cost(const ImageParameters *p_Img, int lambda, const MotionVector *mv, const MotionVector *pmv)
00078 {
00079 #if (USE_RND_COST)
00080 return (rshift_rnd_sf((lambda *(p_Img->mvbits[mv->mv_x - pmv->mv_x] + p_Img->mvbits[mv->mv_y - pmv->mv_y])), LAMBDA_ACCURACY_BITS));
00081 #else
00082 return ((lambda *(p_Img->mvbits[mv->mv_x - pmv->mv_x] + p_Img->mvbits[mv->mv_y - pmv->mv_y]))>> LAMBDA_ACCURACY_BITS);
00083 #endif
00084 }
00085
00086 static inline int ref_cost(const ImageParameters *p_Img, int lambda, short ref, int list_offset)
00087 {
00088 if (p_Img->listXsize[list_offset] <= 1)
00089 return 0;
00090 else
00091 {
00092 #if (USE_RND_COST)
00093 return (rshift_rnd_sf((lambda) * (p_Img->refbits[(ref)]), LAMBDA_ACCURACY_BITS));
00094 #else
00095 return ((lambda *(p_Img->refbits[(ref)]))>> LAMBDA_ACCURACY_BITS);
00096 #endif
00097 }
00098 }
00099
00100 #endif
00101