ref: 45c2fff6b8def33940bafe3fd157d0991057c4fa
parent: 2f53a08aba00895b3378cff1a3af44a7af53de22
author: ruil2 <[email protected]>
date: Wed Jul 9 11:41:04 EDT 2014
interface update
--- a/codec/api/svc/codec_app_def.h
+++ b/codec/api/svc/codec_app_def.h
@@ -91,6 +91,7 @@
ENCODER_LTR_MARKING_FEEDBACK,
ENCOCER_LTR_MARKING_PERIOD,
ENCODER_OPTION_LTR,
+ ENCODER_OPTION_COMPLEXITY,
ENCODER_OPTION_ENABLE_SSEI, //enable SSEI: true--enable ssei; false--disable ssei
ENCODER_OPTION_ENABLE_PREFIX_NAL_ADDING, //enable prefix: true--enable prefix; false--disable prefix
@@ -272,12 +273,16 @@
SCREEN_CONTENT_REAL_TIME,//screen content signal
} EUsageType;
+typedef enum {
+ LOW_COMPLEXITY, //the lowest compleixty,the fastest speed,
+ MEDIUM_COMPLEXITY, //medium complexity, medium speed,medium quality
+ HIGH_COMPLEXITY, //high complexity, lowest speed, high quality
+} ECOMPLEXITY_MODE;
// TODO: Refine the parameters definition.
// SVC Encoding Parameters
typedef struct TagEncParamBase {
EUsageType
iUsageType; //application type;// CAMERA_VIDEO_REAL_TIME: //camera video signal; SCREEN_CONTENT_REAL_TIME: screen content signal;
- int iInputCsp; // color space of input sequence
int iPicWidth; // width of picture in samples
int iPicHeight; // height of picture in samples
@@ -291,7 +296,6 @@
typedef struct TagEncParamExt {
EUsageType
iUsageType; //application type;// CAMERA_VIDEO_REAL_TIME: //camera video signal; SCREEN_CONTENT_REAL_TIME: screen content signal;
- int iInputCsp; // color space of input sequence
int iPicWidth; // width of picture in samples
int iPicHeight; // height of picture in samples
@@ -303,9 +307,9 @@
int iSpatialLayerNum; // layer number at spatial level
SSpatialLayerConfig sSpatialLayers[MAX_SPATIAL_LAYER_NUM];
+ ECOMPLEXITY_MODE iComplexityMode;
unsigned int uiIntraPeriod; // period of Intra frame
int iNumRefFrame; // number of reference frame used
- unsigned int uiFrameToBeCoded; // frame to be encoded (at input frame rate)
bool bEnableSpsPpsIdAddition;
bool bPrefixNalAddingCtrl;
bool bEnableSSEI;
--- a/codec/console/enc/src/welsenc.cpp
+++ b/codec/console/enc/src/welsenc.cpp
@@ -99,6 +99,7 @@
string strSeqFile; // for cmd lines
string strLayerCfgFile[MAX_DEPENDENCY_LAYER];
char sRecFileName[MAX_DEPENDENCY_LAYER][MAX_FNAME_LEN];
+ uint32_t uiFrameToBeCoded;
} SFilesSet;
@@ -224,7 +225,7 @@
} else if (strTag[0].compare ("MaxFrameRate") == 0) {
pSvcParam.fMaxFrameRate = (float)atof (strTag[1].c_str());
} else if (strTag[0].compare ("FramesToBeEncoded") == 0) {
- pSvcParam.uiFrameToBeCoded = atoi (strTag[1].c_str());
+ sFileSet.uiFrameToBeCoded = 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) {
@@ -403,7 +404,7 @@
pSrcPic->iPicHeight = atoi (argv[n++]);
else if (!strcmp (pCommand, "-frms") && (n < argc))
- pSvcParam.uiFrameToBeCoded = atoi (argv[n++]);
+ sFileSet.uiFrameToBeCoded = atoi (argv[n++]);
else if (!strcmp (pCommand, "-numtl") && (n < argc))
pSvcParam.iTemporalLayerNum = atoi (argv[n++]);
@@ -581,11 +582,10 @@
sParam.bEnableFrameSkip = 1; // frame skipping
sParam.bEnableLongTermReference = 0; // long term reference control
sParam.iLtrMarkPeriod = 30;
- sParam.iInputCsp = videoFormatI420; // color space of input sequence
sParam.uiIntraPeriod = 320; // period of Intra frame
sParam.bEnableSpsPpsIdAddition = 1;
sParam.bPrefixNalAddingCtrl = 0;
-
+ sParam.iComplexityMode = MEDIUM_COMPLEXITY;
int iIndexLayer = 0;
sParam.sSpatialLayers[iIndexLayer].uiProfileIdc = PRO_BASELINE;
sParam.sSpatialLayers[iIndexLayer].iVideoWidth = 160;
@@ -736,7 +736,7 @@
sSvcParam.iPicWidth = (!sSvcParam.iPicWidth) ? iSourceWidth : sSvcParam.iPicWidth;
sSvcParam.iPicHeight = (!sSvcParam.iPicHeight) ? iSourceHeight : sSvcParam.iPicHeight;
- iTotalFrameMax = (int32_t)sSvcParam.uiFrameToBeCoded;
+ iTotalFrameMax = (int32_t)fs.uiFrameToBeCoded;
if (cmResultSuccess != pPtrEnc->InitializeExt (&sSvcParam)) { // SVC encoder initialization
fprintf (stderr, "SVC encoder Initialize failed\n");
@@ -789,8 +789,8 @@
}
iFrameIdx = 0;
- while (iFrameIdx < iTotalFrameMax && (((int32_t)sSvcParam.uiFrameToBeCoded <= 0)
- || (iFrameIdx < (int32_t)sSvcParam.uiFrameToBeCoded))) {
+ while (iFrameIdx < iTotalFrameMax && (((int32_t)fs.uiFrameToBeCoded <= 0)
+ || (iFrameIdx < (int32_t)fs.uiFrameToBeCoded))) {
#ifdef ONLY_ENC_FRAMES_NUM
// Only encoded some limited frames here
--- a/codec/encoder/core/inc/param_svc.h
+++ b/codec/encoder/core/inc/param_svc.h
@@ -133,9 +133,8 @@
param.iPicHeight = 0; // actual input picture height
param.fMaxFrameRate = MAX_FRAME_RATE; // maximal frame rate [Hz / fps]
- param.iInputCsp = videoFormatI420; // input sequence color space in default
- param.uiFrameToBeCoded = (uint32_t) - 1; // frame to be encoded (at input frame rate)
+ param.iComplexityMode = MEDIUM_COMPLEXITY;
param.iTargetBitrate = 0; // overall target bitrate introduced in RC module
param.iMaxBitrate = MAX_BIT_RATE;
param.iMultipleThreadIdc = 1;
@@ -203,7 +202,7 @@
iCountThreadsNum = 1; // # derived from disable_multiple_slice_idc (=0 or >1) means;
iDecompStages = 0; // GOP size dependency, unknown here and be revised later
-
+ iComplexityMode = MEDIUM_COMPLEXITY;
memset (sDependencyLayers, 0, sizeof (SSpatialLayerInternal)*MAX_DEPENDENCY_LAYER);
memset (sSpatialLayers, 0 , sizeof (SSpatialLayerConfig)*MAX_SPATIAL_LAYER_NUM);
@@ -223,7 +222,6 @@
int32_t ParamBaseTranscode (const SEncParamBase& pCodingParam) {
- iInputCsp = pCodingParam.iInputCsp; // color space of input sequence
fMaxFrameRate = WELS_CLIP3 (pCodingParam.fMaxFrameRate, MIN_FRAME_RATE, MAX_FRAME_RATE);
iTargetBitrate = pCodingParam.iTargetBitrate;
iUsageType = pCodingParam.iUsageType;
@@ -271,7 +269,6 @@
}
void GetBaseParams (SEncParamBase* pCodingParam) {
pCodingParam->iUsageType = iUsageType;
- pCodingParam->iInputCsp = iInputCsp;
pCodingParam->iPicWidth = iPicWidth;
pCodingParam->iPicHeight = iPicHeight;
pCodingParam->iTargetBitrate = iTargetBitrate;
@@ -281,12 +278,10 @@
int32_t ParamTranscode (const SEncParamExt& pCodingParam) {
float fParamMaxFrameRate = WELS_CLIP3 (pCodingParam.fMaxFrameRate, MIN_FRAME_RATE, MAX_FRAME_RATE);
- iInputCsp = pCodingParam.iInputCsp; // color space of input sequence
- uiFrameToBeCoded = (uint32_t) -
- 1; // frame to be encoded (at input frame rate), -1 dependents on length of input sequence
iUsageType = pCodingParam.iUsageType;
iPicWidth = pCodingParam.iPicWidth;
iPicHeight = pCodingParam.iPicHeight;
+ iComplexityMode = pCodingParam.iComplexityMode;
SUsedPicRect.iLeft = 0;
SUsedPicRect.iTop = 0;
@@ -297,7 +292,8 @@
/* Deblocking loop filter */
iLoopFilterDisableIdc = pCodingParam.iLoopFilterDisableIdc; // 0: on, 1: off, 2: on except for slice boundaries,
- if (iLoopFilterDisableIdc == 0 && iMultipleThreadIdc != 1) // Loop filter requested to be enabled, with threading enabled
+ if (iLoopFilterDisableIdc == 0
+ && iMultipleThreadIdc != 1) // Loop filter requested to be enabled, with threading enabled
iLoopFilterDisableIdc = 2; // Disable loop filter on slice boundaries since that's not allowed with multithreading
iLoopFilterAlphaC0Offset = pCodingParam.iLoopFilterAlphaC0Offset; // AlphaOffset: valid range [-6, 6], default 0
iLoopFilterBetaOffset = pCodingParam.iLoopFilterBetaOffset; // BetaOffset: valid range [-6, 6], default 0
--- a/codec/encoder/core/inc/svc_mode_decision.h
+++ b/codec/encoder/core/inc/svc_mode_decision.h
@@ -69,7 +69,7 @@
// MD from background detection
//////////////
bool WelsMdInterJudgeBGDPskip (void* pEnc, void* pMd, SSlice* pSlice, SMB* pCurMb, SMbCache* pMbCache,
- bool* bKeepSkip);
+ bool* bKeepSkip);
bool WelsMdInterJudgeBGDPskipFalse (void* pEnc, void* pMd, SSlice* pSlice, SMB* pCurMb, SMbCache* pMbCache,
bool* bKeepSkip);
--- a/codec/encoder/core/src/encoder_ext.cpp
+++ b/codec/encoder/core/src/encoder_ext.cpp
@@ -3712,7 +3712,7 @@
// we can not use direct struct based memcpy due some fields need keep unchanged as before
pOldParam->fMaxFrameRate = pNewParam->fMaxFrameRate; // maximal frame rate [Hz / fps]
- pOldParam->iInputCsp = pNewParam->iInputCsp; // color space of input sequence
+ pOldParam->iComplexityMode = pNewParam->iComplexityMode; // color space of input sequence
pOldParam->uiIntraPeriod = pNewParam->uiIntraPeriod; // intra period (multiple of GOP size as desired)
pOldParam->bEnableSpsPpsIdAddition = pNewParam->bEnableSpsPpsIdAddition;
pOldParam->bPrefixNalAddingCtrl = pNewParam->bPrefixNalAddingCtrl;
--- a/codec/encoder/plus/src/welsEncoderExt.cpp
+++ b/codec/encoder/plus/src/welsEncoderExt.cpp
@@ -293,14 +293,6 @@
}
#endif//REC_FRAME_COUNT
- const int32_t iColorspace = pCfg->iInputCsp;
- if (videoFormatI420 != iColorspace) {
- WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, "CWelsH264SVCEncoder::Initialize(), invalid iInputCsp= %d.\n",
- iColorspace);
- Uninitialize();
- return cmInitParaError;
- }
-
// Check valid parameters
const int32_t iNumOfLayers = pCfg->iSpatialLayerNum;
if (iNumOfLayers < 1 || iNumOfLayers > MAX_DEPENDENCY_LAYER) {
@@ -378,7 +370,6 @@
}
const int32_t kiDecStages = WELS_LOG2 (pCfg->uiGopSize);
- pCfg->iInputCsp = iColorspace;
pCfg->iTemporalLayerNum = (int8_t) (1 + kiDecStages);
pCfg->iLoopFilterAlphaC0Offset = WELS_CLIP3 (pCfg->iLoopFilterAlphaC0Offset, -6, 6);
pCfg->iLoopFilterBetaOffset = WELS_CLIP3 (pCfg->iLoopFilterBetaOffset, -6, 6);
@@ -393,7 +384,6 @@
return cmInitParaError;
}
- m_iCspInternal = iColorspace;
m_bInitialFlag = true;
return cmResultSuccess;
@@ -645,16 +635,12 @@
case ENCODER_OPTION_SVC_ENCODE_PARAM_EXT: { // SVC Encoding Parameter
SEncParamExt sEncodingParam;
SWelsSvcCodingParam sConfig;
- int32_t iInputColorspace = 0;
int32_t iTargetWidth = 0;
int32_t iTargetHeight = 0;
memcpy (&sEncodingParam, pOption, sizeof (SEncParamExt)); // confirmed_safe_unsafe_usage
WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,
- "ENCODER_OPTION_SVC_ENCODE_PARAM_EXT, sEncodingParam.iInputCsp= 0x%x\n",
- sEncodingParam.iInputCsp);
- WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,
- "coding_param->iPicWidth= %d;coding_param->iPicHeight= %d;coding_param->iTargetBitrate= %d; coding_param->iMaxBitrate= %d; coding_param->iRCMode= %d;coding_param->iPaddingFlag= %d;coding_param->iTemporalLayerNum= %d;coding_param->iSpatialLayerNum= %d;coding_param->fFrameRate= %.6ff;coding_param->iInputCsp= %d;coding_param->uiIntraPeriod= %d;coding_param->bEnableSpsPpsIdAddition = %d;coding_param->bPrefixNalAddingCtrl = %d;coding_param->bEnableDenoise= %d;coding_param->bEnableBackgroundDetection= %d;coding_param->bEnableAdaptiveQuant= %d;coding_param->bEnableAdaptiveQuant= %d;coding_param->bEnableLongTermReference= %d;coding_param->iLtrMarkPeriod= %d;\n",
+ "coding_param->iPicWidth= %d;coding_param->iPicHeight= %d;coding_param->iTargetBitrate= %d; coding_param->iMaxBitrate= %d; coding_param->iRCMode= %d;coding_param->iPaddingFlag= %d;coding_param->iTemporalLayerNum= %d;coding_param->iSpatialLayerNum= %d;coding_param->fFrameRate= %.6ff;coding_param->uiIntraPeriod= %d;coding_param->bEnableSpsPpsIdAddition = %d;coding_param->bPrefixNalAddingCtrl = %d;coding_param->bEnableDenoise= %d;coding_param->bEnableBackgroundDetection= %d;coding_param->bEnableAdaptiveQuant= %d;coding_param->bEnableAdaptiveQuant= %d;coding_param->bEnableLongTermReference= %d;coding_param->iLtrMarkPeriod= %d;\n",
sEncodingParam.iPicWidth,
sEncodingParam.iPicHeight,
sEncodingParam.iTargetBitrate,
@@ -664,7 +650,6 @@
sEncodingParam.iTemporalLayerNum,
sEncodingParam.iSpatialLayerNum,
sEncodingParam.fMaxFrameRate,
- sEncodingParam.iInputCsp,
sEncodingParam.uiIntraPeriod,
sEncodingParam.bEnableSpsPpsIdAddition,
sEncodingParam.bPrefixNalAddingCtrl,
@@ -702,7 +687,6 @@
return cmInitParaError;
}
- iInputColorspace = sEncodingParam.iInputCsp;
if (sConfig.ParamTranscode (sEncodingParam)) {
return cmInitParaError;
}
@@ -711,11 +695,10 @@
}
iTargetWidth = sConfig.iPicWidth;
iTargetHeight = sConfig.iPicHeight;
- if (m_iCspInternal != iInputColorspace || m_iMaxPicWidth != iTargetWidth
- || m_iMaxPicHeight != iTargetHeight) { // for color space due to changed
+ if (m_iMaxPicWidth != iTargetWidth
+ || m_iMaxPicHeight != iTargetHeight) {
m_iMaxPicWidth = iTargetWidth;
m_iMaxPicHeight = iTargetHeight;
- m_iCspInternal = iInputColorspace;
}
#ifdef REC_FRAME_COUNT
WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,
@@ -724,7 +707,6 @@
#endif//REC_FRAME_COUNT
/* New configuration available here */
- sConfig.iInputCsp = m_iCspInternal; // I420 in default designed for presentation in encoder used internal
sConfig.DetermineTemporalSettings();
/* Check every field whether there is new request for memory block changed or else, Oct. 24, 2008 */
@@ -953,6 +935,11 @@
m_pEncContext->iDropNumber = pValue->iDropNum;
}
break;
+ case ENCODER_OPTION_COMPLEXITY: {
+ int32_t iValue = * ((int32_t*)pOption);
+ m_pEncContext->pSvcParam->iComplexityMode = (ECOMPLEXITY_MODE)iValue;
+ }
+ break;
default:
return cmInitParaError;
}
@@ -1053,6 +1040,10 @@
} else {
pInfo->iBitrate = m_pEncContext->pSvcParam->sSpatialLayers[pInfo->iLayer].iMaxSpatialBitrate;
}
+ }
+ break;
+ case ENCODER_OPTION_COMPLEXITY: {
+ * ((int32_t*)pOption) = m_pEncContext->pSvcParam->iComplexityMode;
}
break;
default:
--- a/module/gmp-openh264.cpp
+++ b/module/gmp-openh264.cpp
@@ -232,7 +232,6 @@
// TODO([email protected]). Scary conversion from unsigned char to float below.
param.fMaxFrameRate = static_cast<float> (codecSettings.mMaxFramerate);
- param.iInputCsp = videoFormatI420;
rv = encoder_->Initialize (¶m);
if (rv) {
--- a/test/api/BaseEncoderTest.cpp
+++ b/test/api/BaseEncoderTest.cpp
@@ -16,7 +16,6 @@
param.iPicWidth = width;
param.iPicHeight = height;
param.iTargetBitrate = 5000000;
- param.iInputCsp = videoFormatI420;
return encoder->Initialize (¶m);
} else {
@@ -28,7 +27,6 @@
param.iPicWidth = width;
param.iPicHeight = height;
param.iTargetBitrate = 5000000;
- param.iInputCsp = videoFormatI420;
param.bEnableDenoise = denoise;
param.iSpatialLayerNum = layers;
--- a/test/encoder/EncUT_EncoderExt.cpp
+++ b/test/encoder/EncUT_EncoderExt.cpp
@@ -41,7 +41,6 @@
void EncoderInterfaceTest::TemporalLayerSettingTest() {
- pParamExt->iInputCsp = 23;
pParamExt->iPicWidth = m_iWidth;
pParamExt->iPicHeight = m_iHeight;
pParamExt->iTargetBitrate = 60000;