shithub: openh264

Download patch

ref: a4cecd80048e187033fc4ee084abb4d6c7a79e66
parent: 14f5518e6a5f4e4a84de04045d749bd0e1119e5a
parent: 50fe120a3e3ace78d17cdf3a831ece356eb1aa3d
author: Licai Guo <[email protected]>
date: Fri Mar 7 05:58:28 EST 2014

Merge pull request #426 from volvet/simplify-layer-process

simplify-layer-process

--- a/codec/encoder/core/inc/wels_preprocess.h
+++ b/codec/encoder/core/inc/wels_preprocess.h
@@ -121,7 +121,6 @@
 
  private:
   int32_t SingleLayerPreprocess (sWelsEncCtx* pEncCtx, const SSourcePicture* kpSrc, Scaled_Picture* m_sScaledPicture);
-  int32_t MultiLayerPreprocess (sWelsEncCtx* pEncCtx, const SSourcePicture* kpSrcPic);
 
   void	BilateralDenoising (SPicture* pSrc, const int32_t iWidth, const int32_t iHeight);
   bool  DetectSceneChange (SPicture* pCurPicture, SPicture* pRefPicture);
@@ -150,7 +149,6 @@
   CWelsLib*        m_pEncLib;
   sWelsEncCtx*     m_pEncCtx;
   bool             m_bInitDone;
-  bool             m_bOfficialBranch;
   /* For Downsampling & VAA I420 based source pictures */
   SPicture*        m_pSpatialPic[MAX_DEPENDENCY_LAYER][MAX_TEMPORAL_LEVEL + 1 +
       LONG_TERM_REF_NUM];	// need memory requirement with total number of (log2(uiGopSize)+1+1+long_term_ref_num)
--- a/codec/encoder/core/src/wels_preprocess.cpp
+++ b/codec/encoder/core/src/wels_preprocess.cpp
@@ -204,7 +204,6 @@
   m_pInterfaceVp = NULL;
   m_pEncLib = NULL;
   m_bInitDone = false;
-  m_bOfficialBranch  = false;
   m_pEncCtx = pEncCtx;
   memset (&m_sScaledPicture, 0, sizeof (m_sScaledPicture));
   memset (m_pSpatialPic, 0, sizeof(m_pSpatialPic));
@@ -316,13 +315,6 @@
     if (WelsPreprocessReset (pCtx) != 0)
       return -1;
 
-    m_bOfficialBranch  = (iNumDependencyLayer != 1);
-    if ( iNumDependencyLayer == 1 ) {
-      if (pSvcParam->sDependencyLayers[0].iFrameWidth != kpSrcPic->iPicWidth ||
-          pSvcParam->sDependencyLayers[0].iFrameHeight != kpSrcPic->iPicHeight) {
-        m_bOfficialBranch = true;
-      }
-    }
     m_bInitDone = true;
   }
 
@@ -333,12 +325,7 @@
   if (pSvcParam->uiIntraPeriod)
     pCtx->pVaa->bIdrPeriodFlag = (1 + pCtx->iFrameIndex >= (int32_t)pSvcParam->uiIntraPeriod) ? true : false;
 
-  if (m_bOfficialBranch) {	// Perform Down Sampling potentially due to application
-    iSpatialNum	= SingleLayerPreprocess (pCtx, kpSrcPic, &m_sScaledPicture);
-  } else { // for console each spatial pictures are available there
-    iSpatialNum = 1;
-    MultiLayerPreprocess (pCtx, kpSrcPic);
-  }
+  iSpatialNum = SingleLayerPreprocess (pCtx, kpSrcPic, &m_sScaledPicture);
 
   return iSpatialNum;
 }
@@ -518,46 +505,6 @@
   return iSpatialNum;
 }
 
-int32_t CWelsPreProcess::MultiLayerPreprocess (sWelsEncCtx* pCtx, const SSourcePicture* kpSrcPic) {
-  SWelsSvcCodingParam* pSvcParam	= pCtx->pSvcParam;
-  const SSourcePicture* pSrc			= NULL;
-  SPicture* pDstPic						= NULL;
-  const int32_t iSpatialLayersCfgCount =
-    pSvcParam->iSpatialLayerNum;	// count number of spatial layers to be encoded in cfg
-  int32_t j							= -1;
-
-  // do not clear j, just let it continue to save complexity
-  do {
-    ++ j;
-    if (pSvcParam->sDependencyLayers[j].iFrameWidth == kpSrcPic->iPicWidth &&
-        pSvcParam->sDependencyLayers[j].iFrameHeight == kpSrcPic->iPicHeight) {
-      break;
-    }
-  } while (j < iSpatialLayersCfgCount);
-
-  assert (j < iSpatialLayersCfgCount);
-  pDstPic = m_pSpatialPic[j][m_uiSpatialLayersInTemporal[j] - 1];
-
-  WelsUpdateSpatialIdxMap (pCtx, 0, pDstPic, j);
-
-  WelsMoveMemoryWrapper (pSvcParam, pDstPic, kpSrcPic, kpSrcPic->iPicWidth, kpSrcPic->iPicHeight);
-
-  if (pSvcParam->bEnableDenoise)
-    BilateralDenoising (pDstPic, kpSrcPic->iPicWidth, kpSrcPic->iPicHeight);
-
-  m_pLastSpatialPicture[j][1]	= pDstPic;
-
-  if (pSvcParam->bEnableSceneChangeDetect && (1 == pSvcParam->iSpatialLayerNum)
-      && !pCtx->pVaa->bIdrPeriodFlag && !pCtx->bEncCurFrmAsIdrFlag) {
-    SPicture* pRef = pCtx->pLtr[0].bReceivedT0LostFlag ?
-                     m_pSpatialPic[0][m_uiSpatialLayersInTemporal[0] + pCtx->pVaa->uiValidLongTermPicIdx] :
-                     m_pLastSpatialPicture[0][0];
-
-    pCtx->pVaa->bSceneChangeFlag = DetectSceneChange (pDstPic, pRef);
-  }
-
-  return 0;
-}
 
 /*!
  * \brief	Whether input picture need be scaled?