shithub: openh264

Download patch

ref: 443630b0989caf89975e3c839816abdcd11a1f85
parent: e9429e2f93de3d8a07c9eea105fdc3a264184428
parent: 84b441d4e44eb3beb5ee1fd32d82b8e06142c1af
author: huili2 <huili2@cisco.com>
date: Thu Jun 18 04:33:19 EDT 2015

Merge pull request #1992 from sijchen/ps11

[Encoder] Refactoring: move the post-encoding exchanging in preprocessing to more reasonable function

--- a/codec/encoder/core/src/wels_preprocess.cpp
+++ b/codec/encoder/core/src/wels_preprocess.cpp
@@ -252,12 +252,11 @@
 
       AdaptiveQuantCalculation (pCtx->pVaa, pCurPic, pRefPic);
     }
-    WelsExchangeSpatialPictures (&m_pLastSpatialPicture[kiDidx][1], &m_pLastSpatialPicture[kiDidx][0]);
   }
   return 0;
 }
 
-int32_t CWelsPreProcess::GetCurPicPosition(const int32_t kiDidx) {
+int32_t CWelsPreProcess::GetCurPicPosition (const int32_t kiDidx) {
   return (m_uiSpatialLayersInTemporal[kiDidx] - 1);
 }
 
@@ -265,7 +264,10 @@
     const int8_t iCurTid, const int32_t kiDidx) {
   if (pCtx->pSvcParam->iUsageType == SCREEN_CONTENT_REAL_TIME)
     return 0;
-  const int32_t kiCurPos = GetCurPicPosition(kiDidx);
+
+  WelsExchangeSpatialPictures (&m_pLastSpatialPicture[kiDidx][1], &m_pLastSpatialPicture[kiDidx][0]);
+
+  const int32_t kiCurPos = GetCurPicPosition (kiDidx);
   if (iCurTid < kiCurPos || pParam->iDecompStages == 0) {
     if ((iCurTid >= MAX_TEMPORAL_LEVEL) || (kiCurPos > MAX_TEMPORAL_LEVEL)) {
       InitLastSpatialPictures (pCtx);
@@ -278,7 +280,7 @@
       pCtx->bRefOfCurTidIsLtr[kiDidx][iCurTid] = false;
     }
     WelsExchangeSpatialPictures (&m_pSpatialPic[kiDidx][kiCurPos],
-                                   &m_pSpatialPic[kiDidx][iCurTid]);
+                                 &m_pSpatialPic[kiDidx][iCurTid]);
   }
   return 0;
 }
@@ -332,7 +334,8 @@
     iShrinkWidth = pScaledPicture->iScaledWidth[iDependencyId];
     iShrinkHeight = pScaledPicture->iScaledHeight[iDependencyId];
   }
-  DownsamplePadding (pSrcPic, pDstPic, iSrcWidth, iSrcHeight, iShrinkWidth, iShrinkHeight, iTargetWidth, iTargetHeight, false);
+  DownsamplePadding (pSrcPic, pDstPic, iSrcWidth, iSrcHeight, iShrinkWidth, iShrinkHeight, iTargetWidth, iTargetHeight,
+                     false);
 
   if (pSvcParam->bEnableSceneChangeDetect && !pCtx->pVaa->bIdrPeriodFlag) {
     if (pSvcParam->iUsageType == SCREEN_CONTENT_REAL_TIME) {
@@ -387,7 +390,8 @@
         pDstPic = m_pSpatialPic[iDependencyId][iPicturePos]; // small
         iShrinkWidth = pScaledPicture->iScaledWidth[iDependencyId];
         iShrinkHeight = pScaledPicture->iScaledHeight[iDependencyId];
-        DownsamplePadding (pSrcPic, pDstPic, iSrcWidth, iSrcHeight, iShrinkWidth, iShrinkHeight, iTargetWidth, iTargetHeight, true);
+        DownsamplePadding (pSrcPic, pDstPic, iSrcWidth, iSrcHeight, iShrinkWidth, iShrinkHeight, iTargetWidth, iTargetHeight,
+                           true);
 
         WelsUpdateSpatialIdxMap (pCtx, iActualSpatialLayerNum - 1, pDstPic, iDependencyId);