--- estimation_pvop.c 2004/04/20 06:10:40 1.4 +++ estimation_pvop.c 2004/07/08 07:12:54 1.8 @@ -21,7 +21,7 @@ * along with this program ; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: estimation_pvop.c,v 1.4 2004/04/20 06:10:40 syskin Exp $ + * $Id: estimation_pvop.c,v 1.8 2004/07/08 07:12:54 syskin Exp $ * ****************************************************************************/ @@ -42,7 +42,7 @@ static const int xvid_me_lambda_vec8[32] = { 0 ,(int)(1.00235 * NEIGH_TEND_8X8 + 0.5), - (int)(1.15582 + NEIGH_TEND_8X8 + 0.5), (int)(1.31976*NEIGH_TEND_8X8 + 0.5), + (int)(1.15582*NEIGH_TEND_8X8 + 0.5), (int)(1.31976*NEIGH_TEND_8X8 + 0.5), (int)(1.49591*NEIGH_TEND_8X8 + 0.5), (int)(1.68601*NEIGH_TEND_8X8 + 0.5), (int)(1.89187*NEIGH_TEND_8X8 + 0.5), (int)(2.11542*NEIGH_TEND_8X8 + 0.5), (int)(2.35878*NEIGH_TEND_8X8 + 0.5), (int)(2.62429*NEIGH_TEND_8X8 + 0.5), @@ -312,7 +312,8 @@ const IMAGE * const pCurrent, const IMAGE * const pRef, const IMAGE * const vGMC, - const int coding_type) + const int coding_type, + const int skip_sad) { int mode = MODE_INTER; int mcsel = 0; @@ -338,8 +339,8 @@ } /* final skip decision, a.k.a. "the vector you found, really that good?" */ - if (skip_possible && (pMB->sad16 < (int)iQuant * MAX_SAD00_FOR_SKIP)) - if ( (100*sad)/(pMB->sad16+1) > FINAL_SKIP_THRESH) + if (skip_possible && (skip_sad < (int)iQuant * MAX_SAD00_FOR_SKIP)) + if ( (100*skip_sad)/(pMB->sad16+1) > FINAL_SKIP_THRESH) if (Data->chroma || xvid_me_SkipDecisionP(pCurrent, pRef, x, y, Data->iEdgedWidth/2, iQuant, Data->rrv)) { mode = MODE_NOT_CODED; sad = 0; @@ -529,7 +530,8 @@ if(!Data->qpel) { /* halfpel mode */ if (MotionFlags & XVID_ME_HALFPELREFINE8) - xvid_me_SubpelRefine(Data, CheckCandidate, 0); /* perform halfpel refine of current best vector */ + /* perform halfpel refine of current best vector */ + xvid_me_SubpelRefine(Data->currentMV[0], Data, CheckCandidate, 0); } else { /* qpel mode */ Data->currentQMV->x = 2*Data->currentMV->x; @@ -543,7 +545,7 @@ } else if(MotionFlags & XVID_ME_QUARTERPELREFINE8) { /* full */ if (MotionFlags & XVID_ME_HALFPELREFINE8) { - xvid_me_SubpelRefine(Data, CheckCandidate8, 0); /* hpel part */ + xvid_me_SubpelRefine(Data->currentMV[0], Data, CheckCandidate8, 0); /* hpel part */ Data->currentQMV->x = 2*Data->currentMV->x; Data->currentQMV->y = 2*Data->currentMV->y; } @@ -552,7 +554,7 @@ pParam->width, pParam->height, Data->iFcode, 2, 0); Data->qpel_precision = 1; - xvid_me_SubpelRefine(Data, CheckCandidate8, 0); /* qpel part */ + xvid_me_SubpelRefine(Data->currentQMV[0], Data, CheckCandidate8, 0); /* qpel part */ } } @@ -721,7 +723,7 @@ if(!Data->qpel) { /* halfpel mode */ if (MotionFlags & XVID_ME_HALFPELREFINE16) - xvid_me_SubpelRefine(Data, CheckCandidate, 0); + xvid_me_SubpelRefine(Data->currentMV[0], Data, CheckCandidate, 0); } else { /* qpel mode */ @@ -738,7 +740,7 @@ if(MotionFlags & (XVID_ME_QUARTERPELREFINE16 | XVID_ME_QUARTERPELREFINE16_RD)) { /* full */ if (MotionFlags & XVID_ME_HALFPELREFINE16) { - xvid_me_SubpelRefine(Data, CheckCandidate, 0); /* hpel part */ + xvid_me_SubpelRefine(Data->currentMV[0], Data, CheckCandidate, 0); /* hpel part */ for(i = 0; i < 5; i++) { Data->currentQMV[i].x = 2 * Data->currentMV[i].x; Data->currentQMV[i].y = 2 * Data->currentMV[i].y; @@ -748,7 +750,7 @@ pParam->width, pParam->height, Data->iFcode, 2, 0); Data->qpel_precision = 1; if(MotionFlags & XVID_ME_QUARTERPELREFINE16) - xvid_me_SubpelRefine(Data, CheckCandidate, 0); /* qpel part */ + xvid_me_SubpelRefine(Data->currentQMV[0], Data, CheckCandidate, 0); /* qpel part */ } } } @@ -896,6 +898,8 @@ sad32v_c(pCurrent->y + (x + y * iEdgedWidth) * 32, pRef->y + (x + y * iEdgedWidth) * 32, pParam->edged_width, pMB->sad8 ); + + sad00 = 4*MAX(MAX(pMB->sad8[0], pMB->sad8[1]), MAX(pMB->sad8[2], pMB->sad8[3])); if (Data.chroma) { Data.chromaSAD = sad8(pCurrent->u + x*8 + y*(iEdgedWidth/2)*8, @@ -903,19 +907,13 @@ + sad8(pCurrent->v + (x + y*(iEdgedWidth/2))*8, pRef->v + (x + y*(iEdgedWidth/2))*8, iEdgedWidth/2); pMB->sad16 += Data.chromaSAD; + sad00 += Data.chromaSAD; } - sad00 = pMB->sad16; - /* initial skip decision */ /* no early skip for GMC (global vector = skip vector is unknown!) */ if (current->coding_type != S_VOP) { /* no fast SKIP for S(GMC)-VOPs */ - if (pMB->dquant == 0 - && pMB->sad8[0] < pMB->quant * skip_thresh - && pMB->sad8[1] < pMB->quant * skip_thresh - && pMB->sad8[2] < pMB->quant * skip_thresh - && pMB->sad8[3] < pMB->quant * skip_thresh) - + if (pMB->dquant == 0 && sad00 < pMB->quant * skip_thresh) if (Data.chroma || xvid_me_SkipDecisionP(pCurrent, pRef, x, y, iEdgedWidth/2, pMB->quant, Data.rrv)) { ZeroMacroblockP(pMB, sad00); pMB->mode = MODE_NOT_CODED; @@ -965,7 +963,7 @@ else ModeDecision_SAD(&Data, pMB, pMBs, x, y, pParam, MotionFlags, current->vop_flags, current->vol_flags, - pCurrent, pRef, pGMC, current->coding_type); + pCurrent, pRef, pGMC, current->coding_type, sad00); if (pMB->mode == MODE_INTRA)