fix SM_FIXEDSLCNUM_SLICE bug, add SM_AUTO_SLICE mode
This commit is contained in:
parent
ca457f57e9
commit
7c8ce799c0
@ -160,7 +160,8 @@ typedef enum {
|
||||
SM_RASTER_SLICE = 2, // | according to SlicesAssign | Need input of MB numbers each slice. In addition, if other constraint in SSliceArgument is presented, need to follow the constraints. Typically if MB num and slice size are both constrained, re-encoding may be involved.
|
||||
SM_ROWMB_SLICE = 3, // | according to PictureMBHeight | Typical of single row of mbs each slice?+ slice size constraint which including re-encoding
|
||||
SM_DYN_SLICE = 4, // | according to SliceSize | Dynamic slicing (have no idea about slice_nums until encoding current frame)
|
||||
SM_RESERVED = 5
|
||||
SM_AUTO_SLICE = 5, // | according to thread number
|
||||
SM_RESERVED = 6
|
||||
} SliceModeEnum;
|
||||
|
||||
typedef struct {
|
||||
|
@ -552,6 +552,9 @@ int ParseCommandLine (int argc, char** argv, SSourcePicture* pSrcPic, SEncParamE
|
||||
case 4:
|
||||
pDLayer->sSliceCfg.uiSliceMode = SM_DYN_SLICE;
|
||||
break;
|
||||
case 5:
|
||||
pDLayer->sSliceCfg.uiSliceMode = SM_AUTO_SLICE;
|
||||
break;
|
||||
default:
|
||||
pDLayer->sSliceCfg.uiSliceMode = SM_RESERVED;
|
||||
break;
|
||||
|
@ -226,7 +226,8 @@ int32_t ParamValidationExt (sWelsEncCtx*pCtx,SWelsSvcCodingParam* pCodingParam)
|
||||
fDlp->sSliceCfg.sSliceArgument.uiSliceMbNum[iIdx] = 0;
|
||||
}
|
||||
break;
|
||||
case SM_FIXEDSLCNUM_SLICE: {
|
||||
case SM_FIXEDSLCNUM_SLICE:
|
||||
case SM_AUTO_SLICE:{
|
||||
fDlp->sSliceCfg.sSliceArgument.uiSliceSizeConstraint = 0;
|
||||
|
||||
iMbWidth = (kiPicWidth + 15) >> 4;
|
||||
@ -1690,14 +1691,7 @@ int32_t InitSliceSettings (SWelsSvcCodingParam* pCodingParam, const int32_t kiCp
|
||||
const int32_t kiMbWidth = (pDlp->iFrameWidth + 15) >> 4;
|
||||
const int32_t kiMbHeight = (pDlp->iFrameHeight + 15) >> 4;
|
||||
const int32_t kiMbNumInFrame = kiMbWidth * kiMbHeight;
|
||||
#if defined(MT_ENABLED)
|
||||
int32_t iSliceNum = (SM_FIXEDSLCNUM_SLICE == pMso->uiSliceMode
|
||||
|| SM_DYN_SLICE == pMso->uiSliceMode) ? kiCpuCores :
|
||||
pSlcArg->uiSliceNum; // uiSliceNum per input has been validated at ParamValidationExt()
|
||||
#else//!MT_ENABLED
|
||||
int16_t iSliceNum = pSlcArg->uiSliceNum; // uiSliceNum per input has been validated at ParamValidationExt()
|
||||
#endif//MT_ENABLED
|
||||
|
||||
int32_t iSliceNum = (SM_AUTO_SLICE == pMso->uiSliceMode)? kiCpuCores :pSlcArg->uiSliceNum;
|
||||
// NOTE: Per design, in case MT/DYNAMIC_SLICE_ASSIGN enabled, for SM_FIXEDSLCNUM_SLICE mode,
|
||||
// uiSliceNum of current spatial layer settings equals to uiCpuCores number; SM_DYN_SLICE mode,
|
||||
// uiSliceNum intials as uiCpuCores also, stay tuned dynamically slicing in future
|
||||
@ -1710,6 +1704,7 @@ int32_t InitSliceSettings (SWelsSvcCodingParam* pCodingParam, const int32_t kiCp
|
||||
break; // go through for MT_ENABLED & SM_DYN_SLICE?
|
||||
//#endif//MT_ENABLED
|
||||
case SM_FIXEDSLCNUM_SLICE:
|
||||
case SM_AUTO_SLICE:
|
||||
if (iSliceNum > iMaxSliceCount)
|
||||
iMaxSliceCount = iSliceNum;
|
||||
// need perform check due uiSliceNum might change, although has been initialized somewhere outside
|
||||
@ -2950,7 +2945,8 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou
|
||||
// Encoding this picture might mulitiple sQualityStat layers potentially be encoded as followed
|
||||
|
||||
switch (param_d->sSliceCfg.uiSliceMode) {
|
||||
case SM_FIXEDSLCNUM_SLICE: {
|
||||
case SM_FIXEDSLCNUM_SLICE:
|
||||
case SM_AUTO_SLICE:{
|
||||
#if defined(MT_ENABLED)
|
||||
if ((iCurDid > 0) && (pSvcParam->iMultipleThreadIdc > 1) &&
|
||||
(pSvcParam->sDependencyLayers[iCurDid].sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE
|
||||
@ -3403,7 +3399,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou
|
||||
}
|
||||
|
||||
#if defined(MT_ENABLED)
|
||||
if (param_d->sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE && pSvcParam->iMultipleThreadIdc > 1 &&
|
||||
if ((param_d->sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE||param_d->sSliceCfg.uiSliceMode == SM_AUTO_SLICE) && pSvcParam->iMultipleThreadIdc > 1 &&
|
||||
pSvcParam->iMultipleThreadIdc >= param_d->sSliceCfg.sSliceArgument.uiSliceNum) {
|
||||
CalcSliceComplexRatio (pCtx->pSliceThreading->pSliceComplexRatio[iCurDid], pCtx->pCurDqLayer->pSliceEncCtx,
|
||||
pCtx->pSliceThreading->pSliceConsumeTime[iCurDid]);
|
||||
@ -3444,9 +3440,9 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou
|
||||
|
||||
#if defined(MT_ENABLED)
|
||||
if (pSvcParam->iMultipleThreadIdc > 1 && did_list[0] == BASE_DEPENDENCY_ID
|
||||
&& pSvcParam->sDependencyLayers[0].sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE
|
||||
&& ((pSvcParam->sDependencyLayers[0].sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE)||(pSvcParam->sDependencyLayers[0].sSliceCfg.uiSliceMode == SM_AUTO_SLICE))
|
||||
&& pSvcParam->iMultipleThreadIdc >= pSvcParam->sDependencyLayers[0].sSliceCfg.sSliceArgument.uiSliceNum
|
||||
&& pSvcParam->sDependencyLayers[did_list[iSpatialNum - 1]].sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE
|
||||
&& ((pSvcParam->sDependencyLayers[did_list[iSpatialNum - 1]].sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE)||(pSvcParam->sDependencyLayers[did_list[iSpatialNum - 1]].sSliceCfg.uiSliceMode == SM_AUTO_SLICE))
|
||||
&& pSvcParam->iMultipleThreadIdc >= pSvcParam->sDependencyLayers[did_list[iSpatialNum -
|
||||
1]].sSliceCfg.sSliceArgument.uiSliceNum) {
|
||||
AdjustBaseLayer (pCtx);
|
||||
|
@ -325,7 +325,7 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara
|
||||
while (iIdx < iNumSpatialLayers) {
|
||||
SSliceConfig* pMso = &pPara->sDependencyLayers[iIdx].sSliceCfg;
|
||||
const int32_t kiSliceNum = pMso->sSliceArgument.uiSliceNum;
|
||||
if (pMso->uiSliceMode == SM_FIXEDSLCNUM_SLICE && pPara->iMultipleThreadIdc > 1
|
||||
if (((pMso->uiSliceMode == SM_FIXEDSLCNUM_SLICE)||(pMso->uiSliceMode == SM_AUTO_SLICE)) && pPara->iMultipleThreadIdc > 1
|
||||
&& pPara->iMultipleThreadIdc >= kiSliceNum) {
|
||||
pSmt->pSliceConsumeTime[iIdx] = (uint32_t*)pMa->WelsMallocz (kiSliceNum * sizeof (uint32_t), "pSliceConsumeTime[]");
|
||||
WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pSliceConsumeTime[iIdx]), FreeMemorySvc (ppCtx))
|
||||
@ -727,7 +727,7 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) {
|
||||
pSlice = &pCurDq->sLayerInfo.pSliceInLayer[iSliceIdx];
|
||||
pSliceBs = &pEncPEncCtx->pSliceBs[iSliceIdx];
|
||||
|
||||
bDsaFlag = (pParamD->sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE &&
|
||||
bDsaFlag = (((pParamD->sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE)||(pParamD->sSliceCfg.uiSliceMode == SM_AUTO_SLICE)) &&
|
||||
pCodingParam->iMultipleThreadIdc > 1 &&
|
||||
pCodingParam->iMultipleThreadIdc >= pParamD->sSliceCfg.sSliceArgument.uiSliceNum);
|
||||
if (bDsaFlag)
|
||||
@ -1142,7 +1142,9 @@ void TrackSliceConsumeTime (sWelsEncCtx* pCtx, int32_t* pDidList, const int32_t
|
||||
SSliceCtx* pSliceCtx = pCurDq->pSliceEncCtx;
|
||||
const uint32_t kuiCountSliceNum = pSliceCtx->iSliceNumInFrame;
|
||||
if (pCtx->pSliceThreading) {
|
||||
if (pCtx->pSliceThreading->pFSliceDiff && pMso->uiSliceMode == SM_FIXEDSLCNUM_SLICE && pPara->iMultipleThreadIdc > 1
|
||||
if (pCtx->pSliceThreading->pFSliceDiff
|
||||
&& ((pMso->uiSliceMode == SM_FIXEDSLCNUM_SLICE)||(pMso->uiSliceMode == SM_AUTO_SLICE))
|
||||
&& pPara->iMultipleThreadIdc > 1
|
||||
&& pPara->iMultipleThreadIdc >= kuiCountSliceNum) {
|
||||
uint32_t i = 0;
|
||||
uint32_t uiMaxT = 0;
|
||||
|
@ -84,7 +84,8 @@ int32_t AssignMbMapMultipleSlices (SSliceCtx* pSliceSeg, const SSliceConfig* kpM
|
||||
|
||||
return 0;
|
||||
} else if (SM_RASTER_SLICE == pSliceSeg->uiSliceMode ||
|
||||
SM_FIXEDSLCNUM_SLICE == pSliceSeg->uiSliceMode) {
|
||||
SM_FIXEDSLCNUM_SLICE == pSliceSeg->uiSliceMode||
|
||||
SM_AUTO_SLICE == pSliceSeg->uiSliceMode) {
|
||||
const int32_t* kpSlicesAssignList = (int32_t*) & (kpMso->sSliceArgument.uiSliceMbNum[0]);
|
||||
const int32_t kiCountNumMbInFrame = pSliceSeg->iMbNumInFrame;
|
||||
const int32_t kiCountSliceNumInFrame = pSliceSeg->iSliceNumInFrame;
|
||||
@ -308,7 +309,8 @@ int32_t GetInitialSliceNum (const int32_t kiMbWidth, const int32_t kiMbHeight, S
|
||||
case SM_SINGLE_SLICE:
|
||||
case SM_FIXEDSLCNUM_SLICE:
|
||||
case SM_RASTER_SLICE:
|
||||
case SM_ROWMB_SLICE: {
|
||||
case SM_ROWMB_SLICE:
|
||||
case SM_AUTO_SLICE:{
|
||||
return pMso->sSliceArgument.uiSliceNum;
|
||||
}
|
||||
case SM_DYN_SLICE: {
|
||||
@ -398,7 +400,7 @@ int32_t InitSliceSegment (SSliceCtx* pSliceSeg,
|
||||
return AssignMbMapSingleSlice (pSliceSeg->pOverallMbMap, kiCountMbNum, sizeof (pSliceSeg->pOverallMbMap[0]));
|
||||
} else { //if ( SM_MULTIPLE_SLICE == uiSliceMode )
|
||||
if (uiSliceMode != SM_FIXEDSLCNUM_SLICE && uiSliceMode != SM_ROWMB_SLICE && uiSliceMode != SM_RASTER_SLICE
|
||||
&& uiSliceMode != SM_DYN_SLICE)
|
||||
&& uiSliceMode != SM_DYN_SLICE&& uiSliceMode != SM_AUTO_SLICE)
|
||||
return 1;
|
||||
|
||||
pSliceSeg->pOverallMbMap = (uint8_t*)pMa->WelsMalloc (kiCountMbNum * sizeof (uint8_t), "pSliceSeg->pOverallMbMap");
|
||||
|
@ -34,4 +34,4 @@ SlicesAssign7 0 # count number of MBs in slice #7
|
||||
# 2 SM_RASTER_SLICE | according to SlicesAssign | Need input of MB numbers each slice. In addition, if other constraint in slice_argument is presented, need to follow the constraints. Typically if MB num and slice size are both constrained, re-encoding may be involved.
|
||||
# 3 SM_ROWMB_SLICE | according to PictureMBHeight | Typical of single row of mbs each slice?+ slice size constraint which including re-encoding
|
||||
# 4 SM_DYN_SLICE | according to SliceSize | Dynamic slicing (have no idea about slice_nums until encoding current frame)
|
||||
|
||||
# 5 SM_AUTO_SLICE | according to thread number | the number of slice is decided by the thread number
|
||||
|
@ -35,4 +35,4 @@ SlicesAssign7 0 # count number of MBs in slice #7
|
||||
# 2 SM_RASTER_SLICE | according to SlicesAssign | Need input of MB numbers each slice. In addition, if other constraint in slice_argument is presented, need to follow the constraints. Typically if MB num and slice size are both constrained, re-encoding may be involved.
|
||||
# 3 SM_ROWMB_SLICE | according to PictureMBHeight | Typical of single row of mbs each slice?+ slice size constraint which including re-encoding
|
||||
# 4 SM_DYN_SLICE | according to SliceSize | Dynamic slicing (have no idea about slice_nums until encoding current frame)
|
||||
|
||||
# 5 SM_AUTO_SLICE | according to thread number | the number of slice is decided by the thread number
|
||||
|
@ -35,4 +35,4 @@ SlicesAssign7 0 # count number of MBs in slice #7
|
||||
# 2 SM_RASTER_SLICE | according to SlicesAssign | Need input of MB numbers each slice. In addition, if other constraint in slice_argument is presented, need to follow the constraints. Typically if MB num and slice size are both constrained, re-encoding may be involved.
|
||||
# 3 SM_ROWMB_SLICE | according to PictureMBHeight | Specially for TP. Typical of single row of mbs each slice?+ slice size constraint which including re-encoding
|
||||
# 4 SM_DYN_SLICE | according to SliceSize | Dynamic slicing (have no idea about slice_nums until encoding current frame)
|
||||
|
||||
# 5 SM_AUTO_SLICE | according to thread number | the number of slice is decided by the thread number
|
||||
|
@ -35,4 +35,4 @@ SlicesAssign7 0 # count number of MBs in slice #7
|
||||
# 2 SM_RASTER_SLICE | according to SlicesAssign | Need input of MB numbers each slice. In addition, if other constraint in slice_argument is presented, need to follow the constraints. Typically if MB num and slice size are both constrained, re-encoding may be involved.
|
||||
# 3 SM_ROWMB_SLICE | according to PictureMBHeight | Specially for TP. Typical of single row of mbs each slice?+ slice size constraint which including re-encoding
|
||||
# 4 SM_DYN_SLICE | according to SliceSize | Dynamic slicing (have no idea about slice_nums until encoding current frame)
|
||||
|
||||
# 5 SM_AUTO_SLICE | according to thread number | the number of slice is decided by the thread number
|
||||
|
Loading…
x
Reference in New Issue
Block a user