21 |
* along with this program ; if not, write to the Free Software |
* along with this program ; if not, write to the Free Software |
22 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
23 |
* |
* |
24 |
* $Id: estimation_bvop.c,v 1.28 2010-12-24 13:21:35 Isibaar Exp $ |
* $Id: estimation_bvop.c,v 1.29 2010-12-29 22:39:28 Isibaar Exp $ |
25 |
* |
* |
26 |
****************************************************************************/ |
****************************************************************************/ |
27 |
|
|
396 |
const uint32_t iWcount, |
const uint32_t iWcount, |
397 |
const MACROBLOCK * const pMB, |
const MACROBLOCK * const pMB, |
398 |
const uint32_t mode_curr, |
const uint32_t mode_curr, |
399 |
const VECTOR hint) |
const VECTOR hint, const int bound) |
400 |
{ |
{ |
401 |
|
int lx, ly; /* left */ |
402 |
|
int tx, ty; /* top */ |
403 |
|
int rtx, rty; /* top-right */ |
404 |
|
int ltx, lty; /* top-left */ |
405 |
|
int lpos, tpos, rtpos, ltpos; |
406 |
|
|
407 |
|
lx = x - 1; ly = y; |
408 |
|
tx = x; ty = y - 1; |
409 |
|
rtx = x + 1; rty = y - 1; |
410 |
|
ltx = x - 1; lty = y - 1; |
411 |
|
|
412 |
|
lpos = lx + ly * iWcount; |
413 |
|
rtpos = rtx + rty * iWcount; |
414 |
|
tpos = tx + ty * iWcount; |
415 |
|
ltpos = ltx + lty * iWcount; |
416 |
|
|
417 |
|
|
418 |
/* [0] is prediction */ |
/* [0] is prediction */ |
419 |
/* [1] is zero */ |
/* [1] is zero */ |
420 |
pmv[1].x = pmv[1].y = 0; |
pmv[1].x = pmv[1].y = 0; |
421 |
|
|
422 |
pmv[2].x = hint.x; pmv[2].y = hint.y; |
pmv[2].x = hint.x; pmv[2].y = hint.y; |
423 |
|
|
424 |
if ((y != 0)&&(x != (int)(iWcount+1))) { /* [3] top-right neighbour */ |
if (rtpos >= bound && rtx < (int)iWcount) { /* [3] top-right neighbour */ |
425 |
pmv[3] = ChoosePred(pMB+1-iWcount, mode_curr); |
pmv[3] = ChoosePred(pMB+1-iWcount, mode_curr); |
426 |
} else pmv[3].x = pmv[3].y = 0; |
} else pmv[3].x = pmv[3].y = 0; |
427 |
|
|
428 |
if (y != 0) { |
if (tpos >= bound) { |
429 |
pmv[4] = ChoosePred(pMB-iWcount, mode_curr); |
pmv[4] = ChoosePred(pMB-iWcount, mode_curr); /* [4] top */ |
430 |
} else pmv[4].x = pmv[4].y = 0; |
} else pmv[4].x = pmv[4].y = 0; |
431 |
|
|
432 |
if (x != 0) { |
if (lpos >= bound && lx >= 0) { |
433 |
pmv[5] = ChoosePred(pMB-1, mode_curr); |
pmv[5] = ChoosePred(pMB-1, mode_curr); /* [5] left */ |
434 |
} else pmv[5].x = pmv[5].y = 0; |
} else pmv[5].x = pmv[5].y = 0; |
435 |
|
|
436 |
if (x != 0 && y != 0) { |
if (ltpos >= bound && ltx >= 0) { |
437 |
pmv[6] = ChoosePred(pMB-1-iWcount, mode_curr); |
pmv[6] = ChoosePred(pMB-1-iWcount, mode_curr); /* [6] top-left */ |
438 |
} else pmv[6].x = pmv[6].y = 0; |
} else pmv[6].x = pmv[6].y = 0; |
439 |
} |
} |
440 |
|
|
449 |
int32_t * const best_sad, |
int32_t * const best_sad, |
450 |
const int32_t mode_current, |
const int32_t mode_current, |
451 |
SearchData * const Data, |
SearchData * const Data, |
452 |
VECTOR hint) |
VECTOR hint, const int bound) |
453 |
{ |
{ |
454 |
|
|
455 |
int i; |
int i; |
468 |
hint.x /= 2; hint.y /= 2; |
hint.x /= 2; hint.y /= 2; |
469 |
} |
} |
470 |
|
|
471 |
PreparePredictionsBF(pmv, x, y, pParam->mb_width, pMB, mode_current, hint); |
PreparePredictionsBF(pmv, x, y, pParam->mb_width, pMB, mode_current, hint, bound); |
472 |
|
|
473 |
Data->currentMV->x = Data->currentMV->y = 0; |
Data->currentMV->x = Data->currentMV->y = 0; |
474 |
|
|
1063 |
} |
} |
1064 |
|
|
1065 |
SearchBF_initial(i, j, frame->motion_flags, frame->fcode, pParam, pMB, |
SearchBF_initial(i, j, frame->motion_flags, frame->fcode, pParam, pMB, |
1066 |
&f_predMV, &best_sad, MODE_FORWARD, &Data_f, Data_d.currentMV[1]); |
&f_predMV, &best_sad, MODE_FORWARD, &Data_f, Data_d.currentMV[1], new_bound); |
1067 |
|
|
1068 |
SearchBF_initial(i, j, frame->motion_flags, frame->bcode, pParam, pMB, |
SearchBF_initial(i, j, frame->motion_flags, frame->bcode, pParam, pMB, |
1069 |
&b_predMV, &best_sad, MODE_BACKWARD, &Data_b, Data_d.currentMV[2]); |
&b_predMV, &best_sad, MODE_BACKWARD, &Data_b, Data_d.currentMV[2], new_bound); |
1070 |
|
|
1071 |
if (frame->motion_flags&XVID_ME_BFRAME_EARLYSTOP) |
if (frame->motion_flags&XVID_ME_BFRAME_EARLYSTOP) |
1072 |
fb_thresh = best_sad; |
fb_thresh = best_sad; |
1262 |
} |
} |
1263 |
|
|
1264 |
SearchBF_initial(i, j, frame->motion_flags, frame->fcode, pParam, pMB, |
SearchBF_initial(i, j, frame->motion_flags, frame->fcode, pParam, pMB, |
1265 |
&f_predMV, &best_sad, MODE_FORWARD, &Data_f, Data_d.currentMV[1]); |
&f_predMV, &best_sad, MODE_FORWARD, &Data_f, Data_d.currentMV[1], new_bound); |
1266 |
|
|
1267 |
SearchBF_initial(i, j, frame->motion_flags, frame->bcode, pParam, pMB, |
SearchBF_initial(i, j, frame->motion_flags, frame->bcode, pParam, pMB, |
1268 |
&b_predMV, &best_sad, MODE_BACKWARD, &Data_b, Data_d.currentMV[2]); |
&b_predMV, &best_sad, MODE_BACKWARD, &Data_b, Data_d.currentMV[2], new_bound); |
1269 |
|
|
1270 |
if (frame->motion_flags&XVID_ME_BFRAME_EARLYSTOP) |
if (frame->motion_flags&XVID_ME_BFRAME_EARLYSTOP) |
1271 |
fb_thresh = best_sad; |
fb_thresh = best_sad; |