shithub: openh264

Download patch

ref: 26218731c6e6fb1541957ae667918b387de9f456
parent: f8b0cec68d8b1321db6e251e5b87ceb50548377b
parent: 775eebaf36e69ac1dfb4f1ea18c11f42df477ace
author: Licai Guo <[email protected]>
date: Tue Mar 4 06:15:35 EST 2014

Merge pull request #386 from volvet/refine_processing

refine build spatial list in processing

--- a/codec/encoder/core/inc/wels_preprocess.h
+++ b/codec/encoder/core/inc/wels_preprocess.h
@@ -110,7 +110,7 @@
   int32_t WelsPreprocessReset (sWelsEncCtx* pEncCtx);
   int32_t AllocSpatialPictures (sWelsEncCtx* pCtx, SWelsSvcCodingParam* pParam);
   void    FreeSpatialPictures (sWelsEncCtx* pCtx);
-  int32_t BuildSpatialPicList (sWelsEncCtx* pEncCtx, const SSourcePicture** kppSrcPicList, const int32_t kiConfiguredLayerNum);
+  int32_t BuildSpatialPicList (sWelsEncCtx* pEncCtx, const SSourcePicture* kpSrcPic);
   int32_t AnalyzeSpatialPic (sWelsEncCtx* pEncCtx, const int32_t kiDIdx);
   int32_t UpdateSpatialPictures(sWelsEncCtx* pEncCtx, SWelsSvcCodingParam* pParam, const int8_t iCurTid, const int32_t d_idx);
 
--- a/codec/encoder/core/src/encoder_ext.cpp
+++ b/codec/encoder/core/src/encoder_ext.cpp
@@ -3000,7 +3000,7 @@
   pFbi->iLayerNum	= 0;	// for initialization
   pFbi->uiTimeStamp = pSrcPic->uiTimeStamp;
   // perform csc/denoise/downsample/padding, generate spatial layers
-  iSpatialNum = pCtx->pVpp->BuildSpatialPicList (pCtx, &pSrcPic, 1);
+  iSpatialNum = pCtx->pVpp->BuildSpatialPicList (pCtx, pSrcPic);
   if (iSpatialNum < 1) {	// skip due to temporal layer settings (different frame rate)
     ++ pCtx->iCodingIndex;
     pFbi->eOutputFrameType = WELS_FRAME_TYPE_SKIP;
--- a/codec/encoder/core/src/wels_preprocess.cpp
+++ b/codec/encoder/core/src/wels_preprocess.cpp
@@ -305,8 +305,7 @@
   }
 }
 
-int32_t CWelsPreProcess::BuildSpatialPicList (sWelsEncCtx* pCtx, const SSourcePicture** kppSrcPicList,
-    const int32_t kiConfiguredLayerNum) {
+int32_t CWelsPreProcess::BuildSpatialPicList (sWelsEncCtx* pCtx, const SSourcePicture* kpSrcPic) {
   SWelsSvcCodingParam* pSvcParam = pCtx->pSvcParam;
   int32_t	iNumDependencyLayer = (int32_t)pSvcParam->iSpatialLayerNum;
   int32_t iSpatialNum = 0;
@@ -317,17 +316,11 @@
     if (WelsPreprocessReset (pCtx) != 0)
       return -1;
 
-    m_bOfficialBranch  = (iNumDependencyLayer != kiConfiguredLayerNum);
-    if (!m_bOfficialBranch && (iNumDependencyLayer == 1)) {
-      // check the input source uiSize to decide if need switch to official branch
-      // NOTICE: the layernum=1 case is confused in official/non-official cases!
-      SSourcePicture** pic_queue = (SSourcePicture**)kppSrcPicList;
-      for (int32_t i = 0; i < iNumDependencyLayer; i++) {
-        if (pSvcParam->sDependencyLayers[i].iFrameWidth != pic_queue[i]->iPicWidth ||
-            pSvcParam->sDependencyLayers[i].iFrameHeight != pic_queue[i]->iPicHeight) {
-          m_bOfficialBranch = true;
-          break;
-        }
+    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;
@@ -336,19 +329,15 @@
   if (m_pInterfaceVp == NULL)
     return -1;
 
-  if (kiConfiguredLayerNum <= 0)
-    return -1;
-
   pCtx->pVaa->bSceneChangeFlag = pCtx->pVaa->bIdrPeriodFlag = false;
   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
-    assert (kiConfiguredLayerNum == 1);
-    iSpatialNum	= SingleLayerPreprocess (pCtx, kppSrcPicList[0], &m_sScaledPicture);
+    iSpatialNum	= SingleLayerPreprocess (pCtx, kpSrcPic, &m_sScaledPicture);
   } else { // for console each spatial pictures are available there
-    iSpatialNum	= kiConfiguredLayerNum;
-    MultiLayerPreprocess (pCtx, kppSrcPicList, iSpatialNum);
+    iSpatialNum = 1;
+    MultiLayerPreprocess (pCtx, &kpSrcPic, iSpatialNum);
   }
 
   return iSpatialNum;