ref: c7f2a0b7f66092a869eb83a9578aa101d16a7ae1
parent: cece1fe2cff49110995f9ec70fe766c58965b1d5
author: ruil2 <ruil2@cisco.com>
date: Wed Mar 12 06:44:13 EDT 2014
3Author: ruil2 <ruil2@cisco.com> modify the parameter verification for SM_AUTO_SLICE mode -- uiSliceNum iis ignored
--- a/codec/encoder/core/src/encoder_ext.cpp
+++ b/codec/encoder/core/src/encoder_ext.cpp
@@ -226,8 +226,7 @@
fDlp->sSliceCfg.sSliceArgument.uiSliceMbNum[iIdx] = 0;
}
break;
- case SM_FIXEDSLCNUM_SLICE:
- case SM_AUTO_SLICE:{
+ case SM_FIXEDSLCNUM_SLICE:{
fDlp->sSliceCfg.sSliceArgument.uiSliceSizeConstraint = 0;
iMbWidth = (kiPicWidth + 15) >> 4;
@@ -235,7 +234,7 @@
iMbNumInFrame = iMbWidth * iMbHeight;
iMaxSliceNum = MAX_SLICES_NUM;
if (fDlp->sSliceCfg.sSliceArgument.uiSliceNum <= 0
- || fDlp->sSliceCfg.sSliceArgument.uiSliceNum > iMaxSliceNum) {
+ || fDlp->sSliceCfg.sSliceArgument.uiSliceNum > iMaxSliceNum) {
WelsLog (pCtx, WELS_LOG_ERROR, "ParamValidationExt(), invalid uiSliceNum (%d) settings!\n", fDlp->sSliceCfg.sSliceArgument.uiSliceNum);
return ENC_RETURN_UNSUPPORTED_PARA;
}
@@ -267,6 +266,10 @@
}
}
break;
+ case SM_AUTO_SLICE:{
+ fDlp->sSliceCfg.sSliceArgument.uiSliceSizeConstraint = 0;
+ }
+ break;
case SM_RASTER_SLICE: {
fDlp->sSliceCfg.sSliceArgument.uiSliceSizeConstraint = 0;
@@ -1704,7 +1707,6 @@
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
@@ -1725,6 +1727,40 @@
case SM_ROWMB_SLICE:
if (iSliceNum > iMaxSliceCount)
iMaxSliceCount = iSliceNum;
+ break;
+ case SM_AUTO_SLICE:
+ iMaxSliceCount = MAX_SLICES_NUM;
+ pDlp->sSliceCfg.sSliceArgument.uiSliceNum = kiCpuCores;
+ if (pDlp->sSliceCfg.sSliceArgument.uiSliceNum > iMaxSliceCount){
+ pDlp->sSliceCfg.sSliceArgument.uiSliceNum = iMaxSliceCount;
+ }
+ if (pDlp->sSliceCfg.sSliceArgument.uiSliceNum == 1) {
+ WelsLog (NULL, WELS_LOG_DEBUG,
+ "InitSliceSettings(), uiSliceNum(%d) you set for SM_AUTO_SLICE, now turn to SM_SINGLE_SLICE type!\n",
+ pDlp->sSliceCfg.sSliceArgument.uiSliceNum);
+ pDlp->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE;
+ break;
+ }
+ if (pCodingParam->bEnableRc) { // multiple slices verify with gom
+ //check uiSliceNum
+ GomValidCheckSliceNum (kiMbWidth, kiMbHeight, &pDlp->sSliceCfg.sSliceArgument.uiSliceNum);
+ assert (pDlp->sSliceCfg.sSliceArgument.uiSliceNum > 1);
+ //set uiSliceMbNum with current uiSliceNum
+ GomValidCheckSliceMbNum (kiMbWidth, kiMbHeight, &pDlp->sSliceCfg.sSliceArgument);
+ } else if (!CheckFixedSliceNumMultiSliceSetting (kiMbNumInFrame,
+ &pDlp->sSliceCfg.sSliceArgument)) { // verify interleave mode settings
+ //check uiSliceMbNum with current uiSliceNum
+ WelsLog (NULL, WELS_LOG_ERROR, "InitSliceSettings(), invalid uiSliceMbNum (%d) settings!,now turn to SM_SINGLE_SLICE type\n",
+ pDlp->sSliceCfg.sSliceArgument.uiSliceMbNum[0]);
+ pDlp->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE;
+ pDlp->sSliceCfg.sSliceArgument.uiSliceNum = 1;
+ }
+ // considering the coding efficient and performance, iCountMbNum constraint by MIN_NUM_MB_PER_SLICE condition of multi-pSlice mode settting
+ if (kiMbNumInFrame <= MIN_NUM_MB_PER_SLICE) {
+ pDlp->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE;
+ pDlp->sSliceCfg.sSliceArgument.uiSliceNum = 1;
+ break;
+ }
break;
default:
break;
--- a/testbin/layer2.cfg
+++ b/testbin/layer2.cfg
@@ -34,4 +34,5 @@
# 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 slices is decided by the number of threads
+# 5 SM_AUTO_SLICE | according to thread number | the number of slices is decided by the number of threads,SliceNum is ignored
+
--- a/testbin/layer2_arbitrary_res.cfg
+++ b/testbin/layer2_arbitrary_res.cfg
@@ -35,4 +35,5 @@
# 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 slices is decided by the number of threads
+# 5 SM_AUTO_SLICE | according to thread number | the number of slices is decided by the number of threads,SliceNum is ignored
+
--- a/testbin/layer2_vd.cfg
+++ b/testbin/layer2_vd.cfg
@@ -35,4 +35,5 @@
# 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 slices is decided by the number of threads
+# 5 SM_AUTO_SLICE | according to thread number | the number of slices is decided by the number of threads,SliceNum is ignored
+
--- a/testbin/layer2_vd_rc.cfg
+++ b/testbin/layer2_vd_rc.cfg
@@ -35,4 +35,5 @@
# 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 slices is decided by the number of threads
+# 5 SM_AUTO_SLICE | according to thread number | the number of slices is decided by the number of threads,SliceNum is ignored
+