50 |
#define NEIGH_TEND_8X8 40.0 |
#define NEIGH_TEND_8X8 40.0 |
51 |
#define NEIGH_8X8_BIAS 30 |
#define NEIGH_8X8_BIAS 30 |
52 |
|
|
53 |
|
#define BITS_MULT 16 |
54 |
|
|
55 |
/* Parameters which control inter/inter4v decision */ |
/* Parameters which control inter/inter4v decision */ |
56 |
#define IMV16X16 2 |
#define IMV16X16 2 |
57 |
|
|
137 |
VECTOR directmvF[4]; |
VECTOR directmvF[4]; |
138 |
VECTOR directmvB[4]; |
VECTOR directmvB[4]; |
139 |
const VECTOR * referencemv; |
const VECTOR * referencemv; |
140 |
// _BITS stuff |
// BITS/R-D stuff |
141 |
int16_t * dctSpace; |
int16_t * dctSpace; |
142 |
uint32_t iQuant; |
uint32_t iQuant; |
143 |
uint32_t quant_type; |
uint32_t quant_type; |
303 |
|
|
304 |
int CodeCoeffIntra_CalcBits(const int16_t qcoeff[64], const uint16_t * zigzag); |
int CodeCoeffIntra_CalcBits(const int16_t qcoeff[64], const uint16_t * zigzag); |
305 |
int CodeCoeffInter_CalcBits(const int16_t qcoeff[64], const uint16_t * zigzag); |
int CodeCoeffInter_CalcBits(const int16_t qcoeff[64], const uint16_t * zigzag); |
306 |
/* |
|
307 |
static int |
#define LAMBDA ( (int)(1.0*BITS_MULT) ) |
308 |
CountDistortionSkip(const SearchData * const Data); |
|
|
*/ |
|
309 |
static __inline unsigned int |
static __inline unsigned int |
310 |
Block_CalcBits(uint16_t * const coeff, |
Block_CalcBits( int16_t * const coeff, |
311 |
uint16_t * const data, |
int16_t * const data, |
312 |
const uint32_t quant, const int quant_type, |
const uint32_t quant, const int quant_type, |
313 |
uint32_t * cbp, |
uint32_t * cbp, |
314 |
const int block, |
const int block) |
|
const int RD) |
|
315 |
{ |
{ |
316 |
int sum; |
int sum; |
317 |
|
int bits; |
318 |
|
const int lambda = LAMBDA*quant*quant; |
319 |
|
int distortion = 0; |
320 |
|
int i; |
321 |
|
|
322 |
fdct(data); |
fdct(data); |
323 |
|
|
326 |
|
|
327 |
if (sum > 0) { |
if (sum > 0) { |
328 |
*cbp |= 1 << (5 - block); |
*cbp |= 1 << (5 - block); |
329 |
return CodeCoeffInter_CalcBits(coeff, scan_tables[0]); |
bits = BITS_MULT * CodeCoeffInter_CalcBits(coeff, scan_tables[0]); |
330 |
} else return 0; |
} else bits = 0; |
331 |
|
|
332 |
|
if (quant_type == 0) dequant_inter(coeff, coeff, quant); |
333 |
|
else dequant4_inter(coeff, coeff, quant); |
334 |
|
|
335 |
|
for (i = 0; i < 64; i++) { |
336 |
|
distortion += (data[i] - coeff[i])*(data[i] - coeff[i]); |
337 |
|
} |
338 |
|
bits += (BITS_MULT*BITS_MULT*distortion)/lambda; |
339 |
|
|
340 |
|
|
341 |
|
return bits; |
342 |
|
} |
343 |
|
|
344 |
|
static __inline unsigned int |
345 |
|
Block_CalcBitsIntra(int16_t * const coeff, |
346 |
|
int16_t * const data, |
347 |
|
const uint32_t quant, const int quant_type, |
348 |
|
uint32_t * cbp, |
349 |
|
const int block, |
350 |
|
int * dcpred) |
351 |
|
{ |
352 |
|
int bits, i; |
353 |
|
const int lambda = LAMBDA*quant*quant; |
354 |
|
int distortion = 0; |
355 |
|
uint32_t iDcScaler = get_dc_scaler(quant, block > 3); |
356 |
|
int b_dc; |
357 |
|
|
358 |
|
fdct(data); |
359 |
|
data[0] -= 1024; |
360 |
|
|
361 |
|
if (quant_type == 0) quant_intra(coeff, data, quant, iDcScaler); |
362 |
|
else quant4_intra(coeff, data, quant, iDcScaler); |
363 |
|
|
364 |
|
b_dc = coeff[0]; |
365 |
|
if (block < 4) { |
366 |
|
coeff[0] -= *dcpred; |
367 |
|
*dcpred = b_dc; |
368 |
|
} |
369 |
|
|
370 |
|
*cbp |= 1 << (5 - block); |
371 |
|
bits = BITS_MULT*CodeCoeffIntra_CalcBits(coeff, scan_tables[0]); |
372 |
|
bits += BITS_MULT*dcy_tab[coeff[0] + 255].len; |
373 |
|
if (bits != 0) *cbp |= 1 << (5 - block); |
374 |
|
|
375 |
|
coeff[0] = b_dc; |
376 |
|
if (quant_type == 0) dequant_intra(coeff, coeff, quant, iDcScaler); |
377 |
|
else dequant4_intra(coeff, coeff, quant, iDcScaler); |
378 |
|
|
379 |
|
for (i = 0; i < 64; i++) { |
380 |
|
distortion += (data[i] - coeff[i])*(data[i] - coeff[i]); |
381 |
|
} |
382 |
|
|
383 |
|
bits += (BITS_MULT*BITS_MULT*distortion)/lambda; |
384 |
|
|
385 |
|
return bits; |
386 |
} |
} |
387 |
|
|
388 |
#endif /* _MOTION_EST_H_ */ |
#endif /* _MOTION_EST_H_ */ |