[Bf-blender-cvs] [3fbc866] multiview: Stereo output core - support rect/rectf instead of ImBufs only (for openexr multilayer)
Dalai Felinto
noreply at git.blender.org
Thu Aug 14 19:56:03 CEST 2014
Commit: 3fbc86607711cb3edf999f6262969fe24ede7650
Author: Dalai Felinto
Date: Wed Aug 13 23:25:47 2014 +0200
Branches: multiview
https://developer.blender.org/rB3fbc86607711cb3edf999f6262969fe24ede7650
Stereo output core - support rect/rectf instead of ImBufs only (for openexr multilayer)
===================================================================
M source/blender/imbuf/IMB_imbuf.h
M source/blender/imbuf/intern/stereoimbuf.c
===================================================================
diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h
index a6d45ed..d50b37f 100644
--- a/source/blender/imbuf/IMB_imbuf.h
+++ b/source/blender/imbuf/IMB_imbuf.h
@@ -563,6 +563,8 @@ const char *IMB_ffmpeg_last_error(void);
* \attention Defined in stereoimbuf.c
*/
void IMB_stereo_dimensions(const char mode, const size_t width, const size_t height, size_t *r_width, size_t *r_height);
+int *IMB_stereo_from_rect(struct ImageFormatData *im_format, const size_t x, const size_t y, const size_t channels, int *left, int *right);
+float *IMB_stereo_from_rectf(struct ImageFormatData *im_format, const size_t x, const size_t y, const size_t channels, float *left, float *right);
struct ImBuf *IMB_stereoImBuf(struct ImageFormatData *im_format, struct ImBuf *left, struct ImBuf *right);
#endif
diff --git a/source/blender/imbuf/intern/stereoimbuf.c b/source/blender/imbuf/intern/stereoimbuf.c
index 0f11e19..2f05cc8 100644
--- a/source/blender/imbuf/intern/stereoimbuf.c
+++ b/source/blender/imbuf/intern/stereoimbuf.c
@@ -29,10 +29,6 @@
* \ingroup imbuf
*/
-
-/* It's become a bit messy... Basically, only the IMB_ prefixed files
- * should remain. */
-
#include <stddef.h>
#include "IMB_imbuf.h"
@@ -55,11 +51,23 @@
#include "DNA_userdef_types.h"
#include "DNA_scene_types.h"
-static void imb_stereo_anaglyph(enum eStereoAnaglyphType mode, ImBuf *left, ImBuf *right, bool is_float, ImBuf *r_ibuf)
+/* prototypes */
+struct Stereo3DData;
+static void imb_stereo_doit(struct Stereo3DData *s3d_data, struct StereoDisplay *s3d);
+
+typedef struct Stereo3DData {
+ float *rectf[3];
+ uchar *rect[3];
+ size_t x, y, channels;
+ bool is_float;
+} Stereo3DData;
+
+static void imb_stereo_anaglyph(Stereo3DData *s3d, enum eStereoAnaglyphType mode)
{
int x, y;
- size_t width = r_ibuf->x;
- size_t height= r_ibuf->y;
+ size_t width = s3d->x;
+ size_t height= s3d->y;
+ const size_t channels = s3d->channels;
const int stride_from = width;
const int stride_to = width;
@@ -76,111 +84,210 @@ static void imb_stereo_anaglyph(enum eStereoAnaglyphType mode, ImBuf *left, ImBu
g = anaglyph_encoding[mode][1];
b = anaglyph_encoding[mode][2];
- if (is_float){
- float *rect_to = r_ibuf->rect_float;
- const float *rect_left = left->rect_float;
- const float *rect_right= right->rect_float;
-
- /* always RGBA input/output */
- 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,
- };
-
- for (x = 0; x < width; x++, from[0] += 4, from[1] += 4, to += 4) {
- to[0] = from[r][0];
- to[1] = from[g][1];
- to[2] = from[b][2];
- to[3] = MAX2(from[0][2], from[0][2]);
+ if (s3d->is_float){
+ float *rect_to = s3d->rectf[2];
+ float *rect_left = s3d->rectf[0];
+ float *rect_right= s3d->rectf[1];
+
+ if (channels == 3) {
+ for (y = 0; y < height; y++) {
+ float *to = rect_to + stride_to * y * 3;
+ float *from[2] = {
+ rect_left + stride_from * y * 3,
+ rect_right + stride_from * y * 3,
+ };
+
+ for (x = 0; x < width; x++, from[0] += 3, from[1] += 3, to += 3) {
+ to[0] = from[r][0];
+ to[1] = from[g][1];
+ to[2] = from[b][2];
+ }
+ }
+ }
+ else if (channels == 4) {
+ for (y = 0; y < height; y++) {
+ float *to = rect_to + stride_to * y * 4;
+ float *from[2] = {
+ 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) {
+ to[0] = from[r][0];
+ to[1] = from[g][1];
+ to[2] = from[b][2];
+ to[3] = MAX2(from[0][2], from[0][2]);
+ }
}
}
}
else {
- uchar *rect_to = (uchar *)r_ibuf->rect;
- const uchar *rect_left = (uchar *)left->rect;
- const uchar *rect_right= (uchar *)right->rect;
-
- /* always RGBA input/output */
- for (y = 0; y < height; y++) {
- uchar *to = rect_to + stride_to * y * 4;
- uchar *from[2] = {
- 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) {
- to[0] = from[r][0];
- to[1] = from[g][1];
- to[2] = from[b][2];
- to[3] = MAX2(from[0][2], from[0][2]);
+ uchar *rect_to = s3d->rect[2];
+ uchar *rect_left = s3d->rect[0];
+ uchar *rect_right= s3d->rect[1];
+
+ if (channels == 3) {
+ for (y = 0; y < height; y++) {
+ uchar *to = rect_to + stride_to * y * 3;
+ uchar *from[2] = {
+ rect_left + stride_from * y * 3,
+ rect_right + stride_from * y * 3,
+ };
+
+ for (x = 0; x < width; x++, from[0] += 3, from[1] += 3, to += 3) {
+ to[0] = from[r][0];
+ to[1] = from[g][1];
+ to[2] = from[b][2];
+ }
+ }
+ }
+ else if (channels == 4) {
+ for (y = 0; y < height; y++) {
+ uchar *to = rect_to + stride_to * y * 4;
+ uchar *from[2] = {
+ 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) {
+ to[0] = from[r][0];
+ to[1] = from[g][1];
+ to[2] = from[b][2];
+ to[3] = MAX2(from[0][2], from[0][2]);
+ }
}
}
}
}
-static void imb_stereo_interlace(enum eStereoInterlaceType mode, const bool swap, ImBuf *left, ImBuf *right, bool is_float, ImBuf *r_ibuf)
+static void imb_stereo_interlace(Stereo3DData *s3d, enum eStereoInterlaceType mode, const bool swap)
{
int x, y;
- size_t width = r_ibuf->x;
- size_t height= r_ibuf->y;
+ size_t width = s3d->x;
+ size_t height= s3d->y;
+ const size_t channels = s3d->channels;
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;
+ if (s3d->is_float){
+ float *rect_to = s3d->rectf[2];
+ const float *rect_left = s3d->rectf[0];
+ const float *rect_right= s3d->rectf[1];
switch(mode) {
case S3D_INTERLACE_ROW:
{
char i = (char) swap;
for (y = 0; y < height; y++) {
- float *to = rect_to + stride_to * y * 4;
+ float *to = rect_to + stride_to * y * channels;
const float *from[2] = {
- rect_left + stride_from * y * 4,
- rect_right + stride_from * y * 4,
+ rect_left + stride_from * y * channels,
+ rect_right + stride_from * y * channels,
};
- memcpy(to, from[i], sizeof(float) * 4 * stride_from);
+ memcpy(to, from[i], sizeof(float) * channels * 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;
+ if (channels == 1) {
+ for (y = 0; y < height; y++) {
+ float *to = rect_to + stride_to * y;
+ const float *from[2] = {
+ rect_left + stride_from * y,
+ rect_right + stride_from * y,
+ };
+
+ char i = (char) swap;
+ for (x = 0; x < width; x++, from[0] += 1, from[1] += 1, to += 1) {
+ to[0] = from[i][0];
+ i = !i;
+ }
+ }
+ }
+ else if (channels == 3) {
+ for (y = 0; y < height; y++) {
+ float *to = rect_to + stride_to * y * 3;
+ const float *from[2] = {
+ rect_left + stride_from * y * 3,
+ rect_right + stride_from * y * 3,
+ };
+
+ char i = (char) swap;
+ for (x = 0; x < width; x++, from[0] += 3, from[1] += 3, to += 3) {
+ copy_v3_v3(to, from[i]);
+ i = !i;
+ }
+ }
+ }
+ else if (channels == 4) {
+ for (y = 0; y < height; y++) {
+ float *to = rect_to + stride_to * y * channels;
+ const float *from[2] = {
+ rect_left + stride_from * y * channels,
+ rect_right + stride_from * y * channels,
+ };
+
+ 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;
+ if (channels == 1) {
+ char i = (char) swap;
+ for (y = 0; y < height; y++) {
+ float *to = rect_to + stride_to * y;
+ const float *from[2] = {
+ rect_left + stride_from * y,
+ rect_right + stride_from * y,
+ };
+ char j = i;
+ for (x = 0; x < width; x++, from[0] += 1, from[1] += 1, to += 1) {
+ to[0] = from[j][0];
+ j = !j;
+ }
+ i = !i;
+ }
+ }
+ else if (channels == 3) {
+ char i = (char) swap;
+ for (y = 0; y < height; y++) {
+ float *to = rect_to + stride_to * y * 3;
+ const float *from[2] = {
+ rect_left + stride_from * y * 3,
+ rect_right + stride_from * y * 3,
+ };
+ char j = i;
+ for (x = 0; x < width; x++, from[0] += 3, from[1] += 3, to += 3) {
+ copy_v3_v3(to, from[j]);
+ j = !j;
+ }
+ i = !i;
+ }
+ }
+ else if (channels == 4) {
+ 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;
}
- i = !i;
}
break;
}
@@ -191,56 +298,120 @@ static
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list