00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef _ME_EPZS_COMMON_H_
00020 #define _ME_EPZS_COMMON_H_
00021
00022
00023
00024 typedef struct
00025 {
00026 int mb_adaptive_frame_field_flag;
00027 int size_x, size_y;
00028
00029
00030 MotionVector ***frame;
00031
00032 MotionVector ***top;
00033
00034 MotionVector ***bot;
00035 } EPZSColocParams;
00036
00037 typedef struct
00038 {
00039 MotionVector motion;
00040 int start_nmbr;
00041 int next_points;
00042 }
00043 SPoint;
00044
00045 struct epzs_struct
00046 {
00047 int searchPoints;
00048 SPoint *point;
00049 int stopSearch;
00050 int nextLast;
00051 struct epzs_struct *nextpattern;
00052 };
00053
00054 typedef struct epzs_struct EPZSStructure;
00055
00056 typedef enum
00057 {
00058 SDIAMOND = 0,
00059 SQUARE = 1,
00060 EDIAMOND = 2,
00061 LDIAMOND = 3,
00062 SBDIAMOND = 4
00063 } EPZSPatterns;
00064
00065 struct epzs_params {
00066 ImageParameters *p_Img;
00067 uint16 BlkCount;
00068 int searcharray;
00069
00070 int medthres[8];
00071 int maxthres[8];
00072 int minthres[8];
00073 int subthres[8];
00074
00075 int mv_scale [6][MAX_REFERENCE_PICTURES][MAX_REFERENCE_PICTURES];
00076 int mv_scale_update[6][MAX_REFERENCE_PICTURES][MAX_REFERENCE_PICTURES];
00077
00078 uint16 **EPZSMap;
00079
00080 #if EPZSREF
00081 MotionVector *****p_motion;
00082 #else
00083 MotionVector ****p_motion;
00084 #endif
00085
00086 int ***distortion;
00087 int ***bi_distortion;
00088
00089 EPZSStructure *searchPattern;
00090 EPZSStructure *searchPatternD;
00091 EPZSStructure *predictor;
00092
00093 EPZSStructure *window_predictor;
00094 EPZSStructure *window_predictor_ext;
00095
00096 EPZSColocParams *p_colocated;
00097 };
00098
00099 typedef struct epzs_params EPZSParameters;
00100
00101
00102 extern void EPZSBlockTypePredictorsMB (Slice *currSlice, MEBlock *mv_block, SPoint *point, int *prednum);
00103 extern short EPZSSpatialPredictors (EPZSParameters *p_EPZS, PixelPos *block, int list, int list_offset, short ref, char **refPic, short ***tmp_mv);
00104 extern void EPZSTemporalPredictors (Macroblock *currMB, StorablePicture *ref_picture, EPZSParameters *p_EPZS, MEBlock *mv_block, int *prednum, int stopCriterion, int min_mcost);
00105 extern void EPZSBlockTypePredictors (Slice *currSlice, MEBlock *mv_block, SPoint *point, int *prednum);
00106 extern void EPZSWindowPredictors (MotionVector *mv, EPZSStructure *predictor, int *prednum, EPZSStructure *windowPred);
00107 extern void EPZSSpatialMemPredictors (EPZSParameters *p_EPZS, MEBlock *mv_block, int list, int *prednum, int img_width);
00108 extern int EPZSDetermineStopCriterion(EPZSParameters *p_EPZS, int* prevSad, MEBlock *mv_block ,int lambda_dist);
00109
00110 extern void EPZSDelete (ImageParameters *p_Img);
00111 extern void EPZSStructDelete (Slice *currSlice);
00112 extern void EPZSSliceInit (Slice *currSlice);
00113 extern int EPZSInit (ImageParameters *p_Img);
00114 extern int EPZSStructInit (Slice *currSlice);
00115 extern void EPZSOutputStats (InputParameters *p_Inp, FILE * stat, short stats_file);
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128 static inline int add_predictor(MotionVector *cur_mv, MotionVector prd_mv, int mvScale, int shift_mv)
00129 {
00130 *cur_mv = prd_mv;
00131 cur_mv->mv_x = (short) rshift_rnd_sf((mvScale * cur_mv->mv_x), shift_mv);
00132 cur_mv->mv_y = (short) rshift_rnd_sf((mvScale * cur_mv->mv_y), shift_mv);
00133 return (*((int*) cur_mv) != 0);
00134 }
00135
00136 static inline void scale_mv(MotionVector *out_mv, int scale, short *mv, int shift_mv)
00137 {
00138 out_mv->mv_x = (short) rshift_rnd_sf((scale * mv[0]), shift_mv);
00139 out_mv->mv_y = (short) rshift_rnd_sf((scale * mv[1]), shift_mv);
00140 }
00141
00142
00143 static inline void compute_scaled(MotionVector *MotionVector0, MotionVector *MotionVector1, int tempmv_scale[2], short *mv, int invmv_precision)
00144 {
00145 MotionVector0->mv_x = (short) iClip3 (-32768, 32767, rshift_rnd_sf((tempmv_scale[LIST_0] * mv[0]), invmv_precision));
00146 MotionVector0->mv_y = (short) iClip3 (-32768, 32767, rshift_rnd_sf((tempmv_scale[LIST_0] * mv[1]), invmv_precision));
00147 MotionVector1->mv_x = (short) iClip3 (-32768, 32767, rshift_rnd_sf((tempmv_scale[LIST_1] * mv[0]), invmv_precision));
00148 MotionVector1->mv_y = (short) iClip3 (-32768, 32767, rshift_rnd_sf((tempmv_scale[LIST_1] * mv[1]), invmv_precision));
00149 }
00150
00151 #endif
00152
00153