ref: c842c5c9468ba88035750d9ef1771b6c3be0a3bd
parent: e4229db53d98c0f24cc541b13b36788a3b514ddd
author: huade <[email protected]>
date: Thu Nov 19 09:56:58 EST 2015
change input parameters for DynamicAdjustSlicePEncCtxAll etc, SSliceCtx refactoring
--- a/codec/encoder/core/inc/slice_multi_threading.h
+++ b/codec/encoder/core/inc/slice_multi_threading.h
@@ -55,7 +55,7 @@
SMB* pMbList,
const int32_t kiSliceIdc);
-void CalcSliceComplexRatio (void* pRatio, SSliceCtx* pSliceCtx, uint32_t* pSliceConsume);
+void CalcSliceComplexRatio (void* pRatio, SDqLayer* pCurDq, uint32_t* pSliceConsume);
int32_t NeedDynamicAdjust (void* pConsumeTime, const int32_t kiSliceNum);
--- a/codec/encoder/core/inc/svc_enc_slice_segment.h
+++ b/codec/encoder/core/inc/svc_enc_slice_segment.h
@@ -172,22 +172,22 @@
/*!
* \brief Get previous mb to be processed in slice/slice_group: uiSliceIdc (apply in Single/multiple slices and FMO)
*
- * \param pSliceCtx SSlice context
+ * \param pCurDq current layer info
* \param kiMbXY MB xy index
*
* \return prev_mb - successful; -1 - failed;
*/
-int32_t WelsGetPrevMbOfSlice (SSliceCtx* pSliceCtx, const int32_t kiMbXY);
+int32_t WelsGetPrevMbOfSlice (SDqLayer* pCurDq, const int32_t kiMbXY);
/*!
* \brief Get number of mb in slice/slice_group: uiSliceIdc (apply in Single/multiple slices and FMO)
*
- * \param pSliceCtx SSlice context
+ * \param pCurDq current layer info
* \param kiSliceIdc slice/slice_group idc
*
* \return count_num_of_mb - successful; -1 - failed;
*/
-int32_t WelsGetNumMbInSlice (SSliceCtx* pSliceCtx, const int32_t kiSliceIdc);
+int32_t WelsGetNumMbInSlice (SDqLayer* pCurDq, const int32_t kiSliceIdc);
/*!
* Get slice count for multiple slice segment
@@ -194,7 +194,7 @@
*
*/
int32_t GetInitialSliceNum (const int32_t kiMbWidth, const int32_t kiMbHeight, SSliceArgument* pSliceArgument);
-int32_t GetCurrentSliceNum (const SSliceCtx* kpSliceCtx);
+int32_t GetCurrentSliceNum (const SDqLayer* pCurDq);
SSlice* GetSliceByIndex(sWelsEncCtx* pCtx, const int32_t kiSliceIdc);
//checking valid para
@@ -208,7 +208,7 @@
bool GomValidCheckSliceMbNum (const int32_t kiMbWidth, const int32_t kiMbHeight, SSliceArgument* pSliceArg);
//end of checking valid para
-int32_t DynamicAdjustSlicePEncCtxAll (SSliceCtx* pSliceCtx,
+int32_t DynamicAdjustSlicePEncCtxAll (SDqLayer* pCurDq,
int32_t* pRunLength);
}
#endif//WELS_SLICE_SEGMENT_H__
--- a/codec/encoder/core/src/deblocking.cpp
+++ b/codec/encoder/core/src/deblocking.cpp
@@ -755,7 +755,7 @@
int32_t iSliceIdx = 0;
if (SM_SIZELIMITED_SLICE != pSpatialLayer->sSliceArgument.uiSliceMode) {
- iSliceCount = GetCurrentSliceNum (&pCurLayer->sSliceEncCtx);
+ iSliceCount = GetCurrentSliceNum (pCurLayer);
do {
DeblockingFilterSliceAvcbase (pCurLayer, pEnc->pFuncList, iSliceIdx);
++ iSliceIdx;
--- a/codec/encoder/core/src/encoder_ext.cpp
+++ b/codec/encoder/core/src/encoder_ext.cpp
@@ -2863,7 +2863,7 @@
if (fDlp->sSliceArgument.uiSliceMode == SM_SIZELIMITED_SLICE) // need get extra slices for update
iSliceCount = GetInitialSliceNum (pCurDq->iMbWidth, pCurDq->iMbHeight, &fDlp->sSliceArgument);
else
- iSliceCount = GetCurrentSliceNum (&pCurDq->sSliceEncCtx);
+ iSliceCount = GetCurrentSliceNum (pCurDq);
assert (iSliceCount > 0);
int32_t iCurPpsId = pDqIdc->iPpsId;
@@ -3126,7 +3126,7 @@
*/
static inline void PrefetchReferencePicture (sWelsEncCtx* pCtx, const EVideoFrameType keFrameType) {
SSlice* pSliceBase = &pCtx->pCurDqLayer->sLayerInfo.pSliceInLayer[0];
- const int32_t kiSliceCount = GetCurrentSliceNum (&pCtx->pCurDqLayer->sSliceEncCtx);
+ const int32_t kiSliceCount = GetCurrentSliceNum (pCtx->pCurDqLayer);
int32_t iIdx = 0;
uint8_t uiRefIdx = -1;
@@ -4014,7 +4014,7 @@
int32_t iRet = 0;
// THREAD_FULLY_FIRE_MODE/THREAD_PICK_UP_MODE for any mode of non-SM_SIZELIMITED_SLICE
if ((SM_SIZELIMITED_SLICE != pParam->sSliceArgument.uiSliceMode) && (pSvcParam->iMultipleThreadIdc > 1)) {
- iSliceCount = GetCurrentSliceNum (&pCtx->pCurDqLayer->sSliceEncCtx);
+ iSliceCount = GetCurrentSliceNum (pCtx->pCurDqLayer);
if (iLayerNum + 1 >= MAX_LAYER_NUM_OF_FRAME) { // check available layer_bs_info for further writing as followed
WelsLog (pLogCtx, WELS_LOG_ERROR,
"WelsEncoderEncodeExt(), iLayerNum(%d) overflow(max:%d) at iDid= %d uiSliceMode= %d, iSliceCount= %d!",
@@ -4064,7 +4064,7 @@
const bool bNeedPrefix = pCtx->bNeedPrefixNalFlag;
int32_t iSliceIdx = 0;
- iSliceCount = GetCurrentSliceNum (&pCtx->pCurDqLayer->sSliceEncCtx);
+ iSliceCount = GetCurrentSliceNum (pCtx->pCurDqLayer);
while (iSliceIdx < iSliceCount) {
int32_t iSliceSize = 0;
int32_t iPayloadSize = 0;
@@ -4300,7 +4300,7 @@
&& pSvcParam->bUseLoadBalancing
&& pSvcParam->iMultipleThreadIdc > 1 &&
pSvcParam->iMultipleThreadIdc >= pParam->sSliceArgument.uiSliceNum) {
- CalcSliceComplexRatio (pCtx->pSliceThreading->pSliceComplexRatio[iCurDid], &pCtx->pCurDqLayer->sSliceEncCtx,
+ CalcSliceComplexRatio (pCtx->pSliceThreading->pSliceComplexRatio[iCurDid], pCtx->pCurDqLayer,
pCtx->pSliceThreading->pSliceConsumeTime[iCurDid]);
#if defined(MT_DEBUG)
TrackSliceComplexities (pCtx, iCurDid);
--- a/codec/encoder/core/src/ref_list_mgr_svc.cpp
+++ b/codec/encoder/core/src/ref_list_mgr_svc.cpp
@@ -479,7 +479,7 @@
}
void WelsMarkPic (sWelsEncCtx* pCtx) {
SLTRState* pLtr = &pCtx->pLtr[pCtx->uiDependencyId];
- const int32_t kiCountSliceNum = GetCurrentSliceNum (&pCtx->pCurDqLayer->sSliceEncCtx);
+ const int32_t kiCountSliceNum = GetCurrentSliceNum (pCtx->pCurDqLayer);
SSlice* pSliceList = NULL;
if (pCtx->pSvcParam->bEnableLongTermReference && pLtr->bLTRMarkEnable && pCtx->uiTemporalId == 0) {
@@ -641,7 +641,7 @@
void WelsUpdateSliceHeaderSyntax(sWelsEncCtx* pCtx, const int32_t iAbsDiffPicNumMinus1,
SSlice* pSliceList, const int32_t uiFrameType) {
- const int32_t kiCountSliceNum = GetCurrentSliceNum(&pCtx->pCurDqLayer->sSliceEncCtx);
+ const int32_t kiCountSliceNum = GetCurrentSliceNum(pCtx->pCurDqLayer);
SLTRState* pLtr = &pCtx->pLtr[pCtx->uiDependencyId];
int32_t iIdx = 0;
@@ -973,7 +973,7 @@
}
}
- const int32_t iSliceNum = GetCurrentSliceNum(&pCtx->pCurDqLayer->sSliceEncCtx);
+ const int32_t iSliceNum = GetCurrentSliceNum(pCtx->pCurDqLayer);
if (pCtx->iActiveThreadsNum > 1) {
// to do: will replace with thread based buffer later
--- a/codec/encoder/core/src/slice_multi_threading.cpp
+++ b/codec/encoder/core/src/slice_multi_threading.cpp
@@ -127,7 +127,8 @@
} while (iIdx <= kiEndMbInSlice);
}
-void CalcSliceComplexRatio (void* pRatio, SSliceCtx* pSliceCtx, uint32_t* pSliceConsume) {
+void CalcSliceComplexRatio (void* pRatio, SDqLayer* pCurDq, uint32_t* pSliceConsume) {
+ SSliceCtx* pSliceCtx = &pCurDq->sSliceEncCtx;
int32_t* pRatioList = (int32_t*)pRatio;
int32_t iAvI[MAX_SLICES_NUM];
int32_t iSumAv = 0;
@@ -279,7 +280,7 @@
iSliceIdx, pSliceComplexRatio[iSliceIdx] * 1.0f / INT_MULTIPLY, pSliceCtx->pCountMbNumInSlice[iSliceIdx], iMbNumLeft);
- if (DynamicAdjustSlicePEncCtxAll (pSliceCtx, iRunLen) == 0) {
+ if (DynamicAdjustSlicePEncCtxAll (pCurDqLayer, iRunLen) == 0) {
const int32_t kiThreadNum = pCtx->pSvcParam->iCountThreadsNum;
int32_t iThreadIdx = 0;
do {
--- a/codec/encoder/core/src/svc_enc_slice_segment.cpp
+++ b/codec/encoder/core/src/svc_enc_slice_segment.cpp
@@ -622,14 +622,14 @@
/*!
* \brief Get previous mb to be processed in slice/slice_group: uiSliceIdc (apply in Single/multiple slices and FMO)
*
- * \param pSliceCtx SSlice context
- * \param kiMbXY MB xy index
+ * \param pCurDq current layer info
+ * \param kiMbXY MB xy index
*
* \return prev_mb - successful; -1 - failed;
*/
-int32_t WelsGetPrevMbOfSlice (SSliceCtx* pSliceCtx, const int32_t kiMbXY) {
- if (NULL != pSliceCtx) {
- SSliceCtx* pSliceSeg = pSliceCtx;
+int32_t WelsGetPrevMbOfSlice (SDqLayer* pCurDq, const int32_t kiMbXY) {
+ if (NULL != pCurDq) {
+ SSliceCtx* pSliceSeg = &pCurDq->sSliceEncCtx;
if (NULL == pSliceSeg || kiMbXY < 0 || kiMbXY >= pSliceSeg->iMbNumInFrame)
return -1;
if (pSliceSeg->uiSliceMode == SM_SINGLE_SLICE)
@@ -657,7 +657,8 @@
*
* \return count_num_of_mb - successful; -1 - failed;
*/
-int32_t WelsGetNumMbInSlice (SSliceCtx* pSliceCtx, const int32_t kuiSliceIdc) {
+int32_t WelsGetNumMbInSlice (SDqLayer* pCurDq, const int32_t kuiSliceIdc) {
+ SSliceCtx* pSliceCtx = &pCurDq->sSliceEncCtx;
if (NULL == pSliceCtx || kuiSliceIdc < 0)
return -1;
{
@@ -674,11 +675,13 @@
}
}
-int32_t GetCurrentSliceNum (const SSliceCtx* kpSliceCtx) {
+int32_t GetCurrentSliceNum (const SDqLayer* pCurDq) {
+ const SSliceCtx* kpSliceCtx = &pCurDq->sSliceEncCtx;
return (kpSliceCtx != NULL) ? (kpSliceCtx->iSliceNumInFrame) : (-1);
}
-int32_t DynamicAdjustSlicePEncCtxAll (SSliceCtx* pSliceCtx,
+int32_t DynamicAdjustSlicePEncCtxAll (SDqLayer* pCurDq,
int32_t* pRunLength) {
+ SSliceCtx* pSliceCtx = &pCurDq->sSliceEncCtx;
const int32_t iCountNumMbInFrame = pSliceCtx->iMbNumInFrame;
const int32_t iCountSliceNumInFrame = pSliceCtx->iSliceNumInFrame;
int32_t iSameRunLenFlag = 1;
--- a/codec/encoder/core/src/svc_motion_estimate.cpp
+++ b/codec/encoder/core/src/svc_motion_estimate.cpp
@@ -1016,7 +1016,7 @@
//switch related
static uint32_t CountFMECostDown (const SDqLayer* pCurLayer) {
uint32_t uiCostDownSum = 0;
- const int32_t kiSliceCount = GetCurrentSliceNum (&pCurLayer->sSliceEncCtx);
+ const int32_t kiSliceCount = GetCurrentSliceNum (pCurLayer);
if (kiSliceCount >= 1) {
int32_t iSliceIndex = 0;
SSlice* pSlice = &pCurLayer->sLayerInfo.pSliceInLayer[iSliceIndex];