90 |
(int)(29.6436*NEIGH_TEND_8X8 + 0.5), (int)(36.4949*NEIGH_TEND_8X8 + 0.5) }; |
(int)(29.6436*NEIGH_TEND_8X8 + 0.5), (int)(36.4949*NEIGH_TEND_8X8 + 0.5) }; |
91 |
|
|
92 |
// mv.length table |
// mv.length table |
93 |
static const uint32_t mvtab[33] = { |
static const int mvtab[64] = { |
94 |
1, 2, 3, 4, 6, 7, 7, 7, |
1, 2, 3, 4, 6, 7, 7, 7, |
95 |
9, 9, 9, 10, 10, 10, 10, 10, |
9, 9, 9, 10, 10, 10, 10, 10, |
96 |
10, 10, 10, 10, 10, 10, 10, 10, |
10, 10, 10, 10, 10, 10, 10, 10, |
97 |
10, 11, 11, 11, 11, 11, 11, 12, 12 |
10, 11, 11, 11, 11, 11, 11, 12, |
98 |
}; |
12, 12, 12, 12, 12, 12, 12, 12, |
99 |
|
12, 12, 12, 12, 12, 12, 12, 12, |
100 |
|
12, 12, 12, 12, 12, 12, 12, 12, 12 }; |
101 |
|
|
102 |
static const int DQtab[4] = { |
static const int DQtab[4] = { |
103 |
-1, -2, 1, 2 |
-1, -2, 1, 2 |
105 |
|
|
106 |
#define RRV_MV_SCALEDOWN(a) ( (a)>=0 ? (a+1)/2 : (a-1)/2 ) |
#define RRV_MV_SCALEDOWN(a) ( (a)>=0 ? (a+1)/2 : (a-1)/2 ) |
107 |
|
|
|
static const VECTOR zeroMV = {0,0}; |
|
|
|
|
108 |
typedef struct |
typedef struct |
109 |
{ |
{ |
110 |
// general fields |
// general fields |
137 |
const uint8_t * bRefH; |
const uint8_t * bRefH; |
138 |
const uint8_t * bRefV; |
const uint8_t * bRefV; |
139 |
const uint8_t * bRefHV; |
const uint8_t * bRefHV; |
140 |
|
const uint8_t * b_RefCU; |
141 |
|
const uint8_t * b_RefCV; |
142 |
|
|
143 |
VECTOR bpredMV; |
VECTOR bpredMV; |
144 |
uint32_t bFcode; |
uint32_t bFcode; |
145 |
// fields for direct mode |
// fields for direct mode |
146 |
VECTOR directmvF[4]; |
VECTOR directmvF[4]; |
147 |
VECTOR directmvB[4]; |
VECTOR directmvB[4]; |
148 |
const VECTOR * referencemv; |
const VECTOR * referencemv; |
149 |
|
// _BITS stuff |
150 |
|
int16_t * dctSpace; |
151 |
|
|
152 |
} SearchData; |
} SearchData; |
153 |
|
|
228 |
const int x, |
const int x, |
229 |
const int y, |
const int y, |
230 |
const uint32_t MotionFlags, |
const uint32_t MotionFlags, |
231 |
|
const uint32_t GlobalFlags, |
232 |
const uint32_t iQuant, |
const uint32_t iQuant, |
233 |
SearchData * const Data, |
SearchData * const Data, |
234 |
const MBParam * const pParam, |
const MBParam * const pParam, |
249 |
|
|
250 |
#define iDiamondSize 2 |
#define iDiamondSize 2 |
251 |
|
|
252 |
|
static __inline uint32_t |
253 |
|
MakeGoodMotionFlags(const uint32_t MotionFlags, const uint32_t VopFlags, const uint32_t VolFlags) |
254 |
|
{ |
255 |
|
uint32_t Flags = MotionFlags; |
256 |
|
|
257 |
|
if (!(VopFlags & XVID_VOP_MODEDECISION_BITS)) |
258 |
|
Flags &= ~(XVID_ME_QUARTERPELREFINE16_BITS+XVID_ME_QUARTERPELREFINE8_BITS+XVID_ME_HALFPELREFINE16_BITS+XVID_ME_HALFPELREFINE8_BITS+XVID_ME_EXTSEARCH_BITS); |
259 |
|
|
260 |
|
if (Flags & XVID_ME_EXTSEARCH_BITS) |
261 |
|
Flags |= XVID_ME_HALFPELREFINE16_BITS; |
262 |
|
|
263 |
|
if (Flags & XVID_ME_EXTSEARCH_BITS && MotionFlags & XVID_ME_EXTSEARCH8) |
264 |
|
Flags |= XVID_ME_HALFPELREFINE8_BITS; |
265 |
|
|
266 |
|
if (Flags & XVID_ME_HALFPELREFINE16_BITS) |
267 |
|
Flags |= XVID_ME_QUARTERPELREFINE16_BITS; |
268 |
|
|
269 |
|
if (Flags & XVID_ME_HALFPELREFINE8_BITS) { |
270 |
|
Flags |= XVID_ME_QUARTERPELREFINE8_BITS; |
271 |
|
Flags &= ~XVID_ME_HALFPELREFINE8; |
272 |
|
} |
273 |
|
|
274 |
|
if (Flags & XVID_ME_QUARTERPELREFINE8_BITS) |
275 |
|
Flags &= ~XVID_ME_QUARTERPELREFINE8; |
276 |
|
|
277 |
|
if (!(VolFlags & XVID_VOL_QUARTERPEL)) |
278 |
|
Flags &= ~(XVID_ME_QUARTERPELREFINE16+XVID_ME_QUARTERPELREFINE8+XVID_ME_QUARTERPELREFINE16_BITS+XVID_ME_QUARTERPELREFINE8_BITS); |
279 |
|
|
280 |
|
if (!(VopFlags & XVID_VOP_HALFPEL)) |
281 |
|
Flags &= ~(XVID_ME_EXTSEARCH16+XVID_ME_HALFPELREFINE16+XVID_ME_HALFPELREFINE8+XVID_ME_HALFPELREFINE16_BITS+XVID_ME_HALFPELREFINE8_BITS); |
282 |
|
|
283 |
|
if ((VopFlags & XVID_VOP_GREYSCALE) || (VopFlags & XVID_VOP_REDUCED)) |
284 |
|
Flags &= ~(XVID_ME_CHROMA16 + XVID_ME_CHROMA8); |
285 |
|
|
286 |
|
return Flags; |
287 |
|
} |
288 |
|
|
289 |
|
/* BITS mode decision and search */ |
290 |
|
|
291 |
|
#include "../bitstream/zigzag.h" |
292 |
|
#include "../quant/quant_mpeg4.h" |
293 |
|
#include "../quant/quant_h263.h" |
294 |
|
#include "../bitstream/vlc_codes.h" |
295 |
|
|
296 |
|
static int |
297 |
|
CountMBBitsInter(SearchData * const Data, |
298 |
|
const MACROBLOCK * const pMBs, const int x, const int y, |
299 |
|
const MBParam * const pParam, |
300 |
|
const uint32_t MotionFlags); |
301 |
|
|
302 |
|
static int |
303 |
|
CountMBBitsInter4v(const SearchData * const Data, |
304 |
|
MACROBLOCK * const pMB, const MACROBLOCK * const pMBs, |
305 |
|
const int x, const int y, |
306 |
|
const MBParam * const pParam, const uint32_t MotionFlags, |
307 |
|
const VECTOR * const backup); |
308 |
|
|
309 |
|
static int |
310 |
|
CountMBBitsIntra(const SearchData * const Data); |
311 |
|
|
312 |
|
int CodeCoeffIntra_CalcBits(const int16_t qcoeff[64], const uint16_t * zigzag); |
313 |
|
int CodeCoeffInter_CalcBits(const int16_t qcoeff[64], const uint16_t * zigzag); |
314 |
|
|
315 |
#endif /* _MOTION_EST_H_ */ |
#endif /* _MOTION_EST_H_ */ |