--- branches/dev-api-3/xvidcore/src/motion/motion_est.c 2002/11/21 10:33:33 668 +++ branches/dev-api-3/xvidcore/src/motion/motion_est.c 2002/12/08 06:43:34 698 @@ -54,6 +54,11 @@ #define iDiamondSize 2 +static VECTOR +GlobalMotionEst(const MACROBLOCK * const pMBs, + const MBParam * const pParam, const uint32_t iFcode); + + static __inline int d_mv_bits(int x, int y, const uint32_t iFcode) { @@ -1368,7 +1373,7 @@ Data->min_dy *= 2; Data->referencemv = b_mb->qmvs; } else Data->referencemv = b_mb->mvs; - Data->qpel_precision = 0; // it'm a trick. it's 1 not 0, but we need 0 here + Data->qpel_precision = 0; // it's a trick. it's 1 not 0, but we need 0 here for (k = 0; k < 4; k++) { pMB->mvs[k].x = Data->directmvF[k].x = ((TRB * Data->referencemv[k].x) / TRD); @@ -1455,12 +1460,12 @@ SubpelRefine(Data); - *Data->iMinSAD += 1 * Data->lambda16; // one bit is needed to code direct mode +// *Data->iMinSAD += 1 * Data->lambda16; // one bit is needed to code direct mode *best_sad = *Data->iMinSAD; -// if (b_mb->mode == MODE_INTER4V) + if (b_mb->mode == MODE_INTER4V) pMB->mode = MODE_DIRECT; -// else pMB->mode = MODE_DIRECT_NO4V; //for faster compensation + else pMB->mode = MODE_DIRECT_NO4V; //for faster compensation pMB->pmvs[3] = *Data->currentMV; @@ -1535,7 +1540,7 @@ bData.RefV = fData->bRefV = b_RefV + (x + y * iEdgedWidth) * 16; bData.RefHV = fData->bRefHV = b_RefHV + (x + y * iEdgedWidth) * 16; bData.RefQ = fData->RefQ; - fData->qpel_precision = bData.qpel_precision = 0; + fData->qpel_precision = bData.qpel_precision = 0; bData.qpel = fData->qpel; bData.rounding = 0; bData.bpredMV = fData->predMV = *f_predMV; @@ -1546,14 +1551,14 @@ get_range(&bData.min_dx, &bData.max_dx, &bData.min_dy, &bData.max_dy, x, y, 16, pParam->width, pParam->height, bcode, pParam->m_quarterpel); if (fData->currentMV[0].x > fData->max_dx) fData->currentMV[0].x = fData->max_dx; - if (fData->currentMV[0].x < fData->min_dx) fData->currentMV[0].x = fData->min_dy; - if (fData->currentMV[0].y > fData->max_dy) fData->currentMV[0].y = fData->max_dx; - if (fData->currentMV[0].y > fData->min_dy) fData->currentMV[0].y = fData->min_dy; + if (fData->currentMV[0].x < fData->min_dx) fData->currentMV[0].x = fData->min_dx; + if (fData->currentMV[0].y > fData->max_dy) fData->currentMV[0].y = fData->max_dy; + if (fData->currentMV[0].y < fData->min_dy) fData->currentMV[0].y = fData->min_dy; if (fData->currentMV[1].x > bData.max_dx) fData->currentMV[1].x = bData.max_dx; - if (fData->currentMV[1].x < bData.min_dx) fData->currentMV[1].x = bData.min_dy; - if (fData->currentMV[1].y > bData.max_dy) fData->currentMV[1].y = bData.max_dx; - if (fData->currentMV[1].y > bData.min_dy) fData->currentMV[1].y = bData.min_dy; + if (fData->currentMV[1].x < bData.min_dx) fData->currentMV[1].x = bData.min_dx; + if (fData->currentMV[1].y > bData.max_dy) fData->currentMV[1].y = bData.max_dy; + if (fData->currentMV[1].y < bData.min_dy) fData->currentMV[1].y = bData.min_dy; CheckCandidateInt(fData->currentMV[0].x, fData->currentMV[0].y, 255, &iDirection, fData); @@ -1579,9 +1584,8 @@ } while (!(iDirection)); - *fData->iMinSAD += 2 * fData->lambda16; // two bits are needed to code interpolate mode. - if (fData->qpel) { + CheckCandidate = CheckCandidateInt; fData->qpel_precision = bData.qpel_precision = 1; get_range(&fData->min_dx, &fData->max_dx, &fData->min_dy, &fData->max_dy, x, y, 16, pParam->width, pParam->height, fcode, 0); get_range(&bData.min_dx, &bData.max_dx, &bData.min_dy, &bData.max_dy, x, y, 16, pParam->width, pParam->height, bcode, 0); @@ -1593,6 +1597,8 @@ fData->currentQMV[2] = fData->currentQMV[0]; SubpelRefine(&bData); } + + *fData->iMinSAD += 2 * fData->lambda16; // two bits are needed to code interpolate mode. if (*fData->iMinSAD < *best_sad) { *best_sad = *fData->iMinSAD; @@ -1654,7 +1660,7 @@ Data.iEdgedWidth = pParam->edged_width; Data.currentMV = currentMV; Data.currentQMV = currentQMV; Data.iMinSAD = &iMinSAD; - Data.lambda16 = lambda_vec16[frame->quant]; + Data.lambda16 = lambda_vec16[frame->quant] + 2; Data.qpel = pParam->m_quarterpel; Data.rounding = 0; @@ -1751,7 +1757,6 @@ case MODE_DIRECT: case MODE_DIRECT_NO4V: d_count++; - break; default: break; } @@ -2037,7 +2042,7 @@ } #define INTRA_THRESH 1350 -#define INTER_THRESH 900 +#define INTER_THRESH 1200 int @@ -2070,7 +2075,7 @@ IntraThresh -= (IntraThresh * (maxIntra - 5*(maxIntra - intraCount)))/maxIntra; - InterThresh += 300 * (1 - bCount); + InterThresh += 400 * (1 - bCount); if (InterThresh < 200) InterThresh = 200; if (sadInit) (*sadInit) ();