shithub: openh264

Download patch

ref: fcae0c7c48d9433f099f3e38174bf115d1ffba4e
parent: 74a92522e5b92e86e190c77649210c7b5f7bda20
author: sijchen <[email protected]>
date: Tue Mar 25 07:03:37 EDT 2014

Change the output of diamond search from qpel to interpel

--- a/codec/encoder/core/src/encoder_ext.cpp
+++ b/codec/encoder/core/src/encoder_ext.cpp
@@ -2523,6 +2523,8 @@
       pFuncList->pfCalculateSatd = CalculateSatdCost;
       pFuncList->pfInterFineMd = WelsMdInterFinePartition;
     }
+
+
   }
 }
 
--- a/codec/encoder/core/src/svc_motion_estimate.cpp
+++ b/codec/encoder/core/src/svc_motion_estimate.cpp
@@ -44,18 +44,18 @@
 
 namespace WelsSVCEnc {
 
-inline void UpdateMeResults( const SMVUnitXY ksBestMv, const uint32_t kiBestSadCost, uint8_t* pRef, SWelsME * pMe )
+static inline void UpdateMeResults( const SMVUnitXY ksBestMv, const uint32_t kiBestSadCost, uint8_t* pRef, SWelsME * pMe )
 {
   pMe->sMv = ksBestMv;
   pMe->pRefMb = pRef;
   pMe->uiSadCost = kiBestSadCost;
 }
-inline void SvcMeEndSearch( SWelsME * pMe, const uint32_t kuiBestSadCost )
+static inline void MeEndIntepelSearch( SWelsME * pMe )
 {
     /* -> qpel mv */
     pMe->sMv.iMvX <<= 2;
     pMe->sMv.iMvY <<= 2;
-    pMe->uiSatdCost = kuiBestSadCost;
+    pMe->uiSatdCost = pMe->uiSadCost;
 }
 
 
@@ -78,6 +78,7 @@
   //  Step 1: Initial point prediction
   if ( !WelsMotionEstimateInitialPoint (pFuncList, pMe, pSlice, iStrideEnc, iStrideRef) ) {
     WelsMotionEstimateIterativeSearch (pFuncList, pMe, iStrideEnc, iStrideRef, pMe->pRefMb);
+    MeEndIntepelSearch(pMe);
   }
 
   pFuncList->pfCalculateSatd( pFuncList->sSampleDealingFuncs.pfSampleSatd[pMe->uiPixel], pMe, iStrideEnc, iStrideRef );
@@ -151,7 +152,7 @@
   UpdateMeResults( sMv, iBestSadCost, pRefMb, pMe );
   if ( iBestSadCost < static_cast<int32_t>(pMe->uSadPredISatd.uiSadPred) ) {
     //Initial point early Stop
-    SvcMeEndSearch(pMe, iBestSadCost);
+    MeEndIntepelSearch(pMe);
     return true;
   }
   return false;
@@ -226,9 +227,9 @@
 
   }
 
-  /* -> qpel mv */
-  pMe->sMv.iMvX = (iMvDx + pMe->sMvp.iMvX) & 0xFFFC;
-  pMe->sMv.iMvY = (iMvDy + pMe->sMvp.iMvY) & 0xFFFC;
+  /* integer-pel mv */
+  pMe->sMv.iMvX = (iMvDx + pMe->sMvp.iMvX) >>2;
+  pMe->sMv.iMvY = (iMvDy + pMe->sMvp.iMvY) >>2;
   pMe->uiSatdCost = pMe->uiSadCost = (iBestCost);
   pMe->pRefMb = pRefMb;
 }
--- a/test/EncUT_MotionEstimate.cpp
+++ b/test/EncUT_MotionEstimate.cpp
@@ -114,7 +114,7 @@
 
       //the last selection may be affected by MVDcost, that is when (0,0) will be better
       //when comparing (1,1) and (1,0), due to the difference between MVD cost, it is possible that (1,0) is selected while the best match is (1,1)
-      bFoundMatch = ((sMe.sMv.iMvX==(sTargetMv.iMvX*4))||(sMe.sMv.iMvX==0)) && ((sMe.sMv.iMvY==(sTargetMv.iMvY*4))||(sMe.sMv.iMvY==0));
+      bFoundMatch = ((sMe.sMv.iMvX==(sTargetMv.iMvX))||(sMe.sMv.iMvX==0)) && ((sMe.sMv.iMvY==(sTargetMv.iMvY))||(sMe.sMv.iMvY==0));
     }
     if (bDataGeneratorSucceed) {
       //if DataGenerator never succeed, there is no meaning to check iTryTimes