Merge pull request #1121 from ruil2/interface_update_1
interface update
This commit is contained in:
commit
0cafc565be
@ -91,6 +91,7 @@ typedef enum {
|
||||
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 @@ typedef enum {
|
||||
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 TagEncParamBase {
|
||||
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 @@ typedef struct TagEncParamExt {
|
||||
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;
|
||||
|
@ -99,6 +99,7 @@ typedef struct tagFilesSet {
|
||||
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 @@ int ParseConfig (CReadConfig& cRdCfg, SSourcePicture* pSrcPic, SEncParamExt& pSv
|
||||
} 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 @@ int ParseCommandLine (int argc, char** argv, SSourcePicture* pSrcPic, SEncParamE
|
||||
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 @@ int FillSpecificParameters (SEncParamExt& sParam) {
|
||||
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 @@ int ProcessEncoding (ISVCEncoder* pPtrEnc, int argc, char** argv, bool bConfigFi
|
||||
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 @@ int ProcessEncoding (ISVCEncoder* pPtrEnc, int argc, char** argv, bool bConfigFi
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -133,9 +133,8 @@ static void FillDefault (SEncParamExt& param) {
|
||||
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 @@ void FillDefault() {
|
||||
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 @@ void FillDefault() {
|
||||
|
||||
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 @@ int32_t ParamBaseTranscode (const SEncParamBase& pCodingParam) {
|
||||
}
|
||||
void GetBaseParams (SEncParamBase* pCodingParam) {
|
||||
pCodingParam->iUsageType = iUsageType;
|
||||
pCodingParam->iInputCsp = iInputCsp;
|
||||
pCodingParam->iPicWidth = iPicWidth;
|
||||
pCodingParam->iPicHeight = iPicHeight;
|
||||
pCodingParam->iTargetBitrate = iTargetBitrate;
|
||||
@ -281,12 +278,10 @@ void GetBaseParams (SEncParamBase* pCodingParam) {
|
||||
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 @@ int32_t ParamTranscode (const SEncParamExt& pCodingParam) {
|
||||
|
||||
/* 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
|
||||
|
@ -69,7 +69,7 @@ void SetMvBaseEnhancelayer (SWelsMD* pMd, SMB* pCurMb, const SMB* kpRefMb);
|
||||
// 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);
|
||||
|
||||
|
@ -3712,7 +3712,7 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa
|
||||
|
||||
// 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;
|
||||
|
@ -293,14 +293,6 @@ int CWelsH264SVCEncoder::InitializeInternal (SWelsSvcCodingParam* pCfg) {
|
||||
}
|
||||
#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 @@ int CWelsH264SVCEncoder::InitializeInternal (SWelsSvcCodingParam* pCfg) {
|
||||
}
|
||||
|
||||
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 @@ int CWelsH264SVCEncoder::InitializeInternal (SWelsSvcCodingParam* pCfg) {
|
||||
return cmInitParaError;
|
||||
}
|
||||
|
||||
m_iCspInternal = iColorspace;
|
||||
m_bInitialFlag = true;
|
||||
|
||||
return cmResultSuccess;
|
||||
@ -645,16 +635,12 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) {
|
||||
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 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) {
|
||||
sEncodingParam.iTemporalLayerNum,
|
||||
sEncodingParam.iSpatialLayerNum,
|
||||
sEncodingParam.fMaxFrameRate,
|
||||
sEncodingParam.iInputCsp,
|
||||
sEncodingParam.uiIntraPeriod,
|
||||
sEncodingParam.bEnableSpsPpsIdAddition,
|
||||
sEncodingParam.bPrefixNalAddingCtrl,
|
||||
@ -702,7 +687,6 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) {
|
||||
return cmInitParaError;
|
||||
}
|
||||
|
||||
iInputColorspace = sEncodingParam.iInputCsp;
|
||||
if (sConfig.ParamTranscode (sEncodingParam)) {
|
||||
return cmInitParaError;
|
||||
}
|
||||
@ -711,11 +695,10 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) {
|
||||
}
|
||||
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 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) {
|
||||
#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 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) {
|
||||
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;
|
||||
}
|
||||
@ -1055,6 +1042,10 @@ int CWelsH264SVCEncoder::GetOption (ENCODER_OPTION eOptionId, void* pOption) {
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ENCODER_OPTION_COMPLEXITY: {
|
||||
* ((int32_t*)pOption) = m_pEncContext->pSvcParam->iComplexityMode;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return cmInitParaError;
|
||||
}
|
||||
|
@ -232,7 +232,6 @@ class OpenH264VideoEncoder : public GMPVideoEncoder {
|
||||
|
||||
// TODO(ekr@rtfm.com). Scary conversion from unsigned char to float below.
|
||||
param.fMaxFrameRate = static_cast<float> (codecSettings.mMaxFramerate);
|
||||
param.iInputCsp = videoFormatI420;
|
||||
|
||||
rv = encoder_->Initialize (¶m);
|
||||
if (rv) {
|
||||
|
@ -16,7 +16,6 @@ static int InitWithParam (ISVCEncoder* encoder, EUsageType usageType, int width,
|
||||
param.iPicWidth = width;
|
||||
param.iPicHeight = height;
|
||||
param.iTargetBitrate = 5000000;
|
||||
param.iInputCsp = videoFormatI420;
|
||||
|
||||
return encoder->Initialize (¶m);
|
||||
} else {
|
||||
@ -28,7 +27,6 @@ static int InitWithParam (ISVCEncoder* encoder, EUsageType usageType, int width,
|
||||
param.iPicWidth = width;
|
||||
param.iPicHeight = height;
|
||||
param.iTargetBitrate = 5000000;
|
||||
param.iInputCsp = videoFormatI420;
|
||||
param.bEnableDenoise = denoise;
|
||||
param.iSpatialLayerNum = layers;
|
||||
|
||||
|
@ -41,7 +41,6 @@ class EncoderInterfaceTest : public ::testing::Test {
|
||||
|
||||
void EncoderInterfaceTest::TemporalLayerSettingTest() {
|
||||
|
||||
pParamExt->iInputCsp = 23;
|
||||
pParamExt->iPicWidth = m_iWidth;
|
||||
pParamExt->iPicHeight = m_iHeight;
|
||||
pParamExt->iTargetBitrate = 60000;
|
||||
|
Loading…
x
Reference in New Issue
Block a user