Commit: 14da4996ccfbb8d6e6b4297766c1ecc7c278b59e
Author: Dalai Felinto
Date:   Mon Sep 8 05:48:10 2014 +0200
Branches: multiview
https://developer.blender.org/rB14da4996ccfbb8d6e6b4297766c1ecc7c278b59e

Import of all stereo encoded formats (anaglyph, interlace, top-bottom, ...)

This is supported at the moment for single-layer formats only. It works
fine though. The user must be aware that some formats are
highly-destructive and won't never be recovered 1:1 (e.g., interlace and
anaglyph)

===================================================================

M       source/blender/blenkernel/intern/image.c
M       source/blender/blenkernel/intern/scene.c
M       source/blender/imbuf/IMB_imbuf.h
M       source/blender/imbuf/intern/stereoimbuf.c
M       source/blender/render/intern/source/render_result.c

===================================================================

diff --git a/source/blender/blenkernel/intern/image.c 
b/source/blender/blenkernel/intern/image.c
index 3abdb6d..7d97087 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -2764,12 +2764,8 @@ static ImBuf *image_load_sequence_file(Image *ima, 
ImageUser *iuser, int frame)
                        ima->ok = 0;
        }
 
-       if (ima->views_format == R_IMF_VIEWS_STEREO_3D) {
-               /** XXX MV S3D LOAD STEREO IMAGES
-                 * this will mean we will use ibuf[0] and make ibuf[0] = left, 
ibuf[1] = right
-                 * so from that point on we use totviews instead of totfiles 
for ibufs
-                 */
-       }
+       if ((ima->flag & IMA_IS_STEREO) && ima->views_format == 
R_IMF_VIEWS_STEREO_3D)
+               IMB_ImBufFromStereo(ima->stereo3d_format, &ibuf[0], &ibuf[1]);
 
        if (assign) {
                if (!is_multiview)
@@ -2988,12 +2984,8 @@ static ImBuf *image_load_image_file(Image *ima, 
ImageUser *iuser, int cfra)
                        ima->ok = 0;
        }
 
