Skip to content

Commit

Permalink
don't allow negative values
Browse files Browse the repository at this point in the history
  • Loading branch information
noizuy committed Feb 21, 2024
1 parent 7fc732d commit a3c1a38
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ core.bore.FixBrightness(clip clip, int top=0, int bottom=0, int left=0, int righ
```

* `clip`: 32-bit float clip.
* `top = 0`, `bottom = 0`, `left = 0`, `right = 0`: number of lines from each border to adjust. Negative bottom/right values just count from the other side.
* `top = 0`, `bottom = 0`, `left = 0`, `right = 0`: number of lines from each border to adjust.
* `step = 1`: Speed up processing ever so slightly by lowering the number of pixels used to find the adjustment. Might be an unnecessary parameter.
* `upper = 1`: Upper limit of range, this allows excluding pixels.
* `lower = 0`: Lower limit of range, this allows excluding pixels.
Expand Down
12 changes: 4 additions & 8 deletions src/bore.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,8 @@ static void VS_CC fixBrightnessCreate(const VSMap *in, VSMap *out, void *userDat
if (err)
d.bottom = 0;

else if (d.bottom < 0)
d.bottom += vi->height;
else if (d.bottom > vi->height / 2) {
vsapi->mapSetError(out, "FixBrightness: bottom must be in [-height / 2, height / 2]");
vsapi->mapSetError(out, "FixBrightness: bottom must be in [0, height / 2]");
vsapi->freeNode(d.node);
return;
}
Expand All @@ -191,7 +189,7 @@ static void VS_CC fixBrightnessCreate(const VSMap *in, VSMap *out, void *userDat
if (err)
d.left = 0;

else if (d.left > vi->width - 1) {
else if (d.left > vi->width / 2) {
vsapi->mapSetError(out, "FixBrightness: left must be in [0, width / 2]");
vsapi->freeNode(d.node);
return;
Expand All @@ -202,10 +200,8 @@ static void VS_CC fixBrightnessCreate(const VSMap *in, VSMap *out, void *userDat
if (err)
d.right = 0;

else if (d.right < 0)
d.right += vi->width;
else if (d.right > vi->width - 1) {
vsapi->mapSetError(out, "FixBrightness: right must be in [-width / 2, width / 2]");
else if (d.right > vi->width / 2) {
vsapi->mapSetError(out, "FixBrightness: right must be in [0, width / 2]");
vsapi->freeNode(d.node);
return;
}
Expand Down

0 comments on commit a3c1a38

Please sign in to comment.