diff options
Diffstat (limited to 'source/blender/sequencer')
-rw-r--r-- | source/blender/sequencer/SEQ_sequencer.h | 3 | ||||
-rw-r--r-- | source/blender/sequencer/SEQ_time.h | 1 | ||||
-rw-r--r-- | source/blender/sequencer/SEQ_utils.h | 1 | ||||
-rw-r--r-- | source/blender/sequencer/intern/image_cache.c | 4 | ||||
-rw-r--r-- | source/blender/sequencer/intern/render.c | 29 | ||||
-rw-r--r-- | source/blender/sequencer/intern/sequencer.c | 44 | ||||
-rw-r--r-- | source/blender/sequencer/intern/strip_add.c | 16 | ||||
-rw-r--r-- | source/blender/sequencer/intern/strip_relations.c | 4 | ||||
-rw-r--r-- | source/blender/sequencer/intern/strip_time.c | 16 | ||||
-rw-r--r-- | source/blender/sequencer/intern/utils.c | 3 |
10 files changed, 74 insertions, 47 deletions
diff --git a/source/blender/sequencer/SEQ_sequencer.h b/source/blender/sequencer/SEQ_sequencer.h index 4f49b8cb58f..ad0815892f7 100644 --- a/source/blender/sequencer/SEQ_sequencer.h +++ b/source/blender/sequencer/SEQ_sequencer.h @@ -46,12 +46,11 @@ enum { /* seq_dupli' flags */ #define SEQ_DUPE_UNIQUE_NAME (1 << 0) -#define SEQ_DUPE_CONTEXT (1 << 1) -#define SEQ_DUPE_ANIM (1 << 2) #define SEQ_DUPE_ALL (1 << 3) /* otherwise only selected are copied */ #define SEQ_DUPE_IS_RECURSIVE_CALL (1 << 4) struct SequencerToolSettings *SEQ_tool_settings_init(void); +struct SequencerToolSettings *SEQ_tool_settings_ensure(struct Scene *scene); void SEQ_tool_settings_free(struct SequencerToolSettings *tool_settings); eSeqImageFitMethod SEQ_tool_settings_fit_method_get(struct Scene *scene); void SEQ_tool_settings_fit_method_set(struct Scene *scene, eSeqImageFitMethod fit_method); diff --git a/source/blender/sequencer/SEQ_time.h b/source/blender/sequencer/SEQ_time.h index 31549ff3994..67d3a2e5960 100644 --- a/source/blender/sequencer/SEQ_time.h +++ b/source/blender/sequencer/SEQ_time.h @@ -45,6 +45,7 @@ int SEQ_time_find_next_prev_edit(struct Scene *scene, void SEQ_time_update_sequence(struct Scene *scene, struct Sequence *seq); void SEQ_time_update_sequence_bounds(struct Scene *scene, struct Sequence *seq); int SEQ_time_cmp_time_startdisp(const void *a, const void *b); +bool SEQ_time_strip_intersects_frame(const struct Sequence *seq, const int timeline_frame); #ifdef __cplusplus } diff --git a/source/blender/sequencer/SEQ_utils.h b/source/blender/sequencer/SEQ_utils.h index 9d529089ffc..a4dc80d75db 100644 --- a/source/blender/sequencer/SEQ_utils.h +++ b/source/blender/sequencer/SEQ_utils.h @@ -61,6 +61,7 @@ int SEQ_recursive_apply(struct Sequence *seq, int (*apply_fn)(struct Sequence *, void *), void *arg); void SEQ_ensure_unique_name(struct Sequence *seq, struct Scene *scene); + #ifdef __cplusplus } #endif diff --git a/source/blender/sequencer/intern/image_cache.c b/source/blender/sequencer/intern/image_cache.c index a0c95c1c197..5ccf2a027b0 100644 --- a/source/blender/sequencer/intern/image_cache.c +++ b/source/blender/sequencer/intern/image_cache.c @@ -518,7 +518,7 @@ static size_t inflate_file_to_imbuf(ImBuf *ibuf, FILE *file, DiskCacheHeaderEntr static bool seq_disk_cache_read_header(FILE *file, DiskCacheHeader *header) { - fseek(file, 0, 0); + BLI_fseek(file, 0LL, SEEK_SET); const size_t num_items_read = fread(header, sizeof(*header), 1, file); if (num_items_read < 1) { BLI_assert(!"unable to read disk cache header"); @@ -540,7 +540,7 @@ static bool seq_disk_cache_read_header(FILE *file, DiskCacheHeader *header) static size_t seq_disk_cache_write_header(FILE *file, DiskCacheHeader *header) { - fseek(file, 0, 0); + BLI_fseek(file, 0LL, SEEK_SET); return fwrite(header, sizeof(*header), 1, file); } diff --git a/source/blender/sequencer/intern/render.c b/source/blender/sequencer/intern/render.c index f3cea273fdf..0bad66c3d7a 100644 --- a/source/blender/sequencer/intern/render.c +++ b/source/blender/sequencer/intern/render.c @@ -70,6 +70,7 @@ #include "SEQ_proxy.h" #include "SEQ_render.h" #include "SEQ_sequencer.h" +#include "SEQ_time.h" #include "SEQ_utils.h" #include "effects.h" @@ -273,15 +274,6 @@ static bool seq_is_effect_of(const Sequence *seq_effect, const Sequence *possibl * Order of applying these conditions is important. */ static bool must_render_strip(const Sequence *seq, SeqCollection *strips_under_playhead) { - /* Sound strips are not rendered. */ - if (seq->type == SEQ_TYPE_SOUND_RAM) { - return false; - } - /* Muted strips are not rendered. */ - if ((seq->flag & SEQ_MUTE) != 0) { - return false; - } - bool seq_have_effect_in_stack = false; Sequence *seq_iter; SEQ_ITERATOR_FOREACH (seq_iter, strips_under_playhead) { @@ -318,7 +310,7 @@ static SeqCollection *query_strips_at_frame(ListBase *seqbase, const int timelin SeqCollection *collection = SEQ_collection_create(); LISTBASE_FOREACH (Sequence *, seq, seqbase) { - if ((seq->startdisp <= timeline_frame) && (seq->enddisp > timeline_frame)) { + if (SEQ_time_strip_intersects_frame(seq, timeline_frame)) { SEQ_collection_append_strip(seq, collection); } } @@ -340,6 +332,15 @@ static void collection_filter_channel_up_to_incl(SeqCollection *collection, cons static void collection_filter_rendered_strips(SeqCollection *collection) { Sequence *seq; + + /* Remove sound strips and muted strips from collection, because these are not rendered. + * Function must_render_strip() don't have to check for these strips anymore. */ + SEQ_ITERATOR_FOREACH (seq, collection) { + if (seq->type == SEQ_TYPE_SOUND_RAM || (seq->flag & SEQ_MUTE) != 0) { + SEQ_collection_remove_strip(seq, collection); + } + } + SEQ_ITERATOR_FOREACH (seq, collection) { if (must_render_strip(seq, collection)) { continue; @@ -1124,8 +1125,6 @@ static ImBuf *seq_render_movie_strip_view(const SeqRenderData *context, ImBuf *ibuf = NULL; IMB_Proxy_Size psize = SEQ_rendersize_to_proxysize(context->preview_render_size); - IMB_anim_set_preseek(sanim->anim, seq->anim_preseek); - if (SEQ_can_use_proxy(context, seq, psize)) { /* Try to get a proxy image. * Movie proxies are handled by ImBuf module with exception of `custom file` setting. */ @@ -1237,6 +1236,12 @@ static ImBuf *seq_render_movie_strip(const SeqRenderData *context, } if (*r_is_proxy_image == false) { + if (sanim && sanim->anim) { + short fps_denom; + float fps_num; + IMB_anim_get_fps(sanim->anim, &fps_denom, &fps_num, true); + seq->strip->stripdata->orig_fps = fps_denom / fps_num; + } seq->strip->stripdata->orig_width = ibuf->x; seq->strip->stripdata->orig_height = ibuf->y; } diff --git a/source/blender/sequencer/intern/sequencer.c b/source/blender/sequencer/intern/sequencer.c index 55c14944a23..d0bc41062a1 100644 --- a/source/blender/sequencer/intern/sequencer.c +++ b/source/blender/sequencer/intern/sequencer.c @@ -313,6 +313,17 @@ SequencerToolSettings *SEQ_tool_settings_init(void) return tool_settings; } +SequencerToolSettings *SEQ_tool_settings_ensure(Scene *scene) +{ + SequencerToolSettings *tool_settings = scene->toolsettings->sequencer_tool_settings; + if (tool_settings == NULL) { + scene->toolsettings->sequencer_tool_settings = SEQ_tool_settings_init(); + tool_settings = scene->toolsettings->sequencer_tool_settings; + } + + return tool_settings; +} + void SEQ_tool_settings_free(SequencerToolSettings *tool_settings) { MEM_freeN(tool_settings); @@ -320,13 +331,13 @@ void SEQ_tool_settings_free(SequencerToolSettings *tool_settings) eSeqImageFitMethod SEQ_tool_settings_fit_method_get(Scene *scene) { - const SequencerToolSettings *tool_settings = scene->toolsettings->sequencer_tool_settings; + const SequencerToolSettings *tool_settings = SEQ_tool_settings_ensure(scene); return tool_settings->fit_method; } void SEQ_tool_settings_fit_method_set(Scene *scene, eSeqImageFitMethod fit_method) { - SequencerToolSettings *tool_settings = scene->toolsettings->sequencer_tool_settings; + SequencerToolSettings *tool_settings = SEQ_tool_settings_ensure(scene); tool_settings->fit_method = fit_method; } @@ -505,10 +516,6 @@ static Sequence *seq_dupli(const Scene *scene_src, if (dupe_flag & SEQ_DUPE_UNIQUE_NAME) { SEQ_sequence_base_unique_name_recursive(&scene_dst->ed->seqbase, seqn); } - - if (dupe_flag & SEQ_DUPE_ANIM) { - SEQ_dupe_animdata(scene_dst, seq->name + 2, seqn->name + 2); - } } return seqn; @@ -554,30 +561,21 @@ void SEQ_sequence_base_dupli_recursive(const Scene *scene_src, { Sequence *seq; Sequence *seqn = NULL; - Sequence *last_seq = SEQ_select_active_get((Scene *)scene_src); - /* always include meta's strips */ - int dupe_flag_recursive = dupe_flag | SEQ_DUPE_ALL | SEQ_DUPE_IS_RECURSIVE_CALL; for (seq = seqbase->first; seq; seq = seq->next) { seq->tmp = NULL; if ((seq->flag & SELECT) || (dupe_flag & SEQ_DUPE_ALL)) { seqn = seq_dupli(scene_src, scene_dst, nseqbase, seq, dupe_flag, flag); - if (seqn) { /*should never fail */ - if (dupe_flag & SEQ_DUPE_CONTEXT) { - seq->flag &= ~SEQ_ALLSEL; - seqn->flag &= ~(SEQ_LEFTSEL + SEQ_RIGHTSEL + SEQ_LOCK); - } - if (seq->type == SEQ_TYPE_META) { - SEQ_sequence_base_dupli_recursive( - scene_src, scene_dst, &seqn->seqbase, &seq->seqbase, dupe_flag_recursive, flag); - } + if (seqn == NULL) { + continue; /* Should never fail. */ + } - if (dupe_flag & SEQ_DUPE_CONTEXT) { - if (seq == last_seq) { - SEQ_select_active_set(scene_dst, seqn); - } - } + if (seq->type == SEQ_TYPE_META) { + /* Always include meta all strip children. */ + int dupe_flag_recursive = dupe_flag | SEQ_DUPE_ALL | SEQ_DUPE_IS_RECURSIVE_CALL; + SEQ_sequence_base_dupli_recursive( + scene_src, scene_dst, &seqn->seqbase, &seq->seqbase, dupe_flag_recursive, flag); } } } diff --git a/source/blender/sequencer/intern/strip_add.c b/source/blender/sequencer/intern/strip_add.c index 5ec2269b993..9e5afb45f2a 100644 --- a/source/blender/sequencer/intern/strip_add.c +++ b/source/blender/sequencer/intern/strip_add.c @@ -548,15 +548,24 @@ Sequence *SEQ_add_movie_strip(Main *bmain, Scene *scene, ListBase *seqbase, SeqL seq->blend_mode = SEQ_TYPE_CROSS; /* so alpha adjustment fade to the strip below */ + float video_fps = 0.0f; + if (anim_arr[0] != NULL) { - seq->anim_preseek = IMB_anim_get_preseek(anim_arr[0]); seq->len = IMB_anim_get_duration(anim_arr[0], IMB_TC_RECORD_RUN); IMB_anim_load_metadata(anim_arr[0]); + short fps_denom; + float fps_num; + + IMB_anim_get_fps(anim_arr[0], &fps_denom, &fps_num, true); + + video_fps = fps_denom / fps_num; + /* Adjust scene's frame rate settings to match. */ if (load_data->flags & SEQ_LOAD_MOVIE_SYNC_FPS) { - IMB_anim_get_fps(anim_arr[0], &scene->r.frs_sec, &scene->r.frs_sec_base, true); + scene->r.frs_sec = fps_denom; + scene->r.frs_sec_base = fps_num; } /* Set initial scale based on load_data->fit_method. */ @@ -577,6 +586,7 @@ Sequence *SEQ_add_movie_strip(Main *bmain, Scene *scene, ListBase *seqbase, SeqL strip->stripdata = se = MEM_callocN(sizeof(StripElem), "stripelem"); strip->stripdata->orig_width = orig_width; strip->stripdata->orig_height = orig_height; + strip->stripdata->orig_fps = video_fps; BLI_split_dirfile(load_data->path, strip->dir, se->name, sizeof(strip->dir), sizeof(se->name)); seq_add_set_view_transform(scene, seq, load_data); @@ -691,8 +701,6 @@ void SEQ_add_reload_new_file(Main *bmain, Scene *scene, Sequence *seq, const boo seq->len = IMB_anim_get_duration( sanim->anim, seq->strip->proxy ? seq->strip->proxy->tc : IMB_TC_RECORD_RUN); - seq->anim_preseek = IMB_anim_get_preseek(sanim->anim); - seq->len -= seq->anim_startofs; seq->len -= seq->anim_endofs; if (seq->len < 0) { diff --git a/source/blender/sequencer/intern/strip_relations.c b/source/blender/sequencer/intern/strip_relations.c index 1215cb78b56..7c5a3f031db 100644 --- a/source/blender/sequencer/intern/strip_relations.c +++ b/source/blender/sequencer/intern/strip_relations.c @@ -259,7 +259,7 @@ void SEQ_relations_free_imbuf(Scene *scene, ListBase *seqbase, bool for_render) SEQ_prefetch_stop(scene); for (seq = seqbase->first; seq; seq = seq->next) { - if (for_render && CFRA >= seq->startdisp && CFRA <= seq->enddisp) { + if (for_render && SEQ_time_strip_intersects_frame(seq, CFRA)) { continue; } @@ -358,7 +358,7 @@ void SEQ_relations_update_changed_seq_and_deps(Scene *scene, static void sequencer_all_free_anim_ibufs(ListBase *seqbase, int timeline_frame) { for (Sequence *seq = seqbase->first; seq != NULL; seq = seq->next) { - if (seq->enddisp < timeline_frame || seq->startdisp > timeline_frame) { + if (!SEQ_time_strip_intersects_frame(seq, timeline_frame)) { SEQ_relations_sequence_free_anim(seq); } if (seq->type == SEQ_TYPE_META) { diff --git a/source/blender/sequencer/intern/strip_time.c b/source/blender/sequencer/intern/strip_time.c index 40d7fade308..b8b6f62c7aa 100644 --- a/source/blender/sequencer/intern/strip_time.c +++ b/source/blender/sequencer/intern/strip_time.c @@ -409,7 +409,7 @@ static bool strip_exists_at_frame(SeqCollection *all_strips, const int timeline_ { Sequence *seq; SEQ_ITERATOR_FOREACH (seq, all_strips) { - if ((seq->startdisp <= timeline_frame) && (seq->enddisp > timeline_frame)) { + if (SEQ_time_strip_intersects_frame(seq, timeline_frame)) { return true; } } @@ -468,3 +468,17 @@ void seq_time_gap_info_get(const Scene *scene, } } } + +/** + * Test if strip intersects with timeline frame. + * Note: This checks if strip would be rendered at this frame. For rendering it is assumed, that + * timeline frame has width of 1 frame and therefore ends at timeline_frame + 1 + * + * \param seq: Sequence to be checked + * \param timeline_frame: absolute frame position + * \return true if strip intersects with timeline frame. + */ +bool SEQ_time_strip_intersects_frame(const Sequence *seq, const int timeline_frame) +{ + return (seq->startdisp <= timeline_frame) && (seq->enddisp > timeline_frame); +} diff --git a/source/blender/sequencer/intern/utils.c b/source/blender/sequencer/intern/utils.c index cf1d7d66476..9aeb2961751 100644 --- a/source/blender/sequencer/intern/utils.c +++ b/source/blender/sequencer/intern/utils.c @@ -43,6 +43,7 @@ #include "SEQ_relations.h" #include "SEQ_select.h" #include "SEQ_sequencer.h" +#include "SEQ_time.h" #include "SEQ_utils.h" #include "IMB_imbuf.h" @@ -406,7 +407,7 @@ const Sequence *SEQ_get_topmost_sequence(const Scene *scene, int frame) } for (seq = ed->seqbasep->first; seq; seq = seq->next) { - if (seq->flag & SEQ_MUTE || seq->startdisp > frame || seq->enddisp <= frame) { + if (seq->flag & SEQ_MUTE || !SEQ_time_strip_intersects_frame(seq, frame)) { continue; } /* Only use strips that generate an image, not ones that combine |