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_pvop.c,v 1.15 2005-03-04 22:13:33 Isibaar Exp $ |
* $Id: estimation_pvop.c,v 1.16 2005-03-14 00:47:08 Isibaar Exp $ |
25 |
* |
* |
26 |
****************************************************************************/ |
****************************************************************************/ |
27 |
|
|
41 |
#include "motion_inlines.h" |
#include "motion_inlines.h" |
42 |
|
|
43 |
static const int xvid_me_lambda_vec8[32] = |
static const int xvid_me_lambda_vec8[32] = |
44 |
{ 0 ,(int)(1.00235 * NEIGH_TEND_8X8 + 0.5), |
{ 0 ,(int)(1.0 * NEIGH_TEND_8X8 + 0.5), |
45 |
(int)(1.15582*NEIGH_TEND_8X8 + 0.5), (int)(1.31976*NEIGH_TEND_8X8 + 0.5), |
(int)(2.0*NEIGH_TEND_8X8 + 0.5), (int)(3.0*NEIGH_TEND_8X8 + 0.5), |
46 |
(int)(1.49591*NEIGH_TEND_8X8 + 0.5), (int)(1.68601*NEIGH_TEND_8X8 + 0.5), |
(int)(4.0*NEIGH_TEND_8X8 + 0.5), (int)(5.0*NEIGH_TEND_8X8 + 0.5), |
47 |
(int)(1.89187*NEIGH_TEND_8X8 + 0.5), (int)(2.11542*NEIGH_TEND_8X8 + 0.5), |
(int)(6.0*NEIGH_TEND_8X8 + 0.5), (int)(7.0*NEIGH_TEND_8X8 + 0.5), |
48 |
(int)(2.35878*NEIGH_TEND_8X8 + 0.5), (int)(2.62429*NEIGH_TEND_8X8 + 0.5), |
(int)(8.0*NEIGH_TEND_8X8 + 0.5), (int)(9.0*NEIGH_TEND_8X8 + 0.5), |
49 |
(int)(2.91455*NEIGH_TEND_8X8 + 0.5), (int)(3.23253*NEIGH_TEND_8X8 + 0.5), |
(int)(10.0*NEIGH_TEND_8X8 + 0.5), (int)(11.0*NEIGH_TEND_8X8 + 0.5), |
50 |
(int)(3.58158*NEIGH_TEND_8X8 + 0.5), (int)(3.96555*NEIGH_TEND_8X8 + 0.5), |
(int)(12.0*NEIGH_TEND_8X8 + 0.5), (int)(13.0*NEIGH_TEND_8X8 + 0.5), |
51 |
(int)(4.38887*NEIGH_TEND_8X8 + 0.5), (int)(4.85673*NEIGH_TEND_8X8 + 0.5), |
(int)(14.0*NEIGH_TEND_8X8 + 0.5), (int)(15.0*NEIGH_TEND_8X8 + 0.5), |
52 |
(int)(5.37519*NEIGH_TEND_8X8 + 0.5), (int)(5.95144*NEIGH_TEND_8X8 + 0.5), |
(int)(16.0*NEIGH_TEND_8X8 + 0.5), (int)(17.0*NEIGH_TEND_8X8 + 0.5), |
53 |
(int)(6.59408*NEIGH_TEND_8X8 + 0.5), (int)(7.31349*NEIGH_TEND_8X8 + 0.5), |
(int)(18.0*NEIGH_TEND_8X8 + 0.5), (int)(19.0*NEIGH_TEND_8X8 + 0.5), |
54 |
(int)(8.12242*NEIGH_TEND_8X8 + 0.5), (int)(9.03669*NEIGH_TEND_8X8 + 0.5), |
(int)(20.0*NEIGH_TEND_8X8 + 0.5), (int)(21.0*NEIGH_TEND_8X8 + 0.5), |
55 |
(int)(10.0763*NEIGH_TEND_8X8 + 0.5), (int)(11.2669*NEIGH_TEND_8X8 + 0.5), |
(int)(22.0*NEIGH_TEND_8X8 + 0.5), (int)(23.0*NEIGH_TEND_8X8 + 0.5), |
56 |
(int)(12.6426*NEIGH_TEND_8X8 + 0.5), (int)(14.2493*NEIGH_TEND_8X8 + 0.5), |
(int)(24.0*NEIGH_TEND_8X8 + 0.5), (int)(25.0*NEIGH_TEND_8X8 + 0.5), |
57 |
(int)(16.1512*NEIGH_TEND_8X8 + 0.5), (int)(18.442*NEIGH_TEND_8X8 + 0.5), |
(int)(26.0*NEIGH_TEND_8X8 + 0.5), (int)(27.0*NEIGH_TEND_8X8 + 0.5), |
58 |
(int)(21.2656*NEIGH_TEND_8X8 + 0.5), (int)(24.8580*NEIGH_TEND_8X8 + 0.5), |
(int)(28.0*NEIGH_TEND_8X8 + 0.5), (int)(29.0*NEIGH_TEND_8X8 + 0.5), |
59 |
(int)(29.6436*NEIGH_TEND_8X8 + 0.5), (int)(36.4949*NEIGH_TEND_8X8 + 0.5) |
(int)(30.0*NEIGH_TEND_8X8 + 0.5), (int)(31.0*NEIGH_TEND_8X8 + 0.5) |
60 |
}; |
}; |
61 |
|
|
62 |
static void |
static void |
82 |
sad = sad16v(data->Cur, Reference, data->iEdgedWidth, data->temp); |
sad = sad16v(data->Cur, Reference, data->iEdgedWidth, data->temp); |
83 |
t = d_mv_bits(x, y, data->predMV, data->iFcode, data->qpel^data->qpel_precision); |
t = d_mv_bits(x, y, data->predMV, data->iFcode, data->qpel^data->qpel_precision); |
84 |
|
|
85 |
sad += (data->lambda16 * t * sad)>>10; |
sad += (data->lambda16 * t); |
86 |
data->temp[0] += (data->lambda8 * t * (data->temp[0] + NEIGH_8X8_BIAS))>>10; |
data->temp[0] += (data->lambda8 * t); |
87 |
|
|
88 |
if (data->chroma) { |
if (data->chroma) { |
89 |
if (sad >= data->iMinSAD[0]) goto no16; |
if (sad >= data->iMinSAD[0]) goto no16; |
129 |
sad = sad8(data->Cur, Reference, data->iEdgedWidth); |
sad = sad8(data->Cur, Reference, data->iEdgedWidth); |
130 |
t = d_mv_bits(x, y, data->predMV, data->iFcode, data->qpel^data->qpel_precision); |
t = d_mv_bits(x, y, data->predMV, data->iFcode, data->qpel^data->qpel_precision); |
131 |
|
|
132 |
sad += (data->lambda8 * t * (sad+NEIGH_8X8_BIAS))>>10; |
sad += (data->lambda8 * t); |
133 |
|
|
134 |
if (sad < *(data->iMinSAD)) { |
if (sad < *(data->iMinSAD)) { |
135 |
*(data->iMinSAD) = sad; |
*(data->iMinSAD) = sad; |
423 |
Data->predMV, Data->iFcode, 0); |
Data->predMV, Data->iFcode, 0); |
424 |
} |
} |
425 |
|
|
426 |
*(Data->iMinSAD) += (Data->lambda8 * i * (*Data->iMinSAD + NEIGH_8X8_BIAS))>>10; |
*(Data->iMinSAD) += (Data->lambda8 * i); |
427 |
|
|
428 |
if (MotionFlags & (XVID_ME_EXTSEARCH8|XVID_ME_HALFPELREFINE8|XVID_ME_QUARTERPELREFINE8)) { |
if (MotionFlags & (XVID_ME_EXTSEARCH8|XVID_ME_HALFPELREFINE8|XVID_ME_QUARTERPELREFINE8)) { |
429 |
|
|
557 |
else Data->predMV = pmv[0]; |
else Data->predMV = pmv[0]; |
558 |
|
|
559 |
i = d_mv_bits(0, 0, Data->predMV, Data->iFcode, 0); |
i = d_mv_bits(0, 0, Data->predMV, Data->iFcode, 0); |
560 |
Data->iMinSAD[0] = pMB->sad16 + ((Data->lambda16 * i * pMB->sad16)>>10); |
Data->iMinSAD[0] = pMB->sad16 + (Data->lambda16 * i); |
561 |
Data->iMinSAD[1] = pMB->sad8[0] + ((Data->lambda8 * i * (pMB->sad8[0]+NEIGH_8X8_BIAS)) >> 10); |
Data->iMinSAD[1] = pMB->sad8[0] + (Data->lambda8 * i); |
562 |
Data->iMinSAD[2] = pMB->sad8[1]; |
Data->iMinSAD[2] = pMB->sad8[1]; |
563 |
Data->iMinSAD[3] = pMB->sad8[2]; |
Data->iMinSAD[3] = pMB->sad8[2]; |
564 |
Data->iMinSAD[4] = pMB->sad8[3]; |
Data->iMinSAD[4] = pMB->sad8[3]; |