--- branches/dev-api-4/xvidcore/src/motion/motion_est.c 2003/04/14 15:00:49 986 +++ branches/dev-api-4/xvidcore/src/motion/motion_est.c 2003/04/14 15:42:19 987 @@ -200,7 +200,7 @@ GetReferenceB(const int x, const int y, const uint32_t dir, const SearchData * const data) { // dir : 0 = forward, 1 = backward - const uint8_t* const *direction = ( dir == 0 ? data->RefP : data->b_RefP ); + const uint8_t *const *const direction = ( dir == 0 ? data->RefP : data->b_RefP ); const int picture = ((x&1)<<1) | (y&1); const int offset = (x>>1) + (y>>1)*data->iEdgedWidth; return direction[picture] + offset; @@ -351,7 +351,6 @@ data->iMinSAD[3] = data->temp[3]; current[3].x = x; current[3].y = y; } if (data->temp[4] < data->iMinSAD[4]) { data->iMinSAD[4] = data->temp[4]; current[4].x = x; current[4].y = y; } - } static void @@ -384,7 +383,6 @@ } } - static void CheckCandidate32(const int x, const int y, const int Direction, int * const dir, const SearchData * const data) { @@ -465,8 +463,8 @@ if ( (x > data->max_dx) || (x < data->min_dx) || (y > data->max_dy) || (y < data->min_dy) ) return; - sad = sad32v_c(data->Cur, data->RefP[0] + x/2 + (y/2)*(data->iEdgedWidth), - data->iEdgedWidth, data->temp+1); + sad = sad32v_c(data->Cur, data->RefP[0] + (x>>1) + (y>>1)*(data->iEdgedWidth), + data->iEdgedWidth, data->temp+1); if (sad < *(data->iMinSAD)) { *(data->iMinSAD) = sad; @@ -1052,7 +1050,6 @@ if (quant > 31) quant = 31; else if (quant < 1) quant = 1; } - pMB->quant = current->quant; //initial skip decision @@ -1084,8 +1081,9 @@ } if (current->vol_flags & XVID_VOL_GMC ) /* GMC only for S(GMC)-VOPs */ + { current->warp = GlobalMotionEst( pMBs, pParam, current, reference, pRefH, pRefV, pRefHV); - + } return 0; } @@ -1220,7 +1218,6 @@ if (bits_inter4v < bits) { Data->iMinSAD[0] = bits = bits_inter4v; mode = MODE_INTER4V; } } - intra = CountMBBitsIntra(Data); if (intra < bits) { *Data->iMinSAD = bits = intra; return MODE_INTRA; } @@ -1359,7 +1356,6 @@ } if (MotionFlags & XVID_ME_HALFPELREFINE16) - if ((!(MotionFlags & XVID_ME_HALFPELREFINE16_BITS)) || Data->iMinSAD[0] < 200*(int)iQuant) SubpelRefine(Data); for(i = 0; i < 5; i++) { @@ -1371,20 +1367,13 @@ get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 16, pParam->width, pParam->height, Data->iFcode, 1, 0); - - if ((!(MotionFlags & XVID_ME_QUARTERPELREFINE16_BITS)) || (Data->iMinSAD[0] < 200*(int)iQuant)) { - Data->qpel_precision = 1; - SubpelRefine(Data); - } + Data->qpel_precision = 1; + SubpelRefine(Data); } if ((!(VopFlags & XVID_VOP_MODEDECISION_BITS)) && (Data->iMinSAD[0] < (int32_t)iQuant * 30)) inter4v = 0; - if (inter4v && (!(VopFlags & XVID_VOP_MODEDECISION_BITS) || - (!(MotionFlags & XVID_ME_QUARTERPELREFINE8_BITS)) || (!(MotionFlags & XVID_ME_HALFPELREFINE8_BITS)) || - ((!(MotionFlags & XVID_ME_EXTSEARCH_BITS)) && (!(MotionFlags&XVID_ME_EXTSEARCH8)) ))) { - // if decision is BITS-based and all refinement steps will be done in BITS domain, there is no reason to call this loop - + if (inter4v) { SearchData Data8; memcpy(&Data8, Data, sizeof(SearchData)); //quick copy of common data @@ -1396,7 +1385,7 @@ if ((Data->chroma) && (!(VopFlags & XVID_VOP_MODEDECISION_BITS))) { // chroma is only used for comparsion to INTER. if the comparsion will be done in BITS domain, there is no reason to compute it int sumx = 0, sumy = 0; - const int div = 1 + Data->qpel; + const int div = Data->qpel ? 2 : 1; const VECTOR * const mv = Data->qpel ? pMB->qmvs : pMB->mvs; for (i = 0; i < 4; i++) { @@ -2189,8 +2178,8 @@ } } -#define INTRA_THRESH 2400 -#define INTER_THRESH 1300 +#define INTRA_THRESH 2050 +#define INTER_THRESH 1200 int MEanalysis( const IMAGE * const pRef, @@ -2265,7 +2254,7 @@ sSAD /= blocks; s = (10*s) / blocks; - if (s > 4) sSAD += (s - 3) * (300 - 2*b_thresh); //static block - looks bad when in bframe... + if (s > 4) sSAD += (s - 2) * (160 - 2*b_thresh); //static block - looks bad when in bframe... if (sSAD > InterThresh ) return P_VOP; emms(); @@ -2426,7 +2415,7 @@ continue; if ( ( fabs(( sol[0] + (16*mx+8)*sol[1] + (16*my+8)*sol[2] ) - mv.x ) > meanx ) - || ( fabs(( sol[3] - (16*mx+8)*sol[2] + (16*my+8)*sol[1] ) - mv.y ) > meany ) ) + || ( fabs(( sol[3] - (16*mx+8)*sol[2] + (16*my+8)*sol[1] ) - mv.y ) > meany ) ) MBmask[mbnum]=0; else num++; @@ -2569,11 +2558,9 @@ Data8->qpel_precision = Data8->qpel; // checking the vector which has been found by SAD-based 8x8 search (if it's different than the one found so far) - if (Data8->qpel) { - if (!(Data8->currentQMV->x == backup[i+1].x && Data8->currentQMV->y == backup[i+1].y)) - CheckCandidateBits8(backup[i+1].x, backup[i+1].y, 255, &iDirection, Data8); - } else { - if (!(Data8->currentMV->x == backup[i+1].x && Data8->currentMV->y == backup[i+1].y)) + { + VECTOR *v = Data8->qpel ? Data8->currentQMV : Data8->currentMV; + if (!( (v->x == backup[i+1].x) && (v->y == backup[i+1].y) )) CheckCandidateBits8(backup[i+1].x, backup[i+1].y, 255, &iDirection, Data8); }