[Bf-blender-cvs] [97c8c29] multiview: Interlace Output Stereo Modes
Dalai Felinto
noreply at git.blender.org
Sat Aug 9 11:37:22 CEST 2014
Commit: 97c8c290e84f99d298a014af60e4589632740a61
Author: Dalai Felinto
Date: Fri Aug 8 23:41:21 2014 -0300
Branches: multiview
https://developer.blender.org/rB97c8c290e84f99d298a014af60e4589632740a61
Interlace Output Stereo Modes
===================================================================
M source/blender/blenlib/BLI_math_vector.h
M source/blender/blenlib/intern/math_vector_inline.c
M source/blender/imbuf/intern/stereoimbuf.c
===================================================================
diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h
index 6885a5a..96db03e 100644
--- a/source/blender/blenlib/BLI_math_vector.h
+++ b/source/blender/blenlib/BLI_math_vector.h
@@ -66,6 +66,11 @@ MINLINE void copy_v2_v2_char(char r[2], const char a[2]);
MINLINE void copy_v3_v3_char(char r[3], const char a[3]);
MINLINE void copy_v4_v4_char(char r[4], const char a[4]);
+/* unsigned char */
+MINLINE void copy_v2_v2_uchar(unsigned char r[2], const unsigned char a[2]);
+MINLINE void copy_v3_v3_uchar(unsigned char r[3], const unsigned char a[3]);
+MINLINE void copy_v4_v4_uchar(unsigned char r[4], const unsigned char a[4]);
+
/* short */
MINLINE void copy_v2_v2_short(short r[2], const short a[2]);
MINLINE void copy_v3_v3_short(short r[3], const short a[3]);
diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c
index 0a990e0..18b4ac1 100644
--- a/source/blender/blenlib/intern/math_vector_inline.c
+++ b/source/blender/blenlib/intern/math_vector_inline.c
@@ -97,7 +97,7 @@ MINLINE void copy_v4_fl(float r[4], float f)
r[3] = f;
}
-/* short */
+/* char */
MINLINE void copy_v2_v2_char(char r[2], const char a[2])
{
r[0] = a[0];
@@ -119,6 +119,28 @@ MINLINE void copy_v4_v4_char(char r[4], const char a[4])
r[3] = a[3];
}
+/* unsigned char */
+MINLINE void copy_v2_v2_uchar(unsigned char r[2], const unsigned char a[2])
+{
+ r[0] = a[0];
+ r[1] = a[1];
+}
+
+MINLINE void copy_v3_v3_uchar(unsigned char r[3], const unsigned char a[3])
+{
+ r[0] = a[0];
+ r[1] = a[1];
+ r[2] = a[2];
+}
+
+MINLINE void copy_v4_v4_uchar(unsigned char r[4], const unsigned char a[4])
+{
+ r[0] = a[0];
+ r[1] = a[1];
+ r[2] = a[2];
+ r[3] = a[3];
+}
+
/* short */
MINLINE void zero_v3_int(int r[3])
{
diff --git a/source/blender/imbuf/intern/stereoimbuf.c b/source/blender/imbuf/intern/stereoimbuf.c
index adb126a..d1e686d 100644
--- a/source/blender/imbuf/intern/stereoimbuf.c
+++ b/source/blender/imbuf/intern/stereoimbuf.c
@@ -85,8 +85,8 @@ static void imb_stereo_anaglyph(enum eStereoAnaglyphType mode, ImBuf *left, ImBu
for (y = 0; y < height; y++) {
float *to = rect_to + stride_to * y * 4;
const float *from[2] = {
- rect_left + stride_from * y * 4,
- rect_right + stride_from * y * 4,
+ rect_left + stride_from * y * 4,
+ rect_right + stride_from * y * 4,
};
for (x = 0; x < width; x++, from[0] += 4, from[1] += 4, to += 4) {
@@ -107,7 +107,7 @@ static void imb_stereo_anaglyph(enum eStereoAnaglyphType mode, ImBuf *left, ImBu
uchar *to = rect_to + stride_to * y * 4;
uchar *from[2] = {
rect_left + stride_from * y * 4,
- rect_right + stride_from * y * 4,
+ rect_right + stride_from * y * 4,
};
for (x = 0; x < width; x++, from[0] += 4, from[1] += 4, to += 4) {
@@ -120,9 +120,136 @@ static void imb_stereo_anaglyph(enum eStereoAnaglyphType mode, ImBuf *left, ImBu
}
}
-static void imb_stereo_interlace(enum eStereoInterlaceType UNUSED(mode), const bool UNUSED(swap), ImBuf *UNUSED(left), ImBuf *UNUSED(right), bool UNUSED(is_float), ImBuf *UNUSED(r_ibuf))
+static void imb_stereo_interlace(enum eStereoInterlaceType mode, const bool swap, ImBuf *left, ImBuf *right, bool is_float, ImBuf *r_ibuf)
{
- BLI_assert(false);
+ int x, y;
+ size_t width = r_ibuf->x;
+ size_t height= r_ibuf->y;
+
+ const int stride_from = width;
+ const int stride_to = width;
+
+ if (is_float){
+ float *rect_to = r_ibuf->rect_float;
+ const float *rect_left = left->rect_float;
+ const float *rect_right= right->rect_float;
+
+ switch(mode) {
+ case S3D_INTERLACE_ROW:
+ {
+ char i = (char) swap;
+ for (y = 0; y < height; y++) {
+ float *to = rect_to + stride_to * y * 4;
+ const float *from[2] = {
+ rect_left + stride_from * y * 4,
+ rect_right + stride_from * y * 4,
+ };
+ memcpy(to, from[i], sizeof(float) * 4 * stride_from);
+ i = !i;
+ }
+ break;
+ }
+ case S3D_INTERLACE_COLUMN:
+ {
+ for (y = 0; y < height; y++) {
+ float *to = rect_to + stride_to * y * 4;
+ const float *from[2] = {
+ rect_left + stride_from * y * 4,
+ rect_right + stride_from * y * 4,
+ };
+
+ char i = (char) swap;
+ for (x = 0; x < width; x++, from[0] += 4, from[1] += 4, to += 4) {
+ copy_v4_v4(to, from[i]);
+ i = !i;
+ }
+ }
+ break;
+ }
+ case S3D_INTERLACE_CHECKERBOARD:
+ {
+ char i = (char) swap;
+ for (y = 0; y < height; y++) {
+ float *to = rect_to + stride_to * y * 4;
+ const float *from[2] = {
+ rect_left + stride_from * y * 4,
+ rect_right + stride_from * y * 4,
+ };
+ char j = i;
+ for (x = 0; x < width; x++, from[0] += 4, from[1] += 4, to += 4) {
+ copy_v4_v4(to, from[j]);
+ j = !j;
+ }
+ i = !i;
+ }
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+ }
+ else {
+ uchar *rect_to = r_ibuf->rect;
+ const uchar *rect_left = left->rect;
+ const uchar *rect_right= right->rect;
+
+ switch(mode) {
+ case S3D_INTERLACE_ROW:
+ {
+ char i = (char) swap;
+ for (y = 0; y < height; y++) {
+ uchar *to = rect_to + stride_to * y * 4;
+ const uchar *from[2] = {
+ rect_left + stride_from * y * 4,
+ rect_right + stride_from * y * 4,
+ };
+ memcpy(to, from[i], sizeof(uchar) * 4 * stride_from);
+ i = !i;
+ }
+ break;
+ }
+ case S3D_INTERLACE_COLUMN:
+ {
+ for (y = 0; y < height; y++) {
+ uchar *to = rect_to + stride_to * y * 4;
+ const uchar *from[2] = {
+ rect_left + stride_from * y * 4,
+ rect_right + stride_from * y * 4,
+ };
+ char i = (char) swap;
+ for (x = 0; x < width; x++, from[0] += 4, from[1] += 4, to += 4) {
+ copy_v4_v4_uchar(to, from[i]);
+ i = !i;
+ }
+ }
+ break;
+ }
+ case S3D_INTERLACE_CHECKERBOARD:
+ {
+ char i = (char) swap;
+ for (y = 0; y < height; y++) {
+ uchar *to = rect_to + stride_to * y * 4;
+ const uchar *from[2] = {
+ rect_left + stride_from * y * 4,
+ rect_right + stride_from * y * 4,
+ };
+ char j = i;
+ for (x = 0; x < width; x++, from[0] += 4, from[1] += 4, to += 4) {
+ copy_v4_v4_uchar(to, from[j]);
+ j = !j;
+ }
+ i = !i;
+ }
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+ }
}
static void imb_stereo_sidebyside(const bool UNUSED(crosseyed), ImBuf *UNUSED(left), ImBuf *UNUSED(right), bool UNUSED(is_float), ImBuf *UNUSED(r_ibuf))
@@ -151,7 +278,7 @@ static void imb_stereo_topbottom(ImBuf *left, ImBuf *right, bool is_float, ImBuf
float *to = rect_to + stride_to * y * 4;
float *from[2] = {
rect_left + stride_from * y * 4,
- rect_right + stride_from * y * 4,
+ rect_right + stride_from * y * 4,
};
memcpy(to, from[1], sizeof(float) * 4 * stride_from);
More information about the Bf-blender-cvs
mailing list