History

Merge pull request #985 from ruil2/encoder_check

input parameters validation

dongzha committed 12 years ago

Commit b750a3b2 parents 0dcb758 15e225a1 file · +23 −3Browse files

Showing the changes to codec/encoder/core/src/encoder_ext.cpp (1 of 1 file). Show all

Unified · Split

codec/encoder/core/src/encoder_ext.cpp+23−3
@@ -84,6 +84,26 @@ int32_t ParamValidation (SLogContext* pLogCtx, SWelsSvcCodingParam* pCfg) { · 83 unmodified lines
8484 WelsLog (pLogCtx, WELS_LOG_ERROR, "ParamValidation(),Invalid usage type = %d\n", pCfg->iUsageType);
8585 return ENC_RETURN_UNSUPPORTED_PARA;
8686 }
87+ if (pCfg->iUsageType == SCREEN_CONTENT_REAL_TIME) {
88+ if (pCfg->iSpatialLayerNum > 1) {
89+ WelsLog (pLogCtx, WELS_LOG_ERROR, "ParamValidation(),Invalid the number of Spatial layer(%d)for screen content\n",
90+ pCfg->iSpatialLayerNum);
91+ return ENC_RETURN_UNSUPPORTED_PARA;
92+ }
93+ }
94+ if (pCfg->iSpatialLayerNum > 1) {
95+ int32_t iFinalWidth = pCfg->sSpatialLayers[pCfg->iSpatialLayerNum - 1].iVideoWidth;
96+ int32_t iFinalHeight = pCfg->sSpatialLayers[pCfg->iSpatialLayerNum - 1].iVideoWidth;
97+ for (i = 0; i < (pCfg->iSpatialLayerNum - 1); i++) {
98+ SSpatialLayerConfig* fDlp = &pCfg->sSpatialLayers[i];
99+ if ((fDlp->iVideoWidth > iFinalWidth) || (fDlp->iVideoHeight > iFinalHeight)) {
100+ WelsLog (pLogCtx, WELS_LOG_ERROR,
101+ "ParamValidation,Invalid resolution layer(%d) resolution(%d x %d) shoudl be less than the highest spatial layer resolution(%d x %d)\n ",
102+ i, fDlp->iVideoWidth, fDlp->iVideoHeight, iFinalWidth, iFinalHeight);
103+ return ENC_RETURN_UNSUPPORTED_PARA;
104+ }
105+ }
106+ }
87107 for (i = 0; i < pCfg->iSpatialLayerNum; ++ i) {
88108 SSpatialLayerInternal* fDlp = &pCfg->sDependencyLayers[i];
89109 if (fDlp->fOutputFrameRate > fDlp->fInputFrameRate || (fDlp->fInputFrameRate >= -fEpsn
@@ -2941,9 +2961,9 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 2851 unmodified lines
29412961 //loop each layer to check if have skip frame when RC and frame skip enable
29422962 if (RC_OFF_MODE != pCtx->pSvcParam->iRCMode && true == pCtx->pSvcParam->bEnableFrameSkip) {
29432963 bool bSkipMustFlag = false;
2944− for (int32_t i = 0; i< iSpatialNum; i++) {
2945− pCtx->uiDependencyId = (uint8_t)(pSpatialIndexMap+i)->iDid;
2946− pCtx->pFuncList->pfRc.pfWelsRcPicDelayJudge(pCtx);
2964+ for (int32_t i = 0; i < iSpatialNum; i++) {
2965+ pCtx->uiDependencyId = (uint8_t) (pSpatialIndexMap + i)->iDid;
2966+ pCtx->pFuncList->pfRc.pfWelsRcPicDelayJudge (pCtx);
29472967 if (true == pCtx->pWelsSvcRc[pCtx->uiDependencyId].bSkipFlag) {
29482968 bSkipMustFlag = true;
29492969 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t