352 |
} |
} |
353 |
|
|
354 |
|
|
|
static int FrameCodeI(Encoder * pEnc, Bitstream * bs, uint32_t *pBits) |
|
|
{ |
|
|
|
|
|
DECLARE_ALIGNED_MATRIX(dct_codes, 6, 64, int16_t, CACHE_LINE); |
|
|
DECLARE_ALIGNED_MATRIX(qcoeff, 6, 64, int16_t, CACHE_LINE); |
|
|
|
|
|
uint16_t x, y; |
|
|
|
|
|
pEnc->iFrameNum = 0; |
|
|
pEnc->mbParam.rounding_type = 1; |
|
|
pEnc->mbParam.coding_type = I_VOP; |
|
|
|
|
|
BitstreamWriteVolHeader(bs, &pEnc->mbParam); |
|
|
BitstreamWriteVopHeader(bs, &pEnc->mbParam); |
|
|
|
|
|
*pBits = BitstreamPos(bs); |
|
|
|
|
|
pEnc->sStat.iTextBits = 0; |
|
|
pEnc->sStat.kblks = pEnc->mbParam.mb_width * pEnc->mbParam.mb_height; |
|
|
pEnc->sStat.mblks = pEnc->sStat.ublks = 0; |
|
|
|
|
|
for (y = 0; y < pEnc->mbParam.mb_height; y++) |
|
|
for (x = 0; x < pEnc->mbParam.mb_width; x++) |
|
|
{ |
|
|
MACROBLOCK *pMB = &pEnc->pMBs[x + y * pEnc->mbParam.mb_width]; |
|
|
|
|
|
CodeIntraMB(pEnc, pMB); |
|
|
|
|
|
MBTransQuantIntra(&pEnc->mbParam, pMB, x, y, dct_codes, qcoeff, &pEnc->sCurrent); |
|
|
|
|
|
start_timer(); |
|
|
MBPrediction(&pEnc->mbParam, x, y, pEnc->mbParam.mb_width, qcoeff, pEnc->pMBs); |
|
|
stop_prediction_timer(); |
|
|
|
|
|
start_timer(); |
|
|
MBCoding(&pEnc->mbParam, pMB, qcoeff, bs, &pEnc->sStat); |
|
|
stop_coding_timer(); |
|
|
} |
|
|
|
|
|
emms(); |
|
|
|
|
|
*pBits = BitstreamPos(bs) - *pBits; |
|
|
pEnc->sStat.fMvPrevSigma = -1; |
|
|
pEnc->sStat.iMvSum = 0; |
|
|
pEnc->sStat.iMvCount = 0; |
|
|
pEnc->mbParam.fixed_code = 2; |
|
|
|
|
|
return 1; // intra |
|
|
} |
|
|
|
|
|
|
|
355 |
#define FCODEBITS 3 |
#define FCODEBITS 3 |
356 |
#define MODEBITS 5 |
#define MODEBITS 5 |
357 |
|
|
553 |
} |
} |
554 |
|
|
555 |
|
|
556 |
|
static int FrameCodeI(Encoder * pEnc, Bitstream * bs, uint32_t *pBits) |
557 |
|
{ |
558 |
|
|
559 |
|
DECLARE_ALIGNED_MATRIX(dct_codes, 6, 64, int16_t, CACHE_LINE); |
560 |
|
DECLARE_ALIGNED_MATRIX(qcoeff, 6, 64, int16_t, CACHE_LINE); |
561 |
|
|
562 |
|
uint16_t x, y; |
563 |
|
|
564 |
|
pEnc->iFrameNum = 0; |
565 |
|
pEnc->mbParam.rounding_type = 1; |
566 |
|
pEnc->mbParam.coding_type = I_VOP; |
567 |
|
|
568 |
|
BitstreamWriteVolHeader(bs, &pEnc->mbParam); |
569 |
|
BitstreamWriteVopHeader(bs, &pEnc->mbParam); |
570 |
|
|
571 |
|
*pBits = BitstreamPos(bs); |
572 |
|
|
573 |
|
pEnc->sStat.iTextBits = 0; |
574 |
|
pEnc->sStat.kblks = pEnc->mbParam.mb_width * pEnc->mbParam.mb_height; |
575 |
|
pEnc->sStat.mblks = pEnc->sStat.ublks = 0; |
576 |
|
|
577 |
|
for (y = 0; y < pEnc->mbParam.mb_height; y++) |
578 |
|
for (x = 0; x < pEnc->mbParam.mb_width; x++) |
579 |
|
{ |
580 |
|
MACROBLOCK *pMB = &pEnc->pMBs[x + y * pEnc->mbParam.mb_width]; |
581 |
|
|
582 |
|
CodeIntraMB(pEnc, pMB); |
583 |
|
|
584 |
|
MBTransQuantIntra(&pEnc->mbParam, pMB, x, y, dct_codes, qcoeff, &pEnc->sCurrent); |
585 |
|
|
586 |
|
start_timer(); |
587 |
|
MBPrediction(&pEnc->mbParam, x, y, pEnc->mbParam.mb_width, qcoeff, pEnc->pMBs); |
588 |
|
stop_prediction_timer(); |
589 |
|
|
590 |
|
start_timer(); |
591 |
|
MBCoding(&pEnc->mbParam, pMB, qcoeff, bs, &pEnc->sStat); |
592 |
|
stop_coding_timer(); |
593 |
|
} |
594 |
|
|
595 |
|
emms(); |
596 |
|
|
597 |
|
*pBits = BitstreamPos(bs) - *pBits; |
598 |
|
pEnc->sStat.fMvPrevSigma = -1; |
599 |
|
pEnc->sStat.iMvSum = 0; |
600 |
|
pEnc->sStat.iMvCount = 0; |
601 |
|
pEnc->mbParam.fixed_code = 2; |
602 |
|
|
603 |
|
if (pEnc->mbParam.global_flags & XVID_HINTEDME_GET) |
604 |
|
{ |
605 |
|
HintedMEGet(pEnc, 1); |
606 |
|
} |
607 |
|
|
608 |
|
return 1; // intra |
609 |
|
} |
610 |
|
|
611 |
|
|
612 |
#define INTRA_THRESHOLD 0.5 |
#define INTRA_THRESHOLD 0.5 |
613 |
|
|
614 |
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) |
665 |
|
|
666 |
if (bIntra == 1) |
if (bIntra == 1) |
667 |
{ |
{ |
|
if (pEnc->mbParam.global_flags & XVID_HINTEDME_GET) |
|
|
{ |
|
|
HintedMEGet(pEnc, 1); |
|
|
} |
|
668 |
return FrameCodeI(pEnc, bs, pBits); |
return FrameCodeI(pEnc, bs, pBits); |
669 |
} |
} |
670 |
|
|