364 |
|
|
365 |
static int FrameCodeI(Encoder * pEnc, Bitstream * bs, uint32_t *pBits) |
static int FrameCodeI(Encoder * pEnc, Bitstream * bs, uint32_t *pBits) |
366 |
{ |
{ |
367 |
|
#ifdef LINUX |
368 |
|
DECLARE_ALIGNED_MATRIX(dct_codes,6,64,int16_t,16); |
369 |
|
DECLARE_ALIGNED_MATRIX(qcoeff,6,64,int16_t,16); |
370 |
|
#else |
371 |
CACHE_ALIGN int16_t dct_codes[6][64]; |
CACHE_ALIGN int16_t dct_codes[6][64]; |
372 |
CACHE_ALIGN int16_t qcoeff[6][64]; |
CACHE_ALIGN int16_t qcoeff[6][64]; |
373 |
|
#endif |
374 |
uint16_t x, y; |
uint16_t x, y; |
375 |
|
|
376 |
pEnc->iFrameNum = 0; |
pEnc->iFrameNum = 0; |
377 |
pEnc->mbParam.rounding_type = 1; |
pEnc->mbParam.rounding_type = 1; |
378 |
pEnc->mbParam.coding_type = I_VOP; |
pEnc->mbParam.coding_type = I_VOP; |
379 |
|
|
380 |
BitstreamWriteVolHeader(bs, pEnc->mbParam.width, pEnc->mbParam.height, pEnc->mbParam.quant_type); |
BitstreamWriteVolHeader(bs, &pEnc->mbParam); |
381 |
BitstreamWriteVopHeader(bs, I_VOP, pEnc->mbParam.rounding_type, |
BitstreamWriteVopHeader(bs, &pEnc->mbParam); |
|
pEnc->mbParam.quant, |
|
|
pEnc->mbParam.fixed_code); |
|
382 |
|
|
383 |
*pBits = BitstreamPos(bs); |
*pBits = BitstreamPos(bs); |
384 |
|
|
393 |
|
|
394 |
CodeIntraMB(pEnc, pMB); |
CodeIntraMB(pEnc, pMB); |
395 |
|
|
396 |
MBTransQuantIntra(&pEnc->mbParam, x, y, dct_codes, qcoeff, &pEnc->sCurrent); |
MBTransQuantIntra(&pEnc->mbParam, pMB, x, y, dct_codes, qcoeff, &pEnc->sCurrent); |
397 |
|
|
398 |
start_timer(); |
start_timer(); |
399 |
MBPrediction(&pEnc->mbParam, x, y, pEnc->mbParam.mb_width, qcoeff, pEnc->pMBs); |
MBPrediction(&pEnc->mbParam, x, y, pEnc->mbParam.mb_width, qcoeff, pEnc->pMBs); |
421 |
static int FrameCodeP(Encoder * pEnc, Bitstream * bs, uint32_t *pBits, bool force_inter, bool vol_header) |
static int FrameCodeP(Encoder * pEnc, Bitstream * bs, uint32_t *pBits, bool force_inter, bool vol_header) |
422 |
{ |
{ |
423 |
float fSigma; |
float fSigma; |
424 |
|
#ifdef LINUX |
425 |
|
DECLARE_ALIGNED_MATRIX(dct_codes,6,64,int16_t,16); |
426 |
|
DECLARE_ALIGNED_MATRIX(qcoeff,6,64,int16_t,16); |
427 |
|
#else |
428 |
CACHE_ALIGN int16_t dct_codes[6][64]; |
CACHE_ALIGN int16_t dct_codes[6][64]; |
429 |
CACHE_ALIGN int16_t qcoeff[6][64]; |
CACHE_ALIGN int16_t qcoeff[6][64]; |
430 |
|
#endif |
431 |
|
|
432 |
int iLimit; |
int iLimit; |
433 |
uint32_t x, y; |
uint32_t x, y; |
437 |
IMAGE *pCurrent = &pEnc->sCurrent; |
IMAGE *pCurrent = &pEnc->sCurrent; |
438 |
IMAGE *pRef = &pEnc->sReference; |
IMAGE *pRef = &pEnc->sReference; |
439 |
|
|
440 |
image_setedges(pRef,pEnc->mbParam.edged_width, pEnc->mbParam.edged_height, pEnc->mbParam.width, pEnc->mbParam.height); |
start_timer(); |
441 |
|
image_setedges(pRef,pEnc->mbParam.edged_width, pEnc->mbParam.edged_height, pEnc->mbParam.width, pEnc->mbParam.height, pEnc->mbParam.global_flags & XVID_INTERLACING); |
442 |
|
stop_edges_timer(); |
443 |
|
|
444 |
pEnc->mbParam.rounding_type = 1 - pEnc->mbParam.rounding_type; |
pEnc->mbParam.rounding_type = 1 - pEnc->mbParam.rounding_type; |
445 |
|
|
468 |
pEnc->mbParam.coding_type = P_VOP; |
pEnc->mbParam.coding_type = P_VOP; |
469 |
|
|
470 |
if(vol_header) |
if(vol_header) |
471 |
BitstreamWriteVolHeader(bs, pEnc->mbParam.width, pEnc->mbParam.height, pEnc->mbParam.quant_type); |
BitstreamWriteVolHeader(bs, &pEnc->mbParam); |
472 |
|
|
473 |
BitstreamWriteVopHeader(bs, P_VOP, pEnc->mbParam.rounding_type, |
BitstreamWriteVopHeader(bs, &pEnc->mbParam); |
|
pEnc->mbParam.quant, |
|
|
pEnc->mbParam.fixed_code); |
|
474 |
|
|
475 |
*pBits = BitstreamPos(bs); |
*pBits = BitstreamPos(bs); |
476 |
|
|
509 |
} |
} |
510 |
pMB->quant = pEnc->mbParam.quant; |
pMB->quant = pEnc->mbParam.quant; |
511 |
|
|
512 |
pMB->cbp = MBTransQuantInter(&pEnc->mbParam, x, y, dct_codes, qcoeff, pCurrent); |
pMB->field_pred = 0; |
513 |
|
|
514 |
|
pMB->cbp = MBTransQuantInter(&pEnc->mbParam, pMB, x, y, dct_codes, qcoeff, pCurrent); |
515 |
} |
} |
516 |
else |
else |
517 |
{ |
{ |
518 |
CodeIntraMB(pEnc, pMB); |
CodeIntraMB(pEnc, pMB); |
519 |
MBTransQuantIntra(&pEnc->mbParam, x, y, dct_codes, qcoeff, pCurrent); |
MBTransQuantIntra(&pEnc->mbParam, pMB, x, y, dct_codes, qcoeff, pCurrent); |
520 |
} |
} |
521 |
|
|
522 |
start_timer(); |
start_timer(); |