From 07ceb99213166b678f0a0bac9c35e9897f22e827 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 6 Dec 2013 03:46:27 +1100 Subject: Code Cleanup: use strict flags for math lib, add inline declarations --- source/blender/blenlib/intern/math_interp.c | 40 +++++++++++++++-------------- 1 file changed, 21 insertions(+), 19 deletions(-) (limited to 'source/blender/blenlib/intern/math_interp.c') diff --git a/source/blender/blenlib/intern/math_interp.c b/source/blender/blenlib/intern/math_interp.c index 35a763c5173..9af1c8677df 100644 --- a/source/blender/blenlib/intern/math_interp.c +++ b/source/blender/blenlib/intern/math_interp.c @@ -34,6 +34,8 @@ #include "BLI_math.h" +#include "BLI_strict_flags.h" + /************************************************************************** * INTERPOLATIONS * @@ -114,8 +116,8 @@ BLI_INLINE void bicubic_interpolation(const unsigned char *byte_buffer, const fl i = (int)floor(u); j = (int)floor(v); - a = u - i; - b = v - j; + a = u - (float)i; + b = v - (float)j; zero_v4(out); @@ -130,7 +132,7 @@ BLI_INLINE void bicubic_interpolation(const unsigned char *byte_buffer, const fl for (n = -1; n <= 2; n++) { x1 = i + n; CLAMP(x1, 0, width - 1); - wx = P(n - a); + wx = P((float)n - a); for (m = -1; m <= 2; m++) { float data[4]; @@ -223,18 +225,18 @@ BLI_INLINE void bicubic_interpolation(const unsigned char *byte_buffer, const fl } else { if (components == 1) { - byte_output[0] = out[0] + 0.5f; + byte_output[0] = (unsigned char)(out[0] + 0.5f); } else if (components == 3) { - byte_output[0] = out[0] + 0.5f; - byte_output[1] = out[1] + 0.5f; - byte_output[2] = out[2] + 0.5f; + byte_output[0] = (unsigned char)(out[0] + 0.5f); + byte_output[1] = (unsigned char)(out[1] + 0.5f); + byte_output[2] = (unsigned char)(out[2] + 0.5f); } else { - byte_output[0] = out[0] + 0.5f; - byte_output[1] = out[1] + 0.5f; - byte_output[2] = out[2] + 0.5f; - byte_output[3] = out[3] + 0.5f; + byte_output[0] = (unsigned char)(out[0] + 0.5f); + byte_output[1] = (unsigned char)(out[1] + 0.5f); + byte_output[2] = (unsigned char)(out[2] + 0.5f); + byte_output[3] = (unsigned char)(out[3] + 0.5f); } } } @@ -337,18 +339,18 @@ BLI_INLINE void bilinear_interpolation(const unsigned char *byte_buffer, const f a_b = a * b; ma_b = (1.0f - a) * b; a_mb = a * (1.0f - b); ma_mb = (1.0f - a) * (1.0f - b); if (components == 1) { - byte_output[0] = ma_mb * row1[0] + a_mb * row3[0] + ma_b * row2[0] + a_b * row4[0] + 0.5f; + byte_output[0] = (unsigned char)(ma_mb * row1[0] + a_mb * row3[0] + ma_b * row2[0] + a_b * row4[0] + 0.5f); } else if (components == 3) { - byte_output[0] = ma_mb * row1[0] + a_mb * row3[0] + ma_b * row2[0] + a_b * row4[0] + 0.5f; - byte_output[1] = ma_mb * row1[1] + a_mb * row3[1] + ma_b * row2[1] + a_b * row4[1] + 0.5f; - byte_output[2] = ma_mb * row1[2] + a_mb * row3[2] + ma_b * row2[2] + a_b * row4[2] + 0.5f; + byte_output[0] = (unsigned char)(ma_mb * row1[0] + a_mb * row3[0] + ma_b * row2[0] + a_b * row4[0] + 0.5f); + byte_output[1] = (unsigned char)(ma_mb * row1[1] + a_mb * row3[1] + ma_b * row2[1] + a_b * row4[1] + 0.5f); + byte_output[2] = (unsigned char)(ma_mb * row1[2] + a_mb * row3[2] + ma_b * row2[2] + a_b * row4[2] + 0.5f); } else { - byte_output[0] = ma_mb * row1[0] + a_mb * row3[0] + ma_b * row2[0] + a_b * row4[0] + 0.5f; - byte_output[1] = ma_mb * row1[1] + a_mb * row3[1] + ma_b * row2[1] + a_b * row4[1] + 0.5f; - byte_output[2] = ma_mb * row1[2] + a_mb * row3[2] + ma_b * row2[2] + a_b * row4[2] + 0.5f; - byte_output[3] = ma_mb * row1[3] + a_mb * row3[3] + ma_b * row2[3] + a_b * row4[3] + 0.5f; + byte_output[0] = (unsigned char)(ma_mb * row1[0] + a_mb * row3[0] + ma_b * row2[0] + a_b * row4[0] + 0.5f); + byte_output[1] = (unsigned char)(ma_mb * row1[1] + a_mb * row3[1] + ma_b * row2[1] + a_b * row4[1] + 0.5f); + byte_output[2] = (unsigned char)(ma_mb * row1[2] + a_mb * row3[2] + ma_b * row2[2] + a_b * row4[2] + 0.5f); + byte_output[3] = (unsigned char)(ma_mb * row1[3] + a_mb * row3[3] + ma_b * row2[3] + a_b * row4[3] + 0.5f); } } } -- cgit v1.2.3