[Bf-blender-cvs] [578f98d] master: Fix T47452: Translate-node seams w/ subpixel offset
Campbell Barton
noreply at git.blender.org
Wed Feb 17 16:24:42 CET 2016
Commit: 578f98d7ad31d7f1630f674253aeb4872502b6da
Author: Campbell Barton
Date: Thu Feb 18 01:28:41 2016 +1100
Branches: master
https://developer.blender.org/rB578f98d7ad31d7f1630f674253aeb4872502b6da
Fix T47452: Translate-node seams w/ subpixel offset
===================================================================
M source/blender/blenlib/BLI_math_interp.h
M source/blender/blenlib/intern/math_interp.c
M source/blender/compositor/intern/COM_MemoryBuffer.h
===================================================================
diff --git a/source/blender/blenlib/BLI_math_interp.h b/source/blender/blenlib/BLI_math_interp.h
index d2ec7b8..a3c5ce8 100644
--- a/source/blender/blenlib/BLI_math_interp.h
+++ b/source/blender/blenlib/BLI_math_interp.h
@@ -45,6 +45,12 @@ void BLI_bilinear_interpolation_fl(const float *buffer, float *output, int width
void BLI_bilinear_interpolation_char(const unsigned char *buffer, unsigned char *output, int width, int height,
int components, float u, float v);
+void BLI_bilinear_interpolation_wrap_fl(const float *buffer, float *output, int width, int height,
+ int components, float u, float v, bool wrap_x, bool wrap_y);
+
+void BLI_bilinear_interpolation_wrap_char(const unsigned char *buffer, unsigned char *output, int width, int height,
+ int components, float u, float v, bool wrap_x, bool wrap_y);
+
#define EWA_MAXIDX 255
extern const float EWA_WTS[EWA_MAXIDX + 1];
diff --git a/source/blender/blenlib/intern/math_interp.c b/source/blender/blenlib/intern/math_interp.c
index b45d8b4..069d23e 100644
--- a/source/blender/blenlib/intern/math_interp.c
+++ b/source/blender/blenlib/intern/math_interp.c
@@ -262,7 +262,7 @@ void BLI_bicubic_interpolation_char(const unsigned char *buffer, unsigned char *
/* BILINEAR INTERPOLATION */
BLI_INLINE void bilinear_interpolation(const unsigned char *byte_buffer, const float *float_buffer,
unsigned char *byte_output, float *float_output, int width, int height,
- int components, float u, float v)
+ int components, float u, float v, bool wrap_x, bool wrap_y)
{
float a, b;
float a_b, ma_b, a_mb, ma_mb;
@@ -279,11 +279,21 @@ BLI_INLINE void bilinear_interpolation(const unsigned char *byte_buffer, const f
const float *row1, *row2, *row3, *row4;
float empty[4] = {0.0f, 0.0f, 0.0f, 0.0f};
- /* sample area entirely outside image? */
- if (x2 < 0 || x1 > width - 1 || y2 < 0 || y1 > height - 1) {
- copy_vn_fl(float_output, components, 0.0f);
- return;
+ /* pixel value must be already wrapped, however values at boundaries may flip */
+ if (wrap_x) {
+ if (x1 < 0) x1 = width - 1;
+ if (x2 >= width) x2 = 0;
}
+ if (wrap_y) {
+ if (y1 < 0) y1 = height - 1;
+ if (y2 >= height) y2 = 0;
+ }
+
+ CLAMP(x1, 0, width - 1);
+ CLAMP(x2, 0, width - 1);
+
+ CLAMP(y1, 0, height - 1);
+ CLAMP(y2, 0, height - 1);
/* sample including outside of edges of image */
if (x1 < 0 || y1 < 0) row1 = empty;
@@ -364,15 +374,28 @@ BLI_INLINE void bilinear_interpolation(const unsigned char *byte_buffer, const f
void BLI_bilinear_interpolation_fl(const float *buffer, float *output, int width, int height,
int components, float u, float v)
{
- bilinear_interpolation(NULL, buffer, NULL, output, width, height, components, u, v);
+ bilinear_interpolation(NULL, buffer, NULL, output, width, height, components, u, v, false, false);
}
void BLI_bilinear_interpolation_char(const unsigned char *buffer, unsigned char *output, int width, int height,
int components, float u, float v)
{
- bilinear_interpolation(buffer, NULL, output, NULL, width, height, components, u, v);
+ bilinear_interpolation(buffer, NULL, output, NULL, width, height, components, u, v, false, false);
}
+void BLI_bilinear_interpolation_wrap_fl(const float *buffer, float *output, int width, int height,
+ int components, float u, float v, bool wrap_x, bool wrap_y)
+{
+ bilinear_interpolation(NULL, buffer, NULL, output, width, height, components, u, v, wrap_x, wrap_y);
+}
+
+void BLI_bilinear_interpolation_wrap_char(const unsigned char *buffer, unsigned char *output, int width, int height,
+ int components, float u, float v, bool wrap_x, bool wrap_y)
+{
+ bilinear_interpolation(buffer, NULL, output, NULL, width, height, components, u, v, wrap_x, wrap_y);
+}
+
+
/**************************************************************************
* Filtering method based on
* "Creating raster omnimax images from multiple perspective views using the elliptical weighted average filter"
diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.h b/source/blender/compositor/intern/COM_MemoryBuffer.h
index de8c14e..f9e2dd8 100644
--- a/source/blender/compositor/intern/COM_MemoryBuffer.h
+++ b/source/blender/compositor/intern/COM_MemoryBuffer.h
@@ -259,7 +259,9 @@ public:
float u = x;
float v = y;
this->wrap_pixel(u, v, extend_x, extend_y);
- BLI_bilinear_interpolation_fl(this->m_buffer, result, this->m_width, this->m_height, this->m_num_channels, u, v);
+ BLI_bilinear_interpolation_wrap_fl(
+ this->m_buffer, result, this->m_width, this->m_height, this->m_num_channels, u, v,
+ extend_x == COM_MB_REPEAT, extend_y == COM_MB_REPEAT);
}
void readEWA(float *result, const float uv[2], const float derivatives[2][2]);
More information about the Bf-blender-cvs
mailing list