--- trunk/xvidcore/src/motion/motion_est.c 2002/06/12 20:38:41 195 +++ trunk/xvidcore/src/motion/motion_est.c 2002/07/03 12:32:50 254 @@ -528,9 +528,10 @@ const int32_t iEdgedWidth = pParam->edged_width; const uint8_t * cur = pCur->y + x*16 + y*16*iEdgedWidth; int32_t iSAD; - int32_t pred_x,pred_y; + VECTOR pred; + - get_pmv(pMBs, x, y, pParam->mb_width, 0, &pred_x, &pred_y); + pred = get_pmv2(pMBs, pParam->mb_width, 0, x, y, 0); iSAD = sad16( cur, get_ref(pRef, pRefH, pRefV, pRefHV, x, y, 16, 0,0, iEdgedWidth), @@ -540,8 +541,8 @@ currMV->x = 0; currMV->y = 0; - currPMV->x = -pred_x; - currPMV->y = -pred_y; + currPMV->x = -pred.x; + currPMV->y = -pred.y; return iSAD; @@ -1281,6 +1282,7 @@ /* because we might use something like IF (dx>max_dx) THEN dx=max_dx; */ bPredEq = get_pmvdata(pMBs, x, y, iWcount, 0, pmv, psad); + // bPredEq = get_pmvdata2(pMBs, iWcount, 0, x, y, 0, pmv, psad); if ((x == 0) && (y == 0)) { threshA = 512; @@ -1698,8 +1700,8 @@ } /* because we might use IF (dx>max_dx) THEN dx=max_dx; */ - bPredEq = - get_pmvdata(pMBs, (x >> 1), (y >> 1), iWcount, iSubBlock, pmv, psad); + bPredEq = get_pmvdata(pMBs, (x >> 1), (y >> 1), iWcount, iSubBlock, pmv, psad); + // bPredEq = get_pmvdata2(pMBs, iWcount, 0, (x >> 1), (y >> 1), iSubBlock, pmv, psad); if ((x == 0) && (y == 0)) { threshA = 512 / 4; @@ -2010,6 +2012,7 @@ } /* because we might use something like IF (dx>max_dx) THEN dx=max_dx; */ bPredEq = get_pmvdata(pMBs, x, y, iWcount, 0, pmv, psad); + // bPredEq = get_pmvdata2(pMBs, iWcount, 0, x, y, 0, pmv, psad); /* Step 4: Calculate SAD around the Median prediction. MinSAD=SAD @@ -2288,6 +2291,7 @@ } /* because we might use something like IF (dx>max_dx) THEN dx=max_dx; */ bPredEq = get_pmvdata(pMBs, x >> 1, y >> 1, iWcount, iSubBlock, pmv, psad); + // bPredEq = get_pmvdata2(pMBs, iWcount, 0, x >> 1, y >> 1, iSubBlock, pmv, psad); /* Step 4: Calculate SAD around the Median prediction. @@ -2521,20 +2525,39 @@ mb->b_mvs[0].y = 0; continue; } + /* force F_SAD16 + f_sad16 = 100; + b_sad16 = 65535; + + mb->mode = MODE_FORWARD; + mb->mvs[0].x = 1; + mb->mvs[0].y = 1; + mb->b_mvs[0].x = 1; + mb->b_mvs[0].y = 1; + continue; + ^^ force F_SAD16 */ + // forward search f_sad16 = SEARCH16(f_ref->y, f_refH->y, f_refV->y, f_refHV->y, &frame->image, i, j, frame->motion_flags, - frame->quant, frame->fcode, pParam, f_mbs, - f_mbs /* todo */ , + frame->quant, frame->fcode, pParam, + f_mbs, f_mbs, /* todo */ &mb->mvs[0], &pmv_dontcare); // ignore pmv // backward search - b_sad16 = SEARCH16(b_ref->y, b_refH->y, b_refV->y, b_refHV->y, &frame->image, i, j, frame->motion_flags, frame->quant, frame->bcode, pParam, b_mbs, b_mbs, /* todo */ - &mb->b_mvs[0], &pmv_dontcare); // ignore pmv + b_sad16 = SEARCH16(b_ref->y, b_refH->y, b_refV->y, b_refHV->y, + &frame->image, i, j, frame->motion_flags, + frame->quant, frame->bcode, pParam, + b_mbs, b_mbs, /* todo */ + &mb->b_mvs[0], &pmv_dontcare); // ignore pmv // interpolate search (simple, but effective) + i_sad16 = 65535; + + /* + x/y range somewhat buggy i_sad16 = sad16bi_c(frame->image.y + i * 16 + j * 16 * edged_width, get_ref(f_ref->y, f_refH->y, f_refV->y, f_refHV->y, @@ -2546,6 +2569,7 @@ mb->b_mvs[0].x, edged_width), edged_width); + */ // TODO: direct search // predictor + range of [-32,32]