ref: 40566f29f05e2ec8dced96f80dbb47ce23a4cff3
parent: 6f347d17f173d2a44659a3ce9b8e12dc7777fd32
author: huade <huashi@cisco.com>
date: Wed Dec 21 09:47:59 EST 2016
Multi-thread-fixed:RBC#1713:pSlice instead of kiSliceIdx as input parameter in WelsCodeOneSlice
--- a/codec/encoder/core/inc/svc_enc_frame.h
+++ b/codec/encoder/core/inc/svc_enc_frame.h
@@ -118,7 +118,6 @@
int32_t* pLastCodedMbIdxOfPartition; // for dynamic slicing mode
int32_t* pFirstMbIdxOfPartition; // for dynamic slicing mode
int32_t* pEndMbIdxOfPartition; // for dynamic slicing mode
-
int32_t* pFirstMbIdxOfSlice;
int32_t* pCountMbNumInSlice;
--- a/codec/encoder/core/inc/svc_encode_slice.h
+++ b/codec/encoder/core/inc/svc_encode_slice.h
@@ -143,7 +143,7 @@
int32_t WelsCodePSlice (sWelsEncCtx* pEncCtx, SSlice* pSlice);
int32_t WelsCodePOverDynamicSlice (sWelsEncCtx* pEncCtx, SSlice* pSlice);
-int32_t WelsCodeOneSlice (sWelsEncCtx* pEncCtx, const int32_t kiSliceIdx,
+int32_t WelsCodeOneSlice (sWelsEncCtx* pEncCtx, SSlice* pCurSlice,
const int32_t keNalType);
void WelsInitSliceEncodingFuncs (uint32_t uiCpuFlag);
--- a/codec/encoder/core/src/encoder_ext.cpp
+++ b/codec/encoder/core/src/encoder_ext.cpp
@@ -3660,8 +3660,9 @@
iLayerSize = 0;
if (SM_SINGLE_SLICE == pParam->sSliceArgument.uiSliceMode) { // only one slice within a sQualityStat layer
- int32_t iSliceSize = 0;
+ int32_t iSliceSize = 0;
int32_t iPayloadSize = 0;
+ SSlice* pCurSlice = pCtx->pCurDqLayer->ppSliceInLayer[0];
if (pCtx->bNeedPrefixNalFlag) {
pCtx->iEncoderError = AddPrefixNal (pCtx, pLayerBsInfo, &pLayerBsInfo->pNalLengthInByte[0], &iNalIdxInLayer, eNalType,
@@ -3672,8 +3673,8 @@
}
WelsLoadNal (pCtx->pOut, eNalType, eNalRefIdc);
-
- pCtx->iEncoderError = WelsCodeOneSlice (pCtx, 0, eNalType);
+ assert (0 == (int) pCurSlice->uiSliceIdx);
+ pCtx->iEncoderError = WelsCodeOneSlice (pCtx, pCurSlice, eNalType);
WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS)
WelsUnloadNal (pCtx->pOut);
@@ -3793,11 +3794,11 @@
#endif
//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;
int32_t iSliceIdx = 0;
+ SSlice* pCurSlice = NULL;
iSliceCount = GetCurrentSliceNum (pCtx->pCurDqLayer);
while (iSliceIdx < iSliceCount) {
@@ -3812,7 +3813,9 @@
}
WelsLoadNal (pCtx->pOut, eNalType, eNalRefIdc);
- pCtx->iEncoderError = WelsCodeOneSlice (pCtx, iSliceIdx, eNalType);
+ pCurSlice = pCtx->pCurDqLayer->ppSliceInLayer[iSliceIdx];
+ assert (iSliceIdx == (int) pCurSlice->uiSliceIdx);
+ pCtx->iEncoderError = WelsCodeOneSlice (pCtx, pCurSlice, eNalType);
WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS)
WelsUnloadNal (pCtx->pOut);
@@ -4523,6 +4526,7 @@
while (iAnyMbLeftInPartition > 0) {
int32_t iSliceSize = 0;
int32_t iPayloadSize = 0;
+ SSlice* pCurSlice = NULL;
if (iSliceIdx >= (pSliceCtx->iMaxSliceNumConstraint - kiSliceIdxStep)) { // insufficient memory in pSliceInLayer[]
if (pCtx->iActiveThreadsNum == 1) {
@@ -4548,7 +4552,9 @@
}
WelsLoadNal (pCtx->pOut, keNalType, keNalRefIdc);
- iReturn = WelsCodeOneSlice (pCtx, iSliceIdx, keNalType);
+ pCurSlice = pCtx->pCurDqLayer->ppSliceInLayer[iSliceIdx];
+ assert (iSliceIdx == (int) pCurSlice->uiSliceIdx);
+ iReturn = WelsCodeOneSlice (pCtx, pCurSlice, keNalType);
WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS)
WelsUnloadNal (pCtx->pOut);
--- a/codec/encoder/core/src/slice_multi_threading.cpp
+++ b/codec/encoder/core/src/slice_multi_threading.cpp
@@ -594,6 +594,7 @@
const int32_t kiCurDid = pEncPEncCtx->uiDependencyId;
SWelsSvcCodingParam* pCodingParam = pEncPEncCtx->pSvcParam;
SSpatialLayerConfig* pParamD = &pCodingParam->sSpatialLayers[kiCurDid];
+ SSlice* pCurSlice = NULL;
pCurDq = pEncPEncCtx->pCurDqLayer;
eNalType = pEncPEncCtx->eNalType;
@@ -635,8 +636,9 @@
}
WelsLoadNalForSlice (pSliceBs, eNalType, eNalRefIdc);
-
- iReturn = WelsCodeOneSlice (pEncPEncCtx, iSliceIdx, eNalType);
+ pCurSlice = pEncPEncCtx->pCurDqLayer->ppSliceInLayer[iSliceIdx];
+ assert (iSliceIdx == (int) pCurSlice->uiSliceIdx);
+ iReturn = WelsCodeOneSlice (pEncPEncCtx, pCurSlice, eNalType);
if (ENC_RETURN_SUCCESS != iReturn) {
uiThrdRet = iReturn;
WELS_THREAD_SIGNAL_AND_BREAK (pEncPEncCtx->pSliceThreading->pSliceCodedEvent,
@@ -735,8 +737,9 @@
WelsLoadNalForSlice (pSliceBs, eNalType, eNalRefIdc);
-
- iReturn = WelsCodeOneSlice (pEncPEncCtx, iSliceIdx, eNalType);
+ pCurSlice = pEncPEncCtx->pCurDqLayer->ppSliceInLayer[iSliceIdx];
+ assert (iSliceIdx == (int) pCurSlice->uiSliceIdx);
+ iReturn = WelsCodeOneSlice (pEncPEncCtx, pCurSlice, eNalType);
if (ENC_RETURN_SUCCESS != iReturn) {
uiThrdRet = iReturn;
WELS_THREAD_SIGNAL_AND_BREAK (pEncPEncCtx->pSliceThreading->pSliceCodedEvent,
--- a/codec/encoder/core/src/svc_encode_slice.cpp
+++ b/codec/encoder/core/src/svc_encode_slice.cpp
@@ -1279,6 +1279,7 @@
}
*/
+
int32_t ReallocSliceBuffer (sWelsEncCtx* pCtx) {
CMemoryAlign* pMA = pCtx->pMemAlign;
@@ -1461,16 +1462,12 @@
}
*/
-int32_t WelsCodeOneSlice (sWelsEncCtx* pEncCtx, const int32_t kiSliceIdx, const int32_t kiNalType) {
+int32_t WelsCodeOneSlice (sWelsEncCtx* pEncCtx, SSlice* pCurSlice, const int32_t kiNalType) {
SDqLayer* pCurLayer = pEncCtx->pCurDqLayer;
SNalUnitHeaderExt* pNalHeadExt = &pCurLayer->sLayerInfo.sNalHeaderExt;
- SSlice* pCurSlice = pCurLayer->ppSliceInLayer[kiSliceIdx];
SBitStringAux* pBs = pCurSlice->pSliceBsa;
const int32_t kiDynamicSliceFlag = (pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId].sSliceArgument.uiSliceMode
== SM_SIZELIMITED_SLICE);
-
- assert (kiSliceIdx == (int) pCurSlice->uiSliceIdx);
-
if (I_SLICE == pEncCtx->eSliceType) {
pNalHeadExt->bIdrFlag = 1;
pCurSlice->sScaleShift = 0;
--- a/codec/encoder/core/src/wels_task_encoder.cpp
+++ b/codec/encoder/core/src/wels_task_encoder.cpp
@@ -163,7 +163,9 @@
}
WelsLoadNalForSlice (m_pSliceBs, m_eNalType, m_eNalRefIdc);
- int32_t iReturn = WelsCodeOneSlice (m_pCtx, m_iSliceIdx, m_eNalType);
+ SSlice* pCurSlice = m_pCtx->pCurDqLayer->ppSliceInLayer[m_iSliceIdx];
+ assert (m_iSliceIdx == (int) pCurSlice->uiSliceIdx);
+ int32_t iReturn = WelsCodeOneSlice (m_pCtx, pCurSlice, m_eNalType);
if (ENC_RETURN_SUCCESS != iReturn) {
return iReturn;
}
@@ -280,7 +282,9 @@
}
WelsLoadNalForSlice (m_pSliceBs, m_eNalType, m_eNalRefIdc);
- int32_t iReturn = WelsCodeOneSlice (m_pCtx, iLocalSliceIdx, m_eNalType);
+ SSlice* pCurSlice = m_pCtx->pCurDqLayer->ppSliceInLayer[iLocalSliceIdx];
+ assert (iLocalSliceIdx == (int) pCurSlice->uiSliceIdx);
+ int32_t iReturn = WelsCodeOneSlice (m_pCtx, pCurSlice, m_eNalType);
if (ENC_RETURN_SUCCESS != iReturn) {
return iReturn;
}