Commit: 327007e9335339fb9110da62b17ac50e55aee132
Author: Dalai Felinto
Date:   Tue Aug 26 19:02:56 2014 +0200
Branches: multiview
https://developer.blender.org/rB327007e9335339fb9110da62b17ac50e55aee132

New Stereo Output option: Squeezed Frame

So now top-bottom and side-by-side can be saved as squeezed (default) or 
unqueezed (old).

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

M       source/blender/editors/space_image/image_buttons.c
M       source/blender/imbuf/IMB_imbuf.h
M       source/blender/imbuf/intern/stereoimbuf.c
M       source/blender/makesdna/DNA_userdef_types.h
M       source/blender/makesrna/intern/rna_scene.c
M       source/blender/render/intern/source/pipeline.c
M       source/blender/render/intern/source/render_result.c

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

diff --git a/source/blender/editors/space_image/image_buttons.c 
b/source/blender/editors/space_image/image_buttons.c
index f996823..9913c55 100644
--- a/source/blender/editors/space_image/image_buttons.c
+++ b/source/blender/editors/space_image/image_buttons.c
@@ -1069,6 +1069,11 @@ void uiTemplateImageViews(uiLayout *layout, PointerRNA 
*imfptr)
                case S3D_DISPLAY_SIDEBYSIDE:
                {
                        uiItemR(col, &stereo_output_ptr, 
"use_sidebyside_crosseyed", 0, NULL, ICON_NONE);
+                       /* fall-through */
+               }
+               case S3D_DISPLAY_TOPBOTTOM:
+               {
+                       uiItemR(col, &stereo_output_ptr, "use_squeezed_frame", 
0, NULL, ICON_NONE);
                        break;
                }
        }
diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h
index d50b37f..14da688 100644
--- a/source/blender/imbuf/IMB_imbuf.h
+++ b/source/blender/imbuf/IMB_imbuf.h
@@ -562,7 +562,7 @@ 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);
+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);
 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);
diff --git a/source/blender/imbuf/intern/stereoimbuf.c 
b/source/blender/imbuf/intern/stereoimbuf.c
index f5c93c5..6251683 100644
--- a/source/blender/imbuf/intern/stereoimbuf.c
+++ b/source/blender/imbuf/intern/stereoimbuf.c
@@ -518,7 +518,7 @@ static void imb_stereo_topbottom(Stereo3DData *s3d)
        }
 }
 
