shithub: openh264

Download patch

ref: 3c3d4ef64b0f1cab1d510bc88a8d4718a5bd14d7
parent: ce0d371c98fa5150de31faa71d47ce000629943f
parent: bfa16ba8482735b7d9d76057d0708b7d9c68028c
author: ruil2 <[email protected]>
date: Tue May 27 06:05:18 EDT 2014

Merge pull request #897 from lyao2/blockidc

add blockstaticidc pointer for MD

--- a/codec/encoder/core/inc/svc_mode_decision.h
+++ b/codec/encoder/core/inc/svc_mode_decision.h
@@ -57,6 +57,7 @@
 
 SMB* GetRefMb (SDqLayer* pCurLayer, SMB* pCurMb);
 void SetMvBaseEnhancelayer (SWelsMD* pMd, SMB* pCurMb, const SMB* kpRefMb);
+void SetBlockStaticIdcToMd (void* pVaa, void* pMd, SMB* pCurMb, void* pDqLay);
 }
 #endif //SVC_MODE_DECISION_H
 
--- a/codec/encoder/core/inc/wels_preprocess.h
+++ b/codec/encoder/core/inc/wels_preprocess.h
@@ -74,6 +74,7 @@
   SPicture*   pRefPicture;
   int32_t     iSrcListIdx;   //idx in  h->spatial_pic[base_did];
   bool        bSceneLtrFlag;
+  unsigned char*		pBestBlockStaticIdc;
 } SRefInfoParam;
 
 typedef struct {
--- a/codec/encoder/core/src/svc_mode_decision.cpp
+++ b/codec/encoder/core/src/svc_mode_decision.cpp
@@ -153,15 +153,46 @@
   }
 }
 
+void SetBlockStaticIdcToMd (void* pVaa, void* pMd, SMB* pCurMb, void* pDqLay) { //TODO: OPT?
+  SVAAFrameInfoExt_t* pVaaExt = static_cast<SVAAFrameInfoExt_t*> (pVaa);
+  SWelsMD* pWelsMd = static_cast<SWelsMD*> (pMd);
+  SDqLayer* pDqLayer = static_cast<SDqLayer*> (pDqLay);
+
+  const int32_t kiMbX = pCurMb->iMbX;
+  const int32_t kiMbY = pCurMb->iMbY;
+  const int32_t kiMbWidth = pDqLayer->iMbWidth;
+  const int32_t kiWidth = kiMbWidth << 1;
+
+  const int32_t kiBlockIndexUp = (kiMbY << 1) * kiWidth + (kiMbX << 1);
+  const int32_t kiBlockIndexLow = ((kiMbY << 1) + 1) * kiWidth + (kiMbX << 1);
+
+  //fill_blockstaticidc with pVaaExt->pVaaBestBlockStaticIdc
+  pWelsMd->iBlock8x8StaticIdc[0] = pVaaExt->pVaaBestBlockStaticIdc[kiBlockIndexUp];
+  pWelsMd->iBlock8x8StaticIdc[1] = pVaaExt->pVaaBestBlockStaticIdc[kiBlockIndexUp + 1];
+  pWelsMd->iBlock8x8StaticIdc[2] = pVaaExt->pVaaBestBlockStaticIdc[kiBlockIndexLow];
+  pWelsMd->iBlock8x8StaticIdc[3] = pVaaExt->pVaaBestBlockStaticIdc[kiBlockIndexLow + 1];
+
+}
+
 ///////////////////////
-// Scrolling PSkip Decision for screen content
+// Scene Change Detection (SCD) PSkip Decision for screen content
 ////////////////////////
