Skip to content

Commit

Permalink
Sanity checking for more parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
cantabile committed Sep 28, 2014
1 parent f2e561c commit 3b7e575
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/MVAnalyse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,16 @@ static void VS_CC mvanalyseCreate(const VSMap *in, VSMap *out, void *userData, V
d.tffexists = err;


if (d.search < 0 || d.search > 7) {
vsapi->setError(out, "Analyse: search must be between 0 and 7 (inclusive).");
return;
}

if (d.divideExtra < 0 || d.divideExtra > 2) {
vsapi->setError(out, "Analyse: divide must be between 0 and 2 (inclusive).");
return;
}

d.analysisData.yRatioUV = 2; //(vi.IsYV12()) ? 2 : 1;
d.analysisData.xRatioUV = 2; // for YV12 and YUY2, really do not used and assumed to 2

Expand Down
15 changes: 15 additions & 0 deletions src/MVDegrain1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,21 @@ static void VS_CC mvdegrain1Create(const VSMap *in, VSMap *out, void *userData,
d.isse = 1;


if (plane < 0 || plane > 4) {
vsapi->setError(out, "Degrain1: plane must be between 0 and 4 (inclusive).");
return;
}

if (d.nLimit < 0 || d.nLimit > 255) {
vsapi->setError(out, "Degrain1: limit must be between 0 and 255 (inclusive).");
return;
}

if (d.nLimitC < 0 || d.nLimitC > 255) {
vsapi->setError(out, "Degrain1: limitc must be between 0 and 255 (inclusive).");
return;
}

int planes[5] = { YPLANE, UPLANE, VPLANE, UVPLANES, YUVPLANES };
d.YUVplanes = planes[plane];

Expand Down
15 changes: 15 additions & 0 deletions src/MVDegrain2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1155,6 +1155,21 @@ static void VS_CC mvdegrain2Create(const VSMap *in, VSMap *out, void *userData,
d.isse = 1;


if (plane < 0 || plane > 4) {
vsapi->setError(out, "Degrain2: plane must be between 0 and 4 (inclusive).");
return;
}

if (d.nLimit < 0 || d.nLimit > 255) {
vsapi->setError(out, "Degrain2: limit must be between 0 and 255 (inclusive).");
return;
}

if (d.nLimitC < 0 || d.nLimitC > 255) {
vsapi->setError(out, "Degrain2: limitc must be between 0 and 255 (inclusive).");
return;
}

int planes[5] = { YPLANE, UPLANE, VPLANE, UVPLANES, YUVPLANES };
d.YUVplanes = planes[plane];

Expand Down
15 changes: 15 additions & 0 deletions src/MVDegrain3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1442,6 +1442,21 @@ static void VS_CC mvdegrain3Create(const VSMap *in, VSMap *out, void *userData,
d.isse = 1;


if (plane < 0 || plane > 4) {
vsapi->setError(out, "Degrain3: plane must be between 0 and 4 (inclusive).");
return;
}

if (d.nLimit < 0 || d.nLimit > 255) {
vsapi->setError(out, "Degrain3: limit must be between 0 and 255 (inclusive).");
return;
}

if (d.nLimitC < 0 || d.nLimitC > 255) {
vsapi->setError(out, "Degrain3: limitc must be between 0 and 255 (inclusive).");
return;
}

int planes[5] = { YPLANE, UPLANE, VPLANE, UVPLANES, YUVPLANES };
d.YUVplanes = planes[plane];

Expand Down
4 changes: 4 additions & 0 deletions src/MVFlowBlur.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,10 @@ static void VS_CC mvflowblurCreate(const VSMap *in, VSMap *out, void *userData,
return;
}

if (d.prec < 1) {
vsapi->setError(out, "FlowBlur: prec must be at least 1.");
return;
}

d.blur256 = (int)(d.blur * 256.0f / 200.0f);

Expand Down
10 changes: 10 additions & 0 deletions src/MVRecalculate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,16 @@ static void VS_CC mvrecalculateCreate(const VSMap *in, VSMap *out, void *userDat
d.tffexists = err;


if (d.search < 0 || d.search > 7) {
vsapi->setError(out, "Recalculate: search must be between 0 and 7 (inclusive).");
return;
}

if (d.divideExtra < 0 || d.divideExtra > 2) {
vsapi->setError(out, "Recalculate: divide must be between 0 and 2 (inclusive).");
return;
}

d.analysisData.yRatioUV = 2; //(vi.IsYV12()) ? 2 : 1;
d.analysisData.xRatioUV = 2; // for YV12 and YUY2, really do not used and assumed to 2

Expand Down
10 changes: 10 additions & 0 deletions src/MVSuper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,16 @@ static void VS_CC mvsuperCreate(const VSMap *in, VSMap *out, void *userData, VSC
return;
}

if (d.sharp < 0 || d.sharp > 2) {
vsapi->setError(out, "Super: sharp must be between 0 and 2 (inclusive).");
return;
}

if (d.rfilter < 0 || d.rfilter > 4) {
vsapi->setError(out, "Super: rfilter must be between 0 and 4 (inclusive).");
return;
}


d.nModeYUV = d.chroma ? YUVPLANES : YPLANE;

Expand Down

0 comments on commit 3b7e575

Please sign in to comment.