-void IMB_stereo_dimensions(const char mode, const size_t width, const size_t 
height, size_t *r_width, size_t *r_height)
+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)
 {
        switch (mode) {
                case S3D_DISPLAY_BLURAY:
@@ -528,14 +528,14 @@ void IMB_stereo_dimensions(const char mode, const size_t 
width, const size_t hei
                }
                case S3D_DISPLAY_SIDEBYSIDE:
                {
-                       *r_width = width * 2;
+                       *r_width = is_squeezed ? width : width * 2;
                        *r_height = height;
                        break;
                }
                case S3D_DISPLAY_TOPBOTTOM:
                {
                        *r_width = width;
-                       *r_height = height * 2;
+                       *r_height = is_squeezed ? height : height * 2;
                        break;
                }
                case S3D_DISPLAY_ANAGLYPH:
@@ -549,6 +549,72 @@ void IMB_stereo_dimensions(const char mode, const size_t 
width, const size_t hei
        }
 }
 
+/**************************** squeeze frame 
****************************************/
+
+static void imb_stereo_squeeze_ImBuf(ImBuf *ibuf, StereoDisplay *s3d, const 
size_t x, const size_t y)
+{
+       if (ELEM(s3d->display_mode, S3D_DISPLAY_SIDEBYSIDE, 
S3D_DISPLAY_TOPBOTTOM) == false)
+               return;
+
+       if ((s3d->flag & S3D_UNSQUEEZED_FRAME))
+               return;
+
+       IMB_scaleImBuf_threaded(ibuf, x, y);
+}
+
+static void imb_stereo_squeeze_rectf(float *rectf, StereoDisplay *s3d, const 
size_t x, const size_t y, const size_t channels)
+{
+       ImBuf *ibuf;
+       size_t width, height;
+
+       if (ELEM(s3d->display_mode, S3D_DISPLAY_SIDEBYSIDE, 
S3D_DISPLAY_TOPBOTTOM) == false)
+               return;
+
+       if ((s3d->flag & S3D_UNSQUEEZED_FRAME))
+               return;
+
+       /* creates temporary imbuf to store the rectf */
+       IMB_stereo_dimensions(s3d->display_mode, false, x, y, &width, &height);
+       ibuf = IMB_allocImBuf(width, height, channels, IB_rectfloat);
+
+       IMB_buffer_float_from_float(
+                  ibuf->rect_float, rectf, channels,
+                  IB_PROFILE_LINEAR_RGB, IB_PROFILE_LINEAR_RGB, false,
+                  width, height, width, width);
+
+       IMB_scaleImBuf_threaded(ibuf, x, y);
+       rectf = MEM_dupallocN(ibuf->rect_float);
+       IMB_freeImBuf(ibuf);
+}
+
+static void imb_stereo_squeeze_rect(int *rect, StereoDisplay *s3d, const 
size_t x, const size_t y, const size_t channels)
+{
+       ImBuf *ibuf;
+       size_t width, height;
+
+       if (ELEM(s3d->display_mode, S3D_DISPLAY_SIDEBYSIDE, 
S3D_DISPLAY_TOPBOTTOM) == false)
+               return;
+
+       if ((s3d->flag & S3D_UNSQUEEZED_FRAME))
+               return;
+
+       /* creates temporary imbuf to store the rectf */
+       IMB_stereo_dimensions(s3d->display_mode, false, x, y, &width, &height);
+       ibuf = IMB_allocImBuf(width, height, channels, IB_rect);
+
+       IMB_buffer_byte_from_byte(
+                   (unsigned char *)ibuf->rect, (unsigned char *)rect,
+                   IB_PROFILE_SRGB, IB_PROFILE_SRGB, false,
+                   width, height, width, width);
+
+       IMB_scaleImBuf_threaded(ibuf, x, y);
+       rect = MEM_dupallocN(ibuf->rect);
+       IMB_freeImBuf(ibuf);
+}
+
+
+/*************************** preparing to call the functions 
**************************/
+
 static void imb_stereo_data_initialize(Stereo3DData *s3d_data, ImageFormatData 
*im_format,
                                        const size_t x, const size_t y, const 
size_t channels,
                                        int *left_rect, int *right_rect, int 
*r_rect,
@@ -572,11 +638,12 @@ int *IMB_stereo_from_rect(ImageFormatData *im_format, 
const size_t x, const size
        Stereo3DData s3d_data = {{NULL}};
        size_t width, height;
 
-       IMB_stereo_dimensions(im_format->stereo_output.display_mode, x, y, 
&width, &height);
+       IMB_stereo_dimensions(im_format->stereo_output.display_mode, false, x, 
y, &width, &height);
        r_rect = MEM_mallocN(channels * sizeof(int) * width * height, __func__);
 
        imb_stereo_data_initialize(&s3d_data, im_format, x, y, channels, left, 
right, r_rect, NULL, NULL, NULL);
        imb_stereo_doit(&s3d_data, &im_format->stereo_output);
+       imb_stereo_squeeze_rect(r_rect, &im_format->stereo_output, x, y, 
channels);
 
        return r_rect;
 }
@@ -587,11 +654,12 @@ float *IMB_stereo_from_rectf(ImageFormatData *im_format, 
const size_t x, const s
        Stereo3DData s3d_data = {{NULL}};
        size_t width, height;
 
-       IMB_stereo_dimensions(im_format->stereo_output.display_mode, x, y, 
&width, &height);
+       IMB_stereo_dimensions(im_format->stereo_output.display_mode, false, x, 
y, &width, &height);
        r_rectf = MEM_mallocN(channels * sizeof(float) * width * height, 
__func__);
 
        imb_stereo_data_initialize(&s3d_data, im_format, x, y, channels, NULL, 
NULL, NULL, left, right, r_rectf);
        imb_stereo_doit(&s3d_data, &im_format->stereo_output);
+       imb_stereo_squeeze_rectf(r_rectf, &im_format->stereo_output, x, y, 
channels);
 
        return r_rectf;
 }
@@ -604,14 +672,16 @@ ImBuf *IMB_stereoImBuf(ImageFormatData *im_format, ImBuf 
*left, ImBuf *right)
        size_t width, height;
        const bool is_float = im_format->depth > 8;
 
-       IMB_stereo_dimensions(im_format->stereo_output.display_mode, left->x, 
left->y, &width, &height);
+       IMB_stereo_dimensions(im_format->stereo_output.display_mode, false, 
left->x, left->y, &width, &height);
        r_ibuf = IMB_allocImBuf(width, height, left->planes, (is_float ? 
IB_rectfloat : IB_rect));
 
        imb_stereo_data_initialize(&s3d_data, im_format, left->x, left->y, 4,
-                                        (int *)left->rect, (int *)right->rect, 
(int *)r_ibuf->rect,
-                                        left->rect_float, right->rect_float, 
r_ibuf->rect_float);
+                                (int *)left->rect, (int *)right->rect, (int 
*)r_ibuf->rect,
+                                left->rect_float, right->rect_float, 
r_ibuf->rect_float);
 
        imb_stereo_doit(&s3d_data, &im_format->stereo_output);
+       imb_stereo_squeeze_ImBuf(r_ibuf, &im_format->stereo_output, left->x, 
left->y);
+
        return r_ibuf;
 }
 
