2022-02-11 09:07:11 +11:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later
|
2022-02-09 16:21:21 +11:00
|
|
|
* Copyright 2001-2002 NaN Holding BV. All rights reserved.
|
|
|
|
|
* 2003-2009 Blender Foundation.
|
2022-02-11 09:07:11 +11:00
|
|
|
* 2005-2006 Peter Schlaile <peter [at] schlaile [dot] de> */
|
2008-12-15 05:21:44 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup bke
|
2011-02-27 20:40:57 +00:00
|
|
|
*/
|
|
|
|
|
|
2021-08-20 16:30:34 +02:00
|
|
|
#define DNA_DEPRECATED_ALLOW
|
|
|
|
|
|
2008-12-15 05:21:44 +00:00
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
2009-11-22 20:22:35 +00:00
|
|
|
#include "DNA_anim_types.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
|
#include "DNA_sequence_types.h"
|
2021-08-20 16:30:34 +02:00
|
|
|
#include "DNA_sound_types.h"
|
2009-01-12 19:02:08 +00:00
|
|
|
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BLI_listbase.h"
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BKE_idprop.h"
|
|
|
|
|
#include "BKE_lib_id.h"
|
2020-11-16 05:02:30 +01:00
|
|
|
#include "BKE_sound.h"
|
2011-01-07 19:18:31 +00:00
|
|
|
|
2017-04-06 15:37:46 +02:00
|
|
|
#include "DEG_depsgraph.h"
|
2008-12-15 05:21:44 +00:00
|
|
|
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "IMB_colormanagement.h"
|
2008-12-15 05:21:44 +00:00
|
|
|
#include "IMB_imbuf.h"
|
2011-06-23 09:27:56 +00:00
|
|
|
|
2022-04-04 12:52:48 +02:00
|
|
|
#include "SEQ_channels.h"
|
2021-08-20 16:30:34 +02:00
|
|
|
#include "SEQ_edit.h"
|
2020-12-19 06:44:57 +01:00
|
|
|
#include "SEQ_effects.h"
|
|
|
|
|
#include "SEQ_iterator.h"
|
|
|
|
|
#include "SEQ_modifier.h"
|
2021-08-20 16:30:34 +02:00
|
|
|
#include "SEQ_proxy.h"
|
2020-12-19 06:44:57 +01:00
|
|
|
#include "SEQ_relations.h"
|
|
|
|
|
#include "SEQ_select.h"
|
2020-11-16 05:02:30 +01:00
|
|
|
#include "SEQ_sequencer.h"
|
2021-08-20 16:30:34 +02:00
|
|
|
#include "SEQ_sound.h"
|
2020-12-19 06:44:57 +01:00
|
|
|
#include "SEQ_utils.h"
|
2017-10-25 11:02:52 -02:00
|
|
|
|
2021-08-20 16:30:34 +02:00
|
|
|
#include "BLO_read_write.h"
|
|
|
|
|
|
2020-11-16 05:02:30 +01:00
|
|
|
#include "image_cache.h"
|
|
|
|
|
#include "prefetch.h"
|
2020-10-26 00:47:06 +01:00
|
|
|
#include "sequencer.h"
|
2020-11-16 05:02:30 +01:00
|
|
|
#include "utils.h"
|
2009-08-09 21:16:39 +00:00
|
|
|
|
2020-11-16 05:02:30 +01:00
|
|
|
/* -------------------------------------------------------------------- */
|
2020-11-16 16:48:41 +11:00
|
|
|
/** \name Allocate / Free Functions
|
2020-11-16 05:02:30 +01:00
|
|
|
* \{ */
|
2009-12-18 13:28:03 +00:00
|
|
|
|
2022-01-25 17:05:33 +01:00
|
|
|
StripProxy *seq_strip_proxy_alloc(void)
|
|
|
|
|
{
|
|
|
|
|
StripProxy *strip_proxy = MEM_callocN(sizeof(struct StripProxy), "StripProxy");
|
|
|
|
|
strip_proxy->quality = 50;
|
|
|
|
|
strip_proxy->build_tc_flags = SEQ_PROXY_TC_ALL;
|
|
|
|
|
strip_proxy->tc = SEQ_PROXY_TC_RECORD_RUN;
|
|
|
|
|
return strip_proxy;
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-16 05:02:30 +01:00
|
|
|
static Strip *seq_strip_alloc(int type)
|
2009-12-18 13:28:03 +00:00
|
|
|
{
|
2020-11-16 05:02:30 +01:00
|
|
|
Strip *strip = MEM_callocN(sizeof(Strip), "strip");
|
2010-07-06 16:44:05 +00:00
|
|
|
|
2020-11-16 05:02:30 +01:00
|
|
|
if (ELEM(type, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SOUND_HD) == 0) {
|
|
|
|
|
strip->transform = MEM_callocN(sizeof(struct StripTransform), "StripTransform");
|
|
|
|
|
strip->transform->scale_x = 1;
|
|
|
|
|
strip->transform->scale_y = 1;
|
2021-09-21 09:38:30 +02:00
|
|
|
strip->transform->origin[0] = 0.5f;
|
|
|
|
|
strip->transform->origin[1] = 0.5f;
|
2022-02-07 10:31:39 +01:00
|
|
|
strip->transform->filter = SEQ_TRANSFORM_FILTER_BILINEAR;
|
2020-11-16 05:02:30 +01:00
|
|
|
strip->crop = MEM_callocN(sizeof(struct StripCrop), "StripCrop");
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2010-07-06 16:44:05 +00:00
|
|
|
|
2020-11-16 05:02:30 +01:00
|
|
|
strip->us = 1;
|
|
|
|
|
return strip;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
2012-08-08 11:15:32 +00:00
|
|
|
static void seq_free_strip(Strip *strip)
|
2008-12-15 05:21:44 +00:00
|
|
|
{
|
|
|
|
|
strip->us--;
|
2019-04-22 09:39:35 +10:00
|
|
|
if (strip->us > 0) {
|
2012-08-08 11:15:36 +00:00
|
|
|
return;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2012-03-29 22:26:11 +00:00
|
|
|
if (strip->us < 0) {
|
2008-12-15 05:21:44 +00:00
|
|
|
printf("error: negative users in strip\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (strip->stripdata) {
|
|
|
|
|
MEM_freeN(strip->stripdata);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (strip->proxy) {
|
2009-06-08 20:08:19 +00:00
|
|
|
if (strip->proxy->anim) {
|
|
|
|
|
IMB_free_anim(strip->proxy->anim);
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-15 05:21:44 +00:00
|
|
|
MEM_freeN(strip->proxy);
|
|
|
|
|
}
|
|
|
|
|
if (strip->crop) {
|
|
|
|
|
MEM_freeN(strip->crop);
|
|
|
|
|
}
|
|
|
|
|
if (strip->transform) {
|
|
|
|
|
MEM_freeN(strip->transform);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MEM_freeN(strip);
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-19 05:57:27 +01:00
|
|
|
Sequence *SEQ_sequence_alloc(ListBase *lb, int timeline_frame, int machine, int type)
|
2020-11-16 05:02:30 +01:00
|
|
|
{
|
|
|
|
|
Sequence *seq;
|
|
|
|
|
|
|
|
|
|
seq = MEM_callocN(sizeof(Sequence), "addseq");
|
|
|
|
|
BLI_addtail(lb, seq);
|
|
|
|
|
|
|
|
|
|
*((short *)seq->name) = ID_SEQ;
|
|
|
|
|
seq->name[2] = 0;
|
|
|
|
|
|
|
|
|
|
seq->flag = SELECT;
|
|
|
|
|
seq->start = timeline_frame;
|
|
|
|
|
seq->machine = machine;
|
|
|
|
|
seq->sat = 1.0;
|
|
|
|
|
seq->mul = 1.0;
|
|
|
|
|
seq->blend_opacity = 100.0;
|
|
|
|
|
seq->volume = 1.0f;
|
|
|
|
|
seq->pitch = 1.0f;
|
|
|
|
|
seq->scene_sound = NULL;
|
|
|
|
|
seq->type = type;
|
2021-12-20 01:47:34 +01:00
|
|
|
seq->blend_mode = SEQ_TYPE_ALPHAOVER;
|
2020-11-16 05:02:30 +01:00
|
|
|
|
|
|
|
|
seq->strip = seq_strip_alloc(type);
|
|
|
|
|
seq->stereo3d_format = MEM_callocN(sizeof(Stereo3dFormat), "Sequence Stereo Format");
|
|
|
|
|
|
2021-09-29 14:29:32 +02:00
|
|
|
seq->color_tag = SEQUENCE_COLOR_NONE;
|
|
|
|
|
|
2022-04-04 12:52:48 +02:00
|
|
|
if (seq->type == SEQ_TYPE_META) {
|
|
|
|
|
SEQ_channels_ensure(&seq->channels);
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-19 05:57:27 +01:00
|
|
|
SEQ_relations_session_uuid_generate(seq);
|
2020-11-16 05:02:30 +01:00
|
|
|
|
|
|
|
|
return seq;
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-06 09:23:38 +00:00
|
|
|
/* only give option to skip cache locally (static func) */
|
2020-12-19 05:57:27 +01:00
|
|
|
static void seq_sequence_free_ex(Scene *scene,
|
2018-05-11 11:21:30 +02:00
|
|
|
Sequence *seq,
|
|
|
|
|
const bool do_cache,
|
2022-01-19 14:12:23 +01:00
|
|
|
const bool do_id_user)
|
2008-12-15 05:21:44 +00:00
|
|
|
{
|
2019-04-22 09:39:35 +10:00
|
|
|
if (seq->strip) {
|
2012-08-08 11:15:36 +00:00
|
|
|
seq_free_strip(seq->strip);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2008-12-15 05:21:44 +00:00
|
|
|
|
2020-12-19 05:57:27 +01:00
|
|
|
SEQ_relations_sequence_free_anim(seq);
|
2009-08-09 21:16:39 +00:00
|
|
|
|
2012-06-07 15:49:02 +00:00
|
|
|
if (seq->type & SEQ_TYPE_EFFECT) {
|
2020-12-19 05:57:27 +01:00
|
|
|
struct SeqEffectHandle sh = SEQ_effect_handle_get(seq);
|
2018-12-28 13:37:51 +01:00
|
|
|
sh.free(seq, do_id_user);
|
2009-07-08 17:41:45 +00:00
|
|
|
}
|
2008-12-15 05:21:44 +00:00
|
|
|
|
2018-05-11 11:21:30 +02:00
|
|
|
if (seq->sound && do_id_user) {
|
2015-11-09 19:47:10 +01:00
|
|
|
id_us_min(((ID *)seq->sound));
|
2011-05-16 17:14:47 +00:00
|
|
|
}
|
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
if (seq->stereo3d_format) {
|
|
|
|
|
MEM_freeN(seq->stereo3d_format);
|
|
|
|
|
}
|
|
|
|
|
|
2012-12-17 08:45:44 +00:00
|
|
|
/* clipboard has no scene and will never have a sound handle or be active
|
|
|
|
|
* same goes to sequences copy for proxy rebuild job
|
|
|
|
|
*/
|
2012-03-24 06:18:31 +00:00
|
|
|
if (scene) {
|
2009-12-17 16:28:45 +00:00
|
|
|
Editing *ed = scene->ed;
|
|
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (ed->act_seq == seq) {
|
2012-03-29 22:26:11 +00:00
|
|
|
ed->act_seq = NULL;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2009-12-17 16:28:45 +00:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (seq->scene_sound && ELEM(seq->type, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SCENE)) {
|
2015-03-26 11:35:41 +01:00
|
|
|
BKE_sound_remove_scene_sound(scene, seq->scene_sound);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2010-07-13 09:31:28 +00:00
|
|
|
}
|
2010-07-03 21:13:08 +00:00
|
|
|
|
2015-04-02 21:05:12 +11:00
|
|
|
if (seq->prop) {
|
2019-05-16 14:17:11 +02:00
|
|
|
IDP_FreePropertyContent_ex(seq->prop, do_id_user);
|
2015-04-02 21:05:12 +11:00
|
|
|
MEM_freeN(seq->prop);
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-19 15:41:56 +00:00
|
|
|
/* free modifiers */
|
2020-12-19 05:57:27 +01:00
|
|
|
SEQ_modifier_clear(seq);
|
2012-08-19 15:41:56 +00:00
|
|
|
|
2012-08-27 09:01:36 +00:00
|
|
|
/* free cached data used by this strip,
|
|
|
|
|
* also invalidate cache for all dependent sequences
|
2012-09-06 04:45:25 +00:00
|
|
|
*
|
|
|
|
|
* be _very_ careful here, invalidating cache loops over the scene sequences and
|
2019-04-27 12:07:07 +10:00
|
|
|
* assumes the listbase is valid for all strips,
|
|
|
|
|
* this may not be the case if lists are being freed.
|
2020-12-19 05:57:27 +01:00
|
|
|
* this is optional SEQ_relations_invalidate_cache
|
2012-08-27 09:01:36 +00:00
|
|
|
*/
|
2012-09-06 04:45:25 +00:00
|
|
|
if (do_cache) {
|
|
|
|
|
if (scene) {
|
2020-12-19 05:57:27 +01:00
|
|
|
SEQ_relations_invalidate_cache_raw(scene, seq);
|
2012-09-06 04:45:25 +00:00
|
|
|
}
|
|
|
|
|
}
|
2022-04-04 12:52:48 +02:00
|
|
|
if (seq->type == SEQ_TYPE_META) {
|
|
|
|
|
SEQ_channels_free(&seq->channels);
|
|
|
|
|
}
|
2012-08-12 18:24:01 +00:00
|
|
|
|
2008-12-15 05:21:44 +00:00
|
|
|
MEM_freeN(seq);
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-19 14:12:23 +01:00
|
|
|
void SEQ_sequence_free(Scene *scene, Sequence *seq)
|
2012-09-06 09:23:38 +00:00
|
|
|
{
|
2022-01-19 14:12:23 +01:00
|
|
|
seq_sequence_free_ex(scene, seq, true, true);
|
2012-09-06 09:23:38 +00:00
|
|
|
}
|
|
|
|
|
|
2022-01-19 14:12:23 +01:00
|
|
|
void seq_free_sequence_recurse(Scene *scene, Sequence *seq, const bool do_id_user)
|
== Sequencer ==
This patch adds:
* support for proxy building again (missing feature from Blender 2.49)
additionally to the way, Blender 2.49 worked, you can select several
strips at once and make Blender build proxies in the background (using
the job system)
Also a new thing: movie proxies are now build into AVI files, and
the proxy system is moved into ImBuf-library, so that other parts
of blender can also benefit from it.
* Timecode support: to fix seeking issues with files, that have
a) varying frame rates
b) very large GOP lengths
c) are broken inbetween
d) use different time code tracks
the proxy builder can now also build timecode indices, which are
used (optionally) for seeking.
For the first time, it is possible, to do frame exact seeking on
all file types.
* Support for different video-streams in one video file (can be
selected in sequencer, other parts of blender can also use it,
but UI has to be added accordingly)
* IMPORTANT: this patch *requires* ffmpeg 0.7 or newer, since
older versions don't support the pkt_pts field, that is essential
for building timecode indices.
Windows and Mac libs are already updated, Linux-users have to build
their own ffmpeg verions until distros keep up.
2011-08-28 14:46:03 +00:00
|
|
|
{
|
2012-09-06 04:45:25 +00:00
|
|
|
Sequence *iseq, *iseq_next;
|
== Sequencer ==
This patch adds:
* support for proxy building again (missing feature from Blender 2.49)
additionally to the way, Blender 2.49 worked, you can select several
strips at once and make Blender build proxies in the background (using
the job system)
Also a new thing: movie proxies are now build into AVI files, and
the proxy system is moved into ImBuf-library, so that other parts
of blender can also benefit from it.
* Timecode support: to fix seeking issues with files, that have
a) varying frame rates
b) very large GOP lengths
c) are broken inbetween
d) use different time code tracks
the proxy builder can now also build timecode indices, which are
used (optionally) for seeking.
For the first time, it is possible, to do frame exact seeking on
all file types.
* Support for different video-streams in one video file (can be
selected in sequencer, other parts of blender can also use it,
but UI has to be added accordingly)
* IMPORTANT: this patch *requires* ffmpeg 0.7 or newer, since
older versions don't support the pkt_pts field, that is essential
for building timecode indices.
Windows and Mac libs are already updated, Linux-users have to build
their own ffmpeg verions until distros keep up.
2011-08-28 14:46:03 +00:00
|
|
|
|
2020-11-16 05:02:30 +01:00
|
|
|
for (iseq = seq->seqbase.first; iseq; iseq = iseq_next) {
|
|
|
|
|
iseq_next = iseq->next;
|
2022-01-19 14:12:23 +01:00
|
|
|
seq_free_sequence_recurse(scene, iseq, do_id_user);
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
|
2022-01-19 14:12:23 +01:00
|
|
|
seq_sequence_free_ex(scene, seq, false, do_id_user);
|
2020-11-16 05:02:30 +01:00
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2021-09-02 11:29:32 +10:00
|
|
|
Editing *SEQ_editing_get(const Scene *scene)
|
2020-11-16 05:02:30 +01:00
|
|
|
{
|
|
|
|
|
return scene->ed;
|
|
|
|
|
}
|
2019-09-29 16:17:48 -07:00
|
|
|
|
2020-12-19 05:57:27 +01:00
|
|
|
Editing *SEQ_editing_ensure(Scene *scene)
|
2020-11-16 05:02:30 +01:00
|
|
|
{
|
|
|
|
|
if (scene->ed == NULL) {
|
|
|
|
|
Editing *ed;
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2020-11-16 05:02:30 +01:00
|
|
|
ed = scene->ed = MEM_callocN(sizeof(Editing), "addseq");
|
|
|
|
|
ed->seqbasep = &ed->seqbase;
|
|
|
|
|
ed->cache = NULL;
|
|
|
|
|
ed->cache_flag = SEQ_CACHE_STORE_FINAL_OUT;
|
2021-01-08 11:54:53 +01:00
|
|
|
ed->cache_flag |= SEQ_CACHE_STORE_RAW;
|
2022-04-04 16:27:37 +02:00
|
|
|
ed->displayed_channels = &ed->channels;
|
|
|
|
|
SEQ_channels_ensure(ed->displayed_channels);
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-11-16 05:02:30 +01:00
|
|
|
return scene->ed;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-12-19 05:57:27 +01:00
|
|
|
void SEQ_editing_free(Scene *scene, const bool do_id_user)
|
2020-11-16 05:02:30 +01:00
|
|
|
{
|
|
|
|
|
Editing *ed = scene->ed;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-11-16 05:02:30 +01:00
|
|
|
if (ed == NULL) {
|
|
|
|
|
return;
|
2016-01-08 18:30:26 +13:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-12-19 05:57:27 +01:00
|
|
|
seq_prefetch_free(scene);
|
|
|
|
|
seq_cache_destruct(scene);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-08-20 16:30:34 +02:00
|
|
|
/* handle cache freeing above */
|
|
|
|
|
LISTBASE_FOREACH_MUTABLE (Sequence *, seq, &ed->seqbase) {
|
2022-01-19 14:12:23 +01:00
|
|
|
seq_free_sequence_recurse(scene, seq, do_id_user);
|
2020-11-16 05:02:30 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-11-16 05:02:30 +01:00
|
|
|
BLI_freelistN(&ed->metastack);
|
2021-06-16 00:29:17 +02:00
|
|
|
SEQ_sequence_lookup_free(scene);
|
2022-04-04 12:52:48 +02:00
|
|
|
SEQ_channels_free(&ed->channels);
|
2020-11-16 05:02:30 +01:00
|
|
|
MEM_freeN(ed);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-11-16 05:02:30 +01:00
|
|
|
scene->ed = NULL;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-11-16 05:02:30 +01:00
|
|
|
static void seq_new_fix_links_recursive(Sequence *seq)
|
|
|
|
|
{
|
|
|
|
|
SequenceModifierData *smd;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-11-16 05:02:30 +01:00
|
|
|
if (seq->type & SEQ_TYPE_EFFECT) {
|
|
|
|
|
if (seq->seq1 && seq->seq1->tmp) {
|
|
|
|
|
seq->seq1 = seq->seq1->tmp;
|
|
|
|
|
}
|
|
|
|
|
if (seq->seq2 && seq->seq2->tmp) {
|
|
|
|
|
seq->seq2 = seq->seq2->tmp;
|
|
|
|
|
}
|
|
|
|
|
if (seq->seq3 && seq->seq3->tmp) {
|
|
|
|
|
seq->seq3 = seq->seq3->tmp;
|
|
|
|
|
}
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2020-11-16 05:02:30 +01:00
|
|
|
else if (seq->type == SEQ_TYPE_META) {
|
|
|
|
|
Sequence *seqn;
|
|
|
|
|
for (seqn = seq->seqbase.first; seqn; seqn = seqn->next) {
|
|
|
|
|
seq_new_fix_links_recursive(seqn);
|
|
|
|
|
}
|
2009-11-14 19:26:58 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-11-16 05:02:30 +01:00
|
|
|
for (smd = seq->modifiers.first; smd; smd = smd->next) {
|
|
|
|
|
if (smd->mask_sequence && smd->mask_sequence->tmp) {
|
|
|
|
|
smd->mask_sequence = smd->mask_sequence->tmp;
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-11-14 19:26:58 +00:00
|
|
|
}
|
2020-12-16 20:34:26 +01:00
|
|
|
|
|
|
|
|
SequencerToolSettings *SEQ_tool_settings_init(void)
|
|
|
|
|
{
|
|
|
|
|
SequencerToolSettings *tool_settings = MEM_callocN(sizeof(SequencerToolSettings),
|
|
|
|
|
"Sequencer tool settings");
|
|
|
|
|
tool_settings->fit_method = SEQ_SCALE_TO_FIT;
|
2021-07-01 11:02:30 +10:00
|
|
|
tool_settings->snap_mode = SEQ_SNAP_TO_STRIPS | SEQ_SNAP_TO_CURRENT_FRAME |
|
|
|
|
|
SEQ_SNAP_TO_STRIP_HOLD;
|
2021-06-29 20:12:19 +02:00
|
|
|
tool_settings->snap_distance = 15;
|
2021-08-27 12:59:46 +02:00
|
|
|
tool_settings->overlap_mode = SEQ_OVERLAP_SHUFFLE;
|
2021-09-21 09:38:30 +02:00
|
|
|
tool_settings->pivot_point = V3D_AROUND_LOCAL_ORIGINS;
|
2021-08-27 12:59:46 +02:00
|
|
|
|
2020-12-16 20:34:26 +01:00
|
|
|
return tool_settings;
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-25 15:02:31 +02:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-16 20:34:26 +01:00
|
|
|
void SEQ_tool_settings_free(SequencerToolSettings *tool_settings)
|
|
|
|
|
{
|
|
|
|
|
MEM_freeN(tool_settings);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
eSeqImageFitMethod SEQ_tool_settings_fit_method_get(Scene *scene)
|
|
|
|
|
{
|
2021-05-25 15:02:31 +02:00
|
|
|
const SequencerToolSettings *tool_settings = SEQ_tool_settings_ensure(scene);
|
2020-12-16 20:34:26 +01:00
|
|
|
return tool_settings->fit_method;
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-29 20:12:19 +02:00
|
|
|
short SEQ_tool_settings_snap_mode_get(Scene *scene)
|
|
|
|
|
{
|
|
|
|
|
const SequencerToolSettings *tool_settings = SEQ_tool_settings_ensure(scene);
|
|
|
|
|
return tool_settings->snap_mode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
short SEQ_tool_settings_snap_flag_get(Scene *scene)
|
|
|
|
|
{
|
|
|
|
|
const SequencerToolSettings *tool_settings = SEQ_tool_settings_ensure(scene);
|
|
|
|
|
return tool_settings->snap_flag;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int SEQ_tool_settings_snap_distance_get(Scene *scene)
|
|
|
|
|
{
|
|
|
|
|
const SequencerToolSettings *tool_settings = SEQ_tool_settings_ensure(scene);
|
|
|
|
|
return tool_settings->snap_distance;
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-16 20:34:26 +01:00
|
|
|
void SEQ_tool_settings_fit_method_set(Scene *scene, eSeqImageFitMethod fit_method)
|
|
|
|
|
{
|
2021-05-25 15:02:31 +02:00
|
|
|
SequencerToolSettings *tool_settings = SEQ_tool_settings_ensure(scene);
|
2020-12-16 20:34:26 +01:00
|
|
|
tool_settings->fit_method = fit_method;
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-27 12:59:46 +02:00
|
|
|
eSeqOverlapMode SEQ_tool_settings_overlap_mode_get(Scene *scene)
|
|
|
|
|
{
|
|
|
|
|
const SequencerToolSettings *tool_settings = SEQ_tool_settings_ensure(scene);
|
|
|
|
|
return tool_settings->overlap_mode;
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-21 09:38:30 +02:00
|
|
|
int SEQ_tool_settings_pivot_point_get(Scene *scene)
|
|
|
|
|
{
|
|
|
|
|
const SequencerToolSettings *tool_settings = SEQ_tool_settings_ensure(scene);
|
|
|
|
|
return tool_settings->pivot_point;
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-17 02:11:22 +01:00
|
|
|
ListBase *SEQ_active_seqbase_get(const Editing *ed)
|
|
|
|
|
{
|
|
|
|
|
if (ed == NULL) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ed->seqbasep;
|
|
|
|
|
}
|
2021-03-02 12:34:03 +01:00
|
|
|
|
|
|
|
|
void SEQ_seqbase_active_set(Editing *ed, ListBase *seqbase)
|
|
|
|
|
{
|
|
|
|
|
ed->seqbasep = seqbase;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MetaStack *SEQ_meta_stack_alloc(Editing *ed, Sequence *seq_meta)
|
|
|
|
|
{
|
|
|
|
|
MetaStack *ms = MEM_mallocN(sizeof(MetaStack), "metastack");
|
|
|
|
|
BLI_addtail(&ed->metastack, ms);
|
|
|
|
|
ms->parseq = seq_meta;
|
|
|
|
|
ms->oldbasep = ed->seqbasep;
|
2022-04-04 12:52:48 +02:00
|
|
|
ms->old_channels = ed->displayed_channels;
|
2021-03-02 12:34:03 +01:00
|
|
|
copy_v2_v2_int(ms->disp_range, &ms->parseq->startdisp);
|
|
|
|
|
return ms;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SEQ_meta_stack_free(Editing *ed, MetaStack *ms)
|
|
|
|
|
{
|
|
|
|
|
BLI_remlink(&ed->metastack, ms);
|
|
|
|
|
MEM_freeN(ms);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MetaStack *SEQ_meta_stack_active_get(const Editing *ed)
|
|
|
|
|
{
|
2021-12-20 02:15:23 +01:00
|
|
|
if (ed == NULL) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-02 12:34:03 +01:00
|
|
|
return ed->metastack.last;
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-16 05:02:30 +01:00
|
|
|
/** \} */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-11-16 05:02:30 +01:00
|
|
|
/* -------------------------------------------------------------------- */
|
2020-11-16 16:48:41 +11:00
|
|
|
/** \name Duplicate Functions
|
2020-11-16 05:02:30 +01:00
|
|
|
* \{ */
|
2021-12-14 15:49:31 +11:00
|
|
|
|
2019-01-11 19:48:56 +01:00
|
|
|
static Sequence *seq_dupli(const Scene *scene_src,
|
|
|
|
|
Scene *scene_dst,
|
|
|
|
|
ListBase *new_seq_list,
|
|
|
|
|
Sequence *seq,
|
|
|
|
|
int dupe_flag,
|
|
|
|
|
const int flag)
|
2010-06-24 10:04:18 +00:00
|
|
|
{
|
|
|
|
|
Sequence *seqn = MEM_dupallocN(seq);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-07-30 11:58:18 +02:00
|
|
|
if ((flag & LIB_ID_CREATE_NO_MAIN) == 0) {
|
2020-12-29 19:55:48 +01:00
|
|
|
SEQ_relations_session_uuid_generate(seqn);
|
2020-07-30 11:58:18 +02:00
|
|
|
}
|
|
|
|
|
|
2010-06-24 10:04:18 +00:00
|
|
|
seq->tmp = seqn;
|
2012-03-29 22:26:11 +00:00
|
|
|
seqn->strip = MEM_dupallocN(seq->strip);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
seqn->stereo3d_format = MEM_dupallocN(seq->stereo3d_format);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-08-08 11:15:36 +00:00
|
|
|
/* XXX: add F-Curve duplication stuff? */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-06-24 10:04:18 +00:00
|
|
|
if (seq->strip->crop) {
|
|
|
|
|
seqn->strip->crop = MEM_dupallocN(seq->strip->crop);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-06-24 10:04:18 +00:00
|
|
|
if (seq->strip->transform) {
|
|
|
|
|
seqn->strip->transform = MEM_dupallocN(seq->strip->transform);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-06-24 10:04:18 +00:00
|
|
|
if (seq->strip->proxy) {
|
|
|
|
|
seqn->strip->proxy = MEM_dupallocN(seq->strip->proxy);
|
2011-02-13 10:52:18 +00:00
|
|
|
seqn->strip->proxy->anim = NULL;
|
2010-06-24 10:04:18 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-02 21:05:12 +11:00
|
|
|
if (seq->prop) {
|
Refactor ID copying (and to some extent, ID freeing).
This will allow much finer controll over how we copy data-blocks, from
full copy in Main database, to "lighter" ones (out of Main, inside an
already allocated datablock, etc.).
This commit also transfers a llot of what was previously handled by
per-ID-type custom code to generic ID handling code in BKE_library.
Hopefully will avoid in future inconsistencies and missing bits we had
all over the codebase in the past.
It also adds missing copying handling for a few types, most notably
Scene (which where using a fully customized handling previously).
Note that the type of allocation used during copying (regular in Main,
allocated but outside of Main, or not allocated by ID handling code at
all) is stored in ID's, which allows to handle them correctly when
freeing. This needs to be taken care of with caution when doing 'weird'
unusual things with ID copying and/or allocation!
As a final note, while rather noisy, this commit will hopefully not
break too much existing branches, old 'API' has been kept for the main
part, as a wrapper around new code. Cleaning it up will happen later.
Design task : T51804
Phab Diff: D2714
2017-08-07 16:39:55 +02:00
|
|
|
seqn->prop = IDP_CopyProperty_ex(seq->prop, flag);
|
2015-04-02 21:05:12 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-08-19 15:41:56 +00:00
|
|
|
if (seqn->modifiers.first) {
|
2014-02-08 06:07:10 +11:00
|
|
|
BLI_listbase_clear(&seqn->modifiers);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-12-19 05:57:27 +01:00
|
|
|
SEQ_modifier_list_copy(seqn, seq);
|
2012-08-19 15:41:56 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-07 15:49:02 +00:00
|
|
|
if (seq->type == SEQ_TYPE_META) {
|
2011-02-13 10:52:18 +00:00
|
|
|
seqn->strip->stripdata = NULL;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-02-08 06:07:10 +11:00
|
|
|
BLI_listbase_clear(&seqn->seqbase);
|
2021-05-14 17:35:22 +10:00
|
|
|
/* WARNING: This meta-strip is not recursively duplicated here - do this after! */
|
|
|
|
|
// seq_dupli_recursive(&seq->seqbase, &seqn->seqbase);
|
2022-04-04 12:52:48 +02:00
|
|
|
|
|
|
|
|
BLI_listbase_clear(&seqn->channels);
|
|
|
|
|
SEQ_channels_duplicate(&seqn->channels, &seq->channels);
|
2012-03-24 06:18:31 +00:00
|
|
|
}
|
2012-06-07 15:49:02 +00:00
|
|
|
else if (seq->type == SEQ_TYPE_SCENE) {
|
2011-02-13 10:52:18 +00:00
|
|
|
seqn->strip->stripdata = NULL;
|
2019-04-22 09:39:35 +10:00
|
|
|
if (seq->scene_sound) {
|
2017-08-10 13:00:01 +02:00
|
|
|
seqn->scene_sound = BKE_sound_scene_add_scene_sound_defaults(scene_dst, seqn);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
}
|
2013-07-24 07:11:00 +00:00
|
|
|
else if (seq->type == SEQ_TYPE_MOVIECLIP) {
|
|
|
|
|
/* avoid assert */
|
|
|
|
|
}
|
|
|
|
|
else if (seq->type == SEQ_TYPE_MASK) {
|
|
|
|
|
/* avoid assert */
|
|
|
|
|
}
|
2012-06-07 15:49:02 +00:00
|
|
|
else if (seq->type == SEQ_TYPE_MOVIE) {
|
2012-03-29 22:26:11 +00:00
|
|
|
seqn->strip->stripdata = MEM_dupallocN(seq->strip->stripdata);
|
2015-04-06 10:40:12 -03:00
|
|
|
BLI_listbase_clear(&seqn->anims);
|
2012-03-24 06:18:31 +00:00
|
|
|
}
|
2012-06-07 15:49:02 +00:00
|
|
|
else if (seq->type == SEQ_TYPE_SOUND_RAM) {
|
2012-03-29 22:26:11 +00:00
|
|
|
seqn->strip->stripdata = MEM_dupallocN(seq->strip->stripdata);
|
2019-06-04 16:52:48 +02:00
|
|
|
seqn->scene_sound = NULL;
|
Refactor ID copying (and to some extent, ID freeing).
This will allow much finer controll over how we copy data-blocks, from
full copy in Main database, to "lighter" ones (out of Main, inside an
already allocated datablock, etc.).
This commit also transfers a llot of what was previously handled by
per-ID-type custom code to generic ID handling code in BKE_library.
Hopefully will avoid in future inconsistencies and missing bits we had
all over the codebase in the past.
It also adds missing copying handling for a few types, most notably
Scene (which where using a fully customized handling previously).
Note that the type of allocation used during copying (regular in Main,
allocated but outside of Main, or not allocated by ID handling code at
all) is stored in ID's, which allows to handle them correctly when
freeing. This needs to be taken care of with caution when doing 'weird'
unusual things with ID copying and/or allocation!
As a final note, while rather noisy, this commit will hopefully not
break too much existing branches, old 'API' has been kept for the main
part, as a wrapper around new code. Cleaning it up will happen later.
Design task : T51804
Phab Diff: D2714
2017-08-07 16:39:55 +02:00
|
|
|
if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
|
|
|
|
|
id_us_plus((ID *)seqn->sound);
|
|
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
}
|
2012-06-07 15:49:02 +00:00
|
|
|
else if (seq->type == SEQ_TYPE_IMAGE) {
|
2012-03-29 22:26:11 +00:00
|
|
|
seqn->strip->stripdata = MEM_dupallocN(seq->strip->stripdata);
|
2012-03-24 06:18:31 +00:00
|
|
|
}
|
2015-07-01 17:32:56 +02:00
|
|
|
else if (seq->type & SEQ_TYPE_EFFECT) {
|
|
|
|
|
struct SeqEffectHandle sh;
|
2020-12-19 05:57:27 +01:00
|
|
|
sh = SEQ_effect_handle_get(seq);
|
2019-04-22 09:39:35 +10:00
|
|
|
if (sh.copy) {
|
2020-07-16 02:24:37 +02:00
|
|
|
sh.copy(seqn, seq, flag);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-02-13 10:52:18 +00:00
|
|
|
seqn->strip->stripdata = NULL;
|
2012-03-24 06:18:31 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2013-07-24 07:11:00 +00:00
|
|
|
/* sequence type not handled in duplicate! Expect a crash now... */
|
2021-03-24 12:38:08 +11:00
|
|
|
BLI_assert_unreachable();
|
2010-06-24 10:04:18 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-11 19:48:56 +01:00
|
|
|
/* When using SEQ_DUPE_UNIQUE_NAME, it is mandatory to add new sequences in relevant container
|
|
|
|
|
* (scene or meta's one), *before* checking for unique names. Otherwise the meta's list is empty
|
|
|
|
|
* and hence we miss all seqs in that meta that have already been duplicated (see T55668).
|
2019-08-01 13:53:25 +10:00
|
|
|
* Note that unique name check itself could be done at a later step in calling code, once all
|
2019-04-27 12:07:07 +10:00
|
|
|
* seqs have bee duplicated (that was first, simpler solution), but then handling of animation
|
|
|
|
|
* data will be broken (see T60194). */
|
2019-01-11 19:48:56 +01:00
|
|
|
if (new_seq_list != NULL) {
|
|
|
|
|
BLI_addtail(new_seq_list, seqn);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-08-10 13:00:01 +02:00
|
|
|
if (scene_src == scene_dst) {
|
2017-08-10 12:56:32 +02:00
|
|
|
if (dupe_flag & SEQ_DUPE_UNIQUE_NAME) {
|
2021-06-16 00:29:17 +02:00
|
|
|
SEQ_sequence_base_unique_name_recursive(scene_dst, &scene_dst->ed->seqbase, seqn);
|
2017-08-10 12:56:32 +02:00
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-06-24 10:04:18 +00:00
|
|
|
return seqn;
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-11 19:48:56 +01:00
|
|
|
static Sequence *sequence_dupli_recursive_do(const Scene *scene_src,
|
|
|
|
|
Scene *scene_dst,
|
|
|
|
|
ListBase *new_seq_list,
|
|
|
|
|
Sequence *seq,
|
|
|
|
|
const int dupe_flag)
|
2010-06-24 10:04:18 +00:00
|
|
|
{
|
2015-08-05 20:18:57 +10:00
|
|
|
Sequence *seqn;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-08-05 20:18:57 +10:00
|
|
|
seq->tmp = NULL;
|
2019-01-11 19:48:56 +01:00
|
|
|
seqn = seq_dupli(scene_src, scene_dst, new_seq_list, seq, dupe_flag, 0);
|
2012-06-07 15:49:02 +00:00
|
|
|
if (seq->type == SEQ_TYPE_META) {
|
2010-06-25 12:04:04 +00:00
|
|
|
Sequence *s;
|
2012-03-29 22:26:11 +00:00
|
|
|
for (s = seq->seqbase.first; s; s = s->next) {
|
2019-01-11 19:48:56 +01:00
|
|
|
sequence_dupli_recursive_do(scene_src, scene_dst, &seqn->seqbase, s, dupe_flag);
|
2010-06-24 10:04:18 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2019-01-11 19:48:56 +01:00
|
|
|
return seqn;
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-19 05:57:27 +01:00
|
|
|
Sequence *SEQ_sequence_dupli_recursive(
|
2019-01-11 19:48:56 +01:00
|
|
|
const Scene *scene_src, Scene *scene_dst, ListBase *new_seq_list, Sequence *seq, int dupe_flag)
|
|
|
|
|
{
|
|
|
|
|
Sequence *seqn = sequence_dupli_recursive_do(scene_src, scene_dst, new_seq_list, seq, dupe_flag);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-11 19:48:56 +01:00
|
|
|
/* This does not need to be in recursive call itself, since it is already recursive... */
|
2015-04-20 11:51:43 +02:00
|
|
|
seq_new_fix_links_recursive(seqn);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-06-24 10:04:18 +00:00
|
|
|
return seqn;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-12-19 05:57:27 +01:00
|
|
|
void SEQ_sequence_base_dupli_recursive(const Scene *scene_src,
|
2017-08-10 15:06:53 +02:00
|
|
|
Scene *scene_dst,
|
|
|
|
|
ListBase *nseqbase,
|
|
|
|
|
const ListBase *seqbase,
|
Refactor ID copying (and to some extent, ID freeing).
This will allow much finer controll over how we copy data-blocks, from
full copy in Main database, to "lighter" ones (out of Main, inside an
already allocated datablock, etc.).
This commit also transfers a llot of what was previously handled by
per-ID-type custom code to generic ID handling code in BKE_library.
Hopefully will avoid in future inconsistencies and missing bits we had
all over the codebase in the past.
It also adds missing copying handling for a few types, most notably
Scene (which where using a fully customized handling previously).
Note that the type of allocation used during copying (regular in Main,
allocated but outside of Main, or not allocated by ID handling code at
all) is stored in ID's, which allows to handle them correctly when
freeing. This needs to be taken care of with caution when doing 'weird'
unusual things with ID copying and/or allocation!
As a final note, while rather noisy, this commit will hopefully not
break too much existing branches, old 'API' has been kept for the main
part, as a wrapper around new code. Cleaning it up will happen later.
Design task : T51804
Phab Diff: D2714
2017-08-07 16:39:55 +02:00
|
|
|
int dupe_flag,
|
|
|
|
|
const int flag)
|
2010-06-24 10:04:18 +00:00
|
|
|
{
|
|
|
|
|
Sequence *seq;
|
2011-02-13 10:52:18 +00:00
|
|
|
Sequence *seqn = NULL;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-29 22:26:11 +00:00
|
|
|
for (seq = seqbase->first; seq; seq = seq->next) {
|
|
|
|
|
seq->tmp = NULL;
|
2012-03-24 06:18:31 +00:00
|
|
|
if ((seq->flag & SELECT) || (dupe_flag & SEQ_DUPE_ALL)) {
|
2019-01-11 19:48:56 +01:00
|
|
|
seqn = seq_dupli(scene_src, scene_dst, nseqbase, seq, dupe_flag, flag);
|
2021-06-02 21:36:09 +02:00
|
|
|
|
|
|
|
|
if (seqn == NULL) {
|
|
|
|
|
continue; /* Should never fail. */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
2010-06-24 10:04:18 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-04-26 23:35:56 +02:00
|
|
|
/* Fix modifier links recursively from the top level only, when all sequences have been
|
|
|
|
|
* copied. */
|
|
|
|
|
if (dupe_flag & SEQ_DUPE_IS_RECURSIVE_CALL) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-20 11:51:43 +02:00
|
|
|
/* fix modifier linking */
|
|
|
|
|
for (seq = nseqbase->first; seq; seq = seq->next) {
|
|
|
|
|
seq_new_fix_links_recursive(seq);
|
|
|
|
|
}
|
2010-06-24 10:04:18 +00:00
|
|
|
}
|
2021-09-28 10:33:42 +02:00
|
|
|
|
|
|
|
|
bool SEQ_valid_strip_channel(Sequence *seq)
|
|
|
|
|
{
|
|
|
|
|
if (seq->machine < 1) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (seq->machine > MAXSEQ) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-16 20:34:26 +01:00
|
|
|
SequencerToolSettings *SEQ_tool_settings_copy(SequencerToolSettings *tool_settings)
|
|
|
|
|
{
|
|
|
|
|
SequencerToolSettings *tool_settings_copy = MEM_dupallocN(tool_settings);
|
|
|
|
|
return tool_settings_copy;
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-16 05:02:30 +01:00
|
|
|
/** \} */
|
2021-08-20 16:30:34 +02:00
|
|
|
|
|
|
|
|
static bool seq_set_strip_done_cb(Sequence *seq, void *UNUSED(userdata))
|
|
|
|
|
{
|
|
|
|
|
if (seq->strip) {
|
|
|
|
|
seq->strip->done = false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool seq_write_data_cb(Sequence *seq, void *userdata)
|
|
|
|
|
{
|
|
|
|
|
BlendWriter *writer = (BlendWriter *)userdata;
|
|
|
|
|
BLO_write_struct(writer, Sequence, seq);
|
|
|
|
|
if (seq->strip && seq->strip->done == 0) {
|
2021-08-26 12:27:14 +10:00
|
|
|
/* Write strip with 'done' at 0 because read-file. */
|
2021-08-20 16:30:34 +02:00
|
|
|
|
2021-08-26 12:27:14 +10:00
|
|
|
/* TODO this doesn't depend on the `Strip` data to be present? */
|
2021-08-20 16:30:34 +02:00
|
|
|
if (seq->effectdata) {
|
|
|
|
|
switch (seq->type) {
|
|
|
|
|
case SEQ_TYPE_COLOR:
|
|
|
|
|
BLO_write_struct(writer, SolidColorVars, seq->effectdata);
|
|
|
|
|
break;
|
|
|
|
|
case SEQ_TYPE_SPEED:
|
|
|
|
|
BLO_write_struct(writer, SpeedControlVars, seq->effectdata);
|
|
|
|
|
break;
|
|
|
|
|
case SEQ_TYPE_WIPE:
|
|
|
|
|
BLO_write_struct(writer, WipeVars, seq->effectdata);
|
|
|
|
|
break;
|
|
|
|
|
case SEQ_TYPE_GLOW:
|
|
|
|
|
BLO_write_struct(writer, GlowVars, seq->effectdata);
|
|
|
|
|
break;
|
|
|
|
|
case SEQ_TYPE_TRANSFORM:
|
|
|
|
|
BLO_write_struct(writer, TransformVars, seq->effectdata);
|
|
|
|
|
break;
|
|
|
|
|
case SEQ_TYPE_GAUSSIAN_BLUR:
|
|
|
|
|
BLO_write_struct(writer, GaussianBlurVars, seq->effectdata);
|
|
|
|
|
break;
|
|
|
|
|
case SEQ_TYPE_TEXT:
|
|
|
|
|
BLO_write_struct(writer, TextVars, seq->effectdata);
|
|
|
|
|
break;
|
|
|
|
|
case SEQ_TYPE_COLORMIX:
|
|
|
|
|
BLO_write_struct(writer, ColorMixVars, seq->effectdata);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BLO_write_struct(writer, Stereo3dFormat, seq->stereo3d_format);
|
|
|
|
|
|
|
|
|
|
Strip *strip = seq->strip;
|
|
|
|
|
BLO_write_struct(writer, Strip, strip);
|
|
|
|
|
if (strip->crop) {
|
|
|
|
|
BLO_write_struct(writer, StripCrop, strip->crop);
|
|
|
|
|
}
|
|
|
|
|
if (strip->transform) {
|
|
|
|
|
BLO_write_struct(writer, StripTransform, strip->transform);
|
|
|
|
|
}
|
|
|
|
|
if (strip->proxy) {
|
|
|
|
|
BLO_write_struct(writer, StripProxy, strip->proxy);
|
|
|
|
|
}
|
|
|
|
|
if (seq->type == SEQ_TYPE_IMAGE) {
|
|
|
|
|
BLO_write_struct_array(writer,
|
|
|
|
|
StripElem,
|
|
|
|
|
MEM_allocN_len(strip->stripdata) / sizeof(struct StripElem),
|
|
|
|
|
strip->stripdata);
|
|
|
|
|
}
|
|
|
|
|
else if (ELEM(seq->type, SEQ_TYPE_MOVIE, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SOUND_HD)) {
|
|
|
|
|
BLO_write_struct(writer, StripElem, strip->stripdata);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
strip->done = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (seq->prop) {
|
|
|
|
|
IDP_BlendWrite(writer, seq->prop);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SEQ_modifier_blend_write(writer, &seq->modifiers);
|
2022-04-04 12:52:48 +02:00
|
|
|
|
|
|
|
|
LISTBASE_FOREACH (SeqTimelineChannel *, channel, &seq->channels) {
|
|
|
|
|
BLO_write_struct(writer, SeqTimelineChannel, channel);
|
|
|
|
|
}
|
2021-08-20 16:30:34 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SEQ_blend_write(BlendWriter *writer, ListBase *seqbase)
|
|
|
|
|
{
|
|
|
|
|
/* reset write flags */
|
|
|
|
|
SEQ_for_each_callback(seqbase, seq_set_strip_done_cb, NULL);
|
|
|
|
|
|
|
|
|
|
SEQ_for_each_callback(seqbase, seq_write_data_cb, writer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool seq_read_data_cb(Sequence *seq, void *user_data)
|
|
|
|
|
{
|
|
|
|
|
BlendDataReader *reader = (BlendDataReader *)user_data;
|
|
|
|
|
|
|
|
|
|
/* Do as early as possible, so that other parts of reading can rely on valid session UUID. */
|
|
|
|
|
SEQ_relations_session_uuid_generate(seq);
|
|
|
|
|
|
|
|
|
|
BLO_read_data_address(reader, &seq->seq1);
|
|
|
|
|
BLO_read_data_address(reader, &seq->seq2);
|
|
|
|
|
BLO_read_data_address(reader, &seq->seq3);
|
|
|
|
|
|
|
|
|
|
/* a patch: after introduction of effects with 3 input strips */
|
|
|
|
|
if (seq->seq3 == NULL) {
|
|
|
|
|
seq->seq3 = seq->seq2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BLO_read_data_address(reader, &seq->effectdata);
|
|
|
|
|
BLO_read_data_address(reader, &seq->stereo3d_format);
|
|
|
|
|
|
|
|
|
|
if (seq->type & SEQ_TYPE_EFFECT) {
|
|
|
|
|
seq->flag |= SEQ_EFFECT_NOT_LOADED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (seq->type == SEQ_TYPE_TEXT) {
|
|
|
|
|
TextVars *t = seq->effectdata;
|
|
|
|
|
t->text_blf_id = SEQ_FONT_NOT_LOADED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BLO_read_data_address(reader, &seq->prop);
|
|
|
|
|
IDP_BlendDataRead(reader, &seq->prop);
|
|
|
|
|
|
|
|
|
|
BLO_read_data_address(reader, &seq->strip);
|
|
|
|
|
if (seq->strip && seq->strip->done == 0) {
|
|
|
|
|
seq->strip->done = true;
|
|
|
|
|
|
|
|
|
|
if (ELEM(seq->type, SEQ_TYPE_IMAGE, SEQ_TYPE_MOVIE, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SOUND_HD)) {
|
|
|
|
|
BLO_read_data_address(reader, &seq->strip->stripdata);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
seq->strip->stripdata = NULL;
|
|
|
|
|
}
|
|
|
|
|
BLO_read_data_address(reader, &seq->strip->crop);
|
|
|
|
|
BLO_read_data_address(reader, &seq->strip->transform);
|
|
|
|
|
BLO_read_data_address(reader, &seq->strip->proxy);
|
|
|
|
|
if (seq->strip->proxy) {
|
|
|
|
|
seq->strip->proxy->anim = NULL;
|
|
|
|
|
}
|
|
|
|
|
else if (seq->flag & SEQ_USE_PROXY) {
|
|
|
|
|
SEQ_proxy_set(seq, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* need to load color balance to it could be converted to modifier */
|
|
|
|
|
BLO_read_data_address(reader, &seq->strip->color_balance);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SEQ_modifier_blend_read_data(reader, &seq->modifiers);
|
2022-04-04 12:52:48 +02:00
|
|
|
|
|
|
|
|
BLO_read_list(reader, &seq->channels);
|
2021-08-20 16:30:34 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
void SEQ_blend_read(BlendDataReader *reader, ListBase *seqbase)
|
|
|
|
|
{
|
|
|
|
|
SEQ_for_each_callback(seqbase, seq_read_data_cb, reader);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
typedef struct Read_lib_data {
|
|
|
|
|
BlendLibReader *reader;
|
|
|
|
|
Scene *scene;
|
|
|
|
|
} Read_lib_data;
|
|
|
|
|
|
|
|
|
|
static bool seq_read_lib_cb(Sequence *seq, void *user_data)
|
|
|
|
|
{
|
|
|
|
|
Read_lib_data *data = (Read_lib_data *)user_data;
|
|
|
|
|
BlendLibReader *reader = data->reader;
|
|
|
|
|
Scene *sce = data->scene;
|
|
|
|
|
|
|
|
|
|
IDP_BlendReadLib(reader, seq->prop);
|
|
|
|
|
|
|
|
|
|
if (seq->ipo) {
|
|
|
|
|
/* XXX: deprecated - old animation system. */
|
|
|
|
|
BLO_read_id_address(reader, sce->id.lib, &seq->ipo);
|
|
|
|
|
}
|
|
|
|
|
seq->scene_sound = NULL;
|
|
|
|
|
if (seq->scene) {
|
|
|
|
|
BLO_read_id_address(reader, sce->id.lib, &seq->scene);
|
|
|
|
|
seq->scene_sound = NULL;
|
|
|
|
|
}
|
|
|
|
|
if (seq->clip) {
|
|
|
|
|
BLO_read_id_address(reader, sce->id.lib, &seq->clip);
|
|
|
|
|
}
|
|
|
|
|
if (seq->mask) {
|
|
|
|
|
BLO_read_id_address(reader, sce->id.lib, &seq->mask);
|
|
|
|
|
}
|
|
|
|
|
if (seq->scene_camera) {
|
|
|
|
|
BLO_read_id_address(reader, sce->id.lib, &seq->scene_camera);
|
|
|
|
|
}
|
|
|
|
|
if (seq->sound) {
|
|
|
|
|
seq->scene_sound = NULL;
|
|
|
|
|
if (seq->type == SEQ_TYPE_SOUND_HD) {
|
|
|
|
|
seq->type = SEQ_TYPE_SOUND_RAM;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
BLO_read_id_address(reader, sce->id.lib, &seq->sound);
|
|
|
|
|
}
|
|
|
|
|
if (seq->sound) {
|
|
|
|
|
id_us_plus_no_lib((ID *)seq->sound);
|
|
|
|
|
seq->scene_sound = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (seq->type == SEQ_TYPE_TEXT) {
|
|
|
|
|
TextVars *t = seq->effectdata;
|
|
|
|
|
BLO_read_id_address(reader, sce->id.lib, &t->text_font);
|
|
|
|
|
}
|
|
|
|
|
BLI_listbase_clear(&seq->anims);
|
|
|
|
|
|
|
|
|
|
SEQ_modifier_blend_read_lib(reader, sce, &seq->modifiers);
|
2021-09-21 10:38:15 +02:00
|
|
|
|
|
|
|
|
seq->flag &= ~SEQ_FLAG_SKIP_THUMBNAILS;
|
2021-08-20 16:30:34 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SEQ_blend_read_lib(BlendLibReader *reader, Scene *scene, ListBase *seqbase)
|
|
|
|
|
{
|
|
|
|
|
Read_lib_data data = {reader, scene};
|
|
|
|
|
SEQ_for_each_callback(seqbase, seq_read_lib_cb, &data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool seq_blend_read_expand(Sequence *seq, void *user_data)
|
|
|
|
|
{
|
|
|
|
|
BlendExpander *expander = (BlendExpander *)user_data;
|
|
|
|
|
|
|
|
|
|
IDP_BlendReadExpand(expander, seq->prop);
|
|
|
|
|
|
|
|
|
|
if (seq->scene) {
|
|
|
|
|
BLO_expand(expander, seq->scene);
|
|
|
|
|
}
|
|
|
|
|
if (seq->scene_camera) {
|
|
|
|
|
BLO_expand(expander, seq->scene_camera);
|
|
|
|
|
}
|
|
|
|
|
if (seq->clip) {
|
|
|
|
|
BLO_expand(expander, seq->clip);
|
|
|
|
|
}
|
|
|
|
|
if (seq->mask) {
|
|
|
|
|
BLO_expand(expander, seq->mask);
|
|
|
|
|
}
|
|
|
|
|
if (seq->sound) {
|
|
|
|
|
BLO_expand(expander, seq->sound);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (seq->type == SEQ_TYPE_TEXT && seq->effectdata) {
|
|
|
|
|
TextVars *data = seq->effectdata;
|
|
|
|
|
BLO_expand(expander, data->text_font);
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SEQ_blend_read_expand(BlendExpander *expander, ListBase *seqbase)
|
|
|
|
|
{
|
|
|
|
|
SEQ_for_each_callback(seqbase, seq_blend_read_expand, expander);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Depsgraph update functions. */
|
|
|
|
|
|
|
|
|
|
static bool seq_disable_sound_strips_cb(Sequence *seq, void *user_data)
|
|
|
|
|
{
|
|
|
|
|
Scene *scene = (Scene *)user_data;
|
|
|
|
|
if (seq->scene_sound != NULL) {
|
|
|
|
|
BKE_sound_remove_scene_sound(scene, seq->scene_sound);
|
|
|
|
|
seq->scene_sound = NULL;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool seq_update_seq_cb(Sequence *seq, void *user_data)
|
|
|
|
|
{
|
|
|
|
|
Scene *scene = (Scene *)user_data;
|
|
|
|
|
if (seq->scene_sound == NULL) {
|
|
|
|
|
if (seq->sound != NULL) {
|
|
|
|
|
seq->scene_sound = BKE_sound_add_scene_sound_defaults(scene, seq);
|
|
|
|
|
}
|
|
|
|
|
else if (seq->type == SEQ_TYPE_SCENE) {
|
|
|
|
|
if (seq->scene != NULL) {
|
|
|
|
|
BKE_sound_ensure_scene(seq->scene);
|
|
|
|
|
seq->scene_sound = BKE_sound_scene_add_scene_sound_defaults(scene, seq);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (seq->scene_sound != NULL) {
|
|
|
|
|
/* Make sure changing volume via sequence's properties panel works correct.
|
|
|
|
|
*
|
|
|
|
|
* Ideally, the entire BKE_scene_update_sound() will happen from a dependency graph, so
|
|
|
|
|
* then it is no longer needed to do such manual forced updates. */
|
|
|
|
|
if (seq->type == SEQ_TYPE_SCENE && seq->scene != NULL) {
|
|
|
|
|
BKE_sound_set_scene_volume(seq->scene, seq->scene->audio.volume);
|
|
|
|
|
if ((seq->flag & SEQ_SCENE_STRIPS) == 0 && seq->scene->sound_scene != NULL &&
|
|
|
|
|
seq->scene->ed != NULL) {
|
|
|
|
|
SEQ_for_each_callback(&seq->scene->ed->seqbase, seq_disable_sound_strips_cb, seq->scene);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (seq->sound != NULL) {
|
|
|
|
|
if (scene->id.recalc & ID_RECALC_AUDIO || seq->sound->id.recalc & ID_RECALC_AUDIO) {
|
|
|
|
|
BKE_sound_update_scene_sound(seq->scene_sound, seq->sound);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
BKE_sound_set_scene_sound_volume(
|
|
|
|
|
seq->scene_sound, seq->volume, (seq->flag & SEQ_AUDIO_VOLUME_ANIMATED) != 0);
|
|
|
|
|
BKE_sound_set_scene_sound_pitch(
|
|
|
|
|
seq->scene_sound, seq->pitch, (seq->flag & SEQ_AUDIO_PITCH_ANIMATED) != 0);
|
|
|
|
|
BKE_sound_set_scene_sound_pan(
|
|
|
|
|
seq->scene_sound, seq->pan, (seq->flag & SEQ_AUDIO_PAN_ANIMATED) != 0);
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SEQ_eval_sequences(Depsgraph *depsgraph, Scene *scene, ListBase *seqbase)
|
|
|
|
|
{
|
|
|
|
|
DEG_debug_print_eval(depsgraph, __func__, scene->id.name, scene);
|
|
|
|
|
BKE_sound_ensure_scene(scene);
|
|
|
|
|
|
|
|
|
|
SEQ_for_each_callback(seqbase, seq_update_seq_cb, scene);
|
|
|
|
|
|
|
|
|
|
SEQ_edit_update_muting(scene->ed);
|
|
|
|
|
SEQ_sound_update_bounds_all(scene);
|
|
|
|
|
}
|