shithub: openh264

Download patch

ref: 27da2b21bfbf3e2e08fb6ce48571b065283c7c47
parent: c43e1c8f43edb0f07b50fd083f7fda217d59776b
author: ruil2 <ruil2@cisco.com>
date: Wed Apr 2 13:23:46 EDT 2014

add the condition branch for screen content

--- a/codec/encoder/core/src/encoder_ext.cpp
+++ b/codec/encoder/core/src/encoder_ext.cpp
@@ -1314,7 +1314,11 @@
   //End of Rate control module memory allocation
 
   //pVaa memory allocation
-  (*ppCtx)->pVaa	= (SVAAFrameInfo*)pMa->WelsMallocz (sizeof (SVAAFrameInfo), "pVaa");
+  if(pParam->iUsageType == SCREEN_CONTENT_REAL_TIME)
+    (*ppCtx)->pVaa	= (SVAAFrameInfoExt*)pMa->WelsMallocz (sizeof (SVAAFrameInfoExt), "pVaa");
+  else
+    (*ppCtx)->pVaa	= (SVAAFrameInfo*)pMa->WelsMallocz (sizeof (SVAAFrameInfo), "pVaa");
+
   WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pVaa), FreeMemorySvc (ppCtx))
 
   if ((*ppCtx)->pSvcParam->bEnableAdaptiveQuant) { //malloc mem
--- a/codec/encoder/core/src/ref_list_mgr_svc.cpp
+++ b/codec/encoder/core/src/ref_list_mgr_svc.cpp
@@ -707,6 +707,20 @@
     pLtr->uiLtrMarkInterval = 0;
     pCtx->pVaa->uiValidLongTermPicIdx = 0;
   }
+
+  //update info in src list
+  if (pCtx->pEncPic) {
+    pCtx->pEncPic->iPictureType	    = pCtx->pDecPic->iPictureType;
+    pCtx->pEncPic->iFramePoc		= pCtx->pDecPic->iFramePoc;
+    pCtx->pEncPic->iFrameNum		= pCtx->pDecPic->iFrameNum;
+    pCtx->pEncPic->uiSpatialId		= pCtx->pDecPic->uiSpatialId;
+    pCtx->pEncPic->uiTemporalId	    = pCtx->pDecPic->uiTemporalId;
+    pCtx->pEncPic->iLongTermPicNum  = pCtx->pDecPic->iLongTermPicNum;
+    pCtx->pEncPic->bUsedAsRef       = pCtx->pDecPic->bUsedAsRef;
+    pCtx->pEncPic->bIsLongRef       = pCtx->pDecPic->bIsLongRef;
+    pCtx->pEncPic->bIsSceneLTR      = pCtx->pDecPic->bIsSceneLTR;
+    pCtx->pEncPic->iFrameAverageQp  = pCtx->pDecPic->iFrameAverageQp;
+  }
   return true;
 }
 bool WelsBuildRefListScreen (void* pEncCtx, const int32_t iPOC, int32_t iBestLtrRefIdx) {
--- a/codec/encoder/core/src/wels_preprocess.cpp
+++ b/codec/encoder/core/src/wels_preprocess.cpp
@@ -279,7 +279,11 @@
       ++ i;
     } while (i < kuiRefNumInTemporal);
 
-    m_uiSpatialLayersInTemporal[iDlayerIndex] = kuiLayerInTemporal;
+    if(pParam->iUsageType == SCREEN_CONTENT_REAL_TIME)
+      m_uiSpatialLayersInTemporal[iDlayerIndex] = 1;
+    else
+      m_uiSpatialLayersInTemporal[iDlayerIndex] = kuiLayerInTemporal;
+
     m_uiSpatialPicNum[iDlayerIndex] = kuiRefNumInTemporal;
     ++ iDlayerIndex;
   } while (iDlayerIndex < kiDlayerCount);
@@ -363,12 +367,12 @@
     AdaptiveQuantCalculation (pCtx->pVaa, pCurPic, pRefPic);
   }
 
-  if (pSvcParam->bEnableRc) {
-    AnalyzePictureComplexity (pCtx, pCurPic, pRefPic, kiDidx, bCalculateBGD);
+  if(pSvcParam->iUsageType != SCREEN_CONTENT_REAL_TIME){
+    if (pSvcParam->bEnableRc) {
+      AnalyzePictureComplexity (pCtx, pCurPic, pRefPic, kiDidx, bCalculateBGD);
   }
-
-  WelsExchangeSpatialPictures (&m_pLastSpatialPicture[kiDidx][1], &m_pLastSpatialPicture[kiDidx][0]);
-
+    WelsExchangeSpatialPictures (&m_pLastSpatialPicture[kiDidx][1], &m_pLastSpatialPicture[kiDidx][0]);
+  }
   return 0;
 }