shithub: openh264

Download patch

ref: cae5af52d749570d70d5117166e2a4a5dd8cfa4a
parent: a8ae1346101be6ec1b5f72a861932fbda0cffcde
author: Sijia Chen <sijchen@cisco.com>
date: Thu Jul 9 06:03:00 EDT 2015

use func pointer for deblocking to save judgements at each slice

--- a/codec/encoder/core/inc/deblocking.h
+++ b/codec/encoder/core/inc/deblocking.h
@@ -84,6 +84,7 @@
 void DeblockingFilterFrameAvcbase (SDqLayer* pCurDq, SWelsFuncPtrList* pFunc);
 
 void DeblockingFilterSliceAvcbase (SDqLayer* pCurDq, SWelsFuncPtrList* pFunc, const int32_t kiSliceIdx);
+void DeblockingFilterSliceAvcbaseNull (SDqLayer* pCurDq, SWelsFuncPtrList* pFunc, const int32_t kiSliceIdx);
 }
 
 #endif
--- a/codec/encoder/core/inc/wels_func_ptr_def.h
+++ b/codec/encoder/core/inc/wels_func_ptr_def.h
@@ -83,6 +83,7 @@
     int32_t iBeta);
 typedef void (*PDeblockingBSCalc) (SWelsFuncPtrList* pFunc, SMB* pCurMb, uint8_t uiBS[2][4][4], Mb_Type uiCurMbType,
                                    int32_t iMbStride, int32_t iLeftFlag, int32_t iTopFlag);
+typedef void (*PDeblockingFilterSlice) (SDqLayer* pCurDq, SWelsFuncPtrList* pFunc, const int32_t kiSliceIdx);
 
 typedef struct tagDeblockingFunc {
   PLumaDeblockingLT4Func    pfLumaDeblockingLT4Ver;
@@ -96,6 +97,8 @@
   PChromaDeblockingEQ4Func  pfChromaDeblockingEQ4Hor;
 
   PDeblockingBSCalc         pfDeblockingBSCalc;
+
+  PDeblockingFilterSlice    pfDeblockingFilterSlice;
 } DeblockingFunc;
 
 typedef  void (*PSetNoneZeroCountZeroFunc) (int8_t* pNonZeroCount);
--- a/codec/encoder/core/src/deblocking.cpp
+++ b/codec/encoder/core/src/deblocking.cpp
@@ -739,6 +739,9 @@
   }
 }
 
+void DeblockingFilterSliceAvcbaseNull (SDqLayer* pCurDq, SWelsFuncPtrList* pFunc, const int32_t kiSliceIdx) {
+}
+
 void PerformDeblockingFilter (sWelsEncCtx* pEnc) {
   const int32_t kiCurDid                = pEnc->uiDependencyId;
   SWelsSvcCodingParam* pSvcParam        = pEnc->pSvcParam;
--- a/codec/encoder/core/src/encoder_ext.cpp
+++ b/codec/encoder/core/src/encoder_ext.cpp
@@ -3071,6 +3071,20 @@
   // update some layer dependent variable to save judgements in mb-level
   pCurLayer->bSatdInMdFlag = ((pFuncList->sSampleDealingFuncs.pfMeCost == pFuncList->sSampleDealingFuncs.pfSampleSatd)
                               && (pFuncList->sSampleDealingFuncs.pfMdCost == pFuncList->sSampleDealingFuncs.pfSampleSatd));
+
+  const int32_t kiCurDid            = pCtx->uiDependencyId;
+  const int32_t kiCurTid            = pCtx->uiTemporalId;
+  if (pCurLayer->bDeblockingParallelFlag && (pCurLayer->iLoopFilterDisableIdc != 1)
+#if !defined(ENABLE_FRAME_DUMP)
+      && ( NRI_PRI_LOWEST != pCtx->eNalPriority )
+      && (pCtx->pSvcParam->sDependencyLayers[kiCurDid].iHighestTemporalId == 0
+          || kiCurTid < pCtx->pSvcParam->sDependencyLayers[kiCurDid].iHighestTemporalId)
+#endif// !ENABLE_FRAME_DUMP
+     ) {
+    pFuncList->pfDeblocking.pfDeblockingFilterSlice = DeblockingFilterSliceAvcbase;
+  } else {
+    pFuncList->pfDeblocking.pfDeblockingFilterSlice = DeblockingFilterSliceAvcbaseNull;
+  }
 }
 
 /*!
--- a/codec/encoder/core/src/slice_multi_threading.cpp
+++ b/codec/encoder/core/src/slice_multi_threading.cpp
@@ -753,7 +753,6 @@
     if (WELS_THREAD_ERROR_WAIT_OBJECT_0 == iWaitRet) { // start pSlice coding signal waited
       SLayerBSInfo* pLbi = pPrivateData->pLayerBs;
       const int32_t kiCurDid            = pEncPEncCtx->uiDependencyId;
-      const int32_t kiCurTid            = pEncPEncCtx->uiTemporalId;
       SWelsSvcCodingParam* pCodingParam = pEncPEncCtx->pSvcParam;
       SSpatialLayerConfig* pParamD      = &pCodingParam->sSpatialLayers[kiCurDid];
 
@@ -829,15 +828,7 @@
           }
         }
 
-        if (pCurDq->bDeblockingParallelFlag && pSlice->sSliceHeaderExt.sSliceHeader.uiDisableDeblockingFilterIdc != 1
-#if !defined(ENABLE_FRAME_DUMP)
-            && (eNalRefIdc != NRI_PRI_LOWEST) &&
-            (pCodingParam->sDependencyLayers[kiCurDid].iHighestTemporalId == 0
-             || kiCurTid < pCodingParam->sDependencyLayers[kiCurDid].iHighestTemporalId)
-#endif// !ENABLE_FRAME_DUMP
-           ) {
-          DeblockingFilterSliceAvcbase (pCurDq, pEncPEncCtx->pFuncList, iSliceIdx);
-        }
+        pEncPEncCtx->pFuncList->pfDeblocking.pfDeblockingFilterSlice (pCurDq, pEncPEncCtx->pFuncList, iSliceIdx);
 
         if (bDsaFlag) {
           pEncPEncCtx->pSliceThreading->pSliceConsumeTime[pEncPEncCtx->uiDependencyId][iSliceIdx] = (uint32_t) (
@@ -947,15 +938,7 @@
             }
           }
 
-          if (pCurDq->bDeblockingParallelFlag && pSlice->sSliceHeaderExt.sSliceHeader.uiDisableDeblockingFilterIdc != 1
-#if !defined(ENABLE_FRAME_DUMP)
-              && (eNalRefIdc != NRI_PRI_LOWEST) &&
-              (pCodingParam->sDependencyLayers[kiCurDid].iHighestTemporalId == 0
-               || kiCurTid < pCodingParam->sDependencyLayers[kiCurDid].iHighestTemporalId)
-#endif// !ENABLE_FRAME_DUMP
-             ) {
-            DeblockingFilterSliceAvcbase (pCurDq, pEncPEncCtx->pFuncList, iSliceIdx);
-          }
+          pEncPEncCtx->pFuncList->pfDeblocking.pfDeblockingFilterSlice (pCurDq, pEncPEncCtx->pFuncList, iSliceIdx);
 
 #if defined(SLICE_INFO_OUTPUT)
           fprintf (stderr,