History

add parameter checking on resolution and related UT

Sijia Chen committed 11 years ago

Commit 9442a7a1 parent 8b7af7c3 files · +136 −28Browse files

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

Unified · Split

codec/encoder/core/src/encoder_ext.cpp+6−7
@@ -200,14 +200,13 @@ int32_t ParamValidation (SLogContext* pLogCtx, SWelsSvcCodingParam* pCfg) { · 199 unmodified lines
200200
201201 }
202202 if (pCfg->iSpatialLayerNum > 1) {
203− int32_t iFinalWidth = pCfg->sSpatialLayers[pCfg->iSpatialLayerNum - 1].iVideoWidth;
204− int32_t iFinalHeight = pCfg->sSpatialLayers[pCfg->iSpatialLayerNum - 1].iVideoHeight;
205− for (i = 0; i < (pCfg->iSpatialLayerNum - 1); i++) {
206− SSpatialLayerConfig* fDlp = &pCfg->sSpatialLayers[i];
207− if ((fDlp->iVideoWidth > iFinalWidth) || (fDlp->iVideoHeight > iFinalHeight)) {
203+ for (i = pCfg->iSpatialLayerNum - 1; i > 0; i--) {
204+ SSpatialLayerConfig* fDlpUp = &pCfg->sSpatialLayers[i];
205+ SSpatialLayerConfig* fDlp = &pCfg->sSpatialLayers[i-1];
206+ if ((fDlp->iVideoWidth > fDlpUp->iVideoWidth) || (fDlp->iVideoHeight > fDlpUp->iVideoHeight)) {
208207 WelsLog (pLogCtx, WELS_LOG_ERROR,
209− "ParamValidation,Invalid resolution layer(%d) resolution(%d x %d) should be less than the highest spatial layer resolution(%d x %d) ",
210− i, fDlp->iVideoWidth, fDlp->iVideoHeight, iFinalWidth, iFinalHeight);
208+ "ParamValidation,Invalid resolution layer(%d) resolution(%d x %d) should be less than the upper spatial layer resolution(%d x %d) ",
209+ i, fDlp->iVideoWidth, fDlp->iVideoHeight, fDlpUp->iVideoWidth, fDlpUp->iVideoHeight);
211210 return ENC_RETURN_UNSUPPORTED_PARA;
212211 }
213212 }

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