Skip to content

Commit

Permalink
avoid issues wher min() or max() is defined as a macro
Browse files Browse the repository at this point in the history
  • Loading branch information
devernay committed Jun 6, 2018
1 parent a85dc34 commit 31a5eb8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions Support/Library/ofxsImageEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1793,8 +1793,8 @@ namespace OFX {

void *Image::getPixelAddressNearest(int x, int y)
{
x = std::max(_bounds.x1, std::min(x, _bounds.x2 - 1));
y = std::max(_bounds.y1, std::min(y, _bounds.y2 - 1));
x = (std::max)(_bounds.x1, (std::min)(x, _bounds.x2 - 1));
y = (std::max)(_bounds.y1, (std::min)(y, _bounds.y2 - 1));

char *pix = ((char *) _pixelData) + (size_t)(y - _bounds.y1) * _rowBytes;
pix += (x - _bounds.x1) * _pixelBytes;
Expand All @@ -1803,8 +1803,8 @@ namespace OFX {

const void *Image::getPixelAddressNearest(int x, int y) const
{
x = std::max(_bounds.x1, std::min(x, _bounds.x2 - 1));
y = std::max(_bounds.y1, std::min(y, _bounds.y2 - 1));
x = (std::max)(_bounds.x1, (std::min)(x, _bounds.x2 - 1));
y = (std::max)(_bounds.y1, (std::min)(y, _bounds.y2 - 1));

const char *pix = ((const char *) _pixelData) + (size_t)(y - _bounds.y1) * _rowBytes;
pix += (x - _bounds.x1) * _pixelBytes;
Expand Down
6 changes: 3 additions & 3 deletions Support/Plugins/include/ofxsProcessing.H
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,10 @@ namespace OFX {
#endif
{
// make sure there are at least 4096 pixels per CPU and at least 1 line par CPU
unsigned int nCPUs = (unsigned int)((std::min(std::max(0, _renderWindow.x2 - _renderWindow.x1), 4096) *
(std::max(0, _renderWindow.y2 - _renderWindow.y1))) / 4096);
unsigned int nCPUs = (unsigned int)(((std::min)((std::max)(0, _renderWindow.x2 - _renderWindow.x1), 4096) *
((std::max)(0, _renderWindow.y2 - _renderWindow.y1))) / 4096);
// make sure the number of CPUs is valid (and use at least 1 CPU)
nCPUs = std::max(1u, std::min(nCPUs, OFX::MultiThread::getNumCPUs()));
nCPUs = (std::max)(1u, (std::min)(nCPUs, OFX::MultiThread::getNumCPUs()));

// call the base multi threading code, should put a pre & post thread calls in too
multiThread(nCPUs);
Expand Down

0 comments on commit 31a5eb8

Please sign in to comment.