ref: 8962b7c98baa809867d23d301665b9c0e99db10b
parent: 3d6fdfee3dfe9069e25fe32974fffe522484d47d
parent: d809a7981bf8d2d975228ddf1c419f8bb6d126e3
author: volvet <[email protected]>
date: Thu Mar 13 06:21:39 EDT 2014
Merge pull request #482 from sijchen/me_refactor1 mv range setting refactor
--- a/codec/encoder/core/inc/svc_motion_estimate.h
+++ b/codec/encoder/core/inc/svc_motion_estimate.h
@@ -130,5 +130,16 @@
bool WelsMeSadCostSelect (int32_t* pSadCost, const uint16_t* kpMvdCost, int32_t* pBestCost, const int32_t kiDx,
const int32_t kiDy, int32_t* pIx, int32_t* pIy);
+inline void SetMvWithinMvRange( const int32_t kiMbWidth, const int32_t kiMbHeight, const int32_t kiMbX, const int32_t kiMbY,
+ const int32_t kiMaxMvRange,
+ SMVUnitXY* pMvMin, SMVUnitXY* pMvMax)
+{
+ pMvMin->iMvX = WELS_MAX(-1*((kiMbX + 1)<<4) + INTPEL_NEEDED_MARGIN, -1*kiMaxMvRange);
+ pMvMin->iMvY = WELS_MAX(-1*((kiMbY + 1)<<4) + INTPEL_NEEDED_MARGIN, -1*kiMaxMvRange);
+ pMvMax->iMvX = WELS_MIN( ((kiMbWidth - kiMbX)<<4) - INTPEL_NEEDED_MARGIN, kiMaxMvRange);
+ pMvMax->iMvY = WELS_MIN( ((kiMbHeight - kiMbY)<<4) - INTPEL_NEEDED_MARGIN, kiMaxMvRange);
+}
+
+
}
#endif
--- a/codec/encoder/core/src/svc_base_layer_md.cpp
+++ b/codec/encoder/core/src/svc_base_layer_md.cpp
@@ -359,18 +359,7 @@
ST32 (&pCurMb->sP16x16Mv, 0);
ST32 (&pCurLayer->pDecPic->sMvList[kiMbXY], 0);
- pSlice->sMvMin.iMvX = -16 * (kiMbX + 1) + INTPEL_NEEDED_MARGIN;
- if (pSlice->sMvMin.iMvX < -MV_RANGE)
- pSlice->sMvMin.iMvX = -MV_RANGE;
- pSlice->sMvMin.iMvY = -16 * (kiMbY + 1) + INTPEL_NEEDED_MARGIN;
- if (pSlice->sMvMin.iMvY < -MV_RANGE)
- pSlice->sMvMin.iMvY = -MV_RANGE;
- pSlice->sMvMax.iMvX = 16 * (kiMbWidth - kiMbX) - INTPEL_NEEDED_MARGIN;
- if (pSlice->sMvMax.iMvX > MV_RANGE)
- pSlice->sMvMax.iMvX = MV_RANGE;
- pSlice->sMvMax.iMvY = 16 * (kiMbHeight - kiMbY) - INTPEL_NEEDED_MARGIN;
- if (pSlice->sMvMax.iMvY > MV_RANGE)
- pSlice->sMvMax.iMvY = MV_RANGE;
+ SetMvWithinMvRange( kiMbWidth, kiMbHeight, kiMbX, kiMbY, MV_RANGE, &(pSlice->sMvMin), &(pSlice->sMvMax));
}
int32_t WelsMdI16x16 (SWelsFuncPtrList* pFunc, SDqLayer* pCurDqLayer, SMbCache* pMbCache, int32_t iLambda) {