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.20 2004-12-09 04:58:12 syskin Exp $ |
* $Id: estimation_bvop.c,v 1.21 2004-12-17 10:45:01 syskin Exp $ |
25 |
* |
* |
26 |
****************************************************************************/ |
****************************************************************************/ |
27 |
|
|
965 |
{ |
{ |
966 |
uint32_t i, j; |
uint32_t i, j; |
967 |
int32_t best_sad = 256*4096; |
int32_t best_sad = 256*4096; |
|
int32_t sad2; |
|
968 |
uint32_t skip_sad; |
uint32_t skip_sad; |
969 |
|
int fb_thresh; |
970 |
const MACROBLOCK * const b_mbs = b_reference->mbs; |
const MACROBLOCK * const b_mbs = b_reference->mbs; |
971 |
|
|
972 |
VECTOR f_predMV, b_predMV; |
VECTOR f_predMV, b_predMV; |
1039 |
SearchBF_initial(i, j, frame->motion_flags, frame->bcode, pParam, pMB, |
SearchBF_initial(i, j, frame->motion_flags, frame->bcode, pParam, pMB, |
1040 |
&b_predMV, &best_sad, MODE_BACKWARD, &Data_b, Data_d.currentMV[2]); |
&b_predMV, &best_sad, MODE_BACKWARD, &Data_b, Data_d.currentMV[2]); |
1041 |
|
|
1042 |
sad2 = best_sad; |
if (frame->motion_flags&XVID_ME_BFRAME_EARLYSTOP) |
1043 |
|
fb_thresh = best_sad; |
1044 |
|
else |
1045 |
|
fb_thresh = best_sad + (best_sad>>1); |
1046 |
|
|
1047 |
if (Data_f.iMinSAD[0] < 2*sad2+2000) |
if (Data_f.iMinSAD[0] <= fb_thresh) |
1048 |
SearchBF_final(i, j, frame->motion_flags, pParam, &best_sad, &Data_f); |
SearchBF_final(i, j, frame->motion_flags, pParam, &best_sad, &Data_f); |
1049 |
|
|
1050 |
if (Data_b.iMinSAD[0] < 2*sad2+2000) |
if (Data_b.iMinSAD[0] <= fb_thresh) |
1051 |
SearchBF_final(i, j, frame->motion_flags, pParam, &best_sad, &Data_b); |
SearchBF_final(i, j, frame->motion_flags, pParam, &best_sad, &Data_b); |
1052 |
|
|
1053 |
SearchInterpolate_initial(i, j, frame->motion_flags, pParam, &f_predMV, &b_predMV, &best_sad, |
SearchInterpolate_initial(i, j, frame->motion_flags, pParam, &f_predMV, &b_predMV, &best_sad, |
1054 |
&Data_i, Data_f.currentMV[0], Data_b.currentMV[0]); |
&Data_i, Data_f.currentMV[0], Data_b.currentMV[0]); |
1055 |
|
|
1056 |
if (((Data_i.iMinSAD[0] < 2*best_sad+2000) && !(frame->motion_flags&XVID_ME_FAST_MODEINTERPOLATE)) |
if (((Data_i.iMinSAD[0] < best_sad +(best_sad>>3)) && !(frame->motion_flags&XVID_ME_FAST_MODEINTERPOLATE)) |
1057 |
|| Data_i.iMinSAD[0] <= best_sad) |
|| Data_i.iMinSAD[0] <= best_sad) |
1058 |
|
|
1059 |
SearchInterpolate_final(i, j, frame->motion_flags, pParam, &best_sad, &Data_i); |
SearchInterpolate_final(i, j, frame->motion_flags, pParam, &best_sad, &Data_i); |
1060 |
|
|
1061 |
if ((Data_d.iMinSAD[0] <= 2*best_sad) && (!frame->motion_flags&XVID_ME_SKIP_DELTASEARCH)) |
if (Data_d.iMinSAD[0] <= 2*best_sad) |
1062 |
|
if ((!(frame->motion_flags&XVID_ME_SKIP_DELTASEARCH) && (best_sad > 750)) |
1063 |
|
|| (best_sad > 1000)) |
1064 |
|
|
1065 |
SearchDirect_final(frame->motion_flags, b_mb, &best_sad, &Data_d); |
SearchDirect_final(frame->motion_flags, b_mb, &best_sad, &Data_d); |
1066 |
|
|
1067 |
/* final skip decision */ |
/* final skip decision */ |