1015 |
Data.temp = temp; |
Data.temp = temp; |
1016 |
Data.iFcode = current->fcode; |
Data.iFcode = current->fcode; |
1017 |
Data.rounding = pParam->m_rounding_type; |
Data.rounding = pParam->m_rounding_type; |
1018 |
Data.qpel = current->vol_flags & XVID_QUARTERPEL; |
Data.qpel = current->vol_flags & XVID_VOL_QUARTERPEL; |
1019 |
Data.chroma = MotionFlags & PMV_CHROMA16; |
Data.chroma = MotionFlags & XVID_ME_CHROMA16; |
1020 |
Data.rrv = current->vop_flags & XVID_REDUCED; |
Data.rrv = current->vop_flags & XVID_VOP_REDUCED; |
1021 |
|
|
1022 |
if ((current->vop_flags & XVID_REDUCED)) { |
if ((current->vop_flags & XVID_VOP_REDUCED)) { |
1023 |
mb_width = (pParam->width + 31) / 32; |
mb_width = (pParam->width + 31) / 32; |
1024 |
mb_height = (pParam->height + 31) / 32; |
mb_height = (pParam->height + 31) / 32; |
1025 |
Data.qpel = 0; |
Data.qpel = 0; |
1054 |
|
|
1055 |
//initial skip decision |
//initial skip decision |
1056 |
/* no early skip for GMC (global vector = skip vector is unknown!) */ |
/* no early skip for GMC (global vector = skip vector is unknown!) */ |
1057 |
if (!(current->vol_flags & XVID_GMC)) { /* no fast SKIP for S(GMC)-VOPs */ |
if (!(current->vol_flags & XVID_VOL_GMC)) { /* no fast SKIP for S(GMC)-VOPs */ |
1058 |
if (pMB->dquant == 0 && sad00 < pMB->quant * INITIAL_SKIP_THRESH * (Data.rrv ? 4:1) ) |
if (pMB->dquant == 0 && sad00 < pMB->quant * INITIAL_SKIP_THRESH * (Data.rrv ? 4:1) ) |
1059 |
if (Data.chroma || SkipDecisionP(pCurrent, pRef, x, y, iEdgedWidth/2, pMB->quant, Data.rrv)) { |
if (Data.chroma || SkipDecisionP(pCurrent, pRef, x, y, iEdgedWidth/2, pMB->quant, Data.rrv)) { |
1060 |
SkipMacroblockP(pMB, sad00); |
SkipMacroblockP(pMB, sad00); |
1065 |
SearchP(pRef, pRefH->y, pRefV->y, pRefHV->y, pCurrent, x, |
SearchP(pRef, pRefH->y, pRefV->y, pRefHV->y, pCurrent, x, |
1066 |
y, MotionFlags, current->vol_flags, pMB->quant, |
y, MotionFlags, current->vol_flags, pMB->quant, |
1067 |
&Data, pParam, pMBs, reference->mbs, |
&Data, pParam, pMBs, reference->mbs, |
1068 |
current->vop_flags & XVID_INTER4V, pMB); |
current->vop_flags & XVID_VOP_INTER4V, pMB); |
1069 |
|
|
1070 |
/* final skip decision, a.k.a. "the vector you found, really that good?" */ |
/* final skip decision, a.k.a. "the vector you found, really that good?" */ |
1071 |
if (!(current->vol_flags & XVID_GMC)) { |
if (!(current->vol_flags & XVID_VOL_GMC)) { |
1072 |
if ( pMB->dquant == 0 && sad00 < pMB->quant * MAX_SAD00_FOR_SKIP) { |
if ( pMB->dquant == 0 && sad00 < pMB->quant * MAX_SAD00_FOR_SKIP) { |
1073 |
if (!(current->vop_flags & XVID_MODEDECISION_BITS)) { |
if (!(current->vop_flags & XVID_VOP_MODEDECISION_BITS)) { |
1074 |
if ( (100*pMB->sad16)/(sad00+1) > FINAL_SKIP_THRESH * (Data.rrv ? 4:1) ) |
if ( (100*pMB->sad16)/(sad00+1) > FINAL_SKIP_THRESH * (Data.rrv ? 4:1) ) |
1075 |
if (Data.chroma || SkipDecisionP(pCurrent, pRef, x, y, iEdgedWidth/2, pMB->quant, Data.rrv)) |
if (Data.chroma || SkipDecisionP(pCurrent, pRef, x, y, iEdgedWidth/2, pMB->quant, Data.rrv)) |
1076 |
SkipMacroblockP(pMB, sad00); |
SkipMacroblockP(pMB, sad00); |
1086 |
} |
} |
1087 |
} |
} |
1088 |
|
|
1089 |
if (current->vol_flags & XVID_GMC ) /* GMC only for S(GMC)-VOPs */ |
if (current->vol_flags & XVID_VOL_GMC ) /* GMC only for S(GMC)-VOPs */ |
1090 |
{ |
{ |
1091 |
current->warp = GlobalMotionEst( pMBs, pParam, current, reference, pRefH, pRefV, pRefHV); |
current->warp = GlobalMotionEst( pMBs, pParam, current, reference, pRefH, pRefV, pRefHV); |
1092 |
} |
} |
1166 |
|
|
1167 |
int mode = MODE_INTER; |
int mode = MODE_INTER; |
1168 |
|
|
1169 |
if (!(VopFlags & XVID_MODEDECISION_BITS)) { //normal, fast, SAD-based mode decision |
if (!(VopFlags & XVID_VOP_MODEDECISION_BITS)) { //normal, fast, SAD-based mode decision |
1170 |
// int intra = 0; |
// int intra = 0; |
1171 |
int sad; |
int sad; |
1172 |
int InterBias = MV16_INTER_BIAS; |
int InterBias = MV16_INTER_BIAS; |
1209 |
int bits, intra, i; |
int bits, intra, i; |
1210 |
VECTOR backup[5], *v; |
VECTOR backup[5], *v; |
1211 |
Data->lambda16 = iQuant; |
Data->lambda16 = iQuant; |
1212 |
Data->lambda8 = (pParam->vol_flags & XVID_MPEGQUANT)?1:0; |
Data->lambda8 = (pParam->vol_flags & XVID_VOL_MPEGQUANT)?1:0; |
1213 |
|
|
1214 |
v = Data->qpel ? Data->currentQMV : Data->currentMV; |
v = Data->qpel ? Data->currentQMV : Data->currentMV; |
1215 |
for (i = 0; i < 5; i++) { |
for (i = 0; i < 5; i++) { |
1293 |
Data->iMinSAD[3] = pMB->sad8[2]; |
Data->iMinSAD[3] = pMB->sad8[2]; |
1294 |
Data->iMinSAD[4] = pMB->sad8[3]; |
Data->iMinSAD[4] = pMB->sad8[3]; |
1295 |
|
|
1296 |
if ((!(VopFlags & XVID_MODEDECISION_BITS)) || (x | y)) { |
if ((!(VopFlags & XVID_VOP_MODEDECISION_BITS)) || (x | y)) { |
1297 |
threshA = Data->temp[0]; // that's where we keep this SAD atm |
threshA = Data->temp[0]; // that's where we keep this SAD atm |
1298 |
if (threshA < 512) threshA = 512; |
if (threshA < 512) threshA = 512; |
1299 |
else if (threshA > 1024) threshA = 1024; |
else if (threshA > 1024) threshA = 1024; |
1319 |
if ((Data->iMinSAD[0] <= threshA) || |
if ((Data->iMinSAD[0] <= threshA) || |
1320 |
(MVequal(Data->currentMV[0], (prevMBs+x+y*pParam->mb_width)->mvs[0]) && |
(MVequal(Data->currentMV[0], (prevMBs+x+y*pParam->mb_width)->mvs[0]) && |
1321 |
(Data->iMinSAD[0] < (prevMBs+x+y*pParam->mb_width)->sad16))) { |
(Data->iMinSAD[0] < (prevMBs+x+y*pParam->mb_width)->sad16))) { |
1322 |
if (!(VopFlags & XVID_MODEDECISION_BITS)) inter4v = 0; } |
if (!(VopFlags & XVID_VOP_MODEDECISION_BITS)) inter4v = 0; } |
1323 |
else { |
else { |
1324 |
|
|
1325 |
MainSearchFunc * MainSearchPtr; |
MainSearchFunc * MainSearchPtr; |
1326 |
if (MotionFlags & PMV_USESQUARES16) MainSearchPtr = SquareSearch; |
if (MotionFlags & XVID_ME_USESQUARES16) MainSearchPtr = SquareSearch; |
1327 |
else if (MotionFlags & PMV_ADVANCEDDIAMOND16) MainSearchPtr = AdvDiamondSearch; |
else if (MotionFlags & XVID_ME_ADVANCEDDIAMOND16) MainSearchPtr = AdvDiamondSearch; |
1328 |
else MainSearchPtr = DiamondSearch; |
else MainSearchPtr = DiamondSearch; |
1329 |
|
|
1330 |
MainSearchPtr(Data->currentMV->x, Data->currentMV->y, Data, iDirection); |
MainSearchPtr(Data->currentMV->x, Data->currentMV->y, Data, iDirection); |
1333 |
note that this search is/might be done in halfpel positions, |
note that this search is/might be done in halfpel positions, |
1334 |
which makes it more different than the diamond above */ |
which makes it more different than the diamond above */ |
1335 |
|
|
1336 |
if (MotionFlags & PMV_EXTSEARCH16) { |
if (MotionFlags & XVID_ME_EXTSEARCH16) { |
1337 |
int32_t bSAD; |
int32_t bSAD; |
1338 |
VECTOR startMV = Data->predMV, backupMV = Data->currentMV[0]; |
VECTOR startMV = Data->predMV, backupMV = Data->currentMV[0]; |
1339 |
if (Data->rrv) { |
if (Data->rrv) { |
1364 |
} |
} |
1365 |
} |
} |
1366 |
|
|
1367 |
if (MotionFlags & PMV_HALFPELREFINE16) |
if (MotionFlags & XVID_ME_HALFPELREFINE16) |
1368 |
if ((!(MotionFlags & HALFPELREFINE16_BITS)) || Data->iMinSAD[0] < 200*(int)iQuant) |
if ((!(MotionFlags & XVID_ME_HALFPELREFINE16_BITS)) || Data->iMinSAD[0] < 200*(int)iQuant) |
1369 |
SubpelRefine(Data); |
SubpelRefine(Data); |
1370 |
|
|
1371 |
for(i = 0; i < 5; i++) { |
for(i = 0; i < 5; i++) { |
1373 |
Data->currentQMV[i].y = 2 * Data->currentMV[i].y; |
Data->currentQMV[i].y = 2 * Data->currentMV[i].y; |
1374 |
} |
} |
1375 |
|
|
1376 |
if (MotionFlags & PMV_QUARTERPELREFINE16) |
if (MotionFlags & XVID_ME_QUARTERPELREFINE16) |
1377 |
if ((!(MotionFlags & QUARTERPELREFINE16_BITS)) || (Data->iMinSAD[0] < 200*(int)iQuant)) { |
if ((!(MotionFlags & XVID_ME_QUARTERPELREFINE16_BITS)) || (Data->iMinSAD[0] < 200*(int)iQuant)) { |
1378 |
Data->qpel_precision = 1; |
Data->qpel_precision = 1; |
1379 |
get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 16, |
get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 16, |
1380 |
pParam->width, pParam->height, Data->iFcode, 1, 0); |
pParam->width, pParam->height, Data->iFcode, 1, 0); |
1382 |
SubpelRefine(Data); |
SubpelRefine(Data); |
1383 |
} |
} |
1384 |
|
|
1385 |
if ((!(VopFlags & XVID_MODEDECISION_BITS)) && (Data->iMinSAD[0] < (int32_t)iQuant * 30)) inter4v = 0; |
if ((!(VopFlags & XVID_VOP_MODEDECISION_BITS)) && (Data->iMinSAD[0] < (int32_t)iQuant * 30)) inter4v = 0; |
1386 |
|
|
1387 |
if (inter4v && (!(VopFlags & XVID_MODEDECISION_BITS) || |
if (inter4v && (!(VopFlags & XVID_VOP_MODEDECISION_BITS) || |
1388 |
(!(MotionFlags & QUARTERPELREFINE8_BITS)) || (!(MotionFlags & HALFPELREFINE8_BITS)) || |
(!(MotionFlags & XVID_ME_QUARTERPELREFINE8_BITS)) || (!(MotionFlags & XVID_ME_HALFPELREFINE8_BITS)) || |
1389 |
((!(MotionFlags & EXTSEARCH_BITS)) && (!(MotionFlags&PMV_EXTSEARCH8)) ))) { |
((!(MotionFlags & XVID_ME_EXTSEARCH_BITS)) && (!(MotionFlags&XVID_ME_EXTSEARCH8)) ))) { |
1390 |
// if decision is BITS-based and all refinement steps will be done in BITS domain, there is no reason to call this loop |
// if decision is BITS-based and all refinement steps will be done in BITS domain, there is no reason to call this loop |
1391 |
|
|
1392 |
SearchData Data8; |
SearchData Data8; |
1397 |
Search8(Data, 2*x, 2*y + 1, MotionFlags, pParam, pMB, pMBs, 2, &Data8); |
Search8(Data, 2*x, 2*y + 1, MotionFlags, pParam, pMB, pMBs, 2, &Data8); |
1398 |
Search8(Data, 2*x + 1, 2*y + 1, MotionFlags, pParam, pMB, pMBs, 3, &Data8); |
Search8(Data, 2*x + 1, 2*y + 1, MotionFlags, pParam, pMB, pMBs, 3, &Data8); |
1399 |
|
|
1400 |
if ((Data->chroma) && (!(VopFlags & XVID_MODEDECISION_BITS))) { |
if ((Data->chroma) && (!(VopFlags & XVID_VOP_MODEDECISION_BITS))) { |
1401 |
// chroma is only used for comparsion to INTER. if the comparsion will be done in BITS domain, there is no reason to compute it |
// chroma is only used for comparsion to INTER. if the comparsion will be done in BITS domain, there is no reason to compute it |
1402 |
int sumx = 0, sumy = 0; |
int sumx = 0, sumy = 0; |
1403 |
const int div = 1 + Data->qpel; |
const int div = 1 + Data->qpel; |
1472 |
|
|
1473 |
*(Data->iMinSAD) += (Data->lambda8 * i * (*Data->iMinSAD + NEIGH_8X8_BIAS))>>10; |
*(Data->iMinSAD) += (Data->lambda8 * i * (*Data->iMinSAD + NEIGH_8X8_BIAS))>>10; |
1474 |
|
|
1475 |
if (MotionFlags & (PMV_EXTSEARCH8|PMV_HALFPELREFINE8|PMV_QUARTERPELREFINE8)) { |
if (MotionFlags & (XVID_ME_EXTSEARCH8|XVID_ME_HALFPELREFINE8|XVID_ME_QUARTERPELREFINE8)) { |
1476 |
if (Data->rrv) i = 2; else i = 1; |
if (Data->rrv) i = 2; else i = 1; |
1477 |
|
|
1478 |
Data->Ref = OldData->Ref + i * 8 * ((block&1) + Data->iEdgedWidth*(block>>1)); |
Data->Ref = OldData->Ref + i * 8 * ((block&1) + Data->iEdgedWidth*(block>>1)); |
1489 |
if (!Data->rrv) CheckCandidate = CheckCandidate8; |
if (!Data->rrv) CheckCandidate = CheckCandidate8; |
1490 |
else CheckCandidate = CheckCandidate16no4v; |
else CheckCandidate = CheckCandidate16no4v; |
1491 |
|
|
1492 |
if (MotionFlags & PMV_EXTSEARCH8 && (!(MotionFlags & EXTSEARCH_BITS))) { |
if (MotionFlags & XVID_ME_EXTSEARCH8 && (!(MotionFlags & XVID_ME_EXTSEARCH_BITS))) { |
1493 |
int32_t temp_sad = *(Data->iMinSAD); // store current MinSAD |
int32_t temp_sad = *(Data->iMinSAD); // store current MinSAD |
1494 |
|
|
1495 |
MainSearchFunc *MainSearchPtr; |
MainSearchFunc *MainSearchPtr; |
1496 |
if (MotionFlags & PMV_USESQUARES8) MainSearchPtr = SquareSearch; |
if (MotionFlags & XVID_ME_USESQUARES8) MainSearchPtr = SquareSearch; |
1497 |
else if (MotionFlags & PMV_ADVANCEDDIAMOND8) MainSearchPtr = AdvDiamondSearch; |
else if (MotionFlags & XVID_ME_ADVANCEDDIAMOND8) MainSearchPtr = AdvDiamondSearch; |
1498 |
else MainSearchPtr = DiamondSearch; |
else MainSearchPtr = DiamondSearch; |
1499 |
|
|
1500 |
MainSearchPtr(Data->currentMV->x, Data->currentMV->y, Data, 255); |
MainSearchPtr(Data->currentMV->x, Data->currentMV->y, Data, 255); |
1505 |
} |
} |
1506 |
} |
} |
1507 |
|
|
1508 |
if (MotionFlags & PMV_HALFPELREFINE8) { |
if (MotionFlags & XVID_ME_HALFPELREFINE8) { |
1509 |
int32_t temp_sad = *(Data->iMinSAD); // store current MinSAD |
int32_t temp_sad = *(Data->iMinSAD); // store current MinSAD |
1510 |
|
|
1511 |
SubpelRefine(Data); // perform halfpel refine of current best vector |
SubpelRefine(Data); // perform halfpel refine of current best vector |
1516 |
} |
} |
1517 |
} |
} |
1518 |
|
|
1519 |
if (Data->qpel && MotionFlags & PMV_QUARTERPELREFINE8) { |
if (Data->qpel && MotionFlags & XVID_ME_QUARTERPELREFINE8) { |
1520 |
Data->qpel_precision = 1; |
Data->qpel_precision = 1; |
1521 |
get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 8, |
get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 8, |
1522 |
pParam->width, pParam->height, Data->iFcode, 1, 0); |
pParam->width, pParam->height, Data->iFcode, 1, 0); |
1640 |
CheckCandidate16no4v(pmv[i].x, pmv[i].y, mask, &iDirection, Data); |
CheckCandidate16no4v(pmv[i].x, pmv[i].y, mask, &iDirection, Data); |
1641 |
} |
} |
1642 |
|
|
1643 |
if (MotionFlags & PMV_USESQUARES16) MainSearchPtr = SquareSearch; |
if (MotionFlags & XVID_ME_USESQUARES16) MainSearchPtr = SquareSearch; |
1644 |
else if (MotionFlags & PMV_ADVANCEDDIAMOND16) MainSearchPtr = AdvDiamondSearch; |
else if (MotionFlags & XVID_ME_ADVANCEDDIAMOND16) MainSearchPtr = AdvDiamondSearch; |
1645 |
else MainSearchPtr = DiamondSearch; |
else MainSearchPtr = DiamondSearch; |
1646 |
|
|
1647 |
MainSearchPtr(Data->currentMV->x, Data->currentMV->y, Data, iDirection); |
MainSearchPtr(Data->currentMV->x, Data->currentMV->y, Data, iDirection); |
1817 |
// DIRECT MODE DELTA VECTOR SEARCH. |
// DIRECT MODE DELTA VECTOR SEARCH. |
1818 |
// This has to be made more effective, but at the moment I'm happy it's running at all |
// This has to be made more effective, but at the moment I'm happy it's running at all |
1819 |
|
|
1820 |
if (MotionFlags & PMV_USESQUARES16) MainSearchPtr = SquareSearch; |
if (MotionFlags & XVID_ME_USESQUARES16) MainSearchPtr = SquareSearch; |
1821 |
else if (MotionFlags & PMV_ADVANCEDDIAMOND16) MainSearchPtr = AdvDiamondSearch; |
else if (MotionFlags & XVID_ME_ADVANCEDDIAMOND16) MainSearchPtr = AdvDiamondSearch; |
1822 |
else MainSearchPtr = DiamondSearch; |
else MainSearchPtr = DiamondSearch; |
1823 |
|
|
1824 |
MainSearchPtr(0, 0, Data, 255); |
MainSearchPtr(0, 0, Data, 255); |
2027 |
Data.currentMV = currentMV; Data.currentQMV = currentQMV; |
Data.currentMV = currentMV; Data.currentQMV = currentQMV; |
2028 |
Data.iMinSAD = &iMinSAD; |
Data.iMinSAD = &iMinSAD; |
2029 |
Data.lambda16 = lambda_vec16[frame->quant]; |
Data.lambda16 = lambda_vec16[frame->quant]; |
2030 |
Data.qpel = pParam->vol_flags & XVID_QUARTERPEL; |
Data.qpel = pParam->vol_flags & XVID_VOL_QUARTERPEL; |
2031 |
Data.rounding = 0; |
Data.rounding = 0; |
2032 |
Data.chroma = frame->motion_flags & PMV_CHROMA8; |
Data.chroma = frame->motion_flags & XVID_ME_CHROMA8; |
2033 |
Data.temp = temp; |
Data.temp = temp; |
2034 |
|
|
2035 |
Data.RefQ = f_refV->u; // a good place, also used in MC (for similar purpose) |
Data.RefQ = f_refV->u; // a good place, also used in MC (for similar purpose) |
2151 |
else Data->predMV = get_pmv2(pMBs, pParam->mb_width, 0, x, y, 0); //else median |
else Data->predMV = get_pmv2(pMBs, pParam->mb_width, 0, x, y, 0); //else median |
2152 |
|
|
2153 |
get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 16, |
get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 16, |
2154 |
pParam->width, pParam->height, Data->iFcode - (pParam->vol_flags&XVID_QUARTERPEL?1:0), 0, Data->rrv); |
pParam->width, pParam->height, Data->iFcode - (pParam->vol_flags&XVID_VOL_QUARTERPEL?1:0), 0, Data->rrv); |
2155 |
|
|
2156 |
Data->Cur = pCur + (x + y * pParam->edged_width) * 16; |
Data->Cur = pCur + (x + y * pParam->edged_width) * 16; |
2157 |
Data->Ref = pRef + (x + y * pParam->edged_width) * 16; |
Data->Ref = pRef + (x + y * pParam->edged_width) * 16; |
2208 |
Data.currentMV = currentMV; |
Data.currentMV = currentMV; |
2209 |
Data.iMinSAD = iMinSAD; |
Data.iMinSAD = iMinSAD; |
2210 |
Data.iFcode = Current->fcode; |
Data.iFcode = Current->fcode; |
2211 |
Data.rrv = Current->vop_flags & XVID_REDUCED; |
Data.rrv = Current->vop_flags & XVID_VOP_REDUCED; |
2212 |
Data.temp = temp; |
Data.temp = temp; |
2213 |
CheckCandidate = CheckCandidate32I; |
CheckCandidate = CheckCandidate32I; |
2214 |
|
|
2462 |
if (Data->temp[0] == 0 && Data->temp[1] == 0 && Data->temp[2] == 0 && Data->temp[3] == 0) |
if (Data->temp[0] == 0 && Data->temp[1] == 0 && Data->temp[2] == 0 && Data->temp[3] == 0) |
2463 |
return 0; //quick stop |
return 0; //quick stop |
2464 |
|
|
2465 |
if (MotionFlags & (HALFPELREFINE16_BITS | EXTSEARCH_BITS)) { //we have to prepare for halfpixel-precision search |
if (MotionFlags & (XVID_ME_HALFPELREFINE16_BITS | XVID_ME_EXTSEARCH_BITS)) { //we have to prepare for halfpixel-precision search |
2466 |
for(i = 0; i < 5; i++) bsad[i] = Data->iMinSAD[i]; |
for(i = 0; i < 5; i++) bsad[i] = Data->iMinSAD[i]; |
2467 |
get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 16, |
get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 16, |
2468 |
pParam->width, pParam->height, Data->iFcode - Data->qpel, 0, Data->rrv); |
pParam->width, pParam->height, Data->iFcode - Data->qpel, 0, Data->rrv); |
2480 |
} |
} |
2481 |
} |
} |
2482 |
|
|
2483 |
if (MotionFlags&EXTSEARCH_BITS) SquareSearch(Data->currentMV->x, Data->currentMV->y, Data, iDirection); |
if (MotionFlags&XVID_ME_EXTSEARCH_BITS) SquareSearch(Data->currentMV->x, Data->currentMV->y, Data, iDirection); |
2484 |
|
|
2485 |
if (MotionFlags&HALFPELREFINE16_BITS) SubpelRefine(Data); |
if (MotionFlags&XVID_ME_HALFPELREFINE16_BITS) SubpelRefine(Data); |
2486 |
|
|
2487 |
if (Data->qpel) { |
if (Data->qpel) { |
2488 |
if (MotionFlags&(EXTSEARCH_BITS | HALFPELREFINE16_BITS)) { // there was halfpel-precision search |
if (MotionFlags&(XVID_ME_EXTSEARCH_BITS | XVID_ME_HALFPELREFINE16_BITS)) { // there was halfpel-precision search |
2489 |
for(i = 0; i < 5; i++) if (bsad[i] > Data->iMinSAD[i]) { |
for(i = 0; i < 5; i++) if (bsad[i] > Data->iMinSAD[i]) { |
2490 |
Data->currentQMV[i].x = 2 * Data->currentMV[i].x; // we have found a better match |
Data->currentQMV[i].x = 2 * Data->currentMV[i].x; // we have found a better match |
2491 |
Data->currentQMV[i].y = 2 * Data->currentMV[i].y; |
Data->currentQMV[i].y = 2 * Data->currentMV[i].y; |
2496 |
get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 16, |
get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 16, |
2497 |
pParam->width, pParam->height, Data->iFcode, 1, 0); |
pParam->width, pParam->height, Data->iFcode, 1, 0); |
2498 |
} |
} |
2499 |
if (MotionFlags&QUARTERPELREFINE16_BITS) SubpelRefine(Data); |
if (MotionFlags&XVID_ME_QUARTERPELREFINE16_BITS) SubpelRefine(Data); |
2500 |
} |
} |
2501 |
|
|
2502 |
if (MotionFlags&CHECKPREDICTION_BITS) { //let's check vector equal to prediction |
if (MotionFlags&XVID_ME_CHECKPREDICTION_BITS) { //let's check vector equal to prediction |
2503 |
VECTOR * v = Data->qpel ? Data->currentQMV : Data->currentMV; |
VECTOR * v = Data->qpel ? Data->currentQMV : Data->currentMV; |
2504 |
if (!(Data->predMV.x == v->x && Data->predMV.y == v->y)) |
if (!(Data->predMV.x == v->x && Data->predMV.y == v->y)) |
2505 |
CheckCandidateBits16(Data->predMV.x, Data->predMV.y, 255, &iDirection, Data); |
CheckCandidateBits16(Data->predMV.x, Data->predMV.y, 255, &iDirection, Data); |
2560 |
} |
} |
2561 |
|
|
2562 |
if (Data8->qpel) { |
if (Data8->qpel) { |
2563 |
if (MotionFlags&HALFPELREFINE8_BITS || (MotionFlags&PMV_EXTSEARCH8 && MotionFlags&EXTSEARCH_BITS)) { // halfpixel motion search follows |
if (MotionFlags&XVID_ME_HALFPELREFINE8_BITS || (MotionFlags&XVID_ME_EXTSEARCH8 && MotionFlags&XVID_ME_EXTSEARCH_BITS)) { // halfpixel motion search follows |
2564 |
int32_t s = *Data8->iMinSAD; |
int32_t s = *Data8->iMinSAD; |
2565 |
Data8->currentMV->x = Data8->currentQMV->x/2; |
Data8->currentMV->x = Data8->currentQMV->x/2; |
2566 |
Data8->currentMV->y = Data8->currentQMV->y/2; |
Data8->currentMV->y = Data8->currentQMV->y/2; |
2571 |
if (Data8->currentQMV->x & 1 || Data8->currentQMV->y & 1) |
if (Data8->currentQMV->x & 1 || Data8->currentQMV->y & 1) |
2572 |
CheckCandidateBits8(Data8->currentMV->x, Data8->currentMV->y, 255, &iDirection, Data8); |
CheckCandidateBits8(Data8->currentMV->x, Data8->currentMV->y, 255, &iDirection, Data8); |
2573 |
|
|
2574 |
if (MotionFlags & PMV_EXTSEARCH8 && MotionFlags & EXTSEARCH_BITS) |
if (MotionFlags & XVID_ME_EXTSEARCH8 && MotionFlags & XVID_ME_EXTSEARCH_BITS) |
2575 |
SquareSearch(Data8->currentMV->x, Data8->currentMV->x, Data8, 255); |
SquareSearch(Data8->currentMV->x, Data8->currentMV->x, Data8, 255); |
2576 |
|
|
2577 |
if (MotionFlags & HALFPELREFINE8_BITS) SubpelRefine(Data8); |
if (MotionFlags & XVID_ME_HALFPELREFINE8_BITS) SubpelRefine(Data8); |
2578 |
|
|
2579 |
if(s > *Data8->iMinSAD) { //we have found a better match |
if(s > *Data8->iMinSAD) { //we have found a better match |
2580 |
Data8->currentQMV->x = 2*Data8->currentMV->x; |
Data8->currentQMV->x = 2*Data8->currentMV->x; |
2586 |
pParam->width, pParam->height, Data8->iFcode, 1, 0); |
pParam->width, pParam->height, Data8->iFcode, 1, 0); |
2587 |
|
|
2588 |
} |
} |
2589 |
if (MotionFlags & QUARTERPELREFINE8_BITS) SubpelRefine(Data8); |
if (MotionFlags & XVID_ME_QUARTERPELREFINE8_BITS) SubpelRefine(Data8); |
2590 |
|
|
2591 |
} else // not qpel |
} else // not qpel |
2592 |
if (MotionFlags & HALFPELREFINE8_BITS) SubpelRefine(Data8); //halfpel mode, halfpel refinement |
if (MotionFlags & XVID_ME_HALFPELREFINE8_BITS) SubpelRefine(Data8); //halfpel mode, halfpel refinement |
2593 |
|
|
2594 |
//checking vector equal to predicion |
//checking vector equal to predicion |
2595 |
if (i != 0 && MotionFlags & CHECKPREDICTION_BITS) { |
if (i != 0 && MotionFlags & XVID_ME_CHECKPREDICTION_BITS) { |
2596 |
const VECTOR * v = Data->qpel ? Data8->currentQMV : Data8->currentMV; |
const VECTOR * v = Data->qpel ? Data8->currentQMV : Data8->currentMV; |
2597 |
if (!(Data8->predMV.x == v->x && Data8->predMV.y == v->y)) |
if (!(Data8->predMV.x == v->x && Data8->predMV.y == v->y)) |
2598 |
CheckCandidateBits8(Data8->predMV.x, Data8->predMV.y, 255, &iDirection, Data8); |
CheckCandidateBits8(Data8->predMV.x, Data8->predMV.y, 255, &iDirection, Data8); |