shithub: openh264

Download patch

ref: 938019748d204cfb544c3e7683d28976aac95246
parent: 30687f464702642031d4946d8949d085c933b04b
author: sijchen <[email protected]>
date: Sun May 4 11:03:23 EDT 2014

add scrolling skip function pointers in MD

--- a/codec/encoder/core/inc/svc_base_layer_md.h
+++ b/codec/encoder/core/inc/svc_base_layer_md.h
@@ -102,5 +102,7 @@
 
 //typedef void (*MD_INTRA_MB_BASE) (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurMb);
 
+void WelsInitScrollingSkipFunc (SWelsFuncPtrList* pFuncList, const bool bScrollingDetection);
+
 }
 #endif//WELS_MACROBLOCK_MODE_DECISION_H__
--- a/codec/encoder/core/inc/wels_func_ptr_def.h
+++ b/codec/encoder/core/inc/wels_func_ptr_def.h
@@ -127,6 +127,9 @@
 typedef void (*PInterMdBackgroundInfoUpdateFunc) (SDqLayer* pCurLayer,  SMB* pCurMb, const bool bFlag,
     const int32_t kiRefPictureType);
 
+typedef bool (*PInterMdScrollingPSkipDecisionFunc) (void* pEncCtx, void* pWelsMd, SSlice* slice, SMB* pCurMb,
+    SMbCache* pMbCache);
+
 typedef void (*PInterMdFunc) (void* pEncCtx, void* pWelsMd, SSlice* slice, SMB* pCurMb, SMbCache* pMbCache);
 
 typedef int32_t (*PSampleSadSatdCostFunc) (uint8_t*, int32_t, uint8_t*, int32_t);
@@ -200,6 +203,8 @@
 
   PInterMdBackgroundDecisionFunc          pfInterMdBackgroundDecision;
   PInterMdBackgroundInfoUpdateFunc      pfInterMdBackgroundInfoUpdate;
+
+  PInterMdScrollingPSkipDecisionFunc pfScrollingPSkipDecision;
 
   SMcFunc                sMcFuncs;
   SSampleDealingFunc     sSampleDealingFuncs;
--- a/codec/encoder/core/src/encoder.cpp
+++ b/codec/encoder/core/src/encoder.cpp
@@ -153,6 +153,7 @@
  */
 int32_t InitFunctionPointers (SWelsFuncPtrList* pFuncList, SWelsSvcCodingParam* pParam, uint32_t uiCpuFlag) {
   int32_t iReturn = ENC_RETURN_SUCCESS;
+  bool bScreenContent = (SCREEN_CONTENT_REAL_TIME == pParam->iUsageType);
 
   /* Functionality utilization of CPU instructions dependency */
   pFuncList->pfSetMemZeroSize8	= WelsSetMemZero_c;		// confirmed_safe_unsafe_usage
@@ -184,7 +185,7 @@
   WelsInitIntraPredFuncs (pFuncList, uiCpuFlag);
 
   /* ME func */
-  WelsInitMeFunc (pFuncList, uiCpuFlag, SCREEN_CONTENT_REAL_TIME == pParam->iUsageType);
+  WelsInitMeFunc (pFuncList, uiCpuFlag, bScreenContent);
 
   /* sad, satd, average */
   WelsInitSampleSadFunc (pFuncList, uiCpuFlag);
@@ -191,6 +192,8 @@
 
   //
   WelsInitBGDFunc (pFuncList, pParam->bEnableBackgroundDetection);
+  WelsInitScrollingSkipFunc (pFuncList, bScreenContent&&(pParam->bEnableSceneChangeDetect));
+
   // for pfGetVarianceFromIntraVaa function ptr adaptive by CPU features, 6/7/2010
   InitIntraAnalysisVaaInfo (pFuncList, uiCpuFlag);
 
--- a/codec/encoder/core/src/svc_base_layer_md.cpp
+++ b/codec/encoder/core/src/svc_base_layer_md.cpp
@@ -1634,10 +1634,16 @@
   bool bKeepSkip = bMbLeftAvailPskip && bMbTopAvailPskip && bMbTopRightAvailPskip;
   bool bSkip = false;
 
+  //try BGD skip
   if (pEncCtx->pFuncList->pfInterMdBackgroundDecision (pEncCtx, pWelsMd, pSlice, pCurMb, pMbCache, &bKeepSkip)) {
     return;
   }
 
+  //try static or scrolled Pskip
+  if (pEncCtx->pFuncList->pfScrollingPSkipDecision (pEncCtx, pWelsMd, pSlice, pCurMb, pMbCache)) {
+    return;
+  }
+
   //step 1: try SKIP
   bSkip = WelsMdInterJudgePskip (pEncCtx, pWelsMd, pSlice, pCurMb, pMbCache, bTrySkip);
 
@@ -1861,6 +1867,7 @@
   WelsIMbChromaEncode (pEncCtx, pCurMb, pMbCache);  //add pEnc&rec to MD--2010.3.15
   pCurMb->pSadCost[0] = 0;
 }
+
 
 
 
--- a/codec/encoder/core/src/svc_mode_decision.cpp
+++ b/codec/encoder/core/src/svc_mode_decision.cpp
@@ -31,7 +31,9 @@
  *
  * \file	svc_mode_decision.c
  *
- * \brief	SVC Spatial Enhancement Layer MD
+ * \brief Algorithmetic MD for:
+ * - multi-spatial Enhancement Layer MD;
+ * - Scrolling PSkip Decision for screen content
  *
  * \date	2009.7.29
  *
@@ -157,6 +159,25 @@
   }
 }
 
+///////////////////////
+// Scrolling PSkip Decision for screen content
+////////////////////////
+bool WelsMdInterJudgeScrollingPskip(void* pEncCtx, void* pWelsMd, SSlice* slice, SMB* pCurMb, SMbCache* pMbCache) {
+  //TBD
+  return false;
+}
+bool WelsMdInterJudgeScrollingPskipFalse(void* pEncCtx, void* pWelsMd, SSlice* slice, SMB* pCurMb, SMbCache* pMbCache) {
+  return false;
+}
+
+
+void WelsInitScrollingSkipFunc (SWelsFuncPtrList* pFuncList, const bool bScrollingDetection) {
+  if (bScrollingDetection) {
+    pFuncList->pfScrollingPSkipDecision = WelsMdInterJudgeScrollingPskip;
+  } else {
+    pFuncList->pfScrollingPSkipDecision = WelsMdInterJudgeScrollingPskipFalse;
+  }
+}
 
 
 } // namespace WelsSVCEnc