829 |
|
|
830 |
pMB->sad16 = best_sad; |
pMB->sad16 = best_sad; |
831 |
pMB->mode = mode; |
pMB->mode = mode; |
832 |
|
pMB->cbp = 63; |
833 |
|
|
834 |
switch (mode) { |
switch (mode) { |
835 |
|
|
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; |
985 |
Data_d.rounding = 0; |
Data_d.rounding = 0; |
986 |
Data_d.chroma = frame->motion_flags & XVID_ME_CHROMA_BVOP; |
Data_d.chroma = frame->motion_flags & XVID_ME_CHROMA_BVOP; |
987 |
Data_d.iQuant = frame->quant; |
Data_d.iQuant = frame->quant; |
988 |
|
Data_d.quant_sq = frame->quant*frame->quant; |
989 |
Data_d.dctSpace = dct_space; |
Data_d.dctSpace = dct_space; |
990 |
Data_d.quant_type = !(pParam->vol_flags & XVID_VOL_MPEGQUANT); |
Data_d.quant_type = !(pParam->vol_flags & XVID_VOL_MPEGQUANT); |
991 |
Data_d.mpeg_quant_matrices = pParam->mpeg_quant_matrices; |
Data_d.mpeg_quant_matrices = pParam->mpeg_quant_matrices; |
1029 |
|
|
1030 |
if (pMB->mode == MODE_DIRECT_NONE_MV) { |
if (pMB->mode == MODE_DIRECT_NONE_MV) { |
1031 |
pMB->sad16 = best_sad; |
pMB->sad16 = best_sad; |
1032 |
|
pMB->cbp = 0; |
1033 |
continue; |
continue; |
1034 |
} |
} |
1035 |
|
|
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 */ |
1074 |
|
|
1075 |
if (pMB->mode == MODE_DIRECT_NONE_MV) { /* skipped? */ |
if (pMB->mode == MODE_DIRECT_NONE_MV) { /* skipped? */ |
1076 |
pMB->sad16 = skip_sad; |
pMB->sad16 = skip_sad; |
1077 |
|
pMB->cbp = 0; |
1078 |
continue; |
continue; |
1079 |
} |
} |
1080 |
} |
} |
1081 |
|
|
1082 |
if (frame->vop_flags & XVID_VOP_RD_BVOP) |
if (frame->vop_flags & XVID_VOP_RD_BVOP) |
1083 |
ModeDecision_BVOP_RD(&Data_d, &Data_b, &Data_f, &Data_i, |
ModeDecision_BVOP_RD(&Data_d, &Data_b, &Data_f, &Data_i, |
1084 |
pMB, b_mb, &f_predMV, &b_predMV, frame->motion_flags, pParam, i, j); |
pMB, b_mb, &f_predMV, &b_predMV, frame->motion_flags, pParam, i, j, best_sad); |
1085 |
else |
else |
1086 |
ModeDecision_BVOP_SAD(&Data_d, &Data_b, &Data_f, &Data_i, pMB, b_mb, &f_predMV, &b_predMV); |
ModeDecision_BVOP_SAD(&Data_d, &Data_b, &Data_f, &Data_i, pMB, b_mb, &f_predMV, &b_predMV); |
1087 |
|
|