shithub: openh264

Download patch

ref: ced9e41b5d5923e94877cab1e2e1658b91ccb77a
parent: 7150adc91b4abc0be8453aacdcc68ea37a2314e5
parent: 13d785ec6a733fb0cf3f5cc0b544a6040509f4a4
author: Licai Guo <[email protected]>
date: Wed Mar 5 05:45:35 EST 2014

Merge pull request #399 from volvet/refine-multi-layer-process

refine-multi-layer-process

--- a/codec/encoder/core/inc/wels_preprocess.h
+++ b/codec/encoder/core/inc/wels_preprocess.h
@@ -121,7 +121,7 @@
 
  private:
   int32_t SingleLayerPreprocess (sWelsEncCtx* pEncCtx, const SSourcePicture* kpSrc, Scaled_Picture* m_sScaledPicture);
-  int32_t MultiLayerPreprocess (sWelsEncCtx* pEncCtx, const SSourcePicture** kppSrcPicList, const int32_t kiSpatialNum);
+  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);
--- a/codec/encoder/core/src/wels_preprocess.cpp
+++ b/codec/encoder/core/src/wels_preprocess.cpp
@@ -337,7 +337,7 @@
     iSpatialNum	= SingleLayerPreprocess (pCtx, kpSrcPic, &m_sScaledPicture);
   } else { // for console each spatial pictures are available there
     iSpatialNum = 1;
-    MultiLayerPreprocess (pCtx, &kpSrcPic, iSpatialNum);
+    MultiLayerPreprocess (pCtx, kpSrcPic);
   }
 
   return iSpatialNum;
@@ -518,43 +518,36 @@
   return iSpatialNum;
 }
 
-int32_t CWelsPreProcess::MultiLayerPreprocess (sWelsEncCtx* pCtx, const SSourcePicture** kppSrcPicList,
-    const int32_t kiSpatialNum) {
+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 i							= 0;
   int32_t j							= -1;
 
+  // do not clear j, just let it continue to save complexity
   do {
-    pSrc	= kppSrcPicList[i];
+    ++ j;
+    if (pSvcParam->sDependencyLayers[j].iFrameWidth == kpSrcPic->iPicWidth &&
+        pSvcParam->sDependencyLayers[j].iFrameHeight == kpSrcPic->iPicHeight) {
+      break;
+    }
+  } while (j < iSpatialLayersCfgCount);
 
-    // do not clear j, just let it continue to save complexity
-    do {
-      ++ j;
-      if (pSvcParam->sDependencyLayers[j].iFrameWidth == pSrc->iPicWidth &&
-          pSvcParam->sDependencyLayers[j].iFrameHeight == pSrc->iPicHeight) {
-        break;
-      }
-    } while (j < iSpatialLayersCfgCount);
+  assert (j < iSpatialLayersCfgCount);
+  pDstPic = m_pSpatialPic[j][m_uiSpatialLayersInTemporal[j] - 1];
 
-    assert (j < iSpatialLayersCfgCount);
-    pDstPic = m_pSpatialPic[j][m_uiSpatialLayersInTemporal[j] - 1];
+  WelsUpdateSpatialIdxMap (pCtx, 0, pDstPic, j);
 
-    WelsUpdateSpatialIdxMap (pCtx, i, pDstPic, j);
+  WelsMoveMemoryWrapper (pSvcParam, pDstPic, kpSrcPic, kpSrcPic->iPicWidth, kpSrcPic->iPicHeight);
 
-    WelsMoveMemoryWrapper (pSvcParam, pDstPic, pSrc, pSrc->iPicWidth, pSrc->iPicHeight);
+  if (pSvcParam->bEnableDenoise)
+    BilateralDenoising (pDstPic, kpSrcPic->iPicWidth, kpSrcPic->iPicHeight);
 
-    if (pSvcParam->bEnableDenoise)
-      BilateralDenoising (pDstPic, pSrc->iPicWidth, pSrc->iPicHeight);
+  m_pLastSpatialPicture[j][1]	= pDstPic;
 
-    m_pLastSpatialPicture[j][1]	= pDstPic;
-    ++ i;
-  } while (i < kiSpatialNum);
-
-  if (pSvcParam->bEnableSceneChangeDetect && (kiSpatialNum == pSvcParam->iSpatialLayerNum)
+  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] :