14 changes: 7 additions & 7 deletions src/iop/globaltonemap.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ static inline void process_reinhard(struct dt_iop_module_t *self, dt_dev_pixelpi
#ifdef _OPENMP
#pragma omp parallel for default(none) shared(roi_out, in, out, data) schedule(static)
#endif
for(int k=0; k<roi_out->width*roi_out->height; k++)
for(size_t k=0; k<(size_t)roi_out->width*roi_out->height; k++)
{
float *inp = in + ch*k;
float *outp = out + ch*k;
Expand All @@ -162,7 +162,7 @@ static inline void process_drago(struct dt_iop_module_t *self, dt_dev_pixelpipe_
const float eps = 0.0001f;
float lwmax = eps;

for(int k=0; k<roi_out->width*roi_out->height; k++)
for(size_t k=0; k<(size_t)roi_out->width*roi_out->height; k++)
{
float *inp = in + ch*k;
lwmax = fmaxf(lwmax, (inp[0]*0.01f));
Expand All @@ -173,7 +173,7 @@ static inline void process_drago(struct dt_iop_module_t *self, dt_dev_pixelpipe_
#ifdef _OPENMP
#pragma omp parallel for default(none) shared(roi_out, in, out, lwmax) schedule(static)
#endif
for(int k=0; k<roi_out->width*roi_out->height; k++)
for(size_t k=0; k<(size_t)roi_out->width*roi_out->height; k++)
{
float *inp = in + ch*k;
float *outp = out + ch*k;
Expand All @@ -195,7 +195,7 @@ static inline void process_filmic(struct dt_iop_module_t *self, dt_dev_pixelpipe
#ifdef _OPENMP
#pragma omp parallel for default(none) shared(roi_out, in, out, data) schedule(static)
#endif
for(int k=0; k<roi_out->width*roi_out->height; k++)
for(size_t k=0; k<(size_t)roi_out->width*roi_out->height; k++)
{
float *inp = in + ch*k;
float *outp = out + ch*k;
Expand Down Expand Up @@ -326,10 +326,10 @@ process_cl (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, cl_mem
const int groupsize = maxsizes[0];
const int reducesize = MIN(REDUCESIZE, ROUNDUP(bufsize, groupsize) / groupsize);

dev_m = dt_opencl_alloc_device_buffer(devid, bufsize*sizeof(float));
dev_m = dt_opencl_alloc_device_buffer(devid, (size_t)bufsize*sizeof(float));
if(dev_m == NULL) goto error;

dev_r = dt_opencl_alloc_device_buffer(devid, reducesize*sizeof(float));
dev_r = dt_opencl_alloc_device_buffer(devid, (size_t)reducesize*sizeof(float));
if(dev_r == NULL) goto error;

sizes[0] = bwidth;
Expand Down Expand Up @@ -360,7 +360,7 @@ process_cl (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, cl_mem
if(err != CL_SUCCESS) goto error;

float maximum[reducesize];
err = dt_opencl_read_buffer_from_device(devid, (void*)maximum, dev_r, 0, reducesize*sizeof(float), CL_TRUE);
err = dt_opencl_read_buffer_from_device(devid, (void*)maximum, dev_r, 0, (size_t)reducesize*sizeof(float), CL_TRUE);
if(err != CL_SUCCESS) goto error;

dt_opencl_release_mem_object(dev_r);
Expand Down
4 changes: 2 additions & 2 deletions src/iop/graduatednd.c
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
#endif
for(int y=0; y<roi_out->height; y++)
{
int k=roi_out->width*y*ch;
size_t k = (size_t)roi_out->width*y*ch;
const float *in = (float*)ivoid + k;
float *out = (float*)ovoid + k;

Expand Down Expand Up @@ -728,7 +728,7 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
#endif
for(int y=0; y<roi_out->height; y++)
{
int k=roi_out->width*y*ch;
size_t k = (size_t)roi_out->width*y*ch;
const float *in = (float*)ivoid + k;
float *out = (float*)ovoid + k;

Expand Down
4 changes: 2 additions & 2 deletions src/iop/grain.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,8 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
#endif
for(int j=0; j<roi_out->height; j++)
{
float *in = ((float *)ivoid) + roi_out->width * j * ch;
float *out = ((float *)ovoid) + roi_out->width * j * ch;
float *in = ((float *)ivoid) + (size_t)roi_out->width * j * ch;
float *out = ((float *)ovoid) + (size_t)roi_out->width * j * ch;
for(int i=0; i<roi_out->width; i++)
{
// calculate x, y in a resolution independent way:
Expand Down
14 changes: 7 additions & 7 deletions src/iop/highlights.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ void process(
#endif
for(int j=0; j<roi_out->height; j++)
{
float *out = (float *)ovoid + 4*roi_out->width*j;
float *in = (float *)ivoid + 4*roi_in->width*j;
float *out = (float *)ovoid + (size_t)4*roi_out->width*j;
float *in = (float *)ivoid + (size_t)4*roi_in->width*j;
for(int i=0; i<roi_out->width; i++)
{
_mm_stream_ps(out, _mm_min_ps(clipm, _mm_set_ps(in[3],in[2],in[1],in[0])));
Expand All @@ -195,8 +195,8 @@ void process(
#endif
for(int j=0; j<roi_out->height; j++)
{
float *out = (float *)ovoid + roi_out->width*j;
float *in = (float *)ivoid + roi_out->width*j;
float *out = (float *)ovoid + (size_t)roi_out->width*j;
float *in = (float *)ivoid + (size_t)roi_out->width*j;
for(int i=0; i<roi_out->width; i++)
{
if(i==0 || i==roi_out->width-1 || j==0 || j==roi_out->height-1)
Expand All @@ -215,7 +215,7 @@ void process(
{
for(int ii=0; ii<=1; ii++)
{
const float val = in[jj*roi_out->width + ii];
const float val = in[(size_t)jj*roi_out->width + ii];
mean += val*0.25f;
blend += (fminf(post_clip, val) - near_clip)/(post_clip-near_clip);
}
Expand All @@ -237,7 +237,7 @@ void process(
case DT_IOP_HIGHLIGHTS_CLIP:
{
const __m128 clipm = _mm_set1_ps(clip);
const int n = roi_out->height*roi_out->width;
const size_t n = (size_t)roi_out->height*roi_out->width;
float *const out = (float *)ovoid;
float *const in = (float *)ivoid;
#ifdef _OPENMP
Expand All @@ -247,7 +247,7 @@ void process(
_mm_stream_ps(out+j, _mm_min_ps(clipm, _mm_load_ps(in+j)));
_mm_sfence();
// lets see if there's a non-multiple of four rest to process:
if(n & 3) for(int j=n&~3u; j<n; j++) out[j] = MIN(clip, in[j]);
if(n & 3) for(size_t j=n&~3u; j<n; j++) out[j] = MIN(clip, in[j]);
break;
}
}
Expand Down
15 changes: 7 additions & 8 deletions src/iop/highpass.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ process_cl (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, cl_mem
dev_tmp = dt_opencl_alloc_device(devid, width, height, 4*sizeof(float));
if (dev_tmp == NULL) goto error;

dev_m = dt_opencl_copy_host_to_device_constant(devid, sizeof(float)*wd, mat);
dev_m = dt_opencl_copy_host_to_device_constant(devid, (size_t)sizeof(float)*wd, mat);
if (dev_m == NULL) goto error;

/* invert image */
Expand Down Expand Up @@ -289,7 +289,7 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
#ifdef _OPENMP
#pragma omp parallel for default(none) shared(in,out,roi_out) schedule(static)
#endif
for(int k=0; k<roi_out->width*roi_out->height; k++)
for(size_t k=0; k<(size_t)roi_out->width*roi_out->height; k++)
out[ch*k] = 100.0f-LCLIP(in[ch*k]); // only L in Lab space


Expand All @@ -305,11 +305,11 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void

for(int iteration=0; iteration<BOX_ITERATIONS; iteration++)
{
int index=0;
for(int y=0; y<roi_out->height; y++)
{
float L=0;
int hits = 0;
size_t index = (size_t)y*roi_out->width;
for(int x=-hr; x<roi_out->width; x++)
{
int op = x - hr-1;
Expand All @@ -330,7 +330,6 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void

for (int x=0; x<roi_out->width; x++)
out[(index+x)*ch] = scanline[x];
index+=roi_out->width;
}

/* vertical pass on blurlightness */
Expand All @@ -340,7 +339,7 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
{
float L=0;
int hits=0;
int index = -hr*roi_out->width+x;
size_t index = (size_t)x - hr*roi_out->width;
for(int y=-hr; y<roi_out->height; y++)
{
int op=y-hr-1;
Expand All @@ -361,7 +360,7 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
}

for (int y=0; y<roi_out->height; y++)
out[(y*roi_out->width+x)*ch] = scanline[y];
out[((size_t)y*roi_out->width+x)*ch] = scanline[y];
}
}

Expand All @@ -371,9 +370,9 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
#ifdef _OPENMP
#pragma omp parallel for default(none) shared(roi_out, in, out, data) schedule(static)
#endif
for(int k=0; k<roi_out->width*roi_out->height; k++)
for(size_t k=0; k<(size_t)roi_out->width*roi_out->height; k++)
{
int index = ch*k;
size_t index = ch*k;
// Mix out and in
out[index] = out[index]*0.5 + in[index]*0.5;
out[index] = LCLIP(50.0f+((out[index]-50.0f)*contrast_scale));
Expand Down
6 changes: 3 additions & 3 deletions src/iop/hotpixels.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,16 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
const int min_neighbours = data->permissive ? 3 : 4;

// The loop should output only a few pixels, so just copy everything first
memcpy(o, i, roi_out->width*roi_out->height*sizeof(float));
memcpy(o, i, (size_t)roi_out->width*roi_out->height*sizeof(float));

int fixed = 0;
#ifdef _OPENMP
#pragma omp parallel for default(none) shared(roi_out, i, o) reduction(+:fixed) schedule(static)
#endif
for (int row=2; row<roi_out->height-2; row++)
{
const float *in = (float*)i + width*row+2;
float *out = (float*)o + width*row+2;
const float *in = (float*)i + (size_t)width*row+2;
float *out = (float*)o + (size_t)width*row+2;
for (int col=2; col<width-1; col++, in++, out++)
{
float mid= *in * multiplier;
Expand Down
12 changes: 6 additions & 6 deletions src/iop/invert.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
#endif
for(int j=0; j<roi_out->height; j++)
{
const uint16_t *in = ((uint16_t*)ivoid) + j*roi_out->width;
uint16_t *out = ((uint16_t*)ovoid) + j*roi_out->width;
const uint16_t *in = ((uint16_t*)ivoid) + (size_t)j*roi_out->width;
uint16_t *out = ((uint16_t*)ovoid) + (size_t)j*roi_out->width;
for(int i=0; i<roi_out->width; i++,out++,in++)
{
*out = CLAMP(film_rgb_i[FC(j+roi_out->x, i+roi_out->y, filters)] - (int32_t)in[0], 0, 0xffff);
Expand All @@ -229,8 +229,8 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
#endif
for(int j=0; j<roi_out->height; j++)
{
const float *in = ((float *)ivoid) + j*roi_out->width;
float *out = ((float*)ovoid) + j*roi_out->width;
const float *in = ((float *)ivoid) + (size_t)j*roi_out->width;
float *out = ((float*)ovoid) + (size_t)j*roi_out->width;
for(int i=0; i<roi_out->width; i++,out++,in++)
{
*out = CLAMP(film_rgb[FC(j+roi_out->x, i+roi_out->y, filters)] - *in/(float)0xffff, 0, 1.0f);
Expand All @@ -247,8 +247,8 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
#endif
for(int k=0; k<roi_out->height; k++)
{
const float *in = ((float*)ivoid) + ch*k*roi_out->width;
float *out = ((float*)ovoid) + ch*k*roi_out->width;
const float *in = ((float*)ivoid) + (size_t)ch*k*roi_out->width;
float *out = ((float*)ovoid) + (size_t)ch*k*roi_out->width;
for (int j=0; j<roi_out->width; j++,in+=ch,out+=ch)
for(int c=0; c<3; c++) out[c] = film_rgb[c] - in[c];
}
Expand Down
48 changes: 24 additions & 24 deletions src/iop/lens.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void *ivoi

if(!d->lens->Maker || d->crop <= 0.0f)
{
memcpy(out, in, ch*sizeof(float)*roi_out->width*roi_out->height);
memcpy(out, in, (size_t)ch*sizeof(float)*roi_out->width*roi_out->height);
return;
}

Expand All @@ -205,7 +205,7 @@ process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void *ivoi
LF_MODIFY_GEOMETRY | LF_MODIFY_SCALE))
{
// acquire temp memory for distorted pixel coords
const size_t req2 = roi_out->width*2*3*sizeof(float);
const size_t req2 = (size_t)roi_out->width*2*3*sizeof(float);
if(req2 > 0 && d->tmpbuf2_len < req2*dt_get_num_threads())
{
d->tmpbuf2_len = req2*dt_get_num_threads();
Expand All @@ -224,7 +224,7 @@ process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void *ivoi
lf_modifier_apply_subpixel_geometry_distortion (
modifier, roi_out->x, roi_out->y+y, roi_out->width, 1, pi);
// reverse transform the global coords from lf to our buffer
float *buf = ((float *)ovoid) + y*roi_out->width*ch;
float *buf = ((float *)ovoid) + (size_t)y*roi_out->width*ch;
for (int x = 0; x < roi_out->width; x++,buf+=ch,pi+=6)
{
for(int c=0; c<3; c++)
Expand All @@ -250,7 +250,7 @@ process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void *ivoi
#pragma omp parallel for default(none) shared(roi_out, out, in) schedule(static)
#endif
for (int y = 0; y < roi_out->height; y++)
memcpy(out+ch*y*roi_out->width, in+ch*y*roi_out->width, ch*sizeof(float)*roi_out->width);
memcpy(out+(size_t)ch*y*roi_out->width, in+(size_t)ch*y*roi_out->width, (size_t)ch*sizeof(float)*roi_out->width);
}

if (modflags & LF_MODIFY_VIGNETTING)
Expand All @@ -264,15 +264,15 @@ process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void *ivoi
// actually this way row stride does not matter.
float *buf = out;
lf_modifier_apply_color_modification (modifier,
buf + ch*roi_out->width*y, roi_out->x, roi_out->y + y,
buf + (size_t)ch*roi_out->width*y, roi_out->x, roi_out->y + y,
roi_out->width, 1, pixelformat, ch*roi_out->width);
}
}
}
else // correct distortions:
{
// acquire temp memory for image buffer
const size_t req = roi_in->width*roi_in->height*ch*sizeof(float);
const size_t req = (size_t)roi_in->width*roi_in->height*ch*sizeof(float);
if(req > 0 && d->tmpbuf_len < req)
{
d->tmpbuf_len = req;
Expand All @@ -291,12 +291,12 @@ process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void *ivoi
// actually this way row stride does not matter.
float *buf = d->tmpbuf;
lf_modifier_apply_color_modification (modifier,
buf + ch*roi_in->width*y, roi_in->x, roi_in->y + y,
buf + (size_t)ch*roi_in->width*y, roi_in->x, roi_in->y + y,
roi_in->width, 1, pixelformat, ch*roi_in->width);
}
}

const size_t req2 = roi_out->width*2*3*sizeof(float);
const size_t req2 = (size_t)roi_out->width*2*3*sizeof(float);
if (modflags & (LF_MODIFY_TCA | LF_MODIFY_DISTORTION |
LF_MODIFY_GEOMETRY | LF_MODIFY_SCALE))
{
Expand All @@ -319,7 +319,7 @@ process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void *ivoi
lf_modifier_apply_subpixel_geometry_distortion (
modifier, roi_out->x, roi_out->y+y, roi_out->width, 1, pi);
// reverse transform the global coords from lf to our buffer
float *out = ((float *)ovoid) + y*roi_out->width*ch;
float *out = ((float *)ovoid) + (size_t)y*roi_out->width*ch;
for (int x = 0; x < roi_out->width; x++,pi+=6)
{
for(int c=0; c<3; c++)
Expand All @@ -342,13 +342,13 @@ process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void *ivoi
}
else
{
const size_t len = sizeof(float)*ch*roi_out->width*roi_out->height;
const size_t len = (size_t)sizeof(float)*ch*roi_out->width*roi_out->height;
const float *const input = (d->tmpbuf_len >= len) ? d->tmpbuf : in;
#ifdef _OPENMP
#pragma omp parallel for default(none) shared(roi_out, out) schedule(static)
#endif
for (int y = 0; y < roi_out->height; y++)
memcpy(out+ch*y*roi_out->width, input+ch*y*roi_out->width, ch*sizeof(float)*roi_out->width);
memcpy(out+(size_t)ch*y*roi_out->width, input+(size_t)ch*y*roi_out->width, (size_t)ch*sizeof(float)*roi_out->width);
}
}
lf_modifier_destroy(modifier);
Expand Down Expand Up @@ -386,7 +386,7 @@ process_cl (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, cl_mem
const int height = MAX(iheight, oheight);
const int ch = piece->colors;
const int tmpbufwidth = owidth*2*3;
const int tmpbuflen = d->inverse ? oheight*owidth*2*3*sizeof(float) : MAX(oheight*owidth*2*3, iheight*iwidth*ch)*sizeof(float);
const size_t tmpbuflen = d->inverse ? (size_t)oheight*owidth*2*3*sizeof(float) : MAX((size_t)oheight*owidth*2*3, (size_t)iheight*iwidth*ch)*sizeof(float);
const unsigned int pixelformat = ch == 3 ? LF_CR_3 (RED, GREEN, BLUE) : LF_CR_4 (RED, GREEN, BLUE, UNKNOWN);

const float orig_w = roi_in->scale*piece->iwidth,
Expand Down Expand Up @@ -459,13 +459,13 @@ process_cl (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, cl_mem
#endif
for (int y = 0; y < roi_out->height; y++)
{
float *pi = tmpbuf + y * tmpbufwidth;
float *pi = tmpbuf + (size_t)y * tmpbufwidth;
lf_modifier_apply_subpixel_geometry_distortion (
modifier, roi_out->x, roi_out->y+y, roi_out->width, 1, pi);
}

/* _blocking_ memory transfer: host tmpbuf buffer -> opencl dev_tmpbuf */
err = dt_opencl_write_buffer_to_device(devid, tmpbuf, dev_tmpbuf, 0, owidth*oheight*2*3*sizeof(float), CL_TRUE);
err = dt_opencl_write_buffer_to_device(devid, tmpbuf, dev_tmpbuf, 0, (size_t)owidth*oheight*2*3*sizeof(float), CL_TRUE);
if(err != CL_SUCCESS) goto error;

dt_opencl_set_kernel_arg(devid, ldkernel, 0, sizeof(cl_mem), (void *)&dev_in);
Expand Down Expand Up @@ -496,14 +496,14 @@ process_cl (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, cl_mem
{
/* Colour correction: vignetting and CCI */
// actually this way row stride does not matter.
float *buf = tmpbuf + y * ch*roi_out->width;
float *buf = tmpbuf + (size_t)y * ch*roi_out->width;
for (int k=0; k < ch*roi_out->width; k++) buf[k] = 0.5f;
lf_modifier_apply_color_modification (modifier, buf, roi_out->x, roi_out->y + y,
roi_out->width, 1, pixelformat, ch*roi_out->width);
}

/* _blocking_ memory transfer: host tmpbuf buffer -> opencl dev_tmpbuf */
err = dt_opencl_write_buffer_to_device(devid, tmpbuf, dev_tmpbuf, 0, ch*roi_out->width*roi_out->height*sizeof(float), CL_TRUE);
err = dt_opencl_write_buffer_to_device(devid, tmpbuf, dev_tmpbuf, 0, (size_t)ch*roi_out->width*roi_out->height*sizeof(float), CL_TRUE);
if(err != CL_SUCCESS) goto error;

dt_opencl_set_kernel_arg(devid, gd->kernel_lens_vignette, 0, sizeof(cl_mem), (void *)&dev_tmp);
Expand Down Expand Up @@ -535,14 +535,14 @@ process_cl (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, cl_mem
{
/* Colour correction: vignetting and CCI */
// actually this way row stride does not matter.
float *buf = tmpbuf + y * ch*roi_in->width;
float *buf = tmpbuf + (size_t)y * ch*roi_in->width;
for (int k=0; k < ch*roi_in->width; k++) buf[k] = 0.5f;
lf_modifier_apply_color_modification (modifier, buf, roi_in->x, roi_in->y + y,
roi_in->width, 1, pixelformat, ch*roi_in->width);
}

/* _blocking_ memory transfer: host tmpbuf buffer -> opencl dev_tmpbuf */
err = dt_opencl_write_buffer_to_device(devid, tmpbuf, dev_tmpbuf, 0, ch*roi_in->width*roi_in->height*sizeof(float), CL_TRUE);
err = dt_opencl_write_buffer_to_device(devid, tmpbuf, dev_tmpbuf, 0, (size_t)ch*roi_in->width*roi_in->height*sizeof(float), CL_TRUE);
if(err != CL_SUCCESS) goto error;

dt_opencl_set_kernel_arg(devid, gd->kernel_lens_vignette, 0, sizeof(cl_mem), (void *)&dev_in);
Expand All @@ -568,13 +568,13 @@ process_cl (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, cl_mem
#endif
for (int y = 0; y < roi_out->height; y++)
{
float *pi = tmpbuf + y * tmpbufwidth;
float *pi = tmpbuf + (size_t)y * tmpbufwidth;
lf_modifier_apply_subpixel_geometry_distortion (
modifier, roi_out->x, roi_out->y+y, roi_out->width, 1, pi);
}

/* _blocking_ memory transfer: host tmpbuf buffer -> opencl dev_tmpbuf */
err = dt_opencl_write_buffer_to_device(devid, tmpbuf, dev_tmpbuf, 0, owidth*oheight*2*3*sizeof(float), CL_TRUE);
err = dt_opencl_write_buffer_to_device(devid, tmpbuf, dev_tmpbuf, 0, (size_t)owidth*oheight*2*3*sizeof(float), CL_TRUE);
if(err != CL_SUCCESS) goto error;

dt_opencl_set_kernel_arg(devid, ldkernel, 0, sizeof(cl_mem), (void *)&dev_tmp);
Expand Down Expand Up @@ -629,7 +629,7 @@ void tiling_callback (struct dt_iop_module_t *self, struct dt_dev_pixelpipe_iop_
return;
}

int distort_transform(dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, float *points, int points_count)
int distort_transform(dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, float *points, size_t points_count)
{
dt_iop_lensfun_data_t *d = (dt_iop_lensfun_data_t *)piece->data;

Expand All @@ -645,7 +645,7 @@ int distort_transform(dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, floa
d->target_geom, d->modify_flags, !d->inverse);
float *buf = malloc(2*3*sizeof(float));

for (int i=0; i<points_count*2; i+=2)
for (size_t i=0; i<points_count*2; i+=2)
{
if (modflags & (LF_MODIFY_TCA | LF_MODIFY_DISTORTION | LF_MODIFY_GEOMETRY | LF_MODIFY_SCALE))
{
Expand All @@ -659,7 +659,7 @@ int distort_transform(dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, floa

return 1;
}
int distort_backtransform(dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, float *points, int points_count)
int distort_backtransform(dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, float *points, size_t points_count)
{
dt_iop_lensfun_data_t *d = (dt_iop_lensfun_data_t *)piece->data;
if(!d->lens->Maker || d->crop <= 0.0f) return 0;
Expand All @@ -674,7 +674,7 @@ int distort_backtransform(dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece,
d->target_geom, d->modify_flags, d->inverse);
float *buf = malloc(2*3*sizeof(float));

for (int i=0; i<points_count*2; i+=2)
for (size_t i=0; i<points_count*2; i+=2)
{
if (modflags & (LF_MODIFY_TCA | LF_MODIFY_DISTORTION | LF_MODIFY_GEOMETRY | LF_MODIFY_SCALE))
{
Expand Down
5 changes: 2 additions & 3 deletions src/iop/levels.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
#endif
for(int k=0; k<roi_out->height; k++)
{
float *in = ((float *)i) + k*ch*roi_out->width;
float *out = ((float *)o) + k*ch*roi_out->width;
float *in = ((float *)i) + (size_t)k*ch*roi_out->width;
float *out = ((float *)o) + (size_t)k*ch*roi_out->width;
for (int j=0; j<roi_out->width; j++,in+=ch,out+=ch)
{
float L_in = in[0] / 100.0;
Expand Down Expand Up @@ -104,7 +104,6 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void

}
}

}

#ifdef HAVE_OPENCL
Expand Down
2 changes: 1 addition & 1 deletion src/iop/lowlight.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void *i, v
#ifdef _OPENMP
#pragma omp parallel for default(none) schedule(static) shared(roi_in, roi_out, d, i, o, XYZ_sw)
#endif
for(int k=0; k<roi_out->width*roi_out->height; k++)
for(size_t k=0; k<(size_t)roi_out->width*roi_out->height; k++)
{
float *in = (float *)i + ch*k;
float *out = (float *)o + ch*k;
Expand Down
2 changes: 1 addition & 1 deletion src/iop/lowpass.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
#ifdef _OPENMP
#pragma omp parallel for default(none) shared(in,out,data,roi_out) schedule(static)
#endif
for(int k=0; k<roi_out->width*roi_out->height; k++)
for(size_t k=0; k<(size_t)roi_out->width*roi_out->height; k++)
{
out[k*ch+0] = (out[k*ch+0] < 100.0f) ? data->ctable[CLAMP((int)(out[k*ch+0]/100.0f*0x10000ul), 0, 0xffff)] :
dt_iop_eval_exp(data->cunbounded_coeffs, out[k*ch+0]/100.0f);
Expand Down
8 changes: 4 additions & 4 deletions src/iop/monochrome.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
#endif
for(int k=0; k<roi_out->height; k++)
{
const float *in = ((float *)i) + 4*k*roi_out->width;
float *out = ((float *)o) + 4*k*roi_out->width;
const float *in = ((float *)i) + (size_t)4*k*roi_out->width;
float *out = ((float *)o) + (size_t)4*k*roi_out->width;
for (int j=0; j<roi_out->width; j++,in+=4,out+=4)
{
out[0] = 100.0f*color_filter(in[1], in[2], d->a, d->b, sigma2);
Expand All @@ -188,8 +188,8 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
#endif
for(int k=0; k<roi_out->height; k++)
{
const float *in = ((float *)i) + 4*k*roi_out->width;
float *out = ((float *)o) + 4*k*roi_out->width;
const float *in = ((float *)i) + (size_t)4*k*roi_out->width;
float *out = ((float *)o) + (size_t)4*k*roi_out->width;
for (int j=0; j<roi_out->width; j++,in+=4,out+=4)
{
const float tt = envelope(in[0]);
Expand Down
32 changes: 16 additions & 16 deletions src/iop/nlmeans.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,12 @@ process_cl (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, cl_mem
//float weight[4] = { powf(d->luma, 0.6), powf(d->chroma, 0.6), powf(d->chroma, 0.6), 1.0f };
float weight[4] = { d->luma, d->chroma, d->chroma, 1.0f };

dev_U2 = dt_opencl_alloc_device_buffer(devid, width*height*4*sizeof(float));
dev_U2 = dt_opencl_alloc_device_buffer(devid, (size_t)width*height*4*sizeof(float));
if(dev_U2 == NULL) goto error;

for(int k=0; k<NUM_BUCKETS; k++)
{
buckets[k] = dt_opencl_alloc_device_buffer(devid, width*height*sizeof(float));
buckets[k] = dt_opencl_alloc_device_buffer(devid, (size_t)width*height*sizeof(float));
if(buckets[k] == NULL) goto error;
}

Expand Down Expand Up @@ -385,7 +385,7 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
if(P < 1)
{
// nothing to do from this distance:
memcpy (ovoid, ivoid, sizeof(float)*4*roi_out->width*roi_out->height);
memcpy (ovoid, ivoid, (size_t)sizeof(float)*4*roi_out->width*roi_out->height);
return;
}

Expand All @@ -396,9 +396,9 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
float nL = 1.0f/max_L, nC = 1.0f/max_C;
const float norm2[4] = { nL*nL, nC*nC, nC*nC, 1.0f };

float *Sa = dt_alloc_align(64, sizeof(float)*roi_out->width*dt_get_num_threads());
float *Sa = dt_alloc_align(64, (size_t)sizeof(float)*roi_out->width*dt_get_num_threads());
// we want to sum up weights in col[3], so need to init to 0:
memset(ovoid, 0x0, sizeof(float)*roi_out->width*roi_out->height*4);
memset(ovoid, 0x0, (size_t)sizeof(float)*roi_out->width*roi_out->height*4);

// for each shift vector
for(int kj=-K; kj<=K; kj++)
Expand All @@ -414,9 +414,9 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
for(int j=0; j<roi_out->height; j++)
{
if(j+kj < 0 || j+kj >= roi_out->height) continue;
float *S = Sa + dt_get_thread_num() * roi_out->width;
const float *ins = ((float *)ivoid) + 4*(roi_in->width *(j+kj) + ki);
float *out = ((float *)ovoid) + 4*roi_out->width*j;
float *S = Sa + (size_t)dt_get_thread_num() * roi_out->width;
const float *ins = ((float *)ivoid) + 4*((size_t)roi_in->width *(j+kj) + ki);
float *out = ((float *)ovoid) + 4*(size_t)roi_out->width*j;

const int Pm = MIN(MIN(P, j+kj), j);
const int PM = MIN(MIN(P, roi_out->height-1-j-kj), roi_out->height-1-j);
Expand All @@ -430,8 +430,8 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
{
int i = MAX(0, -ki);
float *s = S + i;
const float *inp = ((float *)ivoid) + 4*i + 4* roi_in->width *(j+jj);
const float *inps = ((float *)ivoid) + 4*i + 4*(roi_in->width *(j+jj+kj) + ki);
const float *inp = ((float *)ivoid) + 4*i + 4* (size_t)roi_in->width *(j+jj);
const float *inps = ((float *)ivoid) + 4*i + 4*((size_t)roi_in->width *(j+jj+kj) + ki);
const int last = roi_out->width + MIN(0, -ki);
for(; i<last; i++, inp+=4, inps+=4, s++)
{
Expand Down Expand Up @@ -466,10 +466,10 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
// sliding window in j direction:
int i = MAX(0, -ki);
float *s = S + i;
const float *inp = ((float *)ivoid) + 4*i + 4* roi_in->width *(j+P+1);
const float *inps = ((float *)ivoid) + 4*i + 4*(roi_in->width *(j+P+1+kj) + ki);
const float *inm = ((float *)ivoid) + 4*i + 4* roi_in->width *(j-P);
const float *inms = ((float *)ivoid) + 4*i + 4*(roi_in->width *(j-P+kj) + ki);
const float *inp = ((float *)ivoid) + 4*i + 4* (size_t)roi_in->width *(j+P+1);
const float *inps = ((float *)ivoid) + 4*i + 4*((size_t)roi_in->width *(j+P+1+kj) + ki);
const float *inm = ((float *)ivoid) + 4*i + 4* (size_t)roi_in->width *(j-P);
const float *inms = ((float *)ivoid) + 4*i + 4*((size_t)roi_in->width *(j-P+kj) + ki);
const int last = roi_out->width + MIN(0, -ki);
for(; ((intptr_t)s & 0xf) != 0 && i<last; i++, inp+=4, inps+=4, inm+=4, inms+=4, s++)
{
Expand Down Expand Up @@ -546,8 +546,8 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
#endif
for(int j=0; j<roi_out->height; j++)
{
float *out = ((float *)ovoid) + 4*roi_out->width*j;
float *in = ((float *)ivoid) + 4*roi_out->width*j;
float *out = ((float *)ovoid) + 4*(size_t)roi_out->width*j;
float *in = ((float *)ivoid) + 4*(size_t)roi_out->width*j;
for(int i=0; i<roi_out->width; i++)
{
_mm_store_ps(out, _mm_add_ps(
Expand Down
4 changes: 2 additions & 2 deletions src/iop/overexposed.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
// FIXME: turn off the module instead?
if(!dev->overexposed.enabled || !dev->gui_attached)
{
memcpy(o, i, roi_out->width*roi_out->height*sizeof(float)*ch);
memcpy(o, i, (size_t)roi_out->width*roi_out->height*sizeof(float)*ch);
return;
}

Expand All @@ -132,7 +132,7 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
#ifdef _OPENMP
#pragma omp parallel for default(none) shared(roi_out, in, out, upper_color, lower_color) schedule(static)
#endif
for(int k=0; k<roi_out->width*roi_out->height; k++)
for(size_t k=0; k<(size_t)roi_out->width*roi_out->height; k++)
{
float *inp = in + ch*k;
float *outp = out + ch*k;
Expand Down
2 changes: 1 addition & 1 deletion src/iop/profile_gamma.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
float *in = (float *)i;
float *out = (float *)o;
const int ch = piece->colors;
for(int k=0; k<roi_out->width*roi_out->height; k++)
for(size_t k=0; k<(size_t)roi_out->width*roi_out->height; k++)
{
out[0] = table[CLAMP((int)(in[0]*0x10000ul), 0, 0xffff)];
out[1] = table[CLAMP((int)(in[1]*0x10000ul), 0, 0xffff)];
Expand Down
26 changes: 13 additions & 13 deletions src/iop/rawdenoise.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ hat_transform(float *temp, const float *const base, int stride, int size, int sc
const float *basep0;
const float *basep1;
const float *basep2;
const int stxsc = stride*scale;
const size_t stxsc = (size_t)stride*scale;

basep0 = base;
basep1 = base + stxsc;
Expand All @@ -134,7 +134,7 @@ static void wavelet_denoise(const float *const in, float *const out, const dt_io
static const float noise[] =
{ 0.8002,0.2735,0.1202,0.0585,0.0291,0.0152,0.0080,0.0044 };

const int size = (roi->width/2+1) * (roi->height/2+1);
const size_t size = (size_t)(roi->width/2+1) * (roi->height/2+1);
#if 0
float maximum = 1.0; /* FIXME */
float black = 0.0; /* FIXME */
Expand All @@ -161,9 +161,9 @@ static void wavelet_denoise(const float *const in, float *const out, const dt_io
#endif
for (int row=c&1; row<roi->height; row+=2)
{
float *fimgp = fimg + size + row/2 * halfwidth;
float *fimgp = fimg + size + (size_t)row/2 * halfwidth;
int col = (c&2)>>1;
const float *inp = in + row*roi->width + col;
const float *inp = in + (size_t)row*roi->width + col;
for (; col<roi->width; col+=2, fimgp++, inp+=2)
*fimgp = sqrt(MAX(0, *inp));
}
Expand All @@ -172,32 +172,32 @@ static void wavelet_denoise(const float *const in, float *const out, const dt_io

for (lev=0; lev < 5; lev++)
{
const int pass1 = size*((lev & 1)*2 + 1);
const int pass2 = 2*size;
const int pass3 = 4*size - pass1;
const size_t pass1 = size*((lev & 1)*2 + 1);
const size_t pass2 = 2*size;
const size_t pass3 = 4*size - pass1;

// filter horizontally and transpose
#ifdef _OPENMP
#pragma omp parallel for default(none) shared(lev) schedule(static)
#endif
for (int col=0; col < halfwidth; col++)
{
hat_transform(fimg+pass2+col*halfheight, fimg+pass1+col, halfwidth, halfheight, 1 << lev);
hat_transform(fimg+pass2+(size_t)col*halfheight, fimg+pass1+col, halfwidth, halfheight, 1 << lev);
}
// filter vertically and transpose back
#ifdef _OPENMP
#pragma omp parallel for default(none) shared(lev) schedule(static)
#endif
for (int row=0; row < halfheight; row++)
{
hat_transform(fimg+pass3+row*halfwidth, fimg+pass2+row, halfheight, halfwidth, 1 << lev);
hat_transform(fimg+pass3+(size_t)row*halfwidth, fimg+pass2+row, halfheight, halfwidth, 1 << lev);
}

const float thold = threshold * noise[lev];
#ifdef _OPENMP
#pragma omp parallel for default(none) shared(lev)
#endif
for (int i=0; i < halfwidth*halfheight; i++)
for (size_t i=0; i < (size_t)halfwidth*halfheight; i++)
{
float *fimgp = fimg + i;
const float diff = fimgp[pass1] - fimgp[pass3];
Expand All @@ -211,9 +211,9 @@ static void wavelet_denoise(const float *const in, float *const out, const dt_io
#endif
for (int row=c&1; row<roi->height; row+=2)
{
const float *fimgp = fimg + row/2 * halfwidth;
const float *fimgp = fimg + (size_t)row/2 * halfwidth;
int col = (c&2)>>1;
float *outp = out + row*roi->width + col;
float *outp = out + (size_t)row*roi->width + col;
for (; col<roi->width; col+=2, fimgp++, outp+=2)
{
float d = fimgp[0] + fimgp[lastpass];
Expand Down Expand Up @@ -269,7 +269,7 @@ void process(struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void *
if (d->threshold > 0.0)
wavelet_denoise(ivoid, ovoid, roi_in, d->threshold, dt_image_flipped_filter(&piece->pipe->image));
else
memcpy(ovoid, ivoid, roi_out->width * roi_out->height * sizeof(float));
memcpy(ovoid, ivoid, (size_t)roi_out->width * roi_out->height * sizeof(float));
}

void reload_defaults(dt_iop_module_t *module)
Expand Down
4 changes: 2 additions & 2 deletions src/iop/relight.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
#endif
for(int k=0; k<roi_out->height; k++)
{
float *in = ((float *)ivoid) + ch*k*roi_out->width;
float *out = ((float *)ovoid) + ch*k*roi_out->width;
float *in = ((float *)ivoid) + (size_t)ch*k*roi_out->width;
float *out = ((float *)ovoid) + (size_t)ch*k*roi_out->width;
for(int j=0; j<roi_out->width; j++,in+=ch,out+=ch)
{
const float lightness = in[0]/100.0;
Expand Down
4 changes: 2 additions & 2 deletions src/iop/shadhi.c
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
#ifdef _OPENMP
#pragma omp parallel for default(none) shared(out, roi_out) schedule(static)
#endif
for(int j=0; j<roi_out->width*roi_out->height*4; j+=4)
for(size_t j=0; j<(size_t)roi_out->width*roi_out->height*4; j+=4)
{
out[j+0] = 100.0f - out[j+0];
out[j+1] = 0.0f;
Expand All @@ -344,7 +344,7 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
#ifdef _OPENMP
#pragma omp parallel for default(none) shared(in, out) schedule(static)
#endif
for(int j=0; j<width*height*ch; j+=ch)
for(size_t j=0; j<(size_t)width*height*ch; j+=ch)
{
float ta[3], tb[3];
_Lab_scale(&in[j], ta);
Expand Down
28 changes: 14 additions & 14 deletions src/iop/sharpen.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,11 +269,11 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
const int rad = MIN(MAXR, ceilf(data->radius * roi_in->scale / piece->iscale));
if(rad == 0)
{
memcpy(ovoid, ivoid, sizeof(float)*ch*roi_out->width*roi_out->height);
memcpy(ovoid, ivoid, (size_t)sizeof(float)*ch*roi_out->width*roi_out->height);
return;
}

float *const tmp = dt_alloc_align(16, sizeof(float)*roi_out->width*roi_out->height);
float *const tmp = dt_alloc_align(16, (size_t)sizeof(float)*roi_out->width*roi_out->height);
if (tmp == NULL)
{
fprintf(stderr,"[sharpen] failed to allocate temporary buffer\n");
Expand Down Expand Up @@ -301,8 +301,8 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
#endif
for(int j=0; j<roi_out->height; j++)
{
const float *in = ((float *)ivoid) + ch*(j*roi_in->width + rad);
float *out = tmp + j*roi_out->width + rad;
const float *in = ((float *)ivoid) + (size_t)ch*(j*roi_in->width + rad);
float *out = tmp + (size_t)j*roi_out->width + rad;
int i;
for(i=rad; i<roi_out->width-wd4*4+rad; i++)
{
Expand Down Expand Up @@ -341,8 +341,8 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
#endif
for(int j=rad; j<roi_out->height-wd4*4+rad; j++)
{
const float *in = tmp + j*roi_in->width;
float *out = ((float *)ovoid) + ch*j*roi_out->width;
const float *in = tmp + (size_t)j*roi_in->width;
float *out = ((float *)ovoid) + (size_t)ch*j*roi_out->width;

const int step = roi_in->width;

Expand All @@ -368,8 +368,8 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
#endif
for(int j=roi_out->height-wd4*4+rad; j<roi_out->height-rad; j++)
{
const float *in = tmp + j*roi_in->width;
float *out = ((float *)ovoid) + ch*j*roi_out->width;
const float *in = tmp + (size_t)j*roi_in->width;
float *out = ((float *)ovoid) + (size_t)ch*j*roi_out->width;
const int step = roi_in->width;

for(int i = 0; i<roi_out->width; i++)
Expand All @@ -389,9 +389,9 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void

// fill unsharpened border
for(int j=0; j<rad; j++)
memcpy(((float*)ovoid) + ch*j*roi_out->width, ((float*)ivoid) + ch*j*roi_in->width, ch*sizeof(float)*roi_out->width);
memcpy(((float*)ovoid) + (size_t)ch*j*roi_out->width, ((float*)ivoid) + (size_t)ch*j*roi_in->width, (size_t)ch*sizeof(float)*roi_out->width);
for(int j=roi_out->height-rad; j<roi_out->height; j++)
memcpy(((float*)ovoid) + ch*j*roi_out->width, ((float*)ivoid) + ch*j*roi_in->width, ch*sizeof(float)*roi_out->width);
memcpy(((float*)ovoid) + (size_t)ch*j*roi_out->width, ((float*)ivoid) + (size_t)ch*j*roi_in->width, (size_t)ch*sizeof(float)*roi_out->width);

dt_free_align(tmp);

Expand All @@ -400,8 +400,8 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
#endif
for(int j=rad; j<roi_out->height-rad; j++)
{
float *in = ((float*)ivoid) + ch*roi_out->width*j;
float *out = ((float*)ovoid) + ch*roi_out->width*j;
float *in = ((float*)ivoid) + (size_t)ch*roi_out->width*j;
float *out = ((float*)ovoid) + (size_t)ch*roi_out->width*j;
for(int i=0; i<rad; i++)
out[ch*i] = in[ch*i];
for(int i=roi_out->width-rad; i<roi_out->width; i++)
Expand All @@ -414,8 +414,8 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
// subtract blurred image, if diff > thrs, add *amount to original image
for(int j=0; j<roi_out->height; j++)
{
float *in = (float *)ivoid + j*ch*roi_out->width;
float *out = (float *)ovoid + j*ch*roi_out->width;
float *in = (float *)ivoid + (size_t)j*ch*roi_out->width;
float *out = (float *)ovoid + (size_t)j*ch*roi_out->width;

for(int i=0; i<roi_out->width; i++)
{
Expand Down
43 changes: 22 additions & 21 deletions src/iop/shrecovery.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,10 @@ create_image_weight(int height, int width, int ch, float *in, float *W, float sc
{
for(int j = 0; j < width; j++)
{
r = in[(i*width+j)*ch];
g = in[(i*width+j)*ch+1];
b = in[(i*width+j)*ch+2];
size_t index = (size_t)i*width+j;
r = in[index*ch];
g = in[index*ch+1];
b = in[index*ch+2];
t1 = factor*(sqr(r-mu) + sqr(g-mu) + sqr(b-mu));
t2 = factor*(sqr(r*scale-mu) + sqr(g*scale-mu) + sqr(b*scale-mu));
if(t2 < t1)
Expand All @@ -137,7 +138,7 @@ create_image_weight(int height, int width, int ch, float *in, float *W, float sc
e1 = exp(t1 - t2);
e2 = 1.0;
}
W[i*width+j] = e1/(e1+e2);
W[index] = e1/(e1+e2);
}
}
}
Expand Down Expand Up @@ -184,11 +185,11 @@ laplace_image(const int size_limit, int width, int height, float *im)
int st1, st2, st3, st4, st5;
for(int i = 0; i < h; i++)
{
l1 = im + max(2*i-2,0)*width*3;
l2 = im + max(2*i-1,0)*width*3;
l3 = im + 2*i*width*3;
l4 = im + min(2*i+1,height-1)*width*3;
l5 = im + min(2*i+2,height-1)*width*3;
l1 = im + (size_t)max(2*i-2,0)*width*3;
l2 = im + (size_t)max(2*i-1,0)*width*3;
l3 = im + (size_t)2*i*width*3;
l4 = im + (size_t)min(2*i+1,height-1)*width*3;
l5 = im + (size_t)min(2*i+2,height-1)*width*3;
for(int j = 0; j < w; j++)
{
st1 = max(2*j-2,0)*3;
Expand Down Expand Up @@ -230,9 +231,9 @@ laplace_image(const int size_limit, int width, int height, float *im)
continue;
i1 = min(max((i-m)/2,0),h-1);
j1 = min(max((j-n)/2,0),w-1);
im[3*(i*width+j)] -= 4*_w_[n+2]*_w_[m+2]*imn[3*(i1*w+j1)];
im[3*(i*width+j)+1] -= 4*_w_[n+2]*_w_[m+2]*imn[3*(i1*w+j1)+1];
im[3*(i*width+j)+2] -= 4*_w_[n+2]*_w_[m+2]*imn[3*(i1*w+j1)+2];
im[3*((size_t)i*width+j)] -= 4*_w_[n+2]*_w_[m+2]*imn[3*((size_t)i1*w+j1)];
im[3*((size_t)i*width+j)+1] -= 4*_w_[n+2]*_w_[m+2]*imn[3*((size_t)i1*w+j1)+1];
im[3*((size_t)i*width+j)+2] -= 4*_w_[n+2]*_w_[m+2]*imn[3*((size_t)i1*w+j1)+2];
}
}
}
Expand All @@ -249,8 +250,8 @@ weighted_image(const int size_limit, int width, int height, float *im1, float *i
int i1, j1, w = width/2, h = height/2;
float *imn1 = im1 + width*height*3, *imn2 = im2 + width*height*3, *wn = W + width*height;

const int LENGTH = width*height;
for(int i = 0; i < LENGTH; i++)
const size_t LENGTH = width*height;
for(size_t i = 0; i < LENGTH; i++)
{
im1[3*i] = im1[3*i]*W[i] + im2[3*i]*(1.0-W[i]);
im1[3*i+1] = im1[3*i+1]*W[i] + im2[3*i+1]*(1.0-W[i]);
Expand All @@ -273,9 +274,9 @@ weighted_image(const int size_limit, int width, int height, float *im1, float *i
continue;
i1 = min(max((i-m)/2,0),h-1);
j1 = min(max((j-n)/2,0),w-1);
im1[3*(i*width+j)] += 4*_w_[n+2]*_w_[m+2]*imn1[3*(i1*w+j1)];
im1[3*(i*width+j)+1] += 4*_w_[n+2]*_w_[m+2]*imn1[3*(i1*w+j1)+1];
im1[3*(i*width+j)+2] += 4*_w_[n+2]*_w_[m+2]*imn1[3*(i1*w+j1)+2];
im1[3*((size_t)i*width+j)] += 4*_w_[n+2]*_w_[m+2]*imn1[3*((size_t)i1*w+j1)];
im1[3*((size_t)i*width+j)+1] += 4*_w_[n+2]*_w_[m+2]*imn1[3*((size_t)i1*w+j1)+1];
im1[3*((size_t)i*width+j)+2] += 4*_w_[n+2]*_w_[m+2]*imn1[3*((size_t)i1*w+j1)+2];

}
}
Expand All @@ -300,10 +301,10 @@ void process(struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void *
create_image_weight(roi_out->width, roi_out->height, ch, in, W, scale, d->mu, d->sigma);
gauss_image_weight(d->size_limit, roi_out->width, roi_out->height, W);

float *im1 = (float*)malloc(6*sizeof(float)*roi_out->height*roi_out->width);
float *im2 = (float*)malloc(6*sizeof(float)*roi_out->height*roi_out->width);
float *im1 = (float*)malloc((size_t)6*sizeof(float)*roi_out->height*roi_out->width);
float *im2 = (float*)malloc((size_t)6*sizeof(float)*roi_out->height*roi_out->width);

const int LENGTH = roi_out->width*roi_out->height;
const size_t LENGTH = (size_t)roi_out->width*roi_out->height;
for(int i = 0; i < LENGTH; i++)
{
im1[i*3] = in[i*ch];
Expand All @@ -325,7 +326,7 @@ void process(struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void *
weighted_image(d->size_limit, roi_out->width, roi_out->height, im1, im2, W);


for(int i = 0; i < LENGTH; i++)
for(size_t i = 0; i < LENGTH; i++)
{
out[i*ch] = im1[3*i];
out[i*ch + 1] = im1[3*i+1];
Expand Down
14 changes: 7 additions & 7 deletions src/iop/soften.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
#ifdef _OPENMP
#pragma omp parallel for default(none) shared(in,out,roi_out) schedule(static)
#endif
for(int k=0; k<roi_out->width*roi_out->height; k++)
for(size_t k=0; k<(size_t)roi_out->width*roi_out->height; k++)
{
int index = ch*k;
size_t index = ch*k;
float h,s,l;
rgb2hsl(&in[index],&h,&s,&l);
s*=saturation;
Expand All @@ -157,7 +157,7 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
for(int y=0; y<roi_out->height; y++)
{
__m128 scanline[size];
int index = y * roi_out->width;
size_t index = (size_t)y * roi_out->width;
__m128 L = _mm_setzero_ps();
int hits = 0;
for(int x=-radius; x<roi_out->width; x++)
Expand Down Expand Up @@ -193,7 +193,7 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
__m128 scanline[size];
__m128 L = _mm_setzero_ps();
int hits=0;
int index = -radius*roi_out->width+x;
size_t index = (size_t)x - radius*roi_out->width;
for(int y=-radius; y<roi_out->height; y++)
{
int op=y-radius-1;
Expand All @@ -215,7 +215,7 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
}

for (int y=0; y<roi_out->height; y++)
_mm_store_ps(&out[(y*roi_out->width+x)*ch], scanline[y]);
_mm_store_ps(&out[((size_t)y*roi_out->width+x)*ch], scanline[y]);
}
}

Expand All @@ -225,7 +225,7 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
#ifdef _OPENMP
#pragma omp parallel for default(none) shared(roi_out, in, out, data) schedule(static)
#endif
for(int k=0; k<roi_out->width*roi_out->height; k++)
for(size_t k=0; k<(size_t)roi_out->width*roi_out->height; k++)
{
int index = ch*k;
_mm_store_ps(&out[index],
Expand Down Expand Up @@ -308,7 +308,7 @@ process_cl (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, cl_mem
dev_tmp = dt_opencl_alloc_device(devid, width, height, 4*sizeof(float));
if (dev_tmp == NULL) goto error;

dev_m = dt_opencl_copy_host_to_device_constant(devid, sizeof(float)*wd, mat);
dev_m = dt_opencl_copy_host_to_device_constant(devid, (size_t)sizeof(float)*wd, mat);
if (dev_m == NULL) goto error;

/* overexpose image */
Expand Down
4 changes: 2 additions & 2 deletions src/iop/splittoning.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
#endif
for(int k=0; k<roi_out->height; k++)
{
in = ((float *)ivoid) + ch*k*roi_out->width;
out = ((float *)ovoid) + ch*k*roi_out->width;
in = ((float *)ivoid) + (size_t)ch*k*roi_out->width;
out = ((float *)ovoid) + (size_t)ch*k*roi_out->width;
for (int j=0; j<roi_out->width; j++,in+=ch,out+=ch)
{
double ra,la;
Expand Down
16 changes: 8 additions & 8 deletions src/iop/spots.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,8 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
#endif
for (int k=0; k<roi_out->height; k++)
{
float *outb = out + ch*k*roi_out->width;
const float *inb = in + ch*roi_in->width*(k+roi_out->y-roi_in->y) + ch*(roi_out->x-roi_in->x);
float *outb = out + (size_t)ch*k*roi_out->width;
const float *inb = in + (size_t)ch*roi_in->width*(k+roi_out->y-roi_in->y) + ch*(roi_out->x-roi_in->x);
memcpy(outb, inb, sizeof(float)*roi_out->width*ch);
}

Expand Down Expand Up @@ -380,9 +380,9 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void

const float f = filter[xx-posx+1]*filter[yy-posy+1];
for(int c=0; c<ch; c++)
out[4*(roi_out->width*(yy-roi_out->y) + xx-roi_out->x) + c] =
out[4*(roi_out->width*(yy-roi_out->y) + xx-roi_out->x) + c] * (1.0f-f) +
in[4*(roi_in->width*(yy-posy+posy_source-roi_in->y) + xx-posx+posx_source-roi_in->x) + c] * f;
out[4*((size_t)roi_out->width*(yy-roi_out->y) + xx-roi_out->x) + c] =
out[4*((size_t)roi_out->width*(yy-roi_out->y) + xx-roi_out->x) + c] * (1.0f-f) +
in[4*((size_t)roi_in->width*(yy-posy+posy_source-roi_in->y) + xx-posx+posx_source-roi_in->x) + c] * f;
}
}
}
Expand Down Expand Up @@ -433,9 +433,9 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
float f = mask[((int)((yy-fts)/roi_in->scale))*width + (int)((xx-fls)/roi_in->scale)]; //we can add the opacity here

for(int c=0; c<ch; c++)
out[4*(roi_out->width*(yy-roi_out->y) + xx-roi_out->x) + c] =
out[4*(roi_out->width*(yy-roi_out->y) + xx-roi_out->x) + c] * (1.0f-f) +
in[4*(roi_in->width*(yy-dy-roi_in->y) + xx-dx-roi_in->x) + c] * f;
out[4*((size_t)roi_out->width*(yy-roi_out->y) + xx-roi_out->x) + c] =
out[4*((size_t)roi_out->width*(yy-roi_out->y) + xx-roi_out->x) + c] * (1.0f-f) +
in[4*((size_t)roi_in->width*(yy-dy-roi_in->y) + xx-dx-roi_in->x) + c] * f;
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/iop/temperature.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
for(int j=0; j<roi_out->height; j++)
{
int i=0;
const uint16_t *in = ((uint16_t *)ivoid) + j*roi_out->width;
float *out = ((float*)ovoid) + j*roi_out->width;
const uint16_t *in = ((uint16_t *)ivoid) + (size_t)j*roi_out->width;
float *out = ((float*)ovoid) + (size_t)j*roi_out->width;

// process unaligned pixels
for ( ; i < ((4-(j*roi_out->width & 3)) & 3) ; i++,out++,in++)
Expand Down Expand Up @@ -249,8 +249,8 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
#endif
for(int j=0; j<roi_out->height; j++)
{
const float *in = ((float *)ivoid) + j*roi_out->width;
float *out = ((float*)ovoid) + j*roi_out->width;
const float *in = ((float *)ivoid) + (size_t)j*roi_out->width;
float *out = ((float*)ovoid) + (size_t)j*roi_out->width;
for(int i=0; i<roi_out->width; i++,out++,in++)
*out = *in * d->coeffs[FC(j+roi_out->x, i+roi_out->y, filters)];
}
Expand All @@ -263,8 +263,8 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
#endif
for(int k=0; k<roi_out->height; k++)
{
const float *in = ((float*)ivoid) + ch*k*roi_out->width;
float *out = ((float*)ovoid) + ch*k*roi_out->width;
const float *in = ((float*)ivoid) + (size_t)ch*k*roi_out->width;
float *out = ((float*)ovoid) + (size_t)ch*k*roi_out->width;
for (int j=0; j<roi_out->width; j++,in+=ch,out+=ch)
for(int c=0; c<3; c++) out[c] = in[c]*d->coeffs[c];
}
Expand Down
4 changes: 2 additions & 2 deletions src/iop/tonecurve.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
#endif
for(int k=0; k<height; k++)
{
float *in = ((float *)i) + k*ch*width;
float *out = ((float *)o) + k*ch*width;
float *in = ((float *)i) + (size_t)k*ch*width;
float *out = ((float *)o) + (size_t)k*ch*width;

for (int j=0; j<width; j++,in+=ch,out+=ch)
{
Expand Down
14 changes: 7 additions & 7 deletions src/iop/tonemap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,13 @@ extern "C"
dt_iop_tonemapping_data_t *data = (dt_iop_tonemapping_data_t *)piece->data;
const int ch = piece->colors;

int width,height,size;
int width,height;
float inv_sigma_s;
const float inv_sigma_r=1.0/0.4;

width=roi_in->width;
height=roi_in->height;
size=width*height;
const size_t size=(size_t)width*height;
const float iw=piece->buf_in.width*roi_out->scale;
const float ih=piece->buf_in.height*roi_out->scale;

Expand All @@ -138,9 +138,9 @@ extern "C"
#endif
for(int j=0; j<height; j++)
{
int index = j*width;
size_t index = (size_t)j*width;
const int thread = omp_get_thread_num();
const float *in = (const float*)ivoid + j*width*ch;
const float *in = (const float*)ivoid + (size_t)j*width*ch;
for(int i=0; i<width; i++, index++, in+=ch)
{
float L = 0.2126*in[0]+ 0.7152*in[1] + 0.0722*in[2];
Expand Down Expand Up @@ -183,9 +183,9 @@ extern "C"
#endif
for(int j=0; j<height; j++)
{
int index = j*width;
const float *in = (const float*)ivoid + j*width*ch;
float *out = (float*)ovoid + j*width*ch;
size_t index = (size_t)j*width;
const float *in = (const float*)ivoid + (size_t)j*width*ch;
float *out = (float*)ovoid + (size_t)j*width*ch;
for(int i=0; i<width; i++, index++, in+=ch, out+=ch)
{
float val[2];
Expand Down
4 changes: 2 additions & 2 deletions src/iop/useless.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ void process(struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void *
#endif
for(int j=0; j<roi_out->height; j++)
{
float *in = ((float *)i) + ch*roi_in->width *j;
float *out = ((float *)o) + ch*roi_out->width*j;
float *in = ((float *)i) + (size_t)ch*roi_in->width *j; // make sure to address input, output and temp buffers with size_t as we want to also
float *out = ((float *)o) + (size_t)ch*roi_out->width*j; // correctly handle huge images
for(int i=0; i<roi_out->width; i++)
{
// calculate world space coordinates:
Expand Down
4 changes: 2 additions & 2 deletions src/iop/useless_simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ void process(struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void *
#endif
for(int j=0; j<roi_out->height; j++)
{
float *in = ((float *)i) + ch*roi_in->width *j;
float *out = ((float *)o) + ch*roi_out->width*j;
float *in = ((float *)i) + (size_t)ch*roi_in->width *j; // make sure to address input, output and temp buffers with size_t as we want to also
float *out = ((float *)o) + (size_t)ch*roi_out->width*j; // correctly handle huge images
for(int i=0; i<roi_out->width; i++)
{
// calculate world space coordinates:
Expand Down
4 changes: 2 additions & 2 deletions src/iop/velvia.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,13 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void

// Apply velvia saturation
if(strength <= 0.0)
memcpy(out, in, sizeof(float)*ch*roi_out->width*roi_out->height);
memcpy(out, in, (size_t)sizeof(float)*ch*roi_out->width*roi_out->height);
else
{
#ifdef _OPENMP
#pragma omp parallel for default(none) shared(roi_out, in, out, data) schedule(static)
#endif
for(int k=0; k<roi_out->width*roi_out->height; k++)
for(size_t k=0; k<(size_t)roi_out->width*roi_out->height; k++)
{
float *inp = in + ch*k;
float *outp = out + ch*k;
Expand Down
2 changes: 1 addition & 1 deletion src/iop/vibrance.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
#endif
for (int k=0; k<roi_out->height; k++)
{
int offs = k*roi_out->width*ch;
size_t offs = (size_t)k*roi_out->width*ch;
for(int l=0; l<(roi_out->width*ch); l+=ch)
{
/* saturation weight 0 - 1 */
Expand Down
2 changes: 1 addition & 1 deletion src/iop/vignette.c
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
#endif
for(int j=0; j<roi_out->height; j++)
{
const int k = ch*roi_out->width*j;
const size_t k = (size_t)ch*roi_out->width*j;
const float *in = (const float *)ivoid + k;
float *out = (float *)ovoid + k;
unsigned int *tea_state = tea_states + 2 * dt_get_thread_num();
Expand Down
8 changes: 4 additions & 4 deletions src/iop/watermark.c
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
gchar *svgdoc = _watermark_get_svgdoc (self, data, &piece->pipe->image);
if (!svgdoc)
{
memcpy(ovoid, ivoid, sizeof(float)*ch*roi_out->width*roi_out->height);
memcpy(ovoid, ivoid, (size_t)sizeof(float)*ch*roi_out->width*roi_out->height);
return;
}

Expand All @@ -601,7 +601,7 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
g_free (svgdoc);
if (!svg || error)
{
memcpy(ovoid, ivoid, sizeof(float)*ch*roi_out->width*roi_out->height);
memcpy(ovoid, ivoid, (size_t)sizeof(float)*ch*roi_out->width*roi_out->height);
return;
}

Expand All @@ -610,13 +610,13 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void

/* create cairo memory surface */
guint8 *image= (guint8 *)g_malloc (stride*roi_out->height);
memset (image,0,stride*roi_out->height);
memset (image,0,(size_t)stride*roi_out->height);
cairo_surface_t *surface = cairo_image_surface_create_for_data (image,CAIRO_FORMAT_ARGB32,roi_out->width,roi_out->height,stride);
if (cairo_surface_status(surface)!= CAIRO_STATUS_SUCCESS)
{
// fprintf(stderr,"Cairo surface error: %s\n",cairo_status_to_string(cairo_surface_status(surface)));
g_free (image);
memcpy(ovoid, ivoid, sizeof(float)*ch*roi_out->width*roi_out->height);
memcpy(ovoid, ivoid, (size_t)sizeof(float)*ch*roi_out->width*roi_out->height);
return;
}

Expand Down
14 changes: 7 additions & 7 deletions src/iop/zonesystem.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
if(g->preview_buffer)
g_free (g->preview_buffer);

buffer = g->preview_buffer = g_malloc (roi_in->width*roi_in->height);
buffer = g->preview_buffer = g_malloc ((size_t)roi_in->width*roi_in->height);
g->preview_width=roi_out->width;
g->preview_height=roi_out->height;
}
Expand All @@ -184,7 +184,7 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
const float sigma2 = (2.5*2.5)*(radius*roi_in->scale/piece->iscale)*(radius*roi_in->scale/piece->iscale);
float weight = 0.0f;

memset(mat, 0, wd*wd*sizeof(float));
memset(mat, 0, (size_t)wd*wd*sizeof(float));

m = mat;
for(int l=-rad; l<=rad; l++) for(int k=-rad; k<=rad; k++,m++)
Expand All @@ -199,8 +199,8 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
#endif
for(int j=rad; j<roi_out->height-rad; j++)
{
in = ((float *)ivoid) + ch*(j*roi_in->width + rad);
out = ((float *)ovoid) + ch*(j*roi_out->width + rad);
in = ((float *)ivoid) + ch*((size_t)j*roi_in->width + rad);
out = ((float *)ovoid) + ch*((size_t)j*roi_out->width + rad);
for(int i=rad; i<roi_out->width-rad; i++)
{
for(int c=0; c<3; c++) out[c] = 0.0f;
Expand All @@ -224,7 +224,7 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
#ifdef _OPENMP
#pragma omp parallel for default(none) shared(roi_out,out,buffer,g,zonemap) schedule(static)
#endif
for (int k=0; k<roi_out->width*roi_out->height; k++)
for (size_t k=0; k<(size_t)roi_out->width*roi_out->height; k++)
{
buffer[k] = _iop_zonesystem_zone_index_from_lightness (out[ch*k]/100.0f, zonemap, size);
}
Expand Down Expand Up @@ -252,8 +252,8 @@ void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void
for (int i=0; i<roi_out->width; i++)
{
/* remap lightness into zonemap and apply lightness */
const float *inp = in + ch*(j*roi_out->width+i);
float *outp = out + ch*(j*roi_out->width+i);
const float *inp = in + ch*((size_t)j*roi_out->width+i);
float *outp = out + ch*((size_t)j*roi_out->width+i);

const int rz = CLAMPS(inp[0]*rzscale, 0, size-2); // zone index

Expand Down