ref: b402a6ab49b5b8ccd88559cf8013fa641a6d30f9
parent: da4dd40eaeebf8065499fff268e700d103384d10
author: huade <[email protected]>
date: Tue Dec 20 03:01:48 EST 2016
Multi-thread-fixed:RBC#1691:refactoring for WelsGetNumMbInSlice
--- a/codec/encoder/core/inc/svc_enc_slice_segment.h
+++ b/codec/encoder/core/inc/svc_enc_slice_segment.h
@@ -180,11 +180,12 @@
* \brief Get number of mb in slice/slice_group: uiSliceIdc (apply in Single/multiple slices and FMO)
*
* \param pCurDq current layer info
+ * \param pSlice slice which request slice num
* \param kiSliceIdc slice/slice_group idc
*
* \return count_num_of_mb - successful; -1 - failed;
*/
-int32_t WelsGetNumMbInSlice (SDqLayer* pCurDq, const int32_t kiSliceIdc);
+int32_t WelsGetNumMbInSlice (SDqLayer* pCurDq, SSlice* pSlice, const int32_t kuiSliceIdc);
/*!
* Get slice count for multiple slice segment
--- a/codec/encoder/core/src/encoder_ext.cpp
+++ b/codec/encoder/core/src/encoder_ext.cpp
@@ -3789,6 +3789,9 @@
//TO DO: add update ppSliceInLayer module based on pSliceInThread[ThreadNum]
// UpdateSliceInLayerInfo(); // reordering
+ //TO DO: add update ppSliceInLayer module based on pSliceInThread[ThreadNum]
+ // UpdateSliceInLayerInfo(); // reordering
+
iLayerSize = AppendSliceToFrameBs (pCtx, pLayerBsInfo, kiPartitionCnt);
} else { // for non-dynamic-slicing mode single threading branch..
const bool bNeedPrefix = pCtx->bNeedPrefixNalFlag;
--- a/codec/encoder/core/src/ref_list_mgr_svc.cpp
+++ b/codec/encoder/core/src/ref_list_mgr_svc.cpp
@@ -494,7 +494,6 @@
void WelsMarkPic (sWelsEncCtx* pCtx) {
SLTRState* pLtr = &pCtx->pLtr[pCtx->uiDependencyId];
const int32_t kiCountSliceNum = GetCurrentSliceNum (pCtx->pCurDqLayer);
- SSlice** ppSliceList = NULL;
if (pCtx->pSvcParam->bEnableLongTermReference && pLtr->bLTRMarkEnable && pCtx->uiTemporalId == 0) {
if (!pLtr->bReceivedT0LostFlag && pLtr->uiLtrMarkInterval > pCtx->pSvcParam->iLtrMarkPeriod
@@ -512,8 +511,7 @@
}
}
- ppSliceList = pCtx->pCurDqLayer->ppSliceInLayer;
- WlesMarkMMCORefInfo (pCtx, pLtr, ppSliceList, kiCountSliceNum);
+ WlesMarkMMCORefInfo (pCtx, pLtr, pCtx->pCurDqLayer->ppSliceInLayer, kiCountSliceNum);
}
int32_t FilterLTRRecoveryRequest (sWelsEncCtx* pCtx, SLTRRecoverRequest* pLTRRecoverRequest) {
@@ -710,9 +708,8 @@
*/
void WelsUpdateRefSyntax (sWelsEncCtx* pCtx, const int32_t iPOC, const int32_t uiFrameType) {
- int32_t iAbsDiffPicNumMinus1 = -1;
- SSlice** ppSliceList = NULL;
- SSpatialLayerInternal* pParamD = &pCtx->pSvcParam->sDependencyLayers[pCtx->uiDependencyId];
+ int32_t iAbsDiffPicNumMinus1 = -1;
+ SSpatialLayerInternal* pParamD = &pCtx->pSvcParam->sDependencyLayers[pCtx->uiDependencyId];
/*syntax for ref_pic_list_reordering()*/
if (pCtx->iNumRef0 > 0) {
iAbsDiffPicNumMinus1 = pParamD->iFrameNum - (pCtx->pRefList0[0]->iFrameNum) - 1;
@@ -725,8 +722,7 @@
}
}
- ppSliceList = pCtx->pCurDqLayer->ppSliceInLayer;
- WelsUpdateSliceHeaderSyntax (pCtx, iAbsDiffPicNumMinus1, ppSliceList, uiFrameType);
+ WelsUpdateSliceHeaderSyntax (pCtx, iAbsDiffPicNumMinus1, pCtx->pCurDqLayer->ppSliceInLayer, uiFrameType);
}
static inline void UpdateOriginalPicInfo (SPicture* pOrigPic, SPicture* pReconPic) {
@@ -916,7 +912,7 @@
SLTRState* pLtr = &pCtx->pLtr[pCtx->uiDependencyId];
int32_t iMaxTid = WELS_LOG2 (pCtx->pSvcParam->uiGopSize);
int32_t iMaxActualLtrIdx = -1;
- SSlice** ppSliceList = NULL;
+
SSpatialLayerInternal* pParamD = &pCtx->pSvcParam->sDependencyLayers[pCtx->uiDependencyId];
if (pCtx->pSvcParam->bEnableLongTermReference)
iMaxActualLtrIdx = pCtx->pSvcParam->iNumRefFrame - STR_ROOM - 1 - WELS_MAX (iMaxTid , 1);
@@ -993,8 +989,7 @@
const int32_t iSliceNum = GetCurrentSliceNum (pCtx->pCurDqLayer);
- ppSliceList = pCtx->pCurDqLayer->ppSliceInLayer;
- WlesMarkMMCORefInfoScreen (pCtx, pLtr, ppSliceList, iSliceNum);
+ WlesMarkMMCORefInfoScreen (pCtx, pLtr, pCtx->pCurDqLayer->ppSliceInLayer, iSliceNum);
return;
}
--- a/codec/encoder/core/src/svc_enc_slice_segment.cpp
+++ b/codec/encoder/core/src/svc_enc_slice_segment.cpp
@@ -608,28 +608,26 @@
* \brief Get number of mb in slice/slice_group: uiSliceIdc (apply in Single/multiple slices and FMO)
*
* \param pSliceCtx SSlice context
+ * \param pSlice slice which request slice num
* \param kuiSliceIdc slice/slice_group idc
*
* \return count_num_of_mb - successful; -1 - failed;
*/
-int32_t WelsGetNumMbInSlice (SDqLayer* pCurDq, const int32_t kuiSliceIdc) {
+int32_t WelsGetNumMbInSlice (SDqLayer* pCurDq, SSlice* pSlice, const int32_t kuiSliceIdc) {
SSliceCtx* pSliceCtx = &pCurDq->sSliceEncCtx;
- SSlice* pSlice = pCurDq->ppSliceInLayer[kuiSliceIdc];
+ bool bInValidFlag = false;
- if (NULL == pSliceCtx || kuiSliceIdc < 0)
+ if (NULL == pSliceCtx || NULL == pSlice || kuiSliceIdc < 0) {
return -1;
- {
- SSliceCtx* pSliceSeg = pSliceCtx;
- if (SM_SINGLE_SLICE != pSliceSeg->uiSliceMode) {
- if (kuiSliceIdc >= pSliceSeg->iSliceNumInFrame)
- return -1;
- return pSlice->iCountMbNumInSlice;
- } else { /*if ( pSliceSeg->uiSliceMode == SM_SINGLE_SLICE )*/
- if (kuiSliceIdc > 0)
- return -1;
- return pSlice->iCountMbNumInSlice;
- }
}
+
+ bInValidFlag = ((SM_SINGLE_SLICE != pSliceCtx->uiSliceMode) && (kuiSliceIdc >= pSliceCtx->iSliceNumInFrame))
+ || ((SM_SINGLE_SLICE == pSliceCtx->uiSliceMode) && (kuiSliceIdc > 0));
+ if(bInValidFlag) {
+ return -1;
+ }
+
+ return pSlice->iCountMbNumInSlice;
}
int32_t GetCurrentSliceNum (const SDqLayer* pCurDq) {