-bool WelsMdInterJudgeScrollingPskip (void* pEncCtx, void* pWelsMd, SSlice* slice, SMB* pCurMb, SMbCache* pMbCache) {
+bool WelsMdInterJudgeSCDPskip (void* pEncCtx, void* pWelsMd, SSlice* slice, SMB* pCurMb, SMbCache* pMbCache) {
+  sWelsEncCtx* pCtx	= (sWelsEncCtx*)pEncCtx;
+  SWelsMD* pMd					= (SWelsMD*)pWelsMd;
+  SDqLayer* pCurDqLayer			= pCtx->pCurDqLayer;
+
+  SetBlockStaticIdcToMd (pCtx->pVaa, pMd, pCurMb, pCurDqLayer);
+
+  //try static Pskip;
+
+  //try scrolled Pskip
   //TBD
+
   return false;
 }
-bool WelsMdInterJudgeScrollingPskipFalse (void* pEncCtx, void* pWelsMd, SSlice* slice, SMB* pCurMb,
-    SMbCache* pMbCache) {
+bool WelsMdInterJudgeSCDPskipFalse (void* pEncCtx, void* pWelsMd, SSlice* slice, SMB* pCurMb,
+                                    SMbCache* pMbCache) {
   return false;
 }
 
@@ -168,9 +199,9 @@
 
 void WelsInitScrollingSkipFunc (SWelsFuncPtrList* pFuncList, const bool bScrollingDetection) {
   if (bScrollingDetection) {
-    pFuncList->pfScrollingPSkipDecision = WelsMdInterJudgeScrollingPskip;
+    pFuncList->pfScrollingPSkipDecision = WelsMdInterJudgeSCDPskip;
   } else {
-    pFuncList->pfScrollingPSkipDecision = WelsMdInterJudgeScrollingPskipFalse;
+    pFuncList->pfScrollingPSkipDecision = WelsMdInterJudgeSCDPskipFalse;
   }
 }
 
--- a/codec/encoder/core/src/wels_preprocess.cpp
+++ b/codec/encoder/core/src/wels_preprocess.cpp
@@ -927,6 +927,7 @@
     SRefInfoParam* pRefSaved) {
   pRefSaved->iSrcListIdx = pRefPicInfo->iSrcListIdx;
   pRefSaved->bSceneLtrFlag = pRefPicInfo->bSceneLtrFlag;
+  pRefSaved->pBestBlockStaticIdc = sSceneChangeResult.pStaticBlockIdc;
 }
 
 void CWelsPreProcess::SaveBestRefToVaa (SRefInfoParam& sRefSaved, SRefInfoParam* pVaaBestRef) {
@@ -974,8 +975,6 @@
   SPicture* pRefPic = NULL;
   SRefInfoParam* pRefPicInfo = NULL;
   uint8_t*  pCurBlockStaticPointer = NULL;
-  uint8_t*  pBestStrBlockStaticPointer = NULL;
-  uint8_t*  pBestLtrBlockStaticPointer = NULL;
 
   const int32_t iNegligibleMotionBlocks = (static_cast<int32_t> ((pCurPicture->iWidthInPixel >> 3) *
                                           (pCurPicture->iHeightInPixel >> 3) * STATIC_SCENE_MOTION_RATIO));
@@ -1046,12 +1045,10 @@
         SaveBestRefToJudgement (iRefPicAvQP, iFrameComplexity, &sLtrJudgement);
         SaveBestRefToLocal (pRefPicInfo, sSceneChangeResult, &sLtrSaved);
         bBestRefIsLtr = bCurRefIsLtr;
-        pBestStrBlockStaticPointer = sSceneChangeResult.pStaticBlockIdc;
       }
       if (bCurRefIsLtr && JudgeBestRef (pRefPic, sSceneLtrJudgement, iFrameComplexity, bIsClosestLtrFrame)) {
         SaveBestRefToJudgement (iRefPicAvQP, iFrameComplexity, &sSceneLtrJudgement);
         SaveBestRefToLocal (pRefPicInfo, sSceneChangeResult, &sSceneLtrSaved);
-        pBestLtrBlockStaticPointer = sSceneChangeResult.pStaticBlockIdc;
       }
 
       if (iMotionBlockNum <= iNegligibleMotionBlocks) {
@@ -1072,6 +1069,7 @@
            pCtx->iCodingIndex);
 
   SaveBestRefToVaa (sLtrSaved, & (pVaaExt->sVaaStrBestRefCandidate[0]));
+  pVaaExt->pVaaBestBlockStaticIdc = sLtrSaved.pBestBlockStaticIdc;
 
   if (0 == iAvailableSceneRefNum) {
     SaveBestRefToVaa (sSceneLtrSaved, & (pVaaExt->sVaaStrBestRefCandidate[1]));