Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions src/common/interpolation.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ static float _maketaps_lanczos(float *taps,
dt_aligned_pixel_t sign;
for_four_channels(c)
{
int a = (int)vt[c];
const int a = (int)vt[c];
r[c] = vt[c] - (float)a;
sign[c] = (a & 1) ? -1.0f : 1.0f;
}
Expand Down Expand Up @@ -429,7 +429,7 @@ static inline float _compute_upsampling_kernel(const dt_interpolation_t *itor,
// yielding an incorrect result for the slightly-negative positions
// that can occur at the top and left edges when doing perspective
// correction
int f = (int)floorf(t) - itor->width + 1;
const int f = (int)floorf(t) - itor->width + 1;
if(first)
{
*first = f;
Expand Down Expand Up @@ -474,10 +474,10 @@ static inline void _compute_downsampling_kernel(const dt_interpolation_t *itor,
}

// Compute first interpolator parameter
float t = xin * outoinratio - (float)xout;
const float t = xin * outoinratio - (float)xout;

// Compute all filter taps
int num_taps = *taps = (int)((w - t) / outoinratio);
const int num_taps = *taps = (int)((w - t) / outoinratio);
itor->maketaps(kernel, num_taps, itor->width, t, outoinratio);
// compute the kernel norm if requested
if(norm)
Expand Down Expand Up @@ -510,8 +510,8 @@ float dt_interpolation_compute_sample(const dt_interpolation_t *itor,
float DT_ALIGNED_ARRAY kernelv[MAX_KERNEL_REQ];

// Compute both horizontal and vertical kernels
float normh = _compute_upsampling_kernel(itor, kernelh, NULL, x);
float normv = _compute_upsampling_kernel(itor, kernelv, NULL, y);
const float normh = _compute_upsampling_kernel(itor, kernelh, NULL, x);
const float normv = _compute_upsampling_kernel(itor, kernelv, NULL, y);

int ix = (int)x;
int iy = (int)y;
Expand Down Expand Up @@ -544,7 +544,7 @@ float dt_interpolation_compute_sample(const dt_interpolation_t *itor,
s += kernelv[i] * h;
in += linestride;
}
r = fmaxf(0.0f, s / (normh * normv));
r = s / (normh * normv);
}
else if(ix >= 0 && iy >= 0 && ix < width && iy < height)
{
Expand Down Expand Up @@ -582,14 +582,14 @@ float dt_interpolation_compute_sample(const dt_interpolation_t *itor,
s += kernelv[i] * h;
}

r = fmaxf(0.0f, s / (normh * normv));
r = s / (normh * normv);
}
else
{
// invalid coordinate
r = 0.0f;
}
return r;
return fmaxf(0.0f, r); // make sure we don't push NaNs
}

/* --------------------------------------------------------------------------
Expand All @@ -612,8 +612,8 @@ void dt_interpolation_compute_pixel4c(const dt_interpolation_t *itor,
float DT_ALIGNED_ARRAY kernelv[MAX_KERNEL_REQ];

// Compute both horizontal and vertical kernels
float normh = _compute_upsampling_kernel(itor, kernelh, NULL, x);
float normv = _compute_upsampling_kernel(itor, kernelv, NULL, y);
const float normh = _compute_upsampling_kernel(itor, kernelh, NULL, x);
const float normv = _compute_upsampling_kernel(itor, kernelv, NULL, y);

// Precompute the inverse of the filter norm for later use
const float oonorm = (1.f / (normh * normv));
Expand Down Expand Up @@ -1102,7 +1102,7 @@ void dt_interpolation_resample(const dt_interpolation_t *itor,
int hkidx = 0; // H(orizontal) K(ernel) I(n)d(e)x

// Number of lines contributing to the output line
int vl = vlength[vlidx++]; // V(ertical) L(ength)
const int vl = vlength[vlidx++]; // V(ertical) L(ength)

// Process each output column
for(size_t ox = 0; ox < (size_t)roi_out->width; ox++)
Expand All @@ -1111,12 +1111,12 @@ void dt_interpolation_resample(const dt_interpolation_t *itor,
dt_aligned_pixel_t vs = { 0.0f, 0.0f, 0.0f, 0.0f };

// Number of horizontal samples contributing to the output
int hl = hlength[hlidx++]; // H(orizontal) L(ength)
const int hl = hlength[hlidx++]; // H(orizontal) L(ength)

for(size_t iy = 0; iy < vl; iy++)
{
// This is our input line
size_t baseidx_vindex = (size_t)vindex[viidx++] * in_stride_floats;
const size_t baseidx_vindex = (size_t)vindex[viidx++] * in_stride_floats;

dt_aligned_pixel_t vhs = { 0.0f, 0.0f, 0.0f, 0.0f };

Expand Down Expand Up @@ -1146,7 +1146,7 @@ void dt_interpolation_resample(const dt_interpolation_t *itor,
// Negative RGB are invalid values no matter the RGB space (light is positive)
dt_aligned_pixel_t pixel;
for_each_channel(c, aligned(vs:16))
pixel[c] = MAX(vs[c], 0.f);
pixel[c] = fmaxf(0.0f, vs[c]);
copy_pixel_nontemporal(out + baseidx, pixel);

// Reset vertical resampling context
Expand Down Expand Up @@ -1565,7 +1565,7 @@ void dt_interpolation_resample_1c(const dt_interpolation_t *itor,
// Output pixel is ready
float *o = (float *)((char *)out + (size_t)oy * out_stride
+ (size_t)ox * sizeof(float));
*o = vs;
*o = fmaxf(0.0f, vs);

// Reset vertical resampling context
viidx -= vl;
Expand Down
Loading