Cleanup: use MIN2/MAX2 in compositor.

This commit is contained in:
Jeroen Bakker 2021-03-05 14:54:32 +01:00
parent 3d3a5bb892
commit ba5961b4cd
47 changed files with 191 additions and 198 deletions

View File

@ -143,7 +143,7 @@ void ExecutionGroup::initExecution()
if (operation->isReadBufferOperation()) {
ReadBufferOperation *readOperation = (ReadBufferOperation *)operation;
this->m_cachedReadOperations.push_back(readOperation);
maxNumber = max(maxNumber, readOperation->getOffset());
maxNumber = MAX2(maxNumber, readOperation->getOffset());
}
}
maxNumber++;
@ -452,13 +452,13 @@ inline void ExecutionGroup::determineChunkRect(rcti *rect,
else {
const unsigned int minx = xChunk * this->m_chunkSize + this->m_viewerBorder.xmin;
const unsigned int miny = yChunk * this->m_chunkSize + this->m_viewerBorder.ymin;
const unsigned int width = min((unsigned int)this->m_viewerBorder.xmax, this->m_width);
const unsigned int height = min((unsigned int)this->m_viewerBorder.ymax, this->m_height);
const unsigned int width = MIN2((unsigned int)this->m_viewerBorder.xmax, this->m_width);
const unsigned int height = MIN2((unsigned int)this->m_viewerBorder.ymax, this->m_height);
BLI_rcti_init(rect,
min(minx, this->m_width),
min(minx + this->m_chunkSize, width),
min(miny, this->m_height),
min(miny + this->m_chunkSize, height));
MIN2(minx, this->m_width),
MIN2(minx + this->m_chunkSize, width),
MIN2(miny, this->m_height),
MIN2(miny + this->m_chunkSize, height));
}
}

View File

@ -20,9 +20,6 @@
#include "MEM_guardedalloc.h"
using std::max;
using std::min;
static unsigned int determine_num_channels(DataType datatype)
{
switch (datatype) {
@ -156,10 +153,10 @@ void MemoryBuffer::copyContentFrom(MemoryBuffer *otherBuffer)
return;
}
unsigned int otherY;
unsigned int minX = max(this->m_rect.xmin, otherBuffer->m_rect.xmin);
unsigned int maxX = min(this->m_rect.xmax, otherBuffer->m_rect.xmax);
unsigned int minY = max(this->m_rect.ymin, otherBuffer->m_rect.ymin);
unsigned int maxY = min(this->m_rect.ymax, otherBuffer->m_rect.ymax);
unsigned int minX = MAX2(this->m_rect.xmin, otherBuffer->m_rect.xmin);
unsigned int maxX = MIN2(this->m_rect.xmax, otherBuffer->m_rect.xmax);
unsigned int minY = MAX2(this->m_rect.ymin, otherBuffer->m_rect.ymin);
unsigned int maxY = MIN2(this->m_rect.ymax, otherBuffer->m_rect.ymax);
int offset;
int otherOffset;

View File

@ -182,10 +182,10 @@ bool NodeOperation::determineDependingAreaOfInterest(rcti *input,
first = false;
}
else {
output->xmin = min(output->xmin, tempOutput.xmin);
output->ymin = min(output->ymin, tempOutput.ymin);
output->xmax = max(output->xmax, tempOutput.xmax);
output->ymax = max(output->ymax, tempOutput.ymax);
output->xmin = MIN2(output->xmin, tempOutput.xmin);
output->ymin = MIN2(output->ymin, tempOutput.ymin);
output->xmax = MAX2(output->xmax, tempOutput.xmax);
output->ymax = MAX2(output->ymax, tempOutput.ymax);
}
}
}

View File

@ -33,10 +33,6 @@
#include "clew.h"
using std::list;
using std::max;
using std::min;
class OpenCLDevice;
class ReadBufferOperation;
class WriteBufferOperation;
@ -239,8 +235,8 @@ class NodeOperation : public SocketReader {
MemoryBuffer * /*outputMemoryBuffer*/,
cl_mem /*clOutputBuffer*/,
MemoryBuffer ** /*inputMemoryBuffers*/,
list<cl_mem> * /*clMemToCleanUp*/,
list<cl_kernel> * /*clKernelsToCleanUp*/)
std::list<cl_mem> * /*clMemToCleanUp*/,
std::list<cl_kernel> * /*clKernelsToCleanUp*/)
{
}
virtual void deinitExecution();

View File

