--- encoder.c 2002/10/02 12:57:25 1.76.2.9 +++ encoder.c 2002/10/05 21:36:35 1.76.2.12 @@ -39,7 +39,7 @@ * MinChen * 14.04.2002 added FrameCodeB() * - * $Id: encoder.c,v 1.76.2.9 2002/10/02 12:57:25 suxen_drol Exp $ + * $Id: encoder.c,v 1.76.2.12 2002/10/05 21:36:35 Isibaar Exp $ * ****************************************************************************/ @@ -880,7 +880,7 @@ if ((pEnc->global & XVID_GLOBAL_DEBUG)) { image_printf(&pEnc->current->image, pEnc->mbParam.edged_width, pEnc->mbParam.height, 5, 5, - "%i if:%i st:%i:%i", pEnc->m_framenum++, pEnc->iFrameNum, pEnc->current->seconds, pEnc->current->ticks); + "%i if:%i st:%i", pEnc->m_framenum++, pEnc->iFrameNum, pEnc->current->stamp); } /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -971,7 +971,7 @@ pEnc->flush_bframes = 1; if ((pEnc->global & XVID_GLOBAL_PACKED) && pEnc->bframenum_tail > 0) { - BitstreamPad(&bs); + BitstreamPadAlways(&bs); input_valid = 0; goto ipvop_loop; } @@ -998,7 +998,7 @@ pEnc->flush_bframes = 1; if ((pEnc->global & XVID_GLOBAL_PACKED)) { - BitstreamPad(&bs); + BitstreamPadAlways(&bs); input_valid = 0; goto ipvop_loop; } @@ -1151,6 +1151,11 @@ pEnc->current->quant = pFrame->quant; } + if ((pEnc->current->global_flags & XVID_QUARTERPEL)) + pEnc->mbParam.m_quarterpel = 1; + else + pEnc->mbParam.m_quarterpel = 0; + if ((pEnc->current->global_flags & XVID_LUMIMASKING)) { int *temp_dquants = (int *) xvid_malloc(pEnc->mbParam.mb_width * @@ -1580,7 +1585,7 @@ int iLimit; int x, y, k; int iSearchRange; - int bIntra; + int bIntra, skip_possible; /* IMAGE *pCurrent = &pEnc->current->image; */ IMAGE *pRef = &pEnc->reference->image; @@ -1606,6 +1611,7 @@ image_interpolate(pRef, &pEnc->vInterH, &pEnc->vInterV, &pEnc->vInterHV, pEnc->mbParam.edged_width, pEnc->mbParam.edged_height, + pEnc->mbParam.m_quarterpel, pEnc->current->rounding_type); stop_inter_timer(); } @@ -1613,8 +1619,11 @@ start_timer(); if (pEnc->current->global_flags & XVID_HINTEDME_SET) { HintedMESet(pEnc, &bIntra); - if (bIntra == 0) MotionEstimationHinted(&pEnc->mbParam, pEnc->current, pEnc->reference, + if (bIntra == 0) { + pEnc->current->fcode = FindFcode(&pEnc->mbParam, pEnc->current); + MotionEstimationHinted(&pEnc->mbParam, pEnc->current, pEnc->reference, &pEnc->vInterH, &pEnc->vInterV, &pEnc->vInterHV); + } } else { @@ -1657,6 +1666,7 @@ dct_codes, pEnc->mbParam.width, pEnc->mbParam.height, pEnc->mbParam.edged_width, + pEnc->mbParam.m_quarterpel, pEnc->current->rounding_type); stop_comp_timer(); @@ -1702,10 +1712,15 @@ /* Finished processing the MB, now check if to CODE or SKIP */ - if ((pMB->mode == MODE_NOT_CODED) || - (pMB->cbp == 0 && pMB->mode == MODE_INTER && pMB->mvs[0].x == 0 && - pMB->mvs[0].y == 0 && pMB->dquant == NO_CHANGE)) { + skip_possible = (pMB->cbp == 0) & (pMB->mode == MODE_INTER) & + (pMB->dquant == NO_CHANGE); + + if(pEnc->mbParam.m_quarterpel) + skip_possible &= (pMB->qmvs[0].x == 0) & (pMB->qmvs[0].y == 0); + else + skip_possible &= (pMB->mvs[0].x == 0) & (pMB->mvs[0].y == 0); + if ((pMB->mode == MODE_NOT_CODED) || (skip_possible)) { /* This is a candidate for SKIPping, but check intermediate B-frames first */ int bSkip = 1; @@ -1725,7 +1740,10 @@ if (!bSkip) { VECTOR predMV; - predMV = get_pmv2(pEnc->current->mbs, pEnc->mbParam.mb_width, 0, x, y, 0); + if(pEnc->mbParam.m_quarterpel) + predMV = get_qpmv2(pEnc->current->mbs, pEnc->mbParam.mb_width, 0, x, y, 0); + else + predMV = get_pmv2(pEnc->current->mbs, pEnc->mbParam.mb_width, 0, x, y, 0); pMB->pmvs[0].x = -predMV.x; pMB->pmvs[0].y = -predMV.y; pMB->mode = MODE_INTER; pMB->cbp = 0; @@ -1760,14 +1778,14 @@ iSearchRange = 1 << (3 + pEnc->mbParam.m_fcode); if ((fSigma > iSearchRange / 3) - && (pEnc->mbParam.m_fcode <= 3)) // maximum search range 128 + && (pEnc->mbParam.m_fcode <= (3 + pEnc->mbParam.m_quarterpel))) // maximum search range 128 { pEnc->mbParam.m_fcode++; iSearchRange *= 2; } else if ((fSigma < iSearchRange / 6) && (pEnc->sStat.fMvPrevSigma >= 0) && (pEnc->sStat.fMvPrevSigma < iSearchRange / 6) - && (pEnc->mbParam.m_fcode >= 2)) // minimum search range 16 + && (pEnc->mbParam.m_fcode >= (2 + pEnc->mbParam.m_quarterpel))) // minimum search range 16 { pEnc->mbParam.m_fcode--; iSearchRange /= 2; @@ -1839,7 +1857,7 @@ start_timer(); image_interpolate(f_ref, &pEnc->f_refh, &pEnc->f_refv, &pEnc->f_refhv, pEnc->mbParam.edged_width, pEnc->mbParam.edged_height, - 0); + pEnc->mbParam.m_quarterpel, 0); stop_inter_timer(); // backward @@ -1849,7 +1867,7 @@ start_timer(); image_interpolate(b_ref, &pEnc->vInterH, &pEnc->vInterV, &pEnc->vInterHV, pEnc->mbParam.edged_width, pEnc->mbParam.edged_height, - 0); + pEnc->mbParam.m_quarterpel, 0); stop_inter_timer(); start_timer();