26 |
* along with this program; if not, write to the Free Software |
* along with this program; if not, write to the Free Software |
27 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
28 |
* |
* |
29 |
* $Id: motion.h,v 1.20 2003-02-19 20:12:43 edgomez Exp $ |
* $Id: motion.h,v 1.21 2003-03-04 11:00:53 syskin Exp $ |
30 |
* |
* |
31 |
***************************************************************************/ |
***************************************************************************/ |
32 |
|
|
48 |
****************************************************************************/ |
****************************************************************************/ |
49 |
|
|
50 |
extern const uint32_t roundtab[16]; |
extern const uint32_t roundtab[16]; |
|
|
|
51 |
/* K = 4 */ |
/* K = 4 */ |
52 |
extern const uint32_t roundtab_76[16]; |
extern const uint32_t roundtab_76[16]; |
53 |
/* K = 2 */ |
/* K = 2 */ |
55 |
/* K = 1 */ |
/* K = 1 */ |
56 |
extern const uint32_t roundtab_79[4]; |
extern const uint32_t roundtab_79[4]; |
57 |
|
|
|
|
|
58 |
/* |
/* |
59 |
* getref: calculate reference image pointer |
* getref: calculate reference image pointer |
60 |
* the decision to use interpolation h/v/hv or the normal image is |
* the decision to use interpolation h/v/hv or the normal image is |
69 |
const uint32_t x, |
const uint32_t x, |
70 |
const uint32_t y, |
const uint32_t y, |
71 |
const uint32_t block, /* block dimension, 8 or 16 */ |
const uint32_t block, /* block dimension, 8 or 16 */ |
|
|
|
72 |
const int32_t dx, |
const int32_t dx, |
73 |
const int32_t dy, |
const int32_t dy, |
74 |
const int32_t stride) |
const int32_t stride) |
75 |
{ |
{ |
|
|
|
|
|
|
76 |
switch (((dx & 1) << 1) + (dy & 1)) { /* ((dx%2)?2:0)+((dy%2)?1:0) */ |
switch (((dx & 1) << 1) + (dy & 1)) { /* ((dx%2)?2:0)+((dy%2)?1:0) */ |
77 |
case 0: |
case 0: |
78 |
return refn + (int) ((x * block + dx / 2) + (y * block + dy / 2) * stride); |
return refn + (int) ((x * block + dx / 2) + (y * block + dy / 2) * stride); |
79 |
case 1: |
case 1: |
80 |
return refv + (int) ((x * block + dx / 2) + (y * block + |
return refv + (int) ((x * block + dx / 2) + (y * block + (dy - 1) / 2) * stride); |
|
(dy - 1) / 2) * stride); |
|
81 |
case 2: |
case 2: |
82 |
return refh + (int) ((x * block + (dx - 1) / 2) + (y * block + |
return refh + (int) ((x * block + (dx - 1) / 2) + (y * block + dy / 2) * stride); |
|
dy / 2) * stride); |
|
83 |
default: |
default: |
84 |
return refhv + (int) ((x * block + (dx - 1) / 2) + (y * block + |
return refhv + (int) ((x * block + (dx - 1) / 2) + (y * block + (dy - 1) / 2) * stride); |
|
(dy - 1) / 2) * stride); |
|
85 |
} |
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
/* This is somehow a copy of get_ref, but with MV instead of X,Y */ |
|
|
|
|
|
static __inline const uint8_t * |
|
|
get_ref_mv(const uint8_t * const refn, |
|
|
const uint8_t * const refh, |
|
|
const uint8_t * const refv, |
|
|
const uint8_t * const refhv, |
|
|
const uint32_t x, |
|
|
const uint32_t y, |
|
|
const uint32_t block, /* block dimension, 8 or 16 */ |
|
|
|
|
|
const VECTOR * mv, /* measured in half-pel! */ |
|
|
|
|
|
const int32_t stride) |
|
|
{ |
|
|
|
|
|
switch ((((mv->x) & 1) << 1) + ((mv->y) & 1)) { |
|
|
case 0: |
|
|
return refn + (int) ((x * block + (mv->x) / 2) + (y * block + |
|
|
(mv->y) / 2) * stride); |
|
|
case 1: |
|
|
return refv + (int) ((x * block + (mv->x) / 2) + (y * block + |
|
|
((mv->y) - 1) / 2) * stride); |
|
|
case 2: |
|
|
return refh + (int) ((x * block + ((mv->x) - 1) / 2) + (y * block + |
|
|
(mv->y) / 2) * stride); |
|
|
default: |
|
|
return refhv + (int) ((x * block + ((mv->x) - 1) / 2) + (y * block + |
|
|
((mv->y) - |
|
|
1) / 2) * stride); |
|
|
} |
|
|
|
|
86 |
} |
} |
87 |
|
|
88 |
void MotionEstimationBVOP(MBParam * const pParam, |
void MotionEstimationBVOP(MBParam * const pParam, |
141 |
MACROBLOCK *const pMBs, // [output] average motion vectors |
MACROBLOCK *const pMBs, // [output] average motion vectors |
142 |
IMAGE *const pGMC); // [output] full warped image |
IMAGE *const pGMC); // [output] full warped image |
143 |
|
|
|
|
|
144 |
VECTOR generate_GMCimageMB( const GMC_DATA *const gmc_data, /* [input] all precalc data */ |
VECTOR generate_GMCimageMB( const GMC_DATA *const gmc_data, /* [input] all precalc data */ |
145 |
const IMAGE *const pRef, // [input] |
const IMAGE *const pRef, // [input] |
146 |
const int mi, const int mj, /* [input] MB position */ |
const int mi, const int mj, /* [input] MB position */ |
150 |
const int rounding, |
const int rounding, |
151 |
IMAGE *const pGMC); /* [outut] generate image */ |
IMAGE *const pGMC); /* [outut] generate image */ |
152 |
|
|
|
|
|
|
|
|
|
/* Hinted ME */ |
|
|
|
|
|
void |
|
|
MotionEstimationHinted( MBParam * const pParam, |
|
|
FRAMEINFO * const current, |
|
|
FRAMEINFO * const reference, |
|
|
const IMAGE * const pRefH, |
|
|
const IMAGE * const pRefV, |
|
|
const IMAGE * const pRefHV); |
|
|
|
|
153 |
int |
int |
154 |
MEanalysis( const IMAGE * const pRef, |
MEanalysis( const IMAGE * const pRef, |
155 |
FRAMEINFO * const Current, |
const FRAMEINFO * const Current, |
156 |
MBParam * const pParam, |
const MBParam * const pParam, |
157 |
int maxIntra, |
const int maxIntra, |
158 |
int intraCount, |
const int intraCount, |
159 |
int bCount); |
const int bCount, |
160 |
|
const int b_thresh); |
|
int |
|
|
FindFcode( const MBParam * const pParam, |
|
|
const FRAMEINFO * const current); |
|
|
|
|
|
|
|
|
int d_amv_penalty(int x, int y, const VECTOR pred, const uint32_t iFcode, const int quant); |
|
|
|
|
161 |
|
|
162 |
#endif /* _MOTION_H_ */ |
#endif /* _MOTION_H_ */ |