20 |
* along with this program ; if not, write to the Free Software |
* along with this program ; if not, write to the Free Software |
21 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
22 |
* |
* |
23 |
* $Id: estimation_rd_based.c,v 1.2 2004-03-22 22:36:24 edgomez Exp $ |
* $Id: estimation_rd_based.c,v 1.3 2004-04-20 06:10:40 syskin Exp $ |
24 |
* |
* |
25 |
****************************************************************************/ |
****************************************************************************/ |
26 |
|
|
312 |
xvid_me_SquareSearch(Data->currentMV->x, Data->currentMV->y, Data, 255, CheckCandidateRD16); |
xvid_me_SquareSearch(Data->currentMV->x, Data->currentMV->y, Data, 255, CheckCandidateRD16); |
313 |
|
|
314 |
if (MotionFlags&XVID_ME_HALFPELREFINE16_RD) |
if (MotionFlags&XVID_ME_HALFPELREFINE16_RD) |
315 |
xvid_me_SubpelRefine(Data, CheckCandidateRD16); |
xvid_me_SubpelRefine(Data, CheckCandidateRD16, 0); |
316 |
|
|
317 |
if (Data->qpel) { |
if (Data->qpel) { |
318 |
if (MotionFlags&(XVID_ME_EXTSEARCH_RD | XVID_ME_HALFPELREFINE16_RD)) { /* there was halfpel-precision search */ |
if (MotionFlags&(XVID_ME_EXTSEARCH_RD | XVID_ME_HALFPELREFINE16_RD)) { /* there was halfpel-precision search */ |
326 |
get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 4, |
get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 4, |
327 |
pParam->width, pParam->height, Data->iFcode, 2, 0); |
pParam->width, pParam->height, Data->iFcode, 2, 0); |
328 |
} |
} |
329 |
if (MotionFlags&XVID_ME_QUARTERPELREFINE16_RD) |
if (MotionFlags & XVID_ME_QUARTERPELREFINE16_RD) { |
330 |
xvid_me_SubpelRefine(Data, CheckCandidateRD16); |
if (MotionFlags & XVID_ME_FASTREFINE16) |
331 |
|
FullRefine_Fast(Data, CheckCandidateRD16, 0); |
332 |
|
else |
333 |
|
xvid_me_SubpelRefine(Data, CheckCandidateRD16, 0); |
334 |
|
} |
335 |
} |
} |
336 |
|
|
337 |
if (MotionFlags&XVID_ME_CHECKPREDICTION_RD) { /* let's check vector equal to prediction */ |
if (MotionFlags&XVID_ME_CHECKPREDICTION_RD) { /* let's check vector equal to prediction */ |
394 |
} |
} |
395 |
|
|
396 |
if (Data8->qpel) { |
if (Data8->qpel) { |
397 |
if (MotionFlags&XVID_ME_HALFPELREFINE8_RD || (MotionFlags&XVID_ME_EXTSEARCH8 && MotionFlags&XVID_ME_EXTSEARCH_RD)) { /* halfpixel motion search follows */ |
int bsad = Data8->iMinSAD[0]; |
398 |
int32_t s = *Data8->iMinSAD; |
int bx = Data8->currentQMV->x; |
399 |
|
int by = Data8->currentQMV->y; |
400 |
|
|
401 |
Data8->currentMV->x = Data8->currentQMV->x/2; |
Data8->currentMV->x = Data8->currentQMV->x/2; |
402 |
Data8->currentMV->y = Data8->currentQMV->y/2; |
Data8->currentMV->y = Data8->currentQMV->y/2; |
403 |
|
|
404 |
|
if (MotionFlags&XVID_ME_HALFPELREFINE8_RD || (MotionFlags&XVID_ME_EXTSEARCH8 && MotionFlags&XVID_ME_EXTSEARCH_RD)) { /* halfpixel motion search follows */ |
405 |
Data8->qpel_precision = 0; |
Data8->qpel_precision = 0; |
406 |
get_range(&Data8->min_dx, &Data8->max_dx, &Data8->min_dy, &Data8->max_dy, 2*x + (i&1), 2*y + (i>>1), 3, |
get_range(&Data8->min_dx, &Data8->max_dx, &Data8->min_dy, &Data8->max_dy, 2*x + (i&1), 2*y + (i>>1), 3, |
407 |
pParam->width, pParam->height, Data8->iFcode - 1, 1, 0); |
pParam->width, pParam->height, Data8->iFcode - 1, 1, 0); |
413 |
xvid_me_SquareSearch(Data8->currentMV->x, Data8->currentMV->x, Data8, 255, CheckCandidateRD8); |
xvid_me_SquareSearch(Data8->currentMV->x, Data8->currentMV->x, Data8, 255, CheckCandidateRD8); |
414 |
|
|
415 |
if (MotionFlags & XVID_ME_HALFPELREFINE8_RD) |
if (MotionFlags & XVID_ME_HALFPELREFINE8_RD) |
416 |
xvid_me_SubpelRefine(Data8, CheckCandidateRD8); |
xvid_me_SubpelRefine(Data8, CheckCandidateRD8, 0); |
417 |
|
|
418 |
if(s > *Data8->iMinSAD) { /* we have found a better match */ |
if(bsad > *Data8->iMinSAD) { /* we have found a better match */ |
419 |
Data8->currentQMV->x = 2*Data8->currentMV->x; |
bx = Data8->currentQMV->x = 2*Data8->currentMV->x; |
420 |
Data8->currentQMV->y = 2*Data8->currentMV->y; |
by = Data8->currentQMV->y = 2*Data8->currentMV->y; |
421 |
|
bsad = Data8->iMinSAD[0]; |
422 |
} |
} |
423 |
|
|
424 |
Data8->qpel_precision = 1; |
Data8->qpel_precision = 1; |
426 |
pParam->width, pParam->height, Data8->iFcode, 2, 0); |
pParam->width, pParam->height, Data8->iFcode, 2, 0); |
427 |
|
|
428 |
} |
} |
429 |
if (MotionFlags & XVID_ME_QUARTERPELREFINE8_RD) |
|
430 |
xvid_me_SubpelRefine(Data8, CheckCandidateRD8); |
if (MotionFlags & XVID_ME_QUARTERPELREFINE8_RD) { |
431 |
|
if (MotionFlags & XVID_ME_FASTREFINE8) |
432 |
|
FullRefine_Fast(Data8, CheckCandidateRD8, 0); |
433 |
|
else xvid_me_SubpelRefine(Data8, CheckCandidateRD8, 0); |
434 |
|
} |
435 |
|
|
436 |
|
if (bsad <= Data->iMinSAD[0]) { |
437 |
|
/* we have not found a better match */ |
438 |
|
Data8->iMinSAD[0] = bsad; |
439 |
|
Data8->currentQMV->x = bx; |
440 |
|
Data8->currentQMV->y = by; |
441 |
|
} |
442 |
|
|
443 |
} else { /* not qpel */ |
} else { /* not qpel */ |
444 |
|
|
446 |
xvid_me_SquareSearch(Data8->currentMV->x, Data8->currentMV->x, Data8, 255, CheckCandidateRD8); |
xvid_me_SquareSearch(Data8->currentMV->x, Data8->currentMV->x, Data8, 255, CheckCandidateRD8); |
447 |
|
|
448 |
if (MotionFlags & XVID_ME_HALFPELREFINE8_RD) |
if (MotionFlags & XVID_ME_HALFPELREFINE8_RD) |
449 |
xvid_me_SubpelRefine(Data8, CheckCandidateRD8); /* halfpel refinement */ |
xvid_me_SubpelRefine(Data8, CheckCandidateRD8, 0); /* halfpel refinement */ |
450 |
} |
} |
451 |
|
|
452 |
/* checking vector equal to predicion */ |
/* checking vector equal to predicion */ |