2 |
* |
* |
3 |
* Modifications: |
* Modifications: |
4 |
* |
* |
5 |
|
* 22.04.2002 remove some compile warning by chenm001 <chenm001@163.com> |
6 |
* 14.04.2002 added MotionEstimationBVOP() |
* 14.04.2002 added MotionEstimationBVOP() |
7 |
* 02.04.2002 add EPZS(^2) as ME algorithm, use PMV_USESQUARES to choose between |
* 02.04.2002 add EPZS(^2) as ME algorithm, use PMV_USESQUARES to choose between |
8 |
* EPZS and EPZS^2 |
* EPZS and EPZS^2 |
907 |
iEdgedWidth, MV_MAX_ERROR); |
iEdgedWidth, MV_MAX_ERROR); |
908 |
iMinSAD += calc_delta_16(currMV->x-pmv[0].x, currMV->y-pmv[0].y, (uint8_t)iFcode) * iQuant; |
iMinSAD += calc_delta_16(currMV->x-pmv[0].x, currMV->y-pmv[0].y, (uint8_t)iFcode) * iQuant; |
909 |
|
|
910 |
if ( (iMinSAD < 256 ) || ( (MVequal(*currMV,pMB->mvs[0])) && (iMinSAD < pMB->sad16) ) ) |
if ( (iMinSAD < 256 ) || ( (MVequal(*currMV,pMB->mvs[0])) && ((uint32_t)iMinSAD < pMB->sad16) ) ) |
911 |
{ |
{ |
912 |
|
|
913 |
if (MotionFlags & PMV_QUICKSTOP16) |
if (MotionFlags & PMV_QUICKSTOP16) |
950 |
CHECK_MV16_CANDIDATE(pmv[2].x,pmv[2].y); |
CHECK_MV16_CANDIDATE(pmv[2].x,pmv[2].y); |
951 |
|
|
952 |
// top right neighbour, if allowed |
// top right neighbour, if allowed |
953 |
if (x != (iWcount-1)) |
if ((uint32_t)x != (iWcount-1)) |
954 |
{ |
{ |
955 |
if (!(MotionFlags & PMV_HALFPEL16 )) |
if (!(MotionFlags & PMV_HALFPEL16 )) |
956 |
{ pmv[3].x = EVEN(pmv[3].x); |
{ pmv[3].x = EVEN(pmv[3].x); |
964 |
If Motion Vector equal to Previous frame motion vector and MinSAD<PrevFrmSAD goto Step 10. |
If Motion Vector equal to Previous frame motion vector and MinSAD<PrevFrmSAD goto Step 10. |
965 |
*/ |
*/ |
966 |
|
|
967 |
if ( (iMinSAD <= threshA) || ( MVequal(*currMV,pMB->mvs[0]) && (iMinSAD < pMB->sad16) ) ) |
if ( (iMinSAD <= threshA) || ( MVequal(*currMV,pMB->mvs[0]) && ((uint32_t)iMinSAD < pMB->sad16) ) ) |
968 |
{ |
{ |
969 |
if (MotionFlags & PMV_QUICKSTOP16) |
if (MotionFlags & PMV_QUICKSTOP16) |
970 |
goto PMVfast16_Terminate_without_Refine; |
goto PMVfast16_Terminate_without_Refine; |
1258 |
iEdgedWidth); |
iEdgedWidth); |
1259 |
iMinSAD += calc_delta_8(currMV->x - pmv[0].x, currMV->y - pmv[0].y, (uint8_t)iFcode) * iQuant; |
iMinSAD += calc_delta_8(currMV->x - pmv[0].x, currMV->y - pmv[0].y, (uint8_t)iFcode) * iQuant; |
1260 |
|
|
1261 |
if ( (iMinSAD < 256/4 ) || ( (MVequal(*currMV,pMB->mvs[iSubBlock])) && (iMinSAD < pMB->sad8[iSubBlock]) ) ) |
if ( (iMinSAD < 256/4 ) || ( (MVequal(*currMV,pMB->mvs[iSubBlock])) && ((uint32_t)iMinSAD < pMB->sad8[iSubBlock]) ) ) |
1262 |
{ |
{ |
1263 |
if (MotionFlags & PMV_QUICKSTOP16) |
if (MotionFlags & PMV_QUICKSTOP16) |
1264 |
goto PMVfast8_Terminate_without_Refine; |
goto PMVfast8_Terminate_without_Refine; |
1317 |
If Motion Vector equal to Previous frame motion vector and MinSAD<PrevFrmSAD goto Step 10. |
If Motion Vector equal to Previous frame motion vector and MinSAD<PrevFrmSAD goto Step 10. |
1318 |
*/ |
*/ |
1319 |
|
|
1320 |
if ( (iMinSAD <= threshA) || ( MVequal(*currMV,pMB->mvs[iSubBlock]) && (iMinSAD < pMB->sad8[iSubBlock]) ) ) |
if ( (iMinSAD <= threshA) || ( MVequal(*currMV,pMB->mvs[iSubBlock]) && ((uint32_t)iMinSAD < pMB->sad8[iSubBlock]) ) ) |
1321 |
{ |
{ |
1322 |
if (MotionFlags & PMV_QUICKSTOP16) |
if (MotionFlags & PMV_QUICKSTOP16) |
1323 |
goto PMVfast8_Terminate_without_Refine; |
goto PMVfast8_Terminate_without_Refine; |
1498 |
iMinSAD += calc_delta_16(currMV->x-pmv[0].x, currMV->y-pmv[0].y, (uint8_t)iFcode) * iQuant; |
iMinSAD += calc_delta_16(currMV->x-pmv[0].x, currMV->y-pmv[0].y, (uint8_t)iFcode) * iQuant; |
1499 |
|
|
1500 |
// thresh1 is fixed to 256 |
// thresh1 is fixed to 256 |
1501 |
if ( (iMinSAD < 256 ) || ( (MVequal(*currMV,pMB->mvs[0])) && (iMinSAD < pMB->sad16) ) ) |
if ( (iMinSAD < 256 ) || ( (MVequal(*currMV,pMB->mvs[0])) && ((uint32_t)iMinSAD < pMB->sad16) ) ) |
1502 |
{ |
{ |
1503 |
if (MotionFlags & PMV_QUICKSTOP16) |
if (MotionFlags & PMV_QUICKSTOP16) |
1504 |
goto EPZS16_Terminate_without_Refine; |
goto EPZS16_Terminate_without_Refine; |
1550 |
CHECK_MV16_CANDIDATE(pmv[2].x,pmv[2].y); |
CHECK_MV16_CANDIDATE(pmv[2].x,pmv[2].y); |
1551 |
|
|
1552 |
// top right neighbour, if allowed |
// top right neighbour, if allowed |
1553 |
if (x != (iWcount-1)) |
if ((uint32_t)x != (iWcount-1)) |
1554 |
{ |
{ |
1555 |
if (!(MotionFlags & PMV_HALFPEL16 )) |
if (!(MotionFlags & PMV_HALFPEL16 )) |
1556 |
{ pmv[3].x = EVEN(pmv[3].x); |
{ pmv[3].x = EVEN(pmv[3].x); |
1565 |
*/ |
*/ |
1566 |
|
|
1567 |
if ( (iMinSAD <= thresh2) |
if ( (iMinSAD <= thresh2) |
1568 |
|| ( MVequal(*currMV,pMB->mvs[0]) && (iMinSAD <= pMB->sad16) ) ) |
|| ( MVequal(*currMV,pMB->mvs[0]) && ((uint32_t)iMinSAD <= pMB->sad16) ) ) |
1569 |
{ |
{ |
1570 |
if (MotionFlags & PMV_QUICKSTOP16) |
if (MotionFlags & PMV_QUICKSTOP16) |
1571 |
goto EPZS16_Terminate_without_Refine; |
goto EPZS16_Terminate_without_Refine; |
1591 |
|
|
1592 |
// right neighbour, if allowed (this value is not written yet, so take it from pMB->mvs |
// right neighbour, if allowed (this value is not written yet, so take it from pMB->mvs |
1593 |
|
|
1594 |
if (x != iWcount-1) |
if ((uint32_t)x != iWcount-1) |
1595 |
CHECK_MV16_CANDIDATE((pMB+1)->mvs[0].x,oldMB->mvs[0].y); |
CHECK_MV16_CANDIDATE((pMB+1)->mvs[0].x,oldMB->mvs[0].y); |
1596 |
|
|
1597 |
// bottom neighbour, dito |
// bottom neighbour, dito |
1598 |
if (y != iHcount-1) |
if ((uint32_t)y != iHcount-1) |
1599 |
CHECK_MV16_CANDIDATE((pMB+iWcount)->mvs[0].x,oldMB->mvs[0].y); |
CHECK_MV16_CANDIDATE((pMB+iWcount)->mvs[0].x,oldMB->mvs[0].y); |
1600 |
|
|
1601 |
/* Terminate if MinSAD <= T_3 (here T_3 = T_2) */ |
/* Terminate if MinSAD <= T_3 (here T_3 = T_2) */ |