55 |
{ 0, 1, 0, 0 }; |
{ 0, 1, 0, 0 }; |
56 |
|
|
57 |
const int xvid_me_lambda_vec16[32] = |
const int xvid_me_lambda_vec16[32] = |
58 |
{ 0 ,(int)(1.00235 * NEIGH_TEND_16X16 + 0.5), |
{ 0 ,(int)(1.0 * NEIGH_TEND_16X16 + 0.5), |
59 |
(int)(1.15582*NEIGH_TEND_16X16 + 0.5), (int)(1.31976*NEIGH_TEND_16X16 + 0.5), |
(int)(2.0*NEIGH_TEND_16X16 + 0.5), (int)(3.0*NEIGH_TEND_16X16 + 0.5), |
60 |
(int)(1.49591*NEIGH_TEND_16X16 + 0.5), (int)(1.68601*NEIGH_TEND_16X16 + 0.5), |
(int)(4.0*NEIGH_TEND_16X16 + 0.5), (int)(5.0*NEIGH_TEND_16X16 + 0.5), |
61 |
(int)(1.89187*NEIGH_TEND_16X16 + 0.5), (int)(2.11542*NEIGH_TEND_16X16 + 0.5), |
(int)(6.0*NEIGH_TEND_16X16 + 0.5), (int)(7.0*NEIGH_TEND_16X16 + 0.5), |
62 |
(int)(2.35878*NEIGH_TEND_16X16 + 0.5), (int)(2.62429*NEIGH_TEND_16X16 + 0.5), |
(int)(8.0*NEIGH_TEND_16X16 + 0.5), (int)(9.0*NEIGH_TEND_16X16 + 0.5), |
63 |
(int)(2.91455*NEIGH_TEND_16X16 + 0.5), (int)(3.23253*NEIGH_TEND_16X16 + 0.5), |
(int)(10.0*NEIGH_TEND_16X16 + 0.5), (int)(11.0*NEIGH_TEND_16X16 + 0.5), |
64 |
(int)(3.58158*NEIGH_TEND_16X16 + 0.5), (int)(3.96555*NEIGH_TEND_16X16 + 0.5), |
(int)(12.0*NEIGH_TEND_16X16 + 0.5), (int)(13.0*NEIGH_TEND_16X16 + 0.5), |
65 |
(int)(4.38887*NEIGH_TEND_16X16 + 0.5), (int)(4.85673*NEIGH_TEND_16X16 + 0.5), |
(int)(14.0*NEIGH_TEND_16X16 + 0.5), (int)(15.0*NEIGH_TEND_16X16 + 0.5), |
66 |
(int)(5.37519*NEIGH_TEND_16X16 + 0.5), (int)(5.95144*NEIGH_TEND_16X16 + 0.5), |
(int)(16.0*NEIGH_TEND_16X16 + 0.5), (int)(17.0*NEIGH_TEND_16X16 + 0.5), |
67 |
(int)(6.59408*NEIGH_TEND_16X16 + 0.5), (int)(7.31349*NEIGH_TEND_16X16 + 0.5), |
(int)(18.0*NEIGH_TEND_16X16 + 0.5), (int)(19.0*NEIGH_TEND_16X16 + 0.5), |
68 |
(int)(8.12242*NEIGH_TEND_16X16 + 0.5), (int)(9.03669*NEIGH_TEND_16X16 + 0.5), |
(int)(20.0*NEIGH_TEND_16X16 + 0.5), (int)(21.0*NEIGH_TEND_16X16 + 0.5), |
69 |
(int)(10.0763*NEIGH_TEND_16X16 + 0.5), (int)(11.2669*NEIGH_TEND_16X16 + 0.5), |
(int)(22.0*NEIGH_TEND_16X16 + 0.5), (int)(23.0*NEIGH_TEND_16X16 + 0.5), |
70 |
(int)(12.6426*NEIGH_TEND_16X16 + 0.5), (int)(14.2493*NEIGH_TEND_16X16 + 0.5), |
(int)(24.0*NEIGH_TEND_16X16 + 0.5), (int)(25.0*NEIGH_TEND_16X16 + 0.5), |
71 |
(int)(16.1512*NEIGH_TEND_16X16 + 0.5), (int)(18.442*NEIGH_TEND_16X16 + 0.5), |
(int)(26.0*NEIGH_TEND_16X16 + 0.5), (int)(27.0*NEIGH_TEND_16X16 + 0.5), |
72 |
(int)(21.2656*NEIGH_TEND_16X16 + 0.5), (int)(24.8580*NEIGH_TEND_16X16 + 0.5), |
(int)(28.0*NEIGH_TEND_16X16 + 0.5), (int)(29.0*NEIGH_TEND_16X16 + 0.5), |
73 |
(int)(29.6436*NEIGH_TEND_16X16 + 0.5), (int)(36.4949*NEIGH_TEND_16X16 + 0.5) |
(int)(30.0*NEIGH_TEND_16X16 + 0.5), (int)(31.0*NEIGH_TEND_16X16 + 0.5) |
74 |
}; |
}; |
75 |
|
|
76 |
/***************************************************************************** |
/***************************************************************************** |
269 |
CHECK_CANDIDATE(x + iDiamondSize, y - iDiamondSize, 2 + 4); |
CHECK_CANDIDATE(x + iDiamondSize, y - iDiamondSize, 2 + 4); |
270 |
break; |
break; |
271 |
case 2 + 8: |
case 2 + 8: |
272 |
CHECK_CANDIDATE(x - iDiamondSize, y - iDiamondSize, 1 + 4); |
CHECK_CANDIDATE(x + iDiamondSize, y - iDiamondSize, 2 + 4); |
|
CHECK_CANDIDATE(x - iDiamondSize, y + iDiamondSize, 1 + 8); |
|
273 |
CHECK_CANDIDATE(x + iDiamondSize, y + iDiamondSize, 2 + 8); |
CHECK_CANDIDATE(x + iDiamondSize, y + iDiamondSize, 2 + 8); |
274 |
|
CHECK_CANDIDATE(x - iDiamondSize, y + iDiamondSize, 1 + 8); |
275 |
break; |
break; |
276 |
case 1 + 8: |
case 1 + 8: |
277 |
CHECK_CANDIDATE(x + iDiamondSize, y - iDiamondSize, 2 + 4); |
CHECK_CANDIDATE(x - iDiamondSize, y - iDiamondSize, 1 + 4); |
|
CHECK_CANDIDATE(x + iDiamondSize, y + iDiamondSize, 2 + 8); |
|
278 |
CHECK_CANDIDATE(x - iDiamondSize, y + iDiamondSize, 1 + 8); |
CHECK_CANDIDATE(x - iDiamondSize, y + iDiamondSize, 1 + 8); |
279 |
|
CHECK_CANDIDATE(x + iDiamondSize, y + iDiamondSize, 2 + 8); |
280 |
break; |
break; |
281 |
default: /* 1+2+4+8 == we didn't find anything at all */ |
default: /* 1+2+4+8 == we didn't find anything at all */ |
282 |
CHECK_CANDIDATE(x - iDiamondSize, y - iDiamondSize, 1 + 4); |
CHECK_CANDIDATE(x - iDiamondSize, y - iDiamondSize, 1 + 4); |
323 |
|
|
324 |
unsigned int * const iDirection = &data->dir; |
unsigned int * const iDirection = &data->dir; |
325 |
|
|
326 |
do { |
for (;;) { |
327 |
*iDirection = 0; |
*iDirection = 0; |
328 |
if (bDirection & 1) CHECK_CANDIDATE(x - iDiamondSize, y, 1); |
if (bDirection & 1) CHECK_CANDIDATE(x - iDiamondSize, y, 1); |
329 |
if (bDirection & 2) CHECK_CANDIDATE(x + iDiamondSize, y, 2); |
if (bDirection & 2) CHECK_CANDIDATE(x + iDiamondSize, y, 2); |
330 |
if (bDirection & 4) CHECK_CANDIDATE(x, y - iDiamondSize, 4); |
if (bDirection & 4) CHECK_CANDIDATE(x, y - iDiamondSize, 4); |
331 |
if (bDirection & 8) CHECK_CANDIDATE(x, y + iDiamondSize, 8); |
if (bDirection & 8) CHECK_CANDIDATE(x, y + iDiamondSize, 8); |
332 |
|
|
333 |
|
if (*iDirection == 0) |
334 |
|
break; |
335 |
|
|
336 |
/* now we're doing diagonal checks near our candidate */ |
/* now we're doing diagonal checks near our candidate */ |
337 |
bDirection = *iDirection; |
bDirection = *iDirection; |
|
if (*iDirection) { /* checking if anything found */ |
|
|
*iDirection = 0; |
|
338 |
x = data->currentMV->x; y = data->currentMV->y; |
x = data->currentMV->x; y = data->currentMV->y; |
339 |
if (bDirection & 3) { /* our candidate is left or right */ |
if (bDirection & 3) { /* our candidate is left or right */ |
340 |
CHECK_CANDIDATE(x, y + iDiamondSize, 8); |
CHECK_CANDIDATE(x, y + iDiamondSize, 8); |
343 |
CHECK_CANDIDATE(x + iDiamondSize, y, 2); |
CHECK_CANDIDATE(x + iDiamondSize, y, 2); |
344 |
CHECK_CANDIDATE(x - iDiamondSize, y, 1); |
CHECK_CANDIDATE(x - iDiamondSize, y, 1); |
345 |
} |
} |
346 |
bDirection += *iDirection; |
bDirection |= *iDirection; |
347 |
x = data->currentMV->x; y = data->currentMV->y; |
x = data->currentMV->x; y = data->currentMV->y; |
348 |
} |
} |
349 |
} |
} |
|
while (bDirection); |
|
|
} |
|
350 |
|
|
351 |
void |
void |
352 |
xvid_me_SubpelRefine(VECTOR centerMV, SearchData * const data, CheckFunc * const CheckCandidate, int dir) |
xvid_me_SubpelRefine(VECTOR centerMV, SearchData * const data, CheckFunc * const CheckCandidate, int dir) |
389 |
|
|
390 |
int xo = 2*data->currentMV[0].x, yo = 2*data->currentMV[0].y; |
int xo = 2*data->currentMV[0].x, yo = 2*data->currentMV[0].y; |
391 |
|
|
392 |
data->currentQMV[0].x = v_best.x = xo; |
data->currentQMV[0].x = v_best.x = v_best2.x = xo; |
393 |
data->currentQMV[0].y = v_best.y = yo; |
data->currentQMV[0].y = v_best.y = v_best2.y = yo; |
394 |
|
|
395 |
data->qpel_precision = 1; |
data->qpel_precision = 1; |
396 |
|
|
495 |
CHECK_CANDIDATE((xo+xo2)>>1, (yo+yo2)>>1, direction); |
CHECK_CANDIDATE((xo+xo2)>>1, (yo+yo2)>>1, direction); |
496 |
|
|
497 |
} |
} |
498 |
|
|
499 |
|
/* it's the positive max, so "32" needs fcode of 2, not 1 */ |
500 |
|
unsigned int |
501 |
|
getMinFcode(const int MVmax) |
502 |
|
{ |
503 |
|
unsigned int fcode; |
504 |
|
for (fcode = 1; (16 << fcode) <= MVmax; fcode++); |
505 |
|
return fcode; |
506 |
|
} |