ref: b0d6cf7b9b26b3c426cf3a60a8e52239c76af005
parent: 699ed2e2a287d3fac25bcb0b7217552cd25bf5f9
parent: d117624657ee9c095e23c84788e13c3a317ecbe7
author: huili2 <[email protected]>
date: Mon Jun 23 10:01:17 EDT 2014
Merge pull request #992 from ruil2/interface_update add interface parameter(profile/levle/numref) support
--- a/codec/api/svc/codec_app_def.h
+++ b/codec/api/svc/codec_app_def.h
@@ -82,6 +82,11 @@
ENCODER_OPTION_RC_MODE,
ENCODER_PADDING_PADDING,
+ ENCODER_OPTION_PROFILE,
+ ENCODER_OPTION_LEVEL,
+ ENCODER_OPTION_NUMBER_REF,
+ ENCODER_OPTION_DELIVERY_STATUS,
+
ENCODER_LTR_RECOVERY_REQUEST,
ENCODER_LTR_MARKING_FEEDBACK,
ENCOCER_LTR_MARKING_PERIOD,
@@ -398,4 +403,20 @@
int iLayer;
char* pFileName;
} SDumpLayer;
+
+typedef struct TagProfileInfo {
+ int iLayer;
+ EProfileIdc uiProfileIdc; //the profile info
+} SProfileInfo;
+
+typedef struct TagLevelInfo {
+ int iLayer;
+ ELevelIdc uiLevelIdc; //the level info
+} SLevelInfo;
+
+typedef struct TagDeliveryStatus{
+ int iDropNum; //the number of video frames that are dropped continuously before delivery to encoder, which is used by screen content.
+ int iDropFrameType; // the frame type that is dropped
+ int iDropFrameSize; // the frame size that is dropped
+}SDeliveryStatus;
#endif//WELS_VIDEO_CODEC_APPLICATION_DEFINITION_H__
--- a/codec/encoder/core/inc/encoder_context.h
+++ b/codec/encoder/core/inc/encoder_context.h
@@ -216,7 +216,7 @@
int32_t iEncoderError;
WELS_MUTEX mutexEncoderError;
-
+ int32_t iDropNumber;
} sWelsEncCtx/*, *PWelsEncCtx*/;
}
#endif//sWelsEncCtx_H__
--- a/codec/encoder/plus/inc/welsEncoderExt.h
+++ b/codec/encoder/plus/inc/welsEncoderExt.h
@@ -104,7 +104,9 @@
private:
int InitializeInternal (SWelsSvcCodingParam* argv);
-
+ void CheckProfileSetting (int32_t iLayer, EProfileIdc uiProfileIdc);
+ void CheckLevelSetting (int32_t iLayer, ELevelIdc uiLevelIdc);
+ void CheckReferenceNumSetting (int32_t iNumRef);
sWelsEncCtx* m_pEncContext;
welsCodecTrace* m_pWelsTrace;
--- a/codec/encoder/plus/src/welsEncoderExt.cpp
+++ b/codec/encoder/plus/src/welsEncoderExt.cpp
@@ -356,16 +356,16 @@
if (pCfg->iUsageType == SCREEN_CONTENT_REAL_TIME) {
if (pCfg->bEnableLongTermReference) {
pCfg->iLTRRefNum = WELS_CLIP3 (pCfg->iLTRRefNum, 1, LONG_TERM_REF_NUM_SCREEN);
- if(pCfg->iNumRefFrame == AUTO_REF_PIC_COUNT)
+ if (pCfg->iNumRefFrame == AUTO_REF_PIC_COUNT)
pCfg->iNumRefFrame = WELS_MAX (1, WELS_LOG2 (pCfg->uiGopSize)) + pCfg->iLTRRefNum;
} else {
pCfg->iLTRRefNum = 0;
- if(pCfg->iNumRefFrame == AUTO_REF_PIC_COUNT)
+ if (pCfg->iNumRefFrame == AUTO_REF_PIC_COUNT)
pCfg->iNumRefFrame = WELS_MAX (1, pCfg->uiGopSize >> 1);
}
} else {
pCfg->iLTRRefNum = pCfg->bEnableLongTermReference ? WELS_CLIP3 (pCfg->iLTRRefNum, 1, LONG_TERM_REF_NUM) : 0;
- if(pCfg->iNumRefFrame == AUTO_REF_PIC_COUNT){
+ if (pCfg->iNumRefFrame == AUTO_REF_PIC_COUNT) {
pCfg->iNumRefFrame = ((pCfg->uiGopSize >> 1) > 1) ? ((pCfg->uiGopSize >> 1) + pCfg->iLTRRefNum) :
(MIN_REF_PIC_COUNT + pCfg->iLTRRefNum);
pCfg->iNumRefFrame = WELS_CLIP3 (pCfg->iNumRefFrame, MIN_REF_PIC_COUNT, MAX_REFERENCE_PICTURE_COUNT_NUM);
@@ -554,7 +554,29 @@
return 0;
}
-
+void CWelsH264SVCEncoder::CheckProfileSetting (int32_t iLayer, EProfileIdc uiProfileIdc) {
+ SSpatialLayerConfig* pLayerInfo = &m_pEncContext->pSvcParam->sSpatialLayers[iLayer];
+ pLayerInfo->uiProfileIdc = uiProfileIdc;
+ if ((iLayer == SPATIAL_LAYER_0) && (uiProfileIdc != PRO_BASELINE)) {
+ pLayerInfo->uiProfileIdc = PRO_BASELINE;
+ WelsLog (m_pEncContext, WELS_LOG_WARNING, "doesn't support profile(%d),change to baseline profile", uiProfileIdc);
+ }
+ if (iLayer > SPATIAL_LAYER_0) {
+ if ((uiProfileIdc != PRO_BASELINE) || (uiProfileIdc != PRO_SCALABLE_BASELINE)) {
+ pLayerInfo->uiProfileIdc = PRO_BASELINE;
+ WelsLog (m_pEncContext, WELS_LOG_WARNING, "doesn't support profile(%d),change to baseline profile", uiProfileIdc);
+ }
+ }
+}
+void CWelsH264SVCEncoder::CheckLevelSetting (int32_t iLayer, ELevelIdc uiLevelIdc) {
+ SSpatialLayerConfig* pLayerInfo = &m_pEncContext->pSvcParam->sSpatialLayers[iLayer];
+ pLayerInfo->uiLevelIdc = uiLevelIdc;
+ //TBD
+}
+void CWelsH264SVCEncoder::CheckReferenceNumSetting (int32_t iNumRef) {
+ m_pEncContext->pSvcParam->iNumRefFrame = iNumRef;
+ //TBD
+}
/************************************************************************
* InDataFormat, IDRInterval, SVC Encode Param, Frame Rate, Bitrate,..
************************************************************************/
@@ -886,6 +908,36 @@
void* ctx = * ((void**)pOption);
m_pWelsTrace->SetTraceCallbackContext (ctx);
}
+ }
+ break;
+ case ENCODER_OPTION_PROFILE: {
+ SProfileInfo* pProfileInfo = (static_cast<SProfileInfo*> (pOption));
+ if ((pProfileInfo->iLayer < SPATIAL_LAYER_0) || (pProfileInfo->iLayer > SPATIAL_LAYER_3)) {
+ WelsLog (m_pEncContext, WELS_LOG_ERROR,
+ "CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_PROFILE,iLayer = %d(rang0-3)\n", pProfileInfo->iLayer);
+ return cmInitParaError;
+ }
+ CheckProfileSetting (pProfileInfo->iLayer, pProfileInfo->uiProfileIdc);
+ }
+ break;
+ case ENCODER_OPTION_LEVEL: {
+ SLevelInfo* pLevelInfo = (static_cast<SLevelInfo*> (pOption));
+ if ((pLevelInfo->iLayer < SPATIAL_LAYER_0) || (pLevelInfo->iLayer > SPATIAL_LAYER_3)) {
+ WelsLog (m_pEncContext, WELS_LOG_ERROR,
+ "CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_PROFILE,iLayer = %d(rang0-3)\n", pLevelInfo->iLayer);
+ return cmInitParaError;
+ }
+ CheckLevelSetting (pLevelInfo->iLayer, pLevelInfo->uiLevelIdc);
+ }
+ break;
+ case ENCODER_OPTION_NUMBER_REF: {
+ int32_t iValue = * ((int32_t*)pOption);
+ CheckReferenceNumSetting (iValue);
+ }
+ break;
+ case ENCODER_OPTION_DELIVERY_STATUS: {
+ SDeliveryStatus *pValue = (static_cast<SDeliveryStatus*>(pOption));
+ m_pEncContext->iDropNumber = pValue->iDropNum;
}
break;
default: