Skip to content

Commit bcba36f

Browse files
Bugfixing various interpolaters
When doing - dt_interpolation_resample() dt_interpolation_resample_roi() - dt_interpolation_resample_cl() dt_interpolation_resample_roi_cl() - dt_interpolation_resample_1c() we don't attempt to keep data above zero, if this is required we must correct outside these interpolators. Notes: - the cpu code did badly on intermediate results - the fast copy modes behave accordingly as keeping data as they are
1 parent 25aa865 commit bcba36f

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

data/kernels/basic.cl

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2972,11 +2972,11 @@ static inline float get_image_channel(read_only image2d_t in,
29722972
const int c)
29732973
{
29742974
float4 pixel = read_imagef(in, sampleri, (int2)(x, y));
2975-
if(c == 0)
2975+
if(c == RED)
29762976
return pixel.x;
2977-
else if(c == 1)
2977+
else if(c == GREEN)
29782978
return pixel.y;
2979-
else if(c == 2)
2979+
else if(c == BLUE)
29802980
return pixel.z;
29812981

29822982
return pixel.w;
@@ -3846,7 +3846,7 @@ interpolation_resample (read_only image2d_t in,
38463846
for (int ix = 0; ix < hl && yvalid; ix++)
38473847
{
38483848
const int xx = lindex[ix];
3849-
float4 hpixel = read_imagef(in, sampleri,(int2)(xx, yy));
3849+
float4 hpixel = readpixel(in, xx, yy);
38503850
vpixel += hpixel * lkernel[ix];
38513851
}
38523852

@@ -3868,12 +3868,8 @@ interpolation_resample (read_only image2d_t in,
38683868
}
38693869

38703870
// store final result
3871-
if (iy == 0 && x < width && y < height)
3872-
{
3873-
// Clip negative RGB that may be produced by Lanczos undershooting
3874-
// Negative RGB are invalid values no matter the RGB space (light is positive)
3875-
write_imagef (out, (int2)(x, y), fmax(buffer[ylid], 0.f));
3876-
}
3871+
if(iy == 0 && x < width && y < height)
3872+
write_imagef(out, (int2)(x, y), buffer[ylid]);
38773873
}
38783874

38793875
/* kernel for the interpolation copy helper */
@@ -3890,7 +3886,7 @@ interpolation_copy(read_only image2d_t dev_in,
38903886
const int ocol = get_global_id(0);
38913887
const int orow = get_global_id(1);
38923888

3893-
if(ocol >= owidth || orow >= oheight) return;
3889+
if(ocol < 0 || ocol >= owidth || orow < 0 || orow >= oheight) return;
38943890

38953891
float4 pix = (float4)( 0.0f, 0.0f, 0.0f, 0.0f );
38963892

@@ -3899,7 +3895,7 @@ interpolation_copy(read_only image2d_t dev_in,
38993895

39003896
if(irow < iheight && irow >= 0 && icol < iwidth && icol >= 0)
39013897
{
3902-
pix = read_imagef(dev_in, samplerA, (int2)(icol, irow));
3898+
pix = readpixel(dev_in, icol, irow);
39033899
}
39043900
write_imagef(dev_out, (int2)(ocol, orow), pix);
39053901
}

src/common/interpolation.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,11 +1142,9 @@ void dt_interpolation_resample(const dt_interpolation_t *itor,
11421142
// Output pixel is ready
11431143
const size_t baseidx = (size_t)oy * out_stride_floats + (size_t)ox * 4;
11441144

1145-
// Clip negative RGB that may be produced by Lanczos undershooting
1146-
// Negative RGB are invalid values no matter the RGB space (light is positive)
11471145
dt_aligned_pixel_t pixel;
11481146
for_each_channel(c, aligned(vs:16))
1149-
pixel[c] = fmaxf(0.0f, vs[c]);
1147+
pixel[c] = vs[c];
11501148
copy_pixel_nontemporal(out + baseidx, pixel);
11511149

11521150
// Reset vertical resampling context
@@ -1565,7 +1563,7 @@ void dt_interpolation_resample_1c(const dt_interpolation_t *itor,
15651563
// Output pixel is ready
15661564
float *o = (float *)((char *)out + (size_t)oy * out_stride
15671565
+ (size_t)ox * sizeof(float));
1568-
*o = fmaxf(0.0f, vs);
1566+
*o = vs;
15691567

15701568
// Reset vertical resampling context
15711569
viidx -= vl;

0 commit comments

Comments
 (0)