ref: ff8bb6238d24a6de812f04c036abdd4ec3c05276
parent: 08f7ad3f1fd0e0e5f7a5dd598fc597774fab94ba
author: huade <huashi@cisco.com>
date: Tue Oct 27 13:44:55 EDT 2015
refact WelsMarkPic based on pSlice buffer refactoring
--- a/codec/encoder/core/inc/svc_enc_slice_segment.h
+++ b/codec/encoder/core/inc/svc_enc_slice_segment.h
@@ -72,6 +72,8 @@
#define JUMPPACKETSIZE_JUDGE(len,mb_idx,max_byte) ( (len) > JUMPPACKETSIZE_CONSTRAINT(max_byte) ) //( (mb_idx+1)%40/*16slice for compare*/ == 0 ) //
//cur_mb_idx is for early tests, can be omit in optimization
+typedef struct TagSlice SSlice;
+typedef struct TagWelsEncCtx sWelsEncCtx;
/*!
* \brief SSlice context
*/
@@ -190,6 +192,7 @@
*/
int32_t GetInitialSliceNum (const int32_t kiMbWidth, const int32_t kiMbHeight, SSliceConfig* pMso);
int32_t GetCurrentSliceNum (const SSliceCtx* kpSliceCtx);
+SSlice* GetSliceByIndex(sWelsEncCtx* pCtx, const int32_t kiSliceIdc);
//checking valid para
int32_t DynamicMaxSliceNumConstraint (uint32_t uiMaximumNum, int32_t uiConsumedNum, uint32_t uiDulplicateTimes);
--- a/codec/encoder/core/src/ref_list_mgr_svc.cpp
+++ b/codec/encoder/core/src/ref_list_mgr_svc.cpp
@@ -444,34 +444,17 @@
return true;
}
-void WelsMarkPic (sWelsEncCtx* pCtx) {
- SLTRState* pLtr = &pCtx->pLtr[pCtx->uiDependencyId];
- const int32_t kiCountSliceNum = GetCurrentSliceNum (pCtx->pCurDqLayer->pSliceEncCtx);
- int32_t iGoPFrameNumInterval = ((pCtx->pSvcParam->uiGopSize >> 1) > 1) ? (pCtx->pSvcParam->uiGopSize >> 1) : (1);
+void WlesMarkMMCORefInfo(sWelsEncCtx* pCtx, SLTRState* pLtr,
+ SSlice* pSliceList, const int32_t kiCountSliceNum) {
int32_t iSliceIdx = 0;
+ int32_t iGoPFrameNumInterval = ((pCtx->pSvcParam->uiGopSize >> 1) > 1) ? (pCtx->pSvcParam->uiGopSize >> 1) : (1);
- if (pCtx->pSvcParam->bEnableLongTermReference && pLtr->bLTRMarkEnable && pCtx->uiTemporalId == 0) {
- if (!pLtr->bReceivedT0LostFlag && pLtr->uiLtrMarkInterval > pCtx->pSvcParam->iLtrMarkPeriod
- && CheckCurMarkFrameNumUsed (pCtx)) {
- pLtr->bLTRMarkingFlag = true;
- pLtr->bLTRMarkEnable = false;
- pLtr->uiLtrMarkInterval = 0;
- for (int32_t i = 0 ; i < MAX_TEMPORAL_LAYER_NUM; ++i) {
- if (pCtx->uiTemporalId < i || pCtx->uiTemporalId == 0) {
- pLtr->iLastLtrIdx[i] = pLtr->iCurLtrIdx;
- }
- }
- } else {
- pLtr->bLTRMarkingFlag = false;
- }
- }
-
for (iSliceIdx = 0; iSliceIdx < kiCountSliceNum; iSliceIdx++) {
- SSliceHeaderExt* pSliceHdrExt = &pCtx->pCurDqLayer->sLayerInfo.pSliceInLayer[iSliceIdx].sSliceHeaderExt;
- SSliceHeader* pSliceHdr = &pSliceHdrExt->sSliceHeader;
- SRefPicMarking* pRefPicMark = &pSliceHdr->sRefMarking;
+ SSliceHeaderExt* pSliceHdrExt = &pSliceList[iSliceIdx].sSliceHeaderExt;
+ SSliceHeader* pSliceHdr = &pSliceHdrExt->sSliceHeader;
+ SRefPicMarking* pRefPicMark = &pSliceHdr->sRefMarking;
- memset (pRefPicMark, 0, sizeof (SRefPicMarking));
+ memset(pRefPicMark, 0, sizeof(SRefPicMarking));
if (pCtx->pSvcParam->bEnableLongTermReference && pLtr->bLTRMarkingFlag) {
if (pLtr->iLTRMarkMode == LTR_DIRECT_MARK) {
@@ -483,12 +466,45 @@
pRefPicMark->SMmcoRef[pRefPicMark->uiMmcoCount].iLongTermFrameIdx = pLtr->iCurLtrIdx;
pRefPicMark->SMmcoRef[pRefPicMark->uiMmcoCount++].iMmcoType = MMCO_LONG;
- } else if (pLtr->iLTRMarkMode == LTR_DELAY_MARK) {
+ }
+ else if (pLtr->iLTRMarkMode == LTR_DELAY_MARK) {
pRefPicMark->SMmcoRef[pRefPicMark->uiMmcoCount].iDiffOfPicNum = iGoPFrameNumInterval;
pRefPicMark->SMmcoRef[pRefPicMark->uiMmcoCount].iLongTermFrameIdx = pLtr->iCurLtrIdx;
pRefPicMark->SMmcoRef[pRefPicMark->uiMmcoCount++].iMmcoType = MMCO_SHORT2LONG;
}
}
+ }
+
+}
+void WelsMarkPic (sWelsEncCtx* pCtx) {
+ SLTRState* pLtr = &pCtx->pLtr[pCtx->uiDependencyId];
+ const int32_t kiCountSliceNum = GetCurrentSliceNum (pCtx->pCurDqLayer->pSliceEncCtx);
+ SSlice* pSliceList = NULL;
+
+ if (pCtx->pSvcParam->bEnableLongTermReference && pLtr->bLTRMarkEnable && pCtx->uiTemporalId == 0) {
+ if (!pLtr->bReceivedT0LostFlag && pLtr->uiLtrMarkInterval > pCtx->pSvcParam->iLtrMarkPeriod
+ && CheckCurMarkFrameNumUsed (pCtx)) {
+ pLtr->bLTRMarkingFlag = true;
+ pLtr->bLTRMarkEnable = false;
+ pLtr->uiLtrMarkInterval = 0;
+ for (int32_t i = 0 ; i < MAX_TEMPORAL_LAYER_NUM; ++i) {
+ if (pCtx->uiTemporalId < i || pCtx->uiTemporalId == 0) {
+ pLtr->iLastLtrIdx[i] = pLtr->iCurLtrIdx;
+ }
+ }
+ } else {
+ pLtr->bLTRMarkingFlag = false;
+ }
+ }
+
+ if (pCtx->iActiveThreadsNum > 1) {
+ //will replace with thread-base pslice buffer later
+ pSliceList = pCtx->pCurDqLayer->sLayerInfo.pSliceInLayer;
+ WlesMarkMMCORefInfo(pCtx, pLtr, pSliceList, kiCountSliceNum);
+ }
+ else {
+ pSliceList = pCtx->pCurDqLayer->sLayerInfo.pSliceInLayer;
+ WlesMarkMMCORefInfo(pCtx, pLtr, pSliceList, kiCountSliceNum);
}
}