Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2015-02-23 22:36:33 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2015-02-23 22:36:33 +0300
commit225f68c324a3417fa3afb745c0e0f7e404737634 (patch)
treee32be7a23955fac66a062dbf6fedcf5ccb5def10 /source/blender/blenlib
parent2081fd1d7de40f7b3e1a529f5b450ed508fe9257 (diff)
Fix interpolation functions ignoring number of components when doing early output
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/BLI_math_vector.h1
-rw-r--r--source/blender/blenlib/intern/math_interp.c14
-rw-r--r--source/blender/blenlib/intern/math_vector.c9
3 files changed, 18 insertions, 6 deletions
diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h
index 0f437b7fc38..33319f36507 100644
--- a/source/blender/blenlib/BLI_math_vector.h
+++ b/source/blender/blenlib/BLI_math_vector.h
@@ -321,6 +321,7 @@ void interp_vn_vn(float *array_tar, const float *array_src, const float t, const
void fill_vn_i(int *array_tar, const int size, const int val);
void fill_vn_short(short *array_tar, const int size, const short val);
void fill_vn_ushort(unsigned short *array_tar, const int size, const unsigned short val);
+void fill_vn_uchar(unsigned char *array_tar, const int size, const unsigned char val);
void fill_vn_fl(float *array_tar, const int size, const float val);
/**************************** Inline Definitions ******************************/
diff --git a/source/blender/blenlib/intern/math_interp.c b/source/blender/blenlib/intern/math_interp.c
index a0c47be8d48..67850463fe2 100644
--- a/source/blender/blenlib/intern/math_interp.c
+++ b/source/blender/blenlib/intern/math_interp.c
@@ -111,10 +111,12 @@ BLI_INLINE void bicubic_interpolation(const unsigned char *byte_buffer, const fl
/* sample area entirely outside image? */
if (ceil(u) < 0 || floor(u) > width - 1 || ceil(v) < 0 || floor(v) > height - 1) {
- if (float_output)
- float_output[0] = float_output[1] = float_output[2] = float_output[3] = 0.0f;
- if (byte_output)
- byte_output[0] = byte_output[1] = byte_output[2] = byte_output[3] = 0;
+ if (float_output) {
+ fill_vn_fl(float_output, components, 0.0f);
+ }
+ if (byte_output) {
+ fill_vn_uchar(byte_output, components, 0);
+ }
return;
}
@@ -279,7 +281,7 @@ BLI_INLINE void bilinear_interpolation(const unsigned char *byte_buffer, const f
/* sample area entirely outside image? */
if (x2 < 0 || x1 > width - 1 || y2 < 0 || y1 > height - 1) {
- float_output[0] = float_output[1] = float_output[2] = float_output[3] = 0.0f;
+ fill_vn_fl(float_output, components, 0.0f);
return;
}
@@ -321,7 +323,7 @@ BLI_INLINE void bilinear_interpolation(const unsigned char *byte_buffer, const f
/* sample area entirely outside image? */
if (x2 < 0 || x1 > width - 1 || y2 < 0 || y1 > height - 1) {
- byte_output[0] = byte_output[1] = byte_output[2] = byte_output[3] = 0;
+ fill_vn_uchar(byte_output, components, 0);
return;
}
diff --git a/source/blender/blenlib/intern/math_vector.c b/source/blender/blenlib/intern/math_vector.c
index d065fa7e5a7..1658c4ffc39 100644
--- a/source/blender/blenlib/intern/math_vector.c
+++ b/source/blender/blenlib/intern/math_vector.c
@@ -1040,6 +1040,15 @@ void fill_vn_ushort(unsigned short *array_tar, const int size, const unsigned sh
}
}
+void fill_vn_uchar(unsigned char *array_tar, const int size, const unsigned char val)
+{
+ unsigned char *tar = array_tar + (size - 1);
+ int i = size;
+ while (i--) {
+ *(tar--) = val;
+ }
+}
+
void fill_vn_fl(float *array_tar, const int size, const float val)
{
float *tar = array_tar + (size - 1);