Sequencer metadata:
authorAntony Riakiotakis <kalast@gmail.com>
Wed, 1 Jul 2015 13:23:09 +0000 (15:23 +0200)
committerAntony Riakiotakis <kalast@gmail.com>
Wed, 1 Jul 2015 13:23:21 +0000 (15:23 +0200)
Add option to render strip metadata to final result, bypassing current
scene metadata.

release/scripts/startup/bl_ui/properties_render.py
source/blender/blenkernel/BKE_image.h
source/blender/blenkernel/intern/image.c
source/blender/editors/render/render_opengl.c
source/blender/imbuf/intern/openexr/openexr_api.cpp
source/blender/makesdna/DNA_scene_types.h
source/blender/makesrna/intern/rna_scene.c
source/blender/render/intern/source/pipeline.c

index 0c68d98a8e1b429b3a162bb1a282410c1fdec6ae..88b7e0802cef11f001c2146dd254e88f30464eec 100644 (file)
@@ -343,7 +343,7 @@ class RENDER_PT_stamp(RenderButtonsPanel, Panel):
 
         rd = context.scene.render
 
-        layout.prop(rd, "use_stamp", text="Stamp Output")
+        layout.prop(rd, "use_stamp")
         col = layout.column()
         col.active = rd.use_stamp
         col.prop(rd, "stamp_font_size", text="Font Size")
@@ -374,6 +374,9 @@ class RENDER_PT_stamp(RenderButtonsPanel, Panel):
         sub = row.row()
         sub.active = rd.use_stamp_note
         sub.prop(rd, "stamp_note_text", text="")
+        if rd.use_sequencer:
+            layout.label("Sequencer")
+            layout.prop(rd, "use_stamp_strip_meta")
 
 
 class RENDER_PT_output(RenderButtonsPanel, Panel):
index facf3cf2103082a329dd6e80d43732dc8393e984..29b073f2a0fed61362a85a024f1d442db100ba63 100644 (file)
@@ -60,11 +60,12 @@ void    BKE_image_free_buffers(struct Image *image);
 /* call from library */
 void    BKE_image_free(struct Image *image);
 
-typedef void (StampCallback)(void *data, const char *propname, const char *propvalue);
+typedef void (StampCallback)(void *data, const char *propname, char *propvalue, int len);
 
-void    BKE_render_result_stamp_info(struct Scene *scene, struct Object *camera, struct RenderResult *rr);
+void    BKE_render_result_stamp_info(struct Scene *scene, struct Object *camera, struct RenderResult *rr, bool allocate_only);
 void    BKE_imbuf_stamp_info(struct RenderResult *rr, struct ImBuf *ibuf);
-void    BKE_stamp_info_callback(void *data, const struct StampData *stamp_data, StampCallback callback);
+void    BKE_stamp_info_from_imbuf(struct RenderResult *rr, struct ImBuf *ibuf);
+void    BKE_stamp_info_callback(void *data, struct StampData *stamp_data, StampCallback callback, bool noskip);
 void    BKE_image_stamp_buf(struct Scene *scene, struct Object *camera, unsigned char *rect, float *rectf, int width, int height, int channels);
 bool    BKE_imbuf_alpha_test(struct ImBuf *ibuf);
 int     BKE_imbuf_write_stamp(struct Scene *scene, struct RenderResult *rr, struct ImBuf *ibuf, const char *name, struct ImageFormatData *imf);
index df4bd6ff3abe13828691856ed1ae745d63133595..97e516baf7ae7bcf4ae5940f25e056ce8f36dbac 100644 (file)
@@ -2058,11 +2058,11 @@ void BKE_image_stamp_buf(
 #undef BUFF_MARGIN_Y
 }
 
-void BKE_render_result_stamp_info(Scene *scene, Object *camera, struct RenderResult *rr)
+void BKE_render_result_stamp_info(Scene *scene, Object *camera, struct RenderResult *rr, bool allocate_only)
 {
        struct StampData *stamp_data;
 
-       if (!(scene && scene->r.stamp & R_STAMP_ALL))
+       if (!(scene && (scene->r.stamp & R_STAMP_ALL)) && !allocate_only)
                return;
 
        if (!rr->stamp_data) {
@@ -2072,22 +2072,23 @@ void BKE_render_result_stamp_info(Scene *scene, Object *camera, struct RenderRes
                stamp_data = rr->stamp_data;
        }
 
-       stampdata(scene, camera, stamp_data, 0);
+       if (!allocate_only)
+               stampdata(scene, camera, stamp_data, 0);
 
        if (!rr->stamp_data) {
                rr->stamp_data = stamp_data;
        }
 }
 
-void BKE_stamp_info_callback(void *data, const struct StampData *stamp_data, StampCallback callback)
+void BKE_stamp_info_callback(void *data, struct StampData *stamp_data, StampCallback callback, bool noskip)
 {
        if (!callback || !stamp_data) {
                return;
        }
 
 #define CALL(member, value_str) \
-       if (stamp_data->member[0]) { \
-               callback(data, value_str, stamp_data->member); \
+       if (noskip || stamp_data->member[0]) { \
+               callback(data, value_str, stamp_data->member, sizeof(stamp_data->member)); \
        } ((void)0)
 
        CALL(file, "File");
@@ -2106,18 +2107,29 @@ void BKE_stamp_info_callback(void *data, const struct StampData *stamp_data, Sta
 }
 
 /* wrap for callback only */
-static void metadata_change_field(void *data, const char *propname, const char *propvalue)
+static void metadata_change_field(void *data, const char *propname, char *propvalue, int UNUSED(len))
 {
        IMB_metadata_change_field(data, propname, propvalue);
 }
 
+static void metadata_get_field(void *data, const char *propname, char *propvalue, int len)
+{
+       IMB_metadata_get_field(data, propname, propvalue, len);
+}
+
 void BKE_imbuf_stamp_info(RenderResult *rr, struct ImBuf *ibuf)
 {
        struct StampData *stamp_data = rr->stamp_data;
 
-       BKE_stamp_info_callback(ibuf, stamp_data, metadata_change_field);
+       BKE_stamp_info_callback(ibuf, stamp_data, metadata_change_field, false);
 }
 
+void BKE_stamp_info_from_imbuf(RenderResult *rr, struct ImBuf *ibuf)
+{
+       struct StampData *stamp_data = rr->stamp_data;
+
+       BKE_stamp_info_callback(ibuf, stamp_data, metadata_get_field, true);
+}
 
 bool BKE_imbuf_alpha_test(ImBuf *ibuf)
 {
index 5c69748e423917765f4d9bad84421d29ca34d3ef..c718dfa922933468cf9bce14eb326ac44880e792 100644 (file)
@@ -240,10 +240,10 @@ static void screen_opengl_views_setup(OGLRender *oglrender)
        /* will only work for non multiview correctly */
        if (v3d) {
                camera = BKE_camera_multiview_render(oglrender->scene, v3d->camera, "new opengl render view");
-               BKE_render_result_stamp_info(oglrender->scene, camera, rr);
+               BKE_render_result_stamp_info(oglrender->scene, camera, rr, false);
        }
        else {
-               BKE_render_result_stamp_info(oglrender->scene, oglrender->scene->camera, rr);
+               BKE_render_result_stamp_info(oglrender->scene, oglrender->scene->camera, rr, false);
        }
 
        RE_ReleaseResult(oglrender->re);
@@ -492,7 +492,7 @@ static void screen_opengl_render_write(OGLRender *oglrender)
                &scene->r.im_format, (scene->r.scemode & R_EXTENSION) != 0, false, NULL);
 
        /* write images as individual images or stereo */
-       BKE_render_result_stamp_info(scene, scene->camera, rr);
+       BKE_render_result_stamp_info(scene, scene->camera, rr, false);
        ok = RE_WriteRenderViewsImage(oglrender->reports, rr, scene, false, name);
 
        RE_ReleaseResultImage(oglrender->re);
@@ -815,7 +815,7 @@ static bool screen_opengl_render_anim_step(bContext *C, wmOperator *op)
                }
        }
        else {
-               BKE_render_result_stamp_info(scene, scene->camera, rr);
+               BKE_render_result_stamp_info(scene, scene->camera, rr, false);
                ok = RE_WriteRenderViewsImage(op->reports, rr, scene, true, name);
                if (ok) {
                        printf("Saved: %s", name);
index 44b7fbf6315cc98823e3fb497c54015bf26945f2..6bb1f0cd0d3c94778ec8f7950f6cebb72addfbf7 100644 (file)
@@ -364,7 +364,7 @@ static void openexr_header_metadata(Header *header, struct ImBuf *ibuf)
                addXDensity(*header, ibuf->ppm[0] / 39.3700787); /* 1 meter = 39.3700787 inches */
 }
 
-static void openexr_header_metadata_callback(void *data, const char *propname, const char *prop)
+static void openexr_header_metadata_callback(void *data, const char *propname, char *prop, int UNUSED(len))
 {
        Header *header = (Header *)data;
        header->insert(propname, StringAttribute(prop));
@@ -860,7 +860,7 @@ int IMB_exr_begin_write(void *handle, const char *filename, int width, int heigh
        }
 
        openexr_header_compression(&header, compress);
-       BKE_stamp_info_callback(&header, stamp, openexr_header_metadata_callback);
+       BKE_stamp_info_callback(&header, const_cast<StampData *>(stamp), openexr_header_metadata_callback, false);
        /* header.lineOrder() = DECREASING_Y; this crashes in windows for file read! */
 
        imb_exr_type_by_channels(header.channels(), *data->multiView, &is_singlelayer, &is_multilayer, &is_multiview);
index b3d6745512de47df500894de29a2fbdc320f7bce..47fd1a4e07c2856a68d7e9ce33fda451fc98e71f 100644 (file)
@@ -1562,6 +1562,7 @@ typedef struct Scene {
 #define R_STAMP_SEQSTRIP       0x0200
 #define R_STAMP_RENDERTIME     0x0400
 #define R_STAMP_CAMERALENS     0x0800
+#define R_STAMP_STRIPMETA      0x1000
 #define R_STAMP_ALL (R_STAMP_TIME|R_STAMP_FRAME|R_STAMP_DATE|R_STAMP_CAMERA|R_STAMP_SCENE| \
                      R_STAMP_NOTE|R_STAMP_MARKER|R_STAMP_FILENAME|R_STAMP_SEQSTRIP|        \
                      R_STAMP_RENDERTIME|R_STAMP_CAMERALENS)
index bc05b37c9e4c62ef1cf55875fccfae2db1853211..231032063878e77ce88fcb3626deda2f52894a0b 100644 (file)
@@ -5685,9 +5685,14 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
 
        prop = RNA_def_property(srna, "use_stamp", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "stamp", R_STAMP_DRAW);
-       RNA_def_property_ui_text(prop, "Render Stamp", "Render the stamp info text in the rendered image");
+       RNA_def_property_ui_text(prop, "Stamp Output", "Render the stamp info text in the rendered image");
        RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-       
+
+       prop = RNA_def_property(srna, "use_stamp_strip_meta", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "stamp", R_STAMP_STRIPMETA);
+       RNA_def_property_ui_text(prop, "Strip Metadata", "Render the metadata of the strip for sequencer");
+       RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
+
        prop = RNA_def_property(srna, "stamp_font_size", PROP_INT, PROP_NONE);
        RNA_def_property_int_sdna(prop, NULL, "stamp_font_id");
        RNA_def_property_range(prop, 8, 64);
index c939c697f1c527dd9527e73cd6b4d4f4960596df..31efdb95ac186cb412cccb11be0e57e97c620b92 100644 (file)
@@ -2617,6 +2617,7 @@ static void do_render_seq(Render *re)
 
                if (out) {
                        ibuf_arr[view_id] = IMB_dupImBuf(out);
+                       IMB_metadata_copy(ibuf_arr[view_id], out);
                        IMB_freeImBuf(out);
                        BKE_sequencer_imbuf_from_sequencer_space(re->scene, ibuf_arr[view_id]);
                }
@@ -2639,6 +2640,12 @@ static void do_render_seq(Render *re)
                        /* copy ibuf into combined pixel rect */
                        render_result_rect_from_ibuf(rr, &re->r, ibuf_arr[view_id], view_id);
 
+                       if (ibuf_arr[view_id]->metadata && (re->r.stamp & R_STAMP_STRIPMETA)) {
+                               /* ensure render stamp info first */
+                               BKE_render_result_stamp_info(NULL, NULL, rr, true);
+                               BKE_stamp_info_from_imbuf(rr, ibuf_arr[view_id]);
+                       }
+
                        if (recurs_depth == 0) { /* with nested scenes, only free on toplevel... */
                                Editing *ed = re->scene->ed;
                                if (ed)
@@ -2678,6 +2685,7 @@ static void do_render_seq(Render *re)
 static void do_render_all_options(Render *re)
 {
        Object *camera;
+       bool render_seq = false;
 
        re->current_scene_update(re->suh, re->scene);
 
@@ -2693,8 +2701,10 @@ static void do_render_all_options(Render *re)
        }
        else if (RE_seq_render_active(re->scene, &re->r)) {
                /* note: do_render_seq() frees rect32 when sequencer returns float images */
-               if (!re->test_break(re->tbh))
+               if (!re->test_break(re->tbh)) {
                        do_render_seq(re);
+                       render_seq = true;
+               }
                
                re->stats_draw(re->sdh, &re->i);
                re->display_update(re->duh, re->result, NULL);
@@ -2714,7 +2724,9 @@ static void do_render_all_options(Render *re)
        
        /* save render result stamp if needed */
        camera = RE_GetCamera(re);
-       BKE_render_result_stamp_info(re->scene, camera, re->result);
+       /* sequence rendering should have taken care of that already */
+       if (!(render_seq && (re->r.stamp & R_STAMP_STRIPMETA)))
+               BKE_render_result_stamp_info(re->scene, camera, re->result, false);
 
        /* stamp image info here */
        if ((re->r.stamp & R_STAMP_ALL) && (re->r.stamp & R_STAMP_DRAW)) {