diff --git a/source/blender/makesdna/DNA_userdef_types.h 
b/source/blender/makesdna/DNA_userdef_types.h
index 3c9d357..f098cba 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -879,6 +879,7 @@ typedef enum eStereoDisplayMode {
 typedef enum eStereoFlag {
        S3D_INTERLACE_SWAP        = (1 << 0),
        S3D_SIDEBYSIDE_CROSSEYED  = (1 << 1),
+       S3D_UNSQUEEZED_FRAME      = (1 << 2),
 } eStereoFlag;
 
 /* StereoDisplay.anaglyph_type */
diff --git a/source/blender/makesrna/intern/rna_scene.c 
b/source/blender/makesrna/intern/rna_scene.c
index 260bfe6..c7bba17 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -4089,6 +4089,10 @@ static void 
rna_def_image_format_stereo_output(BlenderRNA *brna)
        prop = RNA_def_property(srna, "use_sidebyside_crosseyed", PROP_BOOLEAN, 
PROP_BOOLEAN);
        RNA_def_property_boolean_sdna(prop, NULL, "flag", 
S3D_SIDEBYSIDE_CROSSEYED);
        RNA_def_property_ui_text(prop, "Cross-Eyed", "Right eye should see left 
image and vice-versa");
+
+       prop = RNA_def_property(srna, "use_squeezed_frame", PROP_BOOLEAN, 
PROP_BOOLEAN);
+       RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", 
S3D_UNSQUEEZED_FRAME);
+       RNA_def_property_ui_text(prop, "Squeezed Frame", "Combine both views in 
a squeezed image");
 }
 
 /* use for render output and image save operator,
diff --git a/source/blender/render/intern/source/pipeline.c 
b/source/blender/render/intern/source/pipeline.c
index c286007..fdf6743 100644
--- a/source/blender/render/intern/source/pipeline.c
+++ b/source/blender/render/intern/source/pipeline.c
@@ -3303,7 +3303,7 @@ static void get_videos_dimensions(Render *re, RenderData 
*rd, size_t *r_width, s
        if ((rd->scemode & R_MULTIVIEW) &&
            rd->im_format.views_output == R_IMF_VIEWS_STEREO_3D)
        {
-               IMB_stereo_dimensions(rd->im_format.stereo_output.display_mode, 
width, height, r_width, r_height);
+               IMB_stereo_dimensions(rd->im_format.stereo_output.display_mode, 
((rd->im_format.stereo_output.flag & S3D_UNSQUEEZED_FRAME) == 0), width, 
height, r_width, r_height);
        }
        else {
                *r_width = width;
diff --git a/source/blender/render/intern/source/render_result.c 
b/source/blender/render/intern/source/render_result.c
index dface91..6447c64 100644
--- a/source/blender/render/intern/source/render_result.c
+++ b/source/blender/render/intern/source/render_result.c
@@ -1074,7 +1074,7 @@ bool RE_WriteRenderResult(ReportList *reports, 
RenderResult *rr, const char *fil
                rectf_stereo = MEM_mallocN(sizeof(float *) * ((totpasses / 2) + 
1), "RenderResult stereo pairs");
 
                IMB_exr_add_view(exrhandle, "")

@@ 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