From f5cd56ea741ed4440cfd50f7ada99701223c01bb Mon Sep 17 00:00:00 2001 From: ruil2 Date: Tue, 18 Feb 2014 16:57:34 +0800 Subject: [PATCH] use temporal layer num and remove gop size in external configure --- codec/api/svc/codec_app_def.h | 1 - codec/console/enc/src/welsenc.cpp | 8 +- codec/encoder/core/src/encoder_ext.cpp | 2 +- .../core/src/slice_multi_threading.cpp | 2 +- testbin/welsenc.cfg | 128 +++++++++--------- 5 files changed, 70 insertions(+), 71 deletions(-) diff --git a/codec/api/svc/codec_app_def.h b/codec/api/svc/codec_app_def.h index 5f56d89f..8cada91a 100644 --- a/codec/api/svc/codec_app_def.h +++ b/codec/api/svc/codec_app_def.h @@ -224,7 +224,6 @@ typedef struct TagEncParamExt:SEncParamBase SSpatialLayerConfig sSpatialLayers[MAX_SPATIAL_LAYER_NUM]; int iNumRefFrame; // number of reference frame used unsigned int uiFrameToBeCoded; // frame to be encoded (at input frame rate) - unsigned int uiGopSize; bool bEnableRc; short iMultipleThreadIdc; // 1 # 0: auto(dynamic imp. internal encoder); 1: multiple threads imp. disabled; > 1: count number of threads; short iCountThreadsNum; // # derived from disable_multiple_slice_idc (=0 or >1) means; diff --git a/codec/console/enc/src/welsenc.cpp b/codec/console/enc/src/welsenc.cpp index 6d5e26d6..847d87f6 100644 --- a/codec/console/enc/src/welsenc.cpp +++ b/codec/console/enc/src/welsenc.cpp @@ -122,8 +122,8 @@ int ParseConfig (CReadConfig& cRdCfg, SEncParamExt& pSvcParam, SFilesSet& sFileS pSvcParam.uiFrameToBeCoded = atoi (strTag[1].c_str()); } else if (strTag[0].compare ("SourceSequenceInRGB24") == 0) { pSvcParam.iInputCsp = atoi (strTag[1].c_str()) == 0 ? videoFormatI420 : videoFormatRGB; - } else if (strTag[0].compare ("GOPSize") == 0) { - pSvcParam.uiGopSize = atoi (strTag[1].c_str()); + } else if (strTag[0].compare ("TemporalLayerNum") == 0) { + pSvcParam.iTemporalLayerNum = atoi (strTag[1].c_str()); } else if (strTag[0].compare ("IntraPeriod") == 0) { pSvcParam.uiIntraPeriod = atoi (strTag[1].c_str()); } else if (strTag[0].compare ("EnableSpsPpsIDAddition") == 0) { @@ -428,8 +428,8 @@ int ParseCommandLine (int argc, char** argv, SEncParamExt& pSvcParam, SFilesSet& else if (!strcmp (pCommand, "-frms") && (n < argc)) pSvcParam.uiFrameToBeCoded = atoi (argv[n++]); - else if (!strcmp (pCommand, "-gop") && (n < argc)) - pSvcParam.uiGopSize = atoi (argv[n++]); + else if (!strcmp (pCommand, "-numtl") && (n < argc)) + pSvcParam.iTemporalLayerNum = atoi (argv[n++]); else if (!strcmp (pCommand, "-iper") && (n < argc)) pSvcParam.uiIntraPeriod = atoi (argv[n++]); diff --git a/codec/encoder/core/src/encoder_ext.cpp b/codec/encoder/core/src/encoder_ext.cpp index c2a7096d..25edada4 100644 --- a/codec/encoder/core/src/encoder_ext.cpp +++ b/codec/encoder/core/src/encoder_ext.cpp @@ -1838,7 +1838,7 @@ int32_t InitSliceSettings (SWelsSvcCodingParam* pCodingParam, const int32_t kiCp pSlcArg->uiSliceNum; // uiSliceNum per input has been validated at ParamValidationExt() #endif//DYNAMIC_SLICE_ASSIGN #else//!MT_ENABLED - int16_t iSliceNum = pSlcArg->iSliceNum; // uiSliceNum per input has been validated at ParamValidationExt() + int16_t iSliceNum = pSlcArg->uiSliceNum; // uiSliceNum per input has been validated at ParamValidationExt() #endif//MT_ENABLED // NOTE: Per design, in case MT/DYNAMIC_SLICE_ASSIGN enabled, for SM_FIXEDSLCNUM_SLICE mode, diff --git a/codec/encoder/core/src/slice_multi_threading.cpp b/codec/encoder/core/src/slice_multi_threading.cpp index 1339fa7a..3508eb83 100644 --- a/codec/encoder/core/src/slice_multi_threading.cpp +++ b/codec/encoder/core/src/slice_multi_threading.cpp @@ -1459,7 +1459,7 @@ void TrackSliceConsumeTime (sWelsEncCtx* pCtx, int32_t* pDidList, const int32_t while (iSpatialIdx < iSpatialNum) { const int32_t kiDid = pDidList[iSpatialIdx]; SDLayerParam* pDlp = &pPara->sDependencyLayers[kiDid]; - SMulSliceOption* pMso = &pDlp->sSliceCfg; + SSliceConfig* pMso = &pDlp->sSliceCfg; SDqLayer* pCurDq = pCtx->ppDqLayerList[kiDid]; SSliceCtx* pSliceCtx = pCurDq->pSliceEncCtx; const uint32_t kuiCountSliceNum = pSliceCtx->iSliceNumInFrame; diff --git a/testbin/welsenc.cfg b/testbin/welsenc.cfg index 3edc1a4d..82c8f5dd 100644 --- a/testbin/welsenc.cfg +++ b/testbin/welsenc.cfg @@ -1,64 +1,64 @@ -# Cisco Scalable H.264/AVC Extension Encoder Configuration File - -#============================== GENERAL ============================== -OutputFile test.264 # Bitstream file -MaxFrameRate 30 # Maximum frame rate [Hz] -FramesToBeEncoded -1 # Number of frames (at input frame rate) - -GOPSize 4 # GOP Size (at maximum frame rate), 16 -IntraPeriod 0 # Intra Period ( multipler of GoP size or -1) -EnableSpsPpsIDAddition 1 - -EnableFrameCropping 1 # enable frame cropping flag - -#============================== LOOP FILTER ============================== -LoopFilterDisableIDC 0 # Loop filter idc (0: on, 1: off, - # 2: on except for slice boundaries, - # 3: two stage. slice boundries on in second stage - # 4: Luma on but Chroma off (w.r.t. idc=0) - # 5: Luma on except on slice boundaries, but Chroma off in enh. layer (w.r.t. idc=2) - # 6: Luma on in two stage. slice boundries on in second stage, but Chroma off (w.r.t. idc=3) -LoopFilterAlphaC0Offset 0 # AlphaOffset(-6..+6): valid range -LoopFilterBetaOffset 0 # BetaOffset (-6..+6): valid range - -InterLayerLoopFilterDisableIDC 0 # filter idc for inter-layer deblocking (0: on, 1: off, - # 2: on except for slice boundaries, - # 3: two stage. slice boundries on in second stage - # 4: Luma on but Chroma off in enh. layer (w.r.t. idc=0) - # 5: Luma on except on slice boundaries, but Chroma off in enh. layer (w.r.t. idc=2) - # 6: Luma on in two stage. slice boundries on in second stage, but Chroma off (w.r.t. idc=3) -InterLayerLoopFilterAlphaC0Offset 0 # AlphaOffset for inter-layer deblocking -InterLayerLoopFilterBetaOffset 0 # BetaOffset for inter-layer deblocking - -#============================== SOFTWARE IMPLEMENTATION ============================== -MultipleThreadIdc 1 # 0: auto(dynamic imp. internal encoder); 1: multiple threads imp. disabled; > 1: count number of threads; - -#============================== RATE CONTROL ============================== -EnableRC 1 # ENABLE RC -TargetBitrate 5000 # Unit: kbps, controled by EnableRC also -EnableFrameSkip 1 #Enable Frame Skip - -#============================== DENOISE CONTROL ============================== -EnableDenoise 0 # Enable Denoise (1: enable, 0: disable) - -#============================== SCENE CHANGE DETECTION CONTROL ======================= -EnableSceneChangeDetection 1 # Enable Scene Change Detection (1: enable, 0: disable) - -#============================== BACKGROUND DETECTION CONTROL ============================== -EnableBackgroundDetection 1 # BGD control(1: enable, 0: disable) - -#============================== ADAPTIVE QUANTIZATION CONTROL ======================= -EnableAdaptiveQuantization 1 # Enable Adaptive Quantization (1: enable, 0: disable) - -#============================== LONG TERM REFERENCE CONTROL ============================== -EnableLongTermReference 0 # Enable Long Term Reference (1: enable, 0: disable) -LtrMarkPeriod 30 # Long Term Reference Marking Period - -#============================== LAYER DEFINITION ============================== -PrefixNALAddingCtrl 0 # Control flag of adding prefix unit (0: off, 1: on) - # It shall always be on in SVC contexts (i.e. when there are CGS/MGS/spatial enhancement layers) - # Can be disabled when no inter spatial layer prediction in case of its value as 0 -NumLayers 1 # Number of layers -//LayerCfg layer0.cfg # Layer 0 configuration file -//LayerCfg layer1.cfg # Layer 1 configuration file -LayerCfg layer2.cfg # Layer 2 configuration file +# Cisco Scalable H.264/AVC Extension Encoder Configuration File + +#============================== GENERAL ============================== +OutputFile test.264 # Bitstream file +MaxFrameRate 30 # Maximum frame rate [Hz] +FramesToBeEncoded -1 # Number of frames (at input frame rate) + +TemporalLayerNum 3 # temporal layer number(1--4) +IntraPeriod 0 # Intra Period ( multipler of GoP size or -1) +EnableSpsPpsIDAddition 1 + +EnableFrameCropping 1 # enable frame cropping flag + +#============================== LOOP FILTER ============================== +LoopFilterDisableIDC 0 # Loop filter idc (0: on, 1: off, + # 2: on except for slice boundaries, + # 3: two stage. slice boundries on in second stage + # 4: Luma on but Chroma off (w.r.t. idc=0) + # 5: Luma on except on slice boundaries, but Chroma off in enh. layer (w.r.t. idc=2) + # 6: Luma on in two stage. slice boundries on in second stage, but Chroma off (w.r.t. idc=3) +LoopFilterAlphaC0Offset 0 # AlphaOffset(-6..+6): valid range +LoopFilterBetaOffset 0 # BetaOffset (-6..+6): valid range + +InterLayerLoopFilterDisableIDC 0 # filter idc for inter-layer deblocking (0: on, 1: off, + # 2: on except for slice boundaries, + # 3: two stage. slice boundries on in second stage + # 4: Luma on but Chroma off in enh. layer (w.r.t. idc=0) + # 5: Luma on except on slice boundaries, but Chroma off in enh. layer (w.r.t. idc=2) + # 6: Luma on in two stage. slice boundries on in second stage, but Chroma off (w.r.t. idc=3) +InterLayerLoopFilterAlphaC0Offset 0 # AlphaOffset for inter-layer deblocking +InterLayerLoopFilterBetaOffset 0 # BetaOffset for inter-layer deblocking + +#============================== SOFTWARE IMPLEMENTATION ============================== +MultipleThreadIdc 1 # 0: auto(dynamic imp. internal encoder); 1: multiple threads imp. disabled; > 1: count number of threads; + +#============================== RATE CONTROL ============================== +EnableRC 1 # ENABLE RC +TargetBitrate 5000 # Unit: kbps, controled by EnableRC also +EnableFrameSkip 1 #Enable Frame Skip + +#============================== DENOISE CONTROL ============================== +EnableDenoise 0 # Enable Denoise (1: enable, 0: disable) + +#============================== SCENE CHANGE DETECTION CONTROL ======================= +EnableSceneChangeDetection 1 # Enable Scene Change Detection (1: enable, 0: disable) + +#============================== BACKGROUND DETECTION CONTROL ============================== +EnableBackgroundDetection 1 # BGD control(1: enable, 0: disable) + +#============================== ADAPTIVE QUANTIZATION CONTROL ======================= +EnableAdaptiveQuantization 1 # Enable Adaptive Quantization (1: enable, 0: disable) + +#============================== LONG TERM REFERENCE CONTROL ============================== +EnableLongTermReference 0 # Enable Long Term Reference (1: enable, 0: disable) +LtrMarkPeriod 30 # Long Term Reference Marking Period + +#============================== LAYER DEFINITION ============================== +PrefixNALAddingCtrl 0 # Control flag of adding prefix unit (0: off, 1: on) + # It shall always be on in SVC contexts (i.e. when there are CGS/MGS/spatial enhancement layers) + # Can be disabled when no inter spatial layer prediction in case of its value as 0 +NumLayers 1 # Number of layers +//LayerCfg layer0.cfg # Layer 0 configuration file +//LayerCfg layer1.cfg # Layer 1 configuration file +LayerCfg layer2.cfg # Layer 2 configuration file