@ -79,7 +79,7 @@ void OpenCLDevice::execute(WorkPackage *work)
cl_mem OpenCLDevice::COM_clAttachMemoryBufferToKernelParameter(cl_kernel kernel,
int parameterIndex,
int offsetIndex,
list<cl_mem> *cleanup,
std::list<cl_mem> *cleanup,
MemoryBuffer **inputMemoryBuffers,
SocketReader *reader)
{
@ -111,7 +111,7 @@ const cl_image_format *OpenCLDevice::determineImageFormat(MemoryBuffer *memoryBu
cl_mem OpenCLDevice::COM_clAttachMemoryBufferToKernelParameter(cl_kernel kernel,
int parameterIndex,
int offsetIndex,
list<cl_mem> *cleanup,
std::list<cl_mem> *cleanup,
MemoryBuffer **inputMemoryBuffers,
ReadBufferOperation *reader)
{
@ -258,7 +258,7 @@ void OpenCLDevice::COM_clEnqueueRange(cl_kernel kernel,
}
cl_kernel OpenCLDevice::COM_clCreateKernel(const char *kernelname,
list<cl_kernel> *clKernelsToCleanUp)
std::list<cl_kernel> *clKernelsToCleanUp)
{
cl_int error;
cl_kernel kernel = clCreateKernel(this->m_program, kernelname, &error);

View File

@ -25,8 +25,6 @@ class OpenCLDevice;
#include "COM_WorkScheduler.h"
#include "clew.h"
using std::list;
/**
* \brief device representing an GPU OpenCL device.
* an instance of this class represents a single cl_device
@ -107,13 +105,13 @@ class OpenCLDevice : public Device {
cl_mem COM_clAttachMemoryBufferToKernelParameter(cl_kernel kernel,
int parameterIndex,
int offsetIndex,
list<cl_mem> *cleanup,
std::list<cl_mem> *cleanup,
MemoryBuffer **inputMemoryBuffers,
SocketReader *reader);
cl_mem COM_clAttachMemoryBufferToKernelParameter(cl_kernel kernel,
int parameterIndex,
int offsetIndex,
list<cl_mem> *cleanup,
std::list<cl_mem> *cleanup,
MemoryBuffer **inputMemoryBuffers,
ReadBufferOperation *reader);
void COM_clAttachMemoryBufferOffsetToKernelParameter(cl_kernel kernel,
@ -130,5 +128,5 @@ class OpenCLDevice : public Device {
MemoryBuffer *outputMemoryBuffer,
int offsetIndex,
NodeOperation *operation);
cl_kernel COM_clCreateKernel(const char *kernelname, list<cl_kernel> *clKernelsToCleanUp);
cl_kernel COM_clCreateKernel(const char *kernelname, std::list<cl_kernel> *clKernelsToCleanUp);
};

View File

@ -33,7 +33,7 @@ void SwitchViewNode::convertToOperations(NodeConverter &converter,
/* get the internal index of the socket with a matching name */
int nr = BLI_findstringindex(&bnode->inputs, viewName, offsetof(bNodeSocket, name));
nr = max(nr, 0);
nr = MAX2(nr, 0);
result = converter.addInputProxy(getInputSocket(nr), false);
converter.mapOutputSocket(getOutputSocket(0), result);

View File

@ -62,7 +62,7 @@ void BokehBlurOperation::initExecution()
int width = this->m_inputBokehProgram->getWidth();
int height = this->m_inputBokehProgram->getHeight();
float dimension = min(width, height);
float dimension = MIN2(width, height);
this->m_bokehMidX = width / 2.0f;
this->m_bokehMidY = height / 2.0f;
@ -84,7 +84,7 @@ void BokehBlurOperation::executePixel(float output[4], int x, int y, void *data)
int bufferwidth = inputBuffer->getWidth();
int bufferstartx = inputBuffer->getRect()->xmin;
int bufferstarty = inputBuffer->getRect()->ymin;
const float max_dim = max(this->getWidth(), this->getHeight());
const float max_dim = MAX2(this->getWidth(), this->getHeight());
int pixelSize = this->m_size * max_dim / 100.0f;
zero_v4(color_accum);
@ -99,10 +99,10 @@ void BokehBlurOperation::executePixel(float output[4], int x, int y, void *data)
int maxy = y + pixelSize;
int minx = x - pixelSize;
int maxx = x + pixelSize;
miny = max(miny, inputBuffer->getRect()->ymin);
minx = max(minx, inputBuffer->getRect()->xmin);
maxy = min(maxy, inputBuffer->getRect()->ymax);
maxx = min(maxx, inputBuffer->getRect()->xmax);
miny = MAX2(miny, inputBuffer->getRect()->ymin);
minx = MAX2(minx, inputBuffer->getRect()->xmin);
maxy = MIN2(maxy, inputBuffer->getRect()->ymax);
maxx = MIN2(maxx, inputBuffer->getRect()->xmax);
int step = getStep();
int offsetadd = getOffsetAdd() * COM_NUM_CHANNELS_COLOR;
@ -144,7 +144,7 @@ bool BokehBlurOperation::determineDependingAreaOfInterest(rcti *input,
{
rcti newInput;
rcti bokehInput;
const float max_dim = max(this->getWidth(), this->getHeight());
const float max_dim = MAX2(this->getWidth(), this->getHeight());
if (this->m_sizeavailable) {
newInput.xmax = input->xmax + (this->m_size * max_dim / 100.0f);
@ -193,14 +193,14 @@ void BokehBlurOperation::executeOpenCL(OpenCLDevice *device,
MemoryBuffer *outputMemoryBuffer,
cl_mem clOutputBuffer,
MemoryBuffer **inputMemoryBuffers,
list<cl_mem> *clMemToCleanUp,
list<cl_kernel> * /*clKernelsToCleanUp*/)
std::list<cl_mem> *clMemToCleanUp,
std::list<cl_kernel> * /*clKernelsToCleanUp*/)
{
cl_kernel kernel = device->COM_clCreateKernel("bokehBlurKernel", nullptr);
if (!this->m_sizeavailable) {
updateSize();
}
const float max_dim = max(this->getWidth(), this->getHeight());
const float max_dim = MAX2(this->getWidth(), this->getHeight());
cl_int radius = this->m_size * max_dim / 100.0f;
cl_int step = this->getStep();
@ -235,7 +235,7 @@ void BokehBlurOperation::determineResolution(unsigned int resolution[2],
{
NodeOperation::determineResolution(resolution, preferredResolution);
if (this->m_extend_bounds) {
const float max_dim = max(resolution[0], resolution[1]);
const float max_dim = MAX2(resolution[0], resolution[1]);
resolution[0] += 2 * this->m_size * max_dim / 100.0f;
resolution[1] += 2 * this->m_size * max_dim / 100.0f;
}

View File

@ -67,8 +67,8 @@ class BokehBlurOperation : public NodeOperation, public QualityStepHelper {
MemoryBuffer *outputMemoryBuffer,
cl_mem clOutputBuffer,
MemoryBuffer **inputMemoryBuffers,
list<cl_mem> *clMemToCleanUp,
list<cl_kernel> *clKernelsToCleanUp);
std::list<cl_mem> *clMemToCleanUp,
std::list<cl_kernel> *clKernelsToCleanUp);
void setExtendBounds(bool extend_bounds)
{

View File

@ -64,7 +64,7 @@ void BoxMaskOperation::executePixelSampled(float output[4], float x, float y, Pi
switch (this->m_maskType) {
case CMP_NODE_MASKTYPE_ADD:
if (inside) {
output[0] = max(inputMask[0], inputValue[0]);
output[0] = MAX2(inputMask[0], inputValue[0]);
}
else {
output[0] = inputMask[0];

View File

@ -95,7 +95,7 @@ void ChannelMatteOperation::executePixelSampled(float output[4],
this->m_inputImageProgram->readSampled(inColor, x, y, sampler);
/* matte operation */
alpha = inColor[this->m_ids[0]] - max(inColor[this->m_ids[1]], inColor[this->m_ids[2]]);
alpha = inColor[this->m_ids[0]] - MAX2(inColor[this->m_ids[1]], inColor[this->m_ids[2]]);
/* flip because 0.0 is transparent, not 1.0 */
alpha = 1.0f - alpha;
@ -116,5 +116,5 @@ void ChannelMatteOperation::executePixelSampled(float output[4],
*/
/* Don't make something that was more transparent less transparent. */
output[0] = min(alpha, inColor[3]);
output[0] = MIN2(alpha, inColor[3]);
}

View File

@ -38,12 +38,12 @@ class ChannelMatteOperation : public NodeOperation {
float m_limit_range;
/** ids to use for the operations (max and simple)
* alpha = in[ids[0]] - max(in[ids[1]], in[ids[2]])
* alpha = in[ids[0]] - MAX2(in[ids[1]], in[ids[2]])
* the simple operation is using:
* alpha = in[ids[0]] - in[ids[1]]
* but to use the same formula and operation for both we do:
* ids[2] = ids[1]
* alpha = in[ids[0]] - max(in[ids[1]], in[ids[2]])
* alpha = in[ids[0]] - MAX2(in[ids[1]], in[ids[2]])
*/
int m_ids[3];

View File

@ -59,7 +59,7 @@ void ColorBalanceASCCDLOperation::executePixelSampled(float output[4],
this->m_inputColorOperation->readSampled(inputColor, x, y, sampler);
float fac = value[0];
fac = min(1.0f, fac);
fac = MIN2(1.0f, fac);
const float mfac = 1.0f - fac;
output[0] = mfac * inputColor[0] +

View File

@ -64,7 +64,7 @@ void ColorBalanceLGGOperation::executePixelSampled(float output[4],
this->m_inputColorOperation->readSampled(inputColor, x, y, sampler);
float fac = value[0];
fac = min(1.0f, fac);
fac = MIN2(1.0f, fac);
const float mfac = 1.0f - fac;
output[0] = mfac * inputColor[0] +

View File

@ -66,7 +66,7 @@ void ColorCorrectionOperation::executePixelSampled(float output[4],
float r, g, b;
float value = inputMask[0];
value = min(1.0f, value);
value = MIN2(1.0f, value);
const float mvalue = 1.0f - value;
float levelShadows = 0.0;

View File

@ -90,7 +90,7 @@ void ColorSpillOperation::executePixelSampled(float output[4],
float input[4];
this->m_inputFacReader->readSampled(fac, x, y, sampler);
this->m_inputImageReader->readSampled(input, x, y, sampler);
float rfac = min(1.0f, fac[0]);
float rfac = MIN2(1.0f, fac[0]);
float map;
switch (this->m_spillMethod) {

View File

@ -63,13 +63,13 @@ void ConvertDepthToRadiusOperation::initExecution()
(this->getHeight() / (float)this->getWidth()) :
(this->getWidth() / (float)this->getHeight());
this->m_aperture = 0.5f * (this->m_cam_lens / (this->m_aspect * cam_sensor)) / this->m_fStop;
const float minsz = min(getWidth(), getHeight());
const float minsz = MIN2(getWidth(), getHeight());
this->m_dof_sp = minsz /
((cam_sensor / 2.0f) /
this->m_cam_lens); // <- == aspect * min(img->x, img->y) / tan(0.5f * fov);
this->m_cam_lens); // <- == aspect * MIN2(img->x, img->y) / tan(0.5f * fov);
if (this->m_blurPostOperation) {
m_blurPostOperation->setSigma(min(m_aperture * 128.0f, this->m_maxRadius));
m_blurPostOperation->setSigma(MIN2(m_aperture * 128.0f, this->m_maxRadius));
}
}

View File

@ -92,8 +92,8 @@ void ConvolutionEdgeFilterOperation::executePixel(float output[4], int x, int y,
output[3] = in2[3];
/* Make sure we don't return negative color. */
output[0] = max(output[0], 0.0f);
output[1] = max(output[1], 0.0f);
output[2] = max(output[2], 0.0f);
output[3] = max(output[3], 0.0f);
output[0] = MAX2(output[0], 0.0f);
output[1] = MAX2(output[1], 0.0f);
output[2] = MAX2(output[2], 0.0f);
output[3] = MAX2(output[3], 0.0f);
}

View File

@ -105,10 +105,10 @@ void ConvolutionFilterOperation::executePixel(float output[4], int x, int y, voi
output[3] = output[3] * value[0] + in2[3] * mval;
/* Make sure we don't return negative color. */
output[0] = max(output[0], 0.0f);
output[1] = max(output[1], 0.0f);
output[2] = max(output[2], 0.0f);
output[3] = max(output[3], 0.0f);
output[0] = MAX2(output[0], 0.0f);
output[1] = MAX2(output[1], 0.0f);
output[2] = MAX2(output[2], 0.0f);
output[3] = MAX2(output[3], 0.0f);
}
bool ConvolutionFilterOperation::determineDependingAreaOfInterest(

View File

@ -54,10 +54,10 @@ void CropBaseOperation::updateArea()
local_settings.y2 = height - 1;
}
this->m_xmax = max(local_settings.x1, local_settings.x2) + 1;
this->m_xmin = min(local_settings.x1, local_settings.x2);
this->m_ymax = max(local_settings.y1, local_settings.y2) + 1;
this->m_ymin = min(local_settings.y1, local_settings.y2);
this->m_xmax = MAX2(local_settings.x1, local_settings.x2) + 1;
this->m_xmin = MIN2(local_settings.x1, local_settings.x2);
this->m_ymax = MAX2(local_settings.y1, local_settings.y2) + 1;
this->m_ymin = MIN2(local_settings.y1, local_settings.y2);
}
else {
this->m_xmax = 0;

View File

@ -41,7 +41,7 @@ void DilateErodeThresholdOperation::initExecution()
}
else {
if (this->m_inset * 2 > this->m_distance) {
this->m_scope = max(this->m_inset * 2 - this->m_distance, this->m_distance);
this->m_scope = MAX2(this->m_inset * 2 - this->m_distance, this->m_distance);
}
else {
this->m_scope = this->m_distance;
@ -71,10 +71,10 @@ void DilateErodeThresholdOperation::executePixel(float output[4], int x, int y,
MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
float *buffer = inputBuffer->getBuffer();
rcti *rect = inputBuffer->getRect();
const int minx = max(x - this->m_scope, rect->xmin);
const int miny = max(y - this->m_scope, rect->ymin);
const int maxx = min(x + this->m_scope, rect->xmax);
const int maxy = min(y + this->m_scope, rect->ymax);
const int minx = MAX2(x - this->m_scope, rect->xmin);
const int miny = MAX2(y - this->m_scope, rect->ymin);
const int maxx = MIN2(x + this->m_scope, rect->xmax);
const int maxy = MIN2(y + this->m_scope, rect->ymax);
const int bufferWidth = BLI_rcti_size_x(rect);
int offset;
@ -87,7 +87,7 @@ void DilateErodeThresholdOperation::executePixel(float output[4], int x, int y,
if (buffer[offset] < sw) {
const float dx = xi - x;
const float dis = dx * dx + dy * dy;
mindist = min(mindist, dis);
mindist = MIN2(mindist, dis);
}
offset++;
}
@ -102,7 +102,7 @@ void DilateErodeThresholdOperation::executePixel(float output[4], int x, int y,
if (buffer[offset] > sw) {
const float dx = xi - x;
const float dis = dx * dx + dy * dy;
mindist = min(mindist, dis);
mindist = MIN2(mindist, dis);
}
offset++;
}
@ -191,10 +191,10 @@ void DilateDistanceOperation::executePixel(float output[4], int x, int y, void *
MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
float *buffer = inputBuffer->getBuffer();
rcti *rect = inputBuffer->getRect();
const int minx = max(x - this->m_scope, rect->xmin);
const int miny = max(y - this->m_scope, rect->ymin);
const int maxx = min(x + this->m_scope, rect->xmax);
const int maxy = min(y + this->m_scope, rect->ymax);
const int minx = MAX2(x - this->m_scope, rect->xmin);
const int miny = MAX2(y - this->m_scope, rect->ymin);
const int maxx = MIN2(x + this->m_scope, rect->xmax);
const int maxy = MIN2(y + this->m_scope, rect->ymax);
const int bufferWidth = BLI_rcti_size_x(rect);
int offset;
@ -207,7 +207,7 @@ void DilateDistanceOperation::executePixel(float output[4], int x, int y, void *
const float dx = xi - x;
const float dis = dx * dx + dy * dy;
if (dis <= mindist) {
value = max(buffer[offset], value);
value = MAX2(buffer[offset], value);
}
offset++;
}
@ -238,8 +238,8 @@ void DilateDistanceOperation::executeOpenCL(OpenCLDevice *device,
MemoryBuffer *outputMemoryBuffer,
cl_mem clOutputBuffer,
MemoryBuffer **inputMemoryBuffers,
list<cl_mem> *clMemToCleanUp,
list<cl_kernel> * /*clKernelsToCleanUp*/)
std::list<cl_mem> *clMemToCleanUp,
std::list<cl_kernel> * /*clKernelsToCleanUp*/)
{
cl_kernel dilateKernel = device->COM_clCreateKernel("dilateKernel", nullptr);
@ -270,10 +270,10 @@ void ErodeDistanceOperation::executePixel(float output[4], int x, int y, void *d
MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
float *buffer = inputBuffer->getBuffer();
rcti *rect = inputBuffer->getRect();
const int minx = max(x - this->m_scope, rect->xmin);
const int miny = max(y - this->m_scope, rect->ymin);
const int maxx = min(x + this->m_scope, rect->xmax);
const int maxy = min(y + this->m_scope, rect->ymax);
const int minx = MAX2(x - this->m_scope, rect->xmin);
const int miny = MAX2(y - this->m_scope, rect->ymin);
const int maxx = MIN2(x + this->m_scope, rect->xmax);
const int maxy = MIN2(y + this->m_scope, rect->ymax);
const int bufferWidth = BLI_rcti_size_x(rect);
int offset;
@ -286,7 +286,7 @@ void ErodeDistanceOperation::executePixel(float output[4], int x, int y, void *d
const float dx = xi - x;
const float dis = dx * dx + dy * dy;
if (dis <= mindist) {
value = min(buffer[offset], value);
value = MIN2(buffer[offset], value);
}
offset++;
}
@ -298,8 +298,8 @@ void ErodeDistanceOperation::executeOpenCL(OpenCLDevice *device,
MemoryBuffer *outputMemoryBuffer,
cl_mem clOutputBuffer,
MemoryBuffer **inputMemoryBuffers,
list<cl_mem> *clMemToCleanUp,
list<cl_kernel> * /*clKernelsToCleanUp*/)
std::list<cl_mem> *clMemToCleanUp,
std::list<cl_kernel> * /*clKernelsToCleanUp*/)
{
cl_kernel erodeKernel = device->COM_clCreateKernel("erodeKernel", nullptr);
@ -360,10 +360,10 @@ void *DilateStepOperation::initializeTileData(rcti *rect)
int half_window = this->m_iterations;
int window = half_window * 2 + 1;
int xmin = max(0, rect->xmin - half_window);
int ymin = max(0, rect->ymin - half_window);
int xmax = min(width, rect->xmax + half_window);
int ymax = min(height, rect->ymax + half_window);
int xmin = MAX2(0, rect->xmin - half_window);
int ymin = MAX2(0, rect->ymin - half_window);
int xmax = MIN2(width, rect->xmax + half_window);
int ymax = MIN2(height, rect->ymax + half_window);
int bwidth = rect->xmax - rect->xmin;
int bheight = rect->ymax - rect->ymin;
@ -378,7 +378,7 @@ void *DilateStepOperation::initializeTileData(rcti *rect)
// single row or column of input values, padded with FLT_MAX's to
// simplify the logic.
float *temp = (float *)MEM_mallocN(sizeof(float) * (2 * window - 1), "dilate erode temp");
float *buf = (float *)MEM_mallocN(sizeof(float) * (max(bwidth, bheight) + 5 * half_window),
float *buf = (float *)MEM_mallocN(sizeof(float) * (MAX2(bwidth, bheight) + 5 * half_window),
"dilate erode buf");
// The following is based on the van Herk/Gil-Werman algorithm for morphology operations.
@ -396,13 +396,13 @@ void *DilateStepOperation::initializeTileData(rcti *rect)
temp[window - 1] = buf[start];
for (x = 1; x < window; x++) {
temp[window - 1 - x] = max(temp[window - x], buf[start - x]);
temp[window - 1 + x] = max(temp[window + x - 2], buf[start + x]);
temp[window - 1 - x] = MAX2(temp[window - x], buf[start - x]);
temp[window - 1 + x] = MAX2(temp[window + x - 2], buf[start + x]);
}
start = half_window + (i - 1) * window + 1;
for (x = -min(0, start); x < window - max(0, start + window - bwidth); x++) {
rectf[bwidth * (y - ymin) + (start + x)] = max(temp[x], temp[x + window - 1]);
for (x = -MIN2(0, start); x < window - MAX2(0, start + window - bwidth); x++) {
rectf[bwidth * (y - ymin) + (start + x)] = MAX2(temp[x], temp[x + window - 1]);
}
}
}
@ -421,13 +421,14 @@ void *DilateStepOperation::initializeTileData(rcti *rect)
temp[window - 1] = buf[start];
for (y = 1; y < window; y++) {
temp[window - 1 - y] = max(temp[window - y], buf[start - y]);
temp[window - 1 + y] = max(temp[window + y - 2], buf[start + y]);
temp[window - 1 - y] = MAX2(temp[window - y], buf[start - y]);
temp[window - 1 + y] = MAX2(temp[window + y - 2], buf[start + y]);
}
start = half_window + (i - 1) * window + 1;
for (y = -min(0, start); y < window - max(0, start + window - bheight); y++) {
rectf[bwidth * (y + start + (rect->ymin - ymin)) + x] = max(temp[y], temp[y + window - 1]);
for (y = -MIN2(0, start); y < window - MAX2(0, start + window - bheight); y++) {
rectf[bwidth * (y + start + (rect->ymin - ymin)) + x] = MAX2(temp[y],
temp[y + window - 1]);
}
}
}
@ -489,10 +490,10 @@ void *ErodeStepOperation::initializeTileData(rcti *rect)
int half_window = this->m_iterations;
int window = half_window * 2 + 1;
int xmin = max(0, rect->xmin - half_window);
int ymin = max(0, rect->ymin - half_window);
int xmax = min(width, rect->xmax + half_window);
int ymax = min(height, rect->ymax + half_window);
int xmin = MAX2(0, rect->xmin - half_window);
int ymin = MAX2(0, rect->ymin - half_window);
int xmax = MIN2(width, rect->xmax + half_window);
int ymax = MIN2(height, rect->ymax + half_window);
int bwidth = rect->xmax - rect->xmin;
int bheight = rect->ymax - rect->ymin;
@ -507,7 +508,7 @@ void *ErodeStepOperation::initializeTileData(rcti *rect)
// single row or column of input values, padded with FLT_MAX's to
// simplify the logic.
float *temp = (float *)MEM_mallocN(sizeof(float) * (2 * window - 1), "dilate erode temp");
float *buf = (float *)MEM_mallocN(sizeof(float) * (max(bwidth, bheight) + 5 * half_window),
float *buf = (float *)MEM_mallocN(sizeof(float) * (MAX2(bwidth, bheight) + 5 * half_window),
"dilate erode buf");
// The following is based on the van Herk/Gil-Werman algorithm for morphology operations.
@ -525,13 +526,13 @@ void *ErodeStepOperation::initializeTileData(rcti *rect)
temp[window - 1] = buf[start];
for (x = 1; x < window; x++) {
temp[window - 1 - x] = min(temp[window - x], buf[start - x]);
temp[window - 1 + x] = min(temp[window + x - 2], buf[start + x]);
temp[window - 1 - x] = MIN2(temp[window - x], buf[start - x]);
temp[window - 1 + x] = MIN2(temp[window + x - 2], buf[start + x]);
}
start = half_window + (i - 1) * window + 1;
for (x = -min(0, start); x < window - max(0, start + window - bwidth); x++) {
rectf[bwidth * (y - ymin) + (start + x)] = min(temp[x], temp[x + window - 1]);
for (x = -MIN2(0, start); x < window - MAX2(0, start + window - bwidth); x++) {
rectf[bwidth * (y - ymin) + (start + x)] = MIN2(temp[x], temp[x + window - 1]);
}
}
}
@ -550,13 +551,14 @@ void *ErodeStepOperation::initializeTileData(rcti *rect)
temp[window - 1] = buf[start];
for (y = 1; y < window; y++) {
temp[window - 1 - y] = min(temp[window - y], buf[start - y]);
temp[window - 1 + y] = min(temp[window + y - 2], buf[start + y]);
temp[window - 1 - y] = MIN2(temp[window - y], buf[start - y]);
temp[window - 1 + y] = MIN2(temp[window + y - 2], buf[start + y]);
}
start = half_window + (i - 1) * window + 1;
for (y = -min(0, start); y < window - max(0, start + window - bheight); y++) {
rectf[bwidth * (y + start + (rect->ymin - ymin)) + x] = min(temp[y], temp[y + window - 1]);
for (y = -MIN2(0, start); y < window - MAX2(0, start + window - bheight); y++) {
rectf[bwidth * (y + start + (rect->ymin - ymin)) + x] = MIN2(temp[y],
temp[y + window - 1]);
}
}
}

View File

@ -115,8 +115,8 @@ class DilateDistanceOperation : public NodeOperation {
MemoryBuffer *outputMemoryBuffer,
cl_mem clOutputBuffer,
MemoryBuffer **inputMemoryBuffers,
list<cl_mem> *clMemToCleanUp,
list<cl_kernel> *clKernelsToCleanUp);
std::list<cl_mem> *clMemToCleanUp,
std::list<cl_kernel> *clKernelsToCleanUp);
};
class ErodeDistanceOperation : public DilateDistanceOperation {
public:
@ -131,8 +131,8 @@ class ErodeDistanceOperation : public DilateDistanceOperation {
MemoryBuffer *outputMemoryBuffer,
cl_mem clOutputBuffer,
MemoryBuffer **inputMemoryBuffers,
list<cl_mem> *clMemToCleanUp,
list<cl_kernel> *clKernelsToCleanUp);
std::list<cl_mem> *clMemToCleanUp,
std::list<cl_kernel> *clKernelsToCleanUp);
};
class DilateStepOperation : public NodeOperation {

View File

@ -100,8 +100,8 @@ void DirectionalBlurOperation::executeOpenCL(OpenCLDevice *device,
MemoryBuffer *outputMemoryBuffer,
cl_mem clOutputBuffer,
MemoryBuffer **inputMemoryBuffers,
list<cl_mem> *clMemToCleanUp,
list<cl_kernel> * /*clKernelsToCleanUp*/)
std::list<cl_mem> *clMemToCleanUp,
std::list<cl_kernel> * /*clKernelsToCleanUp*/)
{
cl_kernel directionalBlurKernel = device->COM_clCreateKernel("directionalBlurKernel", nullptr);

View File

@ -61,6 +61,6 @@ class DirectionalBlurOperation : public NodeOperation, public QualityStepHelper
MemoryBuffer *outputMemoryBuffer,
cl_mem clOutputBuffer,
MemoryBuffer **inputMemoryBuffers,
list<cl_mem> *clMemToCleanUp,
list<cl_kernel> *clKernelsToCleanUp);
std::list<cl_mem> *clMemToCleanUp,
std::list<cl_kernel> *clKernelsToCleanUp);
};

View File

@ -73,7 +73,7 @@ void EllipseMaskOperation::executePixelSampled(float output[4],
switch (this->m_maskType) {
case CMP_NODE_MASKTYPE_ADD:
if (inside) {
output[0] = max(inputMask[0], inputValue[0]);
output[0] = MAX2(inputMask[0], inputValue[0]);
}
else {
output[0] = inputMask[0];

View File

@ -209,7 +209,7 @@ void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src,
(void)0
// intermediate buffers
sz = max(src_width, src_height);
sz = MAX2(src_width, src_height);
X = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss X buf");
Y = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss Y buf");
W = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss W buf");

View File

@ -256,7 +256,7 @@ void GaussianBlurReferenceOperation::initExecution()
void GaussianBlurReferenceOperation::updateGauss()
{
int i;
int x = max(m_filtersizex, m_filtersizey);
int x = MAX2(m_filtersizex, m_filtersizey);
m_maintabs = (float **)MEM_mallocN(x * sizeof(float *), "gauss array");
for (i = 0; i < x; i++) {
m_maintabs[i] = make_gausstab(i + 1, i + 1);
@ -333,7 +333,7 @@ void GaussianBlurReferenceOperation::executePixel(float output[4], int x, int y,
void GaussianBlurReferenceOperation::deinitExecution()
{
int x, i;
x = max(this->m_filtersizex, this->m_filtersizey);
x = MAX2(this->m_filtersizex, this->m_filtersizey);
for (i = 0; i < x; i++) {
MEM_freeN(this->m_maintabs[i]);
}

View File

@ -122,8 +122,8 @@ void GaussianXBlurOperation::executeOpenCL(OpenCLDevice *device,
MemoryBuffer *outputMemoryBuffer,
cl_mem clOutputBuffer,
MemoryBuffer **inputMemoryBuffers,
list<cl_mem> *clMemToCleanUp,
list<cl_kernel> * /*clKernelsToCleanUp*/)
std::list<cl_mem> *clMemToCleanUp,
std::list<cl_kernel> * /*clKernelsToCleanUp*/)
{
cl_kernel gaussianXBlurOperationKernel = device->COM_clCreateKernel(
"gaussianXBlurOperationKernel", nullptr);

View File

@ -42,8 +42,8 @@ class GaussianXBlurOperation : public BlurBaseOperation {
MemoryBuffer *outputMemoryBuffer,
cl_mem clOutputBuffer,
MemoryBuffer **inputMemoryBuffers,
list<cl_mem> *clMemToCleanUp,
list<cl_kernel> *clKernelsToCleanUp);
std::list<cl_mem> *clMemToCleanUp,
std::list<cl_kernel> *clKernelsToCleanUp);
/**
* \brief initialize the execution

View File

@ -122,8 +122,8 @@ void GaussianYBlurOperation::executeOpenCL(OpenCLDevice *device,
MemoryBuffer *outputMemoryBuffer,
cl_mem clOutputBuffer,
MemoryBuffer **inputMemoryBuffers,
list<cl_mem> *clMemToCleanUp,
list<cl_kernel> * /*clKernelsToCleanUp*/)
std::list<cl_mem> *clMemToCleanUp,
std::list<cl_kernel> * /*clKernelsToCleanUp*/)
{
cl_kernel gaussianYBlurOperationKernel = device->COM_clCreateKernel(
"gaussianYBlurOperationKernel", nullptr);

View File

@ -42,8 +42,8 @@ class GaussianYBlurOperation : public BlurBaseOperation {
MemoryBuffer *outputMemoryBuffer,
cl_mem clOutputBuffer,
MemoryBuffer **inputMemoryBuffers,
list<cl_mem> *clMemToCleanUp,
list<cl_kernel> *clKernelsToCleanUp);
std::list<cl_mem> *clMemToCleanUp,
std::list<cl_kernel> *clKernelsToCleanUp);
/**
* \brief initialize the execution

View File

@ -54,9 +54,9 @@ void GlareThresholdOperation::executePixelSampled(float output[4],
output[1] -= threshold;
output[2] -= threshold;
output[0] = max(output[0], 0.0f);
output[1] = max(output[1], 0.0f);
output[2] = max(output[2], 0.0f);
output[0] = MAX2(output[0], 0.0f);
output[1] = MAX2(output[1], 0.0f);
output[2] = MAX2(output[2], 0.0f);
}
else {
zero_v3(output);

View File

@ -50,7 +50,7 @@ void KeyingBlurOperation::executePixel(float output[4], int x, int y, void *data
float average = 0.0f;
if (this->m_axis == 0) {
const int start = max(0, x - this->m_size + 1), end = min(bufferWidth, x + this->m_size);
const int start = MAX2(0, x - this->m_size + 1), end = MIN2(bufferWidth, x + this->m_size);
for (int cx = start; cx < end; cx++) {
int bufferIndex = (y * bufferWidth + cx);
average += buffer[bufferIndex];
@ -58,8 +58,8 @@ void KeyingBlurOperation::executePixel(float output[4], int x, int y, void *data
}
}
else {
const int start = max(0, y - this->m_size + 1),
end = min(inputBuffer->getHeight(), y + this->m_size);
const int start = MAX2(0, y - this->m_size + 1),
end = MIN2(inputBuffer->getHeight(), y + this->m_size);
for (int cy = start; cy < end; cy++) {
int bufferIndex = (cy * bufferWidth + x);
average += buffer[bufferIndex];

View File

@ -63,8 +63,8 @@ void KeyingDespillOperation::executePixelSampled(float output[4],
const int other_1 = (screen_primary_channel + 1) % 3;
const int other_2 = (screen_primary_channel + 2) % 3;
const int min_channel = min(other_1, other_2);
const int max_channel = max(other_1, other_2);
const int min_channel = MIN2(other_1, other_2);
const int max_channel = MAX2(other_1, other_2);
float average_value, amount;

View File

@ -30,8 +30,8 @@ static float get_pixel_saturation(const float pixelColor[4],
const int other_1 = (primary_channel + 1) % 3;
const int other_2 = (primary_channel + 2) % 3;
const int min_channel = min(other_1, other_2);
const int max_channel = max(other_1, other_2);
const int min_channel = MIN2(other_1, other_2);
const int max_channel = MAX2(other_1, other_2);
const float val = screen_balance * pixelColor[min_channel] +
(1.0f - screen_balance) * pixelColor[max_channel];

View File

@ -54,7 +54,7 @@ void LuminanceMatteOperation::executePixelSampled(float output[4],
float alpha;
/* one line thread-friend algorithm:
* output[0] = min(inputValue[3], min(1.0f, max(0.0f, ((luminance - low) / (high - low))));
* output[0] = MIN2(inputValue[3], MIN2(1.0f, MAX2(0.0f, ((luminance - low) / (high - low))));
*/
/* test range */

View File

@ -84,7 +84,7 @@ class MaskOperation : public NodeOperation {
void setMotionBlurSamples(int samples)
{
this->m_rasterMaskHandleTot = min(max(1, samples), CMP_NODE_MASK_MBLUR_SAMPLES_MAX);
this->m_rasterMaskHandleTot = MIN2(MAX2(1, samples), CMP_NODE_MASK_MBLUR_SAMPLES_MAX);
}
void setMotionBlurShutter(float shutter)
{

View File

@ -351,7 +351,7 @@ void MathMinimumOperation::executePixelSampled(float output[4],
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
output[0] = min(inputValue1[0], inputValue2[0]);
output[0] = MIN2(inputValue1[0], inputValue2[0]);
clampIfNeeded(output);
}
@ -367,7 +367,7 @@ void MathMaximumOperation::executePixelSampled(float output[4],
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
output[0] = max(inputValue1[0], inputValue2[0]);
output[0] = MAX2(inputValue1[0], inputValue2[0]);
clampIfNeeded(output);
}

View File

@ -523,9 +523,9 @@ void MixGlareOperation::executePixelSampled(float output[4],
inputColor1[2] = 0.0f;
}
output[0] = mf * max(inputColor1[0] + value * (inputColor2[0] - inputColor1[0]), 0.0f);
output[1] = mf * max(inputColor1[1] + value * (inputColor2[1] - inputColor1[1]), 0.0f);
output[2] = mf * max(inputColor1[2] + value * (inputColor2[2] - inputColor1[2]), 0.0f);
output[0] = mf * MAX2(inputColor1[0] + value * (inputColor2[0] - inputColor1[0]), 0.0f);
output[1] = mf * MAX2(inputColor1[1] + value * (inputColor2[1] - inputColor1[1]), 0.0f);
output[2] = mf * MAX2(inputColor1[2] + value * (inputColor2[2] - inputColor1[2]), 0.0f);
output[3] = inputColor1[3];
clampIfNeeded(output);

View File

@ -48,8 +48,8 @@ __kernel void bokehBlurKernel(__read_only image2d_t boundingBox, __read_only ima
if (tempBoundingBox > 0.0f && radius > 0 ) {
const int2 bokehImageDim = get_image_dim(bokehImage);
const int2 bokehImageCenter = bokehImageDim/2;
const int2 minXY = max(realCoordinate - radius, zero);
const int2 maxXY = min(realCoordinate + radius, dimension);
const int2 minXY = MAX2(realCoordinate - radius, zero);
const int2 maxXY = MIN2(realCoordinate + radius, dimension);
int nx, ny;
float2 uv;
@ -97,10 +97,10 @@ __kernel void defocusKernel(__read_only image2d_t inputImage, __read_only image2
float4 multiplier_accum = {1.0f, 1.0f, 1.0f, 1.0f};
float4 color_accum;
int minx = max(realCoordinate.s0 - maxBlurScalar, 0);
int miny = max(realCoordinate.s1 - maxBlurScalar, 0);
int maxx = min(realCoordinate.s0 + maxBlurScalar, dimension.s0);
int maxy = min(realCoordinate.s1 + maxBlurScalar, dimension.s1);
int minx = MAX2(realCoordinate.s0 - maxBlurScalar, 0);
int miny = MAX2(realCoordinate.s1 - maxBlurScalar, 0);
int maxx = MIN2(realCoordinate.s0 + maxBlurScalar, dimension.s0);
int maxy = MIN2(realCoordinate.s1 + maxBlurScalar, dimension.s1);
{
int2 inputCoordinate = realCoordinate - offsetInput;
@ -116,7 +116,7 @@ __kernel void defocusKernel(__read_only image2d_t inputImage, __read_only image2
float dx = nx - realCoordinate.s0;
if (dx != 0 || dy != 0) {
inputCoordinate.s0 = nx - offsetInput.s0;
size = min(read_imagef(inputSize, SAMPLER_NEAREST, inputCoordinate).s0 * scalar, size_center);
size = MIN2(read_imagef(inputSize, SAMPLER_NEAREST, inputCoordinate).s0 * scalar, size_center);
if (size > threshold) {
if (size >= fabs(dx) && size >= fabs(dy)) {
float2 uv = {256.0f + dx * 255.0f / size,
@ -157,8 +157,8 @@ __kernel void dilateKernel(__read_only image2d_t inputImage, __write_only image
coords += offset;
const int2 realCoordinate = coords + offsetOutput;
const int2 minXY = max(realCoordinate - scope, zero);
const int2 maxXY = min(realCoordinate + scope, dimension);
const int2 minXY = MAX2(realCoordinate - scope, zero);
const int2 maxXY = MIN2(realCoordinate + scope, dimension);
float value = 0.0f;
int nx, ny;
@ -170,7 +170,7 @@ __kernel void dilateKernel(__read_only image2d_t inputImage, __write_only image
const float deltaX = (realCoordinate.x - nx);
const float measuredDistance = deltaX * deltaX + deltaY * deltaY;
if (measuredDistance <= distanceSquared) {
value = max(value, read_imagef(inputImage, SAMPLER_NEAREST, inputXy).s0);
value = MAX2(value, read_imagef(inputImage, SAMPLER_NEAREST, inputXy).s0);
}
}
}
@ -188,8 +188,8 @@ __kernel void erodeKernel(__read_only image2d_t inputImage, __write_only image2
coords += offset;
const int2 realCoordinate = coords + offsetOutput;
const int2 minXY = max(realCoordinate - scope, zero);
const int2 maxXY = min(realCoordinate + scope, dimension);
const int2 minXY = MAX2(realCoordinate - scope, zero);
const int2 maxXY = MIN2(realCoordinate + scope, dimension);
float value = 1.0f;
int nx, ny;
@ -201,7 +201,7 @@ __kernel void erodeKernel(__read_only image2d_t inputImage, __write_only image2
const float deltaY = (realCoordinate.y - ny);
const float measuredDistance = deltaX * deltaX+deltaY * deltaY;
if (measuredDistance <= distanceSquared) {
value = min(value, read_imagef(inputImage, SAMPLER_NEAREST, inputXy).s0);
value = MIN2(value, read_imagef(inputImage, SAMPLER_NEAREST, inputXy).s0);
}
}
}
@ -268,10 +268,10 @@ __kernel void gaussianXBlurOperationKernel(__read_only image2d_t inputImage,
int2 inputCoordinate = realCoordinate - offsetInput;
float weight = 0.0f;
int xmin = max(realCoordinate.x - filter_size, 0) - offsetInput.x;
int xmax = min(realCoordinate.x + filter_size + 1, dimension.x) - offsetInput.x;
int xmin = MAX2(realCoordinate.x - filter_size, 0) - offsetInput.x;
int xmax = MIN2(realCoordinate.x + filter_size + 1, dimension.x) - offsetInput.x;
for (int nx = xmin, i = max(filter_size - realCoordinate.x, 0); nx < xmax; ++nx, ++i) {
for (int nx = xmin, i = MAX2(filter_size - realCoordinate.x, 0); nx < xmax; ++nx, ++i) {
float w = gausstab[i];
inputCoordinate.x = nx;
color += read_imagef(inputImage, SAMPLER_NEAREST, inputCoordinate) * w;
@ -299,10 +299,10 @@ __kernel void gaussianYBlurOperationKernel(__read_only image2d_t inputImage,
int2 inputCoordinate = realCoordinate - offsetInput;
float weight = 0.0f;
int ymin = max(realCoordinate.y - filter_size, 0) - offsetInput.y;
int ymax = min(realCoordinate.y + filter_size + 1, dimension.y) - offsetInput.y;
int ymin = MAX2(realCoordinate.y - filter_size, 0) - offsetInput.y;
int ymax = MIN2(realCoordinate.y + filter_size + 1, dimension.y) - offsetInput.y;
for (int ny = ymin, i = max(filter_size - realCoordinate.y, 0); ny < ymax; ++ny, ++i) {
for (int ny = ymin, i = MAX2(filter_size - realCoordinate.y, 0); ny < ymax; ++ny, ++i) {
float w = gausstab[i];
inputCoordinate.y = ny;
color += read_imagef(inputImage, SAMPLER_NEAREST, inputCoordinate) * w;

View File

@ -93,10 +93,10 @@ bool RotateOperation::determineDependingAreaOfInterest(rcti *input,
const float y2 = this->m_centerY + (-this->m_sine * dxmax + this->m_cosine * dymin);
const float y3 = this->m_centerY + (-this->m_sine * dxmin + this->m_cosine * dymax);
const float y4 = this->m_centerY + (-this->m_sine * dxmax + this->m_cosine * dymax);
const float minx = min(x1, min(x2, min(x3, x4)));
const float maxx = max(x1, max(x2, max(x3, x4)));
const float miny = min(y1, min(y2, min(y3, y4)));
const float maxy = max(y1, max(y2, max(y3, y4)));
const float minx = MIN2(x1, MIN2(x2, MIN2(x3, x4)));
const float maxx = MAX2(x1, MAX2(x2, MAX2(x3, x4)));
const float miny = MIN2(y1, MIN2(y2, MIN2(y3, y4)));
const float maxy = MAX2(y1, MAX2(y2, MAX2(y3, y4)));
newInput.xmax = ceil(maxx) + 1;
newInput.xmin = floor(minx) - 1;

View File

@ -33,7 +33,7 @@ void SunBeamsOperation::initExecution()
/* convert to pixels */
this->m_source_px[0] = this->m_data.source[0] * this->getWidth();
this->m_source_px[1] = this->m_data.source[1] * this->getHeight();
this->m_ray_length_px = this->m_data.ray_length * max(this->getWidth(), this->getHeight());
this->m_ray_length_px = this->m_data.ray_length * MAX2(this->getWidth(), this->getHeight());
}
/**

View File

@ -51,9 +51,9 @@ void TonemapOperation::executePixel(float output[4], int x, int y, void *data)
output[2] /= ((db == 0.0f) ? 1.0f : db);
const float igm = avg->igm;
if (igm != 0.0f) {
output[0] = powf(max(output[0], 0.0f), igm);
output[1] = powf(max(output[1], 0.0f), igm);
output[2] = powf(max(output[2], 0.0f), igm);
output[0] = powf(MAX2(output[0], 0.0f), igm);
output[1] = powf(MAX2(output[1], 0.0f), igm);
output[2] = powf(MAX2(output[2], 0.0f), igm);
}
}
void PhotoreceptorTonemapOperation::executePixel(float output[4], int x, int y, void *data)

View File

@ -74,7 +74,7 @@ void *VariableSizeBokehBlurOperation::initializeTileData(rcti *rect)
this->determineDependingAreaOfInterest(
rect, (ReadBufferOperation *)this->m_inputSizeProgram, &rect2);
const float max_dim = max(m_width, m_height);
const float max_dim = MAX2(m_width, m_height);
const float scalar = this->m_do_size_scale ? (max_dim / 100.0f) : 1.0f;
data->maxBlurScalar = (int)(data->size->getMaximumValue(&rect2) * scalar);
@ -102,7 +102,7 @@ void VariableSizeBokehBlurOperation::executePixel(float output[4], int x, int y,
float multiplier_accum[4];
float color_accum[4];
const float max_dim = max(m_width, m_height);
const float max_dim = MAX2(m_width, m_height);
const float scalar = this->m_do_size_scale ? (max_dim / 100.0f) : 1.0f;
int maxBlurScalar = tileData->maxBlurScalar;
@ -120,10 +120,10 @@ void VariableSizeBokehBlurOperation::executePixel(float output[4], int x, int y,
int maxx = search[2];
int maxy = search[3];
#else
int minx = max(x - maxBlurScalar, 0);
int miny = max(y - maxBlurScalar, 0);
int maxx = min(x + maxBlurScalar, (int)m_width);
int maxy = min(y + maxBlurScalar, (int)m_height);
int minx = MAX2(x - maxBlurScalar, 0);
int miny = MAX2(y - maxBlurScalar, 0);
int maxx = MIN2(x + maxBlurScalar, (int)m_width);
int maxy = MIN2(y + maxBlurScalar, (int)m_height);
#endif
{
inputSizeBuffer->readNoCheck(tempSize, x, y);
@ -145,7 +145,7 @@ void VariableSizeBokehBlurOperation::executePixel(float output[4], int x, int y,
int offsetColorNxNy = offsetValueNxNy * COM_NUM_CHANNELS_COLOR;
for (int nx = minx; nx < maxx; nx += addXStepValue) {
if (nx != x || ny != y) {
float size = min(inputSizeFloatBuffer[offsetValueNxNy] * scalar, size_center);
float size = MIN2(inputSizeFloatBuffer[offsetValueNxNy] * scalar, size_center);
if (size > this->m_threshold) {
float dx = nx - x;
if (size > fabsf(dx) && size > fabsf(dy)) {
@ -185,8 +185,8 @@ void VariableSizeBokehBlurOperation::executeOpenCL(OpenCLDevice *device,
MemoryBuffer *outputMemoryBuffer,
cl_mem clOutputBuffer,
MemoryBuffer **inputMemoryBuffers,
list<cl_mem> *clMemToCleanUp,
list<cl_kernel> * /*clKernelsToCleanUp*/)
std::list<cl_mem> *clMemToCleanUp,
std::list<cl_kernel> * /*clKernelsToCleanUp*/)
{
cl_kernel defocusKernel = device->COM_clCreateKernel("defocusKernel", nullptr);
@ -197,7 +197,7 @@ void VariableSizeBokehBlurOperation::executeOpenCL(OpenCLDevice *device,
MemoryBuffer *sizeMemoryBuffer = this->m_inputSizeProgram->getInputMemoryBuffer(
inputMemoryBuffers);
const float max_dim = max(m_width, m_height);
const float max_dim = MAX2(m_width, m_height);
cl_float scalar = this->m_do_size_scale ? (max_dim / 100.0f) : 1.0f;
maxBlur = (cl_int)min_ff(sizeMemoryBuffer->getMaximumValue() * scalar, (float)this->m_maxBlur);
@ -235,7 +235,7 @@ bool VariableSizeBokehBlurOperation::determineDependingAreaOfInterest(
rcti newInput;
rcti bokehInput;
const float max_dim = max(m_width, m_height);
const float max_dim = MAX2(m_width, m_height);
const float scalar = this->m_do_size_scale ? (max_dim / 100.0f) : 1.0f;
int maxBlurScalar = this->m_maxBlur * scalar;

View File

@ -80,8 +80,8 @@ class VariableSizeBokehBlurOperation : public NodeOperation, public QualityStepH
MemoryBuffer *outputMemoryBuffer,
cl_mem clOutputBuffer,
MemoryBuffer **inputMemoryBuffers,
list<cl_mem> *clMemToCleanUp,
list<cl_kernel> *clKernelsToCleanUp);
std::list<cl_mem> *clMemToCleanUp,
std::list<cl_kernel> *clKernelsToCleanUp);
};
#ifdef COM_DEFOCUS_SEARCH

View File

@ -143,9 +143,9 @@ void WriteBufferOperation::executeOpenCLRegion(OpenCLDevice *device,
}
// STEP 2
list<cl_mem> *clMemToCleanUp = new list<cl_mem>();
std::list<cl_mem> *clMemToCleanUp = new std::list<cl_mem>();
clMemToCleanUp->push_back(clOutputBuffer);
list<cl_kernel> *clKernelsToCleanUp = new list<cl_kernel>();
std::list<cl_kernel> *clKernelsToCleanUp = new std::list<cl_kernel>();
this->m_input->executeOpenCL(device,
outputBuffer,

View File

@ -83,7 +83,7 @@ void ZCombineAlphaOperation::executePixelSampled(float output[4],
output[0] = fac * color1[0] + ifac * color2[0];
output[1] = fac * color1[1] + ifac * color2[1];
output[2] = fac * color1[2] + ifac * color2[2];
output[3] = max(color1[3], color2[3]);
output[3] = MAX2(color1[3], color2[3]);
}
void ZCombineOperation::deinitExecution()
@ -149,7 +149,7 @@ void ZCombineMaskAlphaOperation::executePixelSampled(float output[4],
output[0] = color1[0] * mfac + color2[0] * fac;
output[1] = color1[1] * mfac + color2[1] * fac;
output[2] = color1[2] * mfac + color2[2] * fac;
output[3] = max(color1[3], color2[3]);
output[3] = MAX2(color1[3], color2[3]);
}
void ZCombineMaskOperation::deinitExecution()