103 |
|
|
104 |
#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 ) |
105 |
|
|
|
static const VECTOR zeroMV = {0,0}; |
|
|
|
|
106 |
typedef struct |
typedef struct |
107 |
{ |
{ |
108 |
// general fields |
// general fields |
224 |
const int x, |
const int x, |
225 |
const int y, |
const int y, |
226 |
const uint32_t MotionFlags, |
const uint32_t MotionFlags, |
227 |
|
const uint32_t GlobalFlags, |
228 |
const uint32_t iQuant, |
const uint32_t iQuant, |
229 |
SearchData * const Data, |
SearchData * const Data, |
230 |
const MBParam * const pParam, |
const MBParam * const pParam, |
245 |
|
|
246 |
#define iDiamondSize 2 |
#define iDiamondSize 2 |
247 |
|
|
248 |
|
static __inline uint32_t |
249 |
|
MakeGoodMotionFlags(const uint32_t MotionFlags, const uint32_t VopFlags, const uint32_t VolFlags) |
250 |
|
{ |
251 |
|
uint32_t Flags = MotionFlags; |
252 |
|
|
253 |
|
if (!(VopFlags & XVID_MODEDECISION_BITS)) |
254 |
|
Flags &= ~(QUARTERPELREFINE16_BITS+QUARTERPELREFINE8_BITS+HALFPELREFINE16_BITS+HALFPELREFINE8_BITS+EXTSEARCH_BITS); |
255 |
|
|
256 |
|
if (Flags & EXTSEARCH_BITS) |
257 |
|
Flags |= HALFPELREFINE16_BITS; |
258 |
|
|
259 |
|
if (Flags & EXTSEARCH_BITS && MotionFlags & PMV_EXTSEARCH8) |
260 |
|
Flags |= HALFPELREFINE8_BITS; |
261 |
|
|
262 |
|
if (Flags & HALFPELREFINE16_BITS) |
263 |
|
Flags |= QUARTERPELREFINE16_BITS; |
264 |
|
|
265 |
|
if (Flags & HALFPELREFINE8_BITS) { |
266 |
|
Flags |= QUARTERPELREFINE8_BITS; |
267 |
|
Flags &= ~PMV_HALFPELREFINE8; |
268 |
|
} |
269 |
|
|
270 |
|
if (Flags & QUARTERPELREFINE8_BITS) |
271 |
|
Flags &= ~PMV_QUARTERPELREFINE8; |
272 |
|
|
273 |
|
if (!(VolFlags & XVID_QUARTERPEL)) |
274 |
|
Flags &= ~(PMV_QUARTERPELREFINE16+PMV_QUARTERPELREFINE8+QUARTERPELREFINE16_BITS+QUARTERPELREFINE8_BITS); |
275 |
|
|
276 |
|
if (!(VopFlags & XVID_HALFPEL)) |
277 |
|
Flags &= ~(PMV_EXTSEARCH16+PMV_HALFPELREFINE16+PMV_HALFPELREFINE8+HALFPELREFINE16_BITS+HALFPELREFINE8_BITS); |
278 |
|
|
279 |
|
if ((VopFlags & XVID_GREYSCALE) || (VopFlags & XVID_REDUCED)) |
280 |
|
Flags &= ~(PMV_CHROMA16 + PMV_CHROMA8); |
281 |
|
|
282 |
|
return Flags; |
283 |
|
} |
284 |
|
|
285 |
|
/* BITS mode decision and search */ |
286 |
|
|
287 |
|
#include "../bitstream/zigzag.h" |
288 |
|
#include "../quant/quant_mpeg4.h" |
289 |
|
#include "../quant/quant_h263.h" |
290 |
|
#include "../bitstream/vlc_codes.h" |
291 |
|
|
292 |
|
static int |
293 |
|
CountMBBitsInter(SearchData * const Data, |
294 |
|
const MACROBLOCK * const pMBs, const int x, const int y, |
295 |
|
const MBParam * const pParam, |
296 |
|
const uint32_t MotionFlags); |
297 |
|
|
298 |
|
static int |
299 |
|
CountMBBitsInter4v(const SearchData * const Data, |
300 |
|
MACROBLOCK * const pMB, const MACROBLOCK * const pMBs, |
301 |
|
const int x, const int y, |
302 |
|
const MBParam * const pParam, const uint32_t MotionFlags, |
303 |
|
const VECTOR * const backup); |
304 |
|
|
305 |
|
static int |
306 |
|
CountMBBitsIntra(const SearchData * const Data); |
307 |
|
|
308 |
|
int CodeCoeffIntra_CalcBits(const int16_t qcoeff[64], const uint16_t * zigzag); |
309 |
|
int CodeCoeffInter_CalcBits(const int16_t qcoeff[64], const uint16_t * zigzag); |
310 |
|
|
311 |
#endif /* _MOTION_EST_H_ */ |
#endif /* _MOTION_EST_H_ */ |