shithub: openh264

Download patch

ref: a3bdf4ffc9dc4ed6c9d6cc4430210dcf5359e228
parent: cfbf32b3fbc23c527f2c73d283394f2b2fb94e09
parent: ee2f87dbbc81e3ac8d9b02685fd3c70fb1376808
author: huili2 <[email protected]>
date: Wed Sep 24 04:59:02 EDT 2014

Merge pull request #1378 from sijchen/ref_refac22

[Encoder] Refactor a function for further strategy adjustment

--- a/codec/encoder/core/src/ref_list_mgr_svc.cpp
+++ b/codec/encoder/core/src/ref_list_mgr_svc.cpp
@@ -680,26 +680,26 @@
   }
 }
 
-static void UpdateSrcPicList (void* pEncCtx) {
-  sWelsEncCtx* pCtx     = (sWelsEncCtx*)pEncCtx;
+static inline void UpdareOriginalPicInfo(SPicture* pOrigPic, SPicture* pReconPic) {
+  if (!pOrigPic)
+    return;
+
+  pOrigPic->iPictureType = pReconPic->iPictureType;
+  pOrigPic->iFramePoc = pReconPic->iFramePoc;
+  pOrigPic->iFrameNum = pReconPic->iFrameNum;
+  pOrigPic->uiSpatialId = pReconPic->uiSpatialId;
+  pOrigPic->uiTemporalId = pReconPic->uiTemporalId;
+  pOrigPic->iLongTermPicNum = pReconPic->iLongTermPicNum;
+  pOrigPic->bUsedAsRef = pReconPic->bUsedAsRef;
+  pOrigPic->bIsLongRef = pReconPic->bIsLongRef;
+  pOrigPic->bIsSceneLTR = pReconPic->bIsSceneLTR;
+  pOrigPic->iFrameAverageQp = pReconPic->iFrameAverageQp;
+}
+
+static void UpdateSrcListLosslessScreenRefSelectionWithLtr(sWelsEncCtx* pCtx) {
   int32_t iDIdx = pCtx->uiDependencyId;
   SPicture** pLongRefList = pCtx->ppRefPicListExt[iDIdx]->pLongRefList;
   SPicture** pLongRefSrcList = &pCtx->pVpp->m_pSpatialPic[iDIdx][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;
-  }
-  PrefetchNextBuffer (pCtx);
   for (int32_t i = 0; i < MAX_REF_PIC_COUNT; ++i) {
     if (NULL == pLongRefSrcList[i + 1] || (NULL != pLongRefList[i] && pLongRefList[i]->bUsedAsRef
                                            && pLongRefList[i]->bIsLongRef)) {
@@ -710,6 +710,14 @@
   }
   WelsExchangeSpatialPictures (&pCtx->pVpp->m_pSpatialPic[iDIdx][0],
                                &pCtx->pVpp->m_pSpatialPic[iDIdx][1 + pCtx->pVaa->uiMarkLongTermPicIdx]);
+}
+static void UpdateSrcPicList (void* pEncCtx) {
+  sWelsEncCtx* pCtx     = (sWelsEncCtx*)pEncCtx;
+  int32_t iDIdx = pCtx->uiDependencyId;
+  //update info in src list
+  UpdareOriginalPicInfo(pCtx->pEncPic, pCtx->pDecPic);
+  PrefetchNextBuffer (pCtx);
+  UpdateSrcListLosslessScreenRefSelectionWithLtr (pCtx);
   SetUnref (pCtx->pVpp->m_pSpatialPic[iDIdx][0]);
 }