shithub: openh264

Download patch

ref: c43e1c8f43edb0f07b50fd083f7fda217d59776b
parent: 6b08aeff9c012b169b90e51ba0fba922c67986bc
parent: 81d588e38e80e88631919818d350cf0c7d81df78
author: sijchen <[email protected]>
date: Wed Apr 2 12:46:16 EDT 2014

Merge pull request #622 from ruil2/dpb_ltr

add LTR processing in reference frame management

--- a/codec/encoder/core/src/ref_list_mgr_svc.cpp
+++ b/codec/encoder/core/src/ref_list_mgr_svc.cpp
@@ -115,6 +115,18 @@
   pRefList->uiShortRefCount--;
 
 }
+static void DeleteNonSceneLTR (sWelsEncCtx* pCtx) {
+  SRefList* pRefList = pCtx->ppRefPicListExt[pCtx->uiDependencyId];
+  for (int32_t i = 0; i < pCtx->pSvcParam->iNumRefFrame; ++i) {
+    SPicture* pRef = pRefList->pLongRefList[i];
+    if (pRef != NULL &&  pRef->bUsedAsRef && pRef->bIsLongRef && (!pRef->bIsSceneLTR) &&
+        (pCtx->uiTemporalId < pRef->uiTemporalId || pCtx->bCurFrameMarkedAsSceneLtr)) {
+      SetUnref (pRef);
+      DeleteLTRFromLongList (pCtx, i);
+    }
+  }
+}
+
 static inline int32_t CompareFrameNum (int32_t iFrameNumA, int32_t iFrameNumB, int32_t iMaxFrameNumPlus1) {
   int64_t iNumA, iNumB, iDiffAB, iDiffMin;
   if (iFrameNumA > iMaxFrameNumPlus1 || iFrameNumB > iMaxFrameNumPlus1) {
@@ -300,6 +312,21 @@
     DeleteSTRFromShortList (pCtx, i);
   }
 }
+
+static inline void LTRMarkProcessScreen (sWelsEncCtx* pCtx) {
+  SRefList* pRefList		= pCtx->ppRefPicListExt[pCtx->uiDependencyId];
+  SPicture** pLongRefList = pRefList->pLongRefList;
+  int32_t iLtrIdx =  pCtx->pDecPic->iLongTermPicNum;
+  pCtx->pVaa->uiMarkLongTermPicIdx = pCtx->pDecPic->iLongTermPicNum;
+
+  if (pLongRefList[iLtrIdx] != NULL) {
+    SetUnref (pLongRefList[iLtrIdx]);
+    DeleteLTRFromLongList (pCtx, iLtrIdx);
+  }
+  pLongRefList[iLtrIdx] = pCtx->pDecPic;
+  pRefList->uiLongRefCount;
+}
+
 static inline void PrefetchNextBuffer (sWelsEncCtx* pCtx) {
   SRefList* pRefList		= pCtx->ppRefPicListExt[pCtx->uiDependencyId];
   const int32_t kiNumRef	= pCtx->pSvcParam->iNumRefFrame;
@@ -669,11 +696,12 @@
     pCtx->pDecPic->iLongTermPicNum = pLtr->iCurLtrIdx;
   }
   if (pCtx->eSliceType == P_SLICE) {
-    //TBD LTR mark
+    DeleteNonSceneLTR (pCtx);
+    LTRMarkProcessScreen (pCtx);
     pLtr->bLTRMarkingFlag = false;
     ++pLtr->uiLtrMarkInterval;
   } else {	// in case IDR currently coding
-    //TBD LTR mark
+    LTRMarkProcessScreen (pCtx);
     pLtr->iCurLtrIdx = 1;
     pLtr->iSceneLtrIdx = 1;
     pLtr->uiLtrMarkInterval = 0;