-       if (ima->views_format == R_IMF_VIEWS_STEREO_3D) {
-               /** XXX MV S3D LOAD STEREO IMAGES
-                 * this will mean we will use ibuf[0] and make ibuf[0] = left, 
ibuf[1] = right
-                 * so from that point on we use totviews instead of totfiles 
for ibufs
-                 */
-       }
+       if ((ima->flag & IMA_IS_STEREO) && ima->views_format == 
R_IMF_VIEWS_STEREO_3D)
+               IMB_ImBufFromStereo(ima->stereo3d_format, &ibuf[0], &ibuf[1]);
 
        if (assign) {
                if (!is_multiview)
diff --git a/source/blender/blenkernel/intern/scene.c 
b/source/blender/blenkernel/intern/scene.c
index 23b4c1a..2120644 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -2183,7 +2183,7 @@ size_t BKE_scene_view_get_id(const RenderData *rd, const 
char *viewname)
        SceneRenderView *srv;
        size_t nr;
 
-       if ((rd->scemode & R_MULTIVIEW) == 0)
+       if ((!rd) || (rd->scemode & R_MULTIVIEW) == 0)
                return 0;
 
        if ((!viewname) || (!viewname[0]))
@@ -2207,7 +2207,7 @@ void BKE_scene_videos_dimensions(const RenderData *rd, 
const size_t width, const
        if ((rd->scemode & R_MULTIVIEW) &&
            rd->im_format.views_format == R_IMF_VIEWS_STEREO_3D)
        {
-               
IMB_stereo_dimensions(rd->im_format.stereo3d_format.display_mode, 
((rd->im_format.stereo3d_format.flag & S3D_UNSQUEEZED_FRAME) == 0), width, 
height, r_width, r_height);
+               
IMB_stereo_write_dimensions(rd->im_format.stereo3d_format.display_mode, 
((rd->im_format.stereo3d_format.flag & S3D_UNSQUEEZED_FRAME) == 0), width, 
height, r_width, r_height);
        }
        else {
                *r_width = width;
diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h
index 14da688..d5305ef 100644
--- a/source/blender/imbuf/IMB_imbuf.h
+++ b/source/blender/imbuf/IMB_imbuf.h
@@ -91,6 +91,7 @@ struct ColorManagedDisplay;
  * \attention defined in DNA_scene_types.h
  */
 struct ImageFormatData;
+struct Stereo3dFormat;
 
 /**
  *
@@ -562,10 +563,11 @@ const char *IMB_ffmpeg_last_error(void);
  *
  * \attention Defined in stereoimbuf.c
  */
-void IMB_stereo_dimensions(const char mode, const bool is_squeezed, const 
size_t width, const size_t height, size_t *r_width, size_t *r_height);
+void IMB_stereo_write_dimensions(const char mode, const bool is_squeezed, 
const size_t width, const size_t height, size_t *r_width, size_t *r_height);
+void IMB_stereo_read_dimensions(const char mode, const bool is_squeezed, 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);
-
+void IMB_ImBufFromStereo(struct Stereo3dFormat *s3d, struct ImBuf **left, 
struct ImBuf **right);
 #endif
 
diff --git a/source/blender/imbuf/intern/stereoimbuf.c 
b/source/blender/imbuf/intern/stereoimbuf.c
index 5a951bd..d0eebe3 100644
--- a/source/blender/imbuf/intern/stereoimbuf.c
+++ b/source/blender/imbuf/intern/stereoimbuf.c
@@ -53,7 +53,8 @@
 
 /* prototypes */
 struct Stereo3DData;
-static void imb_stereo_doit(struct Stereo3DData *s3d_data, struct 
Stereo3dFormat *s3d);
+static void imb_stereo_write_doit(struct Stereo3DData *s3d_data, struct 
Stereo3dFormat *s3d);
+static void imb_stereo_read_doit(struct Stereo3DData *s3d_data, struct 
Stereo3dFormat *s3d);
 
 typedef struct Stereo3DData {
        float *rectf[3];
@@ -62,7 +63,7 @@ typedef struct Stereo3DData {
        bool is_float;
 } Stereo3DData;
 
-static void imb_stereo_anaglyph(Stereo3DData *s3d, enum eStereo3dAnaglyphType 
mode)
+static void imb_stereo_write_anaglyph(Stereo3DData *s3d, enum 
eStereo3dAnaglyphType mode)
 {
        int x, y;
        size_t width = s3d->x;
@@ -160,7 +161,7 @@ static void imb_stereo_anaglyph(Stereo3DData *s3d, enum 
eStereo3dAnaglyphType mo
        }
 }
 
-static void imb_stereo_interlace(Stereo3DData *s3d, enum 
eStereo3dInterlaceType mode, const bool swap)
+static void imb_stereo_write_interlace(Stereo3DData *s3d, enum 
eStereo3dInterlaceType mode, const bool swap)
 {
        int x, y;
        size_t width = s3d->x;
@@ -423,7 +424,8 @@ static void imb_stereo_interlace(Stereo3DData *s3d, enum 
eStereo3dInterlaceType
        }
 }
 
-static void imb_stereo_sidebyside(Stereo3DData *s3d, const bool crosseyed)
+/* stereo output (s3d->rectf[2]) is always unsqueezed */
+static void imb_stereo_write_sidebyside(Stereo3DData *s3d, const bool 
crosseyed)
 {
        int y;
        size_t width = s3d->x;
@@ -438,13 +440,12 @@ static void imb_stereo_sidebyside(Stereo3DData *s3d, 
const bool crosseyed)
 
        if (s3d->is_float){
                float *rect_to = s3d->rectf[2];
-               float *rect_left = s3d->rectf[0];
-               float *rect_right= s3d->rectf[1];
+               const float *rect_left = s3d->rectf[0];
+               const float *rect_right= s3d->rectf[1];
 
-               /* always RGBA input/output */
                for (y = 0; y < height; y++) {
                        float *to = rect_to + stride_to * y * channels;
-                       float *from[2] = {
+                       const float *from[2] = {
                            rect_left + stride_from * y * channels,
                            rect_right + stride_from * y * channels,
                        };
@@ -455,13 +456,12 @@ static void imb_stereo_sidebyside(Stereo3DData *s3d, 
const bool crosseyed)
        }
        else {
                uchar *rect_to = s3d->rect[2];
-               uchar *rect_left = s3d->rect[0];
-               uchar *rect_right= s3d->rect[1];
+               const uchar *rect_left = s3d->rect[0];
+               const uchar *rect_right= s3d->rect[1];
 
-               /* always RGBA input/output */
                for (y = 0; y < height; y++) {
                        uchar *to = rect_to + stride_to * y * channels;
-                       uchar *from[2] = {
+                       const uchar *from[2] = {
                            rect_left + stride_from * y * channels,
                            rect_right + stride_from * y * channels,
                        };
@@ -472,7 +472,8 @@ static void imb_stereo_sidebyside(Stereo3DData *s3d, const 
bool crosseyed)
        }
 }
 
-static void imb_stereo_topbottom(Stereo3DData *s3d)
+/* stereo output (s3d->rectf[2]) is always unsqueezed */
+static void imb_stereo_write_topbottom(Stereo3DData *s3d)
 {
        int y;
        size_t width = s3d->x;
@@ -484,41 +485,41 @@ static void imb_stereo_topbottom(Stereo3DData *s3d)
 
        if (s3d->is_float){
                float *rect_to = s3d->rectf[2];
-               float *rect_left = s3d->rectf[0];
-               float *rect_right= s3d->rectf[1];
+               const float *rect_left = s3d->rectf[0];
+               const float *rect_right= s3d->rectf[1];
 
-               /* always RGBA input/output */
                for (y = 0; y < height; y++) {
                        float *to = rect_to + stride_to * y * channels;
-                       float *from[2] = {
+                       const float *from[2] = {
                            rect_left + stride_from * y * channels,
                            rect_right + stride_from * y * channels,
                        };
 
                        memcpy(to, from[1], sizeof(float) * channels * 
stride_from);
-                       memcpy(to + channels * height * stride_to, from[0], 
sizeof(float) * channels * stride_from);
+                       memcpy(to + channels * height * stride_from, from[0], 
sizeof(float) * channels * stride_from);
                }
        }
        else {
                uchar *rect_to = s3d->rect[2];
-               uchar *rect_left = s3d->rect[0];
-               uchar *rect_right= s3d->rect[1];
+               const uchar *rect_left = s3d->rect[0];
+               const uchar *rect_right= s3d->rect[1];
 
-               /* always RGBA input/output */
                for (y = 0; y < height; y++) {
                        uchar *to = rect_to + stride_to * y * channels;
-                       uchar *from[2] = {
+                       const uchar *from[2] = {
                            rect_left + stride_from * y * channels,
                                rect_right + stride_from * y * channels,
                        };
 
                        memcpy(to, from[1], sizeof(uchar) * channels * 
stride_from);
-                       memcpy(to + channels * height * stride_to, from[0], 
sizeof(uchar) * channels * stride_from);
+                       memcpy(to + channels * height * stride_from, from[0], 
sizeof(uchar) * channels * stride_from);
                }
        }
 }
 
-void IMB_stereo_dimensions(const char mode, const bool is_squeezed, const 
size_t width, const size_t height, size_t *r_width, size_t *r_height)
+/**************************** dimension utils 
****************************************/
+
+void IMB_stereo_write_dimensions(const char mode, const bool is_squeezed, 
const size_t width, const size_t height, size_t *r_width, size_t *r_height)
 {
        switch (mode) {
                case S3D_DISPLAY_BLURAY:
@@ -549,7 +550,38 @@ void IMB_stereo_dimensions(const char mode, const bool 
is_squeezed, const size_t
        }
 }
 
-/**************************** squeeze frame 
****************************************/
+void IMB_stereo_read_dimensions(const char mode, const bool is_squeezed, const 
size_t width, const size_t height, size_t *r_width, size_t *r_height)
+{
+       switch (mode) {
+               case S3D_DISPLAY_BLURAY:
+               {
+                       //TODO need to find the dimensions, forgot how big the 
black bar has to be
+                       break;
+               }
+               case S3D_DISPLAY_SIDEBYSIDE:
+               {
+                       *r_width = is_squeezed ? width / 2 : width;
+                       *r_height = height;
+                       break;
+               }
+               case S3D_DISPLAY_TOPBOTTOM:
+               {
+                       *r_width = width;
+                       *r_height = is_squeezed ? height / 2 : height;
+                       break;
+               }
+               case S3D_DISPLAY_ANAGLYPH:
+               case S3D_DISPLAY_INTERLACE:
+               default:
+               {
+                       *r_width = width;
+                       *r_height = height;
+                       break;
+               }
+       }
+}
+
+/**************************** un/squeeze frame 
****************************************/
 
 static void imb_stereo_squeeze_ImBuf(ImBuf *ibuf, Stereo3dFormat *s3d, const 
size_t x, const size_t y)
 {
@@ -562,6 +594,17 @@ static void imb_stereo_squeeze_ImBuf(ImBuf *ibuf, 
Stereo3dFormat *s3d, const siz
        IMB_scaleImBuf_threaded(ibuf, x

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to