[Bf-blender-cvs] [6725532] multiview: Sequencer: show option to open multiview/stereo 3d movies/images, and pre-load them
Dalai Felinto
noreply at git.blender.org
Wed Nov 19 04:51:23 CET 2014
Commit: 6725532363654f1a57b791da0cefa008189b3d41
Author: Dalai Felinto
Date: Wed Nov 19 01:03:12 2014 -0200
Branches: multiview
https://developer.blender.org/rB6725532363654f1a57b791da0cefa008189b3d41
Sequencer: show option to open multiview/stereo 3d movies/images, and pre-load them
===================================================================
M source/blender/blenkernel/BKE_sequencer.h
M source/blender/blenkernel/intern/sequencer.c
M source/blender/editors/space_sequencer/sequencer_add.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h
index 47a02e3..0e5e674 100644
--- a/source/blender/blenkernel/BKE_sequencer.h
+++ b/source/blender/blenkernel/BKE_sequencer.h
@@ -41,6 +41,7 @@ struct MovieClip;
struct Scene;
struct Sequence;
struct SequenceModifierData;
+struct Stereo3dFormat;
struct Strip;
struct StripElem;
struct bSound;
@@ -350,6 +351,10 @@ typedef struct SeqLoadInfo {
int len; /* only for image strips */
char path[1024]; /* 1024 = FILE_MAX */
+ /* multiview */
+ char views_format;
+ struct Stereo3dFormat *stereo3d_format;
+
/* return values */
char name[64];
struct Sequence *seq_sound; /* for movie's */
diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c
index 09ca622..3a2c9bd 100644
--- a/source/blender/blenkernel/intern/sequencer.c
+++ b/source/blender/blenkernel/intern/sequencer.c
@@ -1353,15 +1353,14 @@ static double seq_rendersize_to_scale_factor(int size)
}
/* the number of files will vary according to the stereo format */
-static size_t seq_num_files(const SeqRenderData *context, Sequence *seq)
+static size_t seq_num_files(Scene *scene, char views_format)
{
- Scene *scene = context->scene;
const bool is_multiview = (scene->r.scemode & R_MULTIVIEW) != 0;
if (!is_multiview) {
return 1;
}
- else if (seq->views_format == R_IMF_VIEWS_STEREO_3D) {
+ else if (views_format == R_IMF_VIEWS_STEREO_3D) {
return 1;
}
/* R_IMF_VIEWS_INDIVIDUAL */
@@ -1395,18 +1394,22 @@ static void seq_open_anim_file(const SeqRenderData *context, Sequence *seq)
BLI_path_abs(dir, G.main->name);
}
- if (is_multiview) {
- size_t totfiles = seq_num_files(context, seq);
+ if (is_multiview && seq->views_format == R_IMF_VIEWS_INDIVIDUAL) {
+ size_t totfiles = seq_num_files(context->scene, seq->views_format);
char prefix[FILE_MAX] = {'\0'};
char *ext = NULL;
int i;
BKE_scene_view_get_prefix(context->scene, name, prefix, &ext);
+ if (prefix[0] == '\0')
+ goto monoview;
+
for (i = 0; i < totfiles; i++) {
const char *viewname = BKE_scene_render_view_name(&context->scene->r, i);
const char *suffix = BKE_scene_view_get_suffix(&context->scene->r, viewname);
char str[FILE_MAX] = {'\0'};
+
StripAnim *sanim = MEM_mallocN(sizeof(StripAnim), "Strip Anim");
BLI_addtail(&seq->anims, sanim);
@@ -1433,7 +1436,10 @@ static void seq_open_anim_file(const SeqRenderData *context, Sequence *seq)
}
}
else {
- StripAnim *sanim = MEM_mallocN(sizeof(StripAnim), "Strip Anim");
+ StripAnim *sanim;
+monoview:
+
+ sanim = MEM_mallocN(sizeof(StripAnim), "Strip Anim");
BLI_addtail(&seq->anims, sanim);
sanim->anim = openanim(name, IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0),
@@ -2828,7 +2834,7 @@ static ImBuf *do_render_strip_uncached(const SeqRenderData *context, Sequence *s
/* don't do anything */
}
else if (is_multiview) {
- size_t totfiles = seq_num_files(context, seq);
+ size_t totfiles = seq_num_files(context->scene, seq->views_format);
size_t totviews = BKE_scene_num_views(&context->scene->r);
struct ImBuf **ibufs;
char prefix[FILE_MAX] = {'\0'};
@@ -4579,6 +4585,11 @@ Sequence *BKE_sequencer_add_image_strip(bContext *C, ListBase *seqbasep, SeqLoad
strip->stripdata = MEM_callocN(seq->len * sizeof(StripElem), "stripelem");
BLI_strncpy(strip->dir, seq_load->path, sizeof(strip->dir));
+ if (seq_load->stereo3d_format)
+ *seq->stereo3d_format = *seq_load->stereo3d_format;
+
+ seq->views_format = seq_load->views_format;
+
seq_load_apply(scene, seq, seq_load);
return seq;
@@ -4667,30 +4678,85 @@ Sequence *BKE_sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoad
Strip *strip;
StripElem *se;
char colorspace[64] = "\0"; /* MAX_COLORSPACE_NAME */
+ size_t totfiles = seq_num_files(scene, seq_load->views_format);
+ bool is_multiview = (scene->r.scemode & R_MULTIVIEW) != 0;
+ int i;
- struct anim *an;
+ struct anim **anims = NULL;
BLI_strncpy(path, seq_load->path, sizeof(path));
BLI_path_abs(path, G.main->name);
- // XXX MV SEQ MOV
- an = openanim(path, IB_rect, 0, colorspace);
+ anims = MEM_callocN(sizeof(struct anim *) * totfiles, "Video files");
- if (an == NULL)
- return NULL;
+ if (is_multiview && (seq_load->views_format == R_IMF_VIEWS_INDIVIDUAL)) {
+ char prefix[FILE_MAX] = {'\0'};
+ char *ext = NULL;
+ size_t j = 0;
+
+ BKE_scene_view_get_prefix(scene, path, prefix, &ext);
+
+ if (prefix[0] == '\0')
+ goto monoview;
+
+ for (i = 0; i < totfiles; i++) {
+ const char *viewname = BKE_scene_render_view_name(&scene->r, i);
+ const char *suffix = BKE_scene_view_get_suffix(&scene->r, viewname);
+ char str[FILE_MAX] = {'\0'};
+
+ sprintf(str, "%s%s%s", prefix, suffix, ext);
+
+ anims[j] = openanim(str, IB_rect, 0, colorspace);
+ if (anims[j]) {
+ j++;
+ }
+ }
+
+ if (j == 0) {
+ MEM_freeN(anims);
+ return NULL;
+ }
+ }
+ else {
+monoview:
+ totfiles = 1;
+ anims[0] = openanim(path, IB_rect, 0, colorspace);
+
+ if (anims[0] == NULL) {
+ MEM_freeN(anims);
+ return NULL;
+ }
+ }
seq = BKE_sequence_alloc(seqbasep, seq_load->start_frame, seq_load->channel);
+
+ /* multiview settings */
+ if (seq_load->stereo3d_format) {
+ *seq->stereo3d_format = *seq_load->stereo3d_format;
+ seq->views_format = seq_load->views_format;
+ }
+
seq->type = SEQ_TYPE_MOVIE;
seq->blend_mode = SEQ_TYPE_CROSS; /* so alpha adjustment fade to the strip below */
- seq->anim = an;
- seq->anim_preseek = IMB_anim_get_preseek(an);
+ for (i = 0; i < totfiles; i++) {
+ if (anims[i]) {
+ StripAnim *sanim = MEM_mallocN(sizeof(StripAnim), "Strip Anim");
+ BLI_addtail(&seq->anims, sanim);
+ sanim->anim = anims[i];
+ }
+ else {
+ break;
+ }
+ }
+
+ seq->anim_preseek = IMB_anim_get_preseek(anims[0]);
BLI_strncpy(seq->name + 2, "Movie", SEQ_NAME_MAXSTR - 2);
BKE_sequence_base_unique_name_recursive(&scene->ed->seqbase, seq);
/* basic defaults */
seq->strip = strip = MEM_callocN(sizeof(Strip), "strip");
- seq->len = IMB_anim_get_duration(an, IMB_TC_RECORD_RUN);
+ seq->len = IMB_anim_get_duration(anims[0], IMB_TC_RECORD_RUN);
strip->us = 1;
BLI_strncpy(seq->strip->colorspace_settings.name, colorspace, sizeof(seq->strip->colorspace_settings.name));
@@ -4718,6 +4784,7 @@ Sequence *BKE_sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoad
/* can be NULL */
seq_load_apply(scene, seq, seq_load);
+ MEM_freeN(anims);
return seq;
}
diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c
index a94ce52..da8e318 100644
--- a/source/blender/editors/space_sequencer/sequencer_add.c
+++ b/source/blender/editors/space_sequencer/sequencer_add.c
@@ -62,6 +62,7 @@
#include "ED_sequencer.h"
#include "UI_view2d.h"
+#include "UI_interface.h"
#include "BKE_sound.h"
@@ -72,6 +73,10 @@
/* own include */
#include "sequencer_intern.h"
+typedef struct SequencerAddData {
+ ImageFormatData im_format;
+} SequencerAddData;
+
/* Generic functions, reused by add strip operators */
/* avoid passing multiple args and be more verbose */
@@ -224,6 +229,18 @@ static void seq_load_operator_info(SeqLoadInfo *seq_load, wmOperator *op)
}
RNA_PROP_END;
}
+
+ if ((prop = RNA_struct_find_property(op->ptr, "use_multiple_views")) && RNA_property_boolean_get(op->ptr, prop)) {
+ if (op->customdata) {
+ SequencerAddData *sad = op->customdata;
+ ImageFormatData *imf = &sad->im_format;
+
+ seq_load->views_format = imf->views_format;
+
+ /* operator custom data is always released after the SeqLoadInfo, no need to handle the memory here */
+ seq_load->stereo3d_format = &imf->stereo3d_format;
+ }
+ }
}
/**
@@ -575,6 +592,9 @@ static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoad
return OPERATOR_CANCELLED;
}
+ if (op->customdata)
+ MEM_freeN(op->customdata);
+
BKE_sequencer_sort(scene);
BKE_sequencer_update_muting(ed);
@@ -583,15 +603,40 @@ static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoad
return OPERATOR_FINISHED;
}
+/* add sequencer operators */
+static void sequencer_add_init(bContext *UNUSED(C), wmOperator *op)
+{
+ op->customdata = MEM_callocN(sizeof(SequencerAddData), __func__);
+}
+
+static void sequencer_add_cancel(bContext *UNUSED(C), wmOperator *op)
+{
+ if (op->customdata)
+ MEM_freeN(op->customdata);
+ op->customdata = NULL;
+}
+
+static bool sequencer_add_draw_check_prop(PointerRNA *UNUSED(ptr), PropertyRNA *prop)
+{
+ const char *prop_id = RNA_property_identifier(prop);
+
+ return !(STREQ(prop_id, "filepath") ||
+ STREQ(prop_id, "directory") ||
+ STREQ(prop_id, "filename")
+ );
+}
+
/* add movie operator */
static int sequencer_add_movie_strip_exec(bContext *C, wmOperator *op)
{
return sequencer_add_generic_strip_exec(C, op, BKE_sequencer_add_movie_strip);
}
-
static int sequencer_add_movie_strip_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
+ PropertyRNA *prop;
+ Scene *scene = CTX_data_scene(C);
+
/* This is for drag and drop */
if ((RNA_struct_property_is_set(op->ptr, "files") && RNA_collection_length(op->ptr, "files")) ||
RNA_struct_property_is_set(op->ptr, "filepath"))
@@ -601,6 +646,12 @@ static int sequencer_add_movie_strip_invoke(bContext *C, wmOperator *op, const w
}
sequencer_generic_invoke_xy__internal(C, op, 0, SEQ_TYPE_MOVIE);
+
+ sequencer_add_init(C, op);
+
+ /* show multiview save options only if scene has multiviews */
+ prop = RNA_struct_find_property(op->ptr, "use_multiple_views");
+ RNA_property_boolean_set(op->ptr, prop, (scene->r.scemode & R_MULTIVIEW));
WM_event_add_fileselect(C, op);
return OPERATOR_RUNNING_MODAL;
@@ -608,6 +659,25 @@ static int sequencer_add_movie_strip_invoke(bContext *C, wmOperator *op, const w
//return sequencer_add_movie_strip_exec(C, op);
}
+static void sequencer_add_draw(bContext *UNUSED(C), wmOperator *op)
+{
+ uiLayout *layout = op->layout;
+ SequencerAddData *sad = op->customdata;
+ ImageFormatData *imf = &sad->im_format;
+ PointerRNA imf_ptr, pt
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list