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; |
143 |
|
uint32_t quant_type; |
144 |
|
|
145 |
} SearchData; |
} SearchData; |
146 |
|
|
221 |
const int x, |
const int x, |
222 |
const int y, |
const int y, |
223 |
const uint32_t MotionFlags, |
const uint32_t MotionFlags, |
224 |
const uint32_t GlobalFlags, |
const uint32_t VopFlags, |
225 |
const uint32_t iQuant, |
const uint32_t VolFlags, |
226 |
SearchData * const Data, |
SearchData * const Data, |
227 |
const MBParam * const pParam, |
const MBParam * const pParam, |
228 |
const MACROBLOCK * const pMBs, |
const MACROBLOCK * const pMBs, |
229 |
const MACROBLOCK * const prevMBs, |
const MACROBLOCK * const prevMBs, |
|
int inter4v, |
|
230 |
MACROBLOCK * const pMB); |
MACROBLOCK * const pMB); |
231 |
|
|
|
|
|
232 |
static WARPPOINTS |
static WARPPOINTS |
233 |
GlobalMotionEst(const MACROBLOCK * const pMBs, |
GlobalMotionEst(const MACROBLOCK * const pMBs, |
234 |
const MBParam * const pParam, |
const MBParam * const pParam, |
283 |
#include "../quant/quant_mpeg4.h" |
#include "../quant/quant_mpeg4.h" |
284 |
#include "../quant/quant_h263.h" |
#include "../quant/quant_h263.h" |
285 |
#include "../bitstream/vlc_codes.h" |
#include "../bitstream/vlc_codes.h" |
286 |
|
#include "../dct/fdct.h" |
287 |
|
|
288 |
static int |
static int |
289 |
CountMBBitsInter(SearchData * const Data, |
CountMBBitsInter(SearchData * const Data, |
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 |
|
#define LAMBDA ( (int)(1.0*BITS_MULT) ) |
308 |
|
|
309 |
|
static __inline unsigned int |
310 |
|
Block_CalcBits( int16_t * const coeff, |
311 |
|
int16_t * const data, |
312 |
|
const uint32_t quant, const int quant_type, |
313 |
|
uint32_t * cbp, |
314 |
|
const int block) |
315 |
|
{ |
316 |
|
int sum; |
317 |
|
int bits; |
318 |
|
const int lambda = LAMBDA*quant*quant; |
319 |
|
int distortion = 0; |
320 |
|
int i; |
321 |
|
|
322 |
|
fdct(data); |
323 |
|
|
324 |
|
if (quant_type == 0) sum = quant_inter(coeff, data, quant); |
325 |
|
else sum = quant4_inter(coeff, data, quant); |
326 |
|
|
327 |
|
if (sum > 0) { |
328 |
|
*cbp |= 1 << (5 - block); |
329 |
|
bits = BITS_MULT * CodeCoeffInter_CalcBits(coeff, scan_tables[0]); |
330 |
|
} 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_ */ |