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> */
|
2020-11-16 05:02:30 +01:00
|
|
|
|
|
|
|
/** \file
|
|
|
|
* \ingroup bke
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
#include "DNA_sequence_types.h"
|
|
|
|
|
|
|
|
#include "BLI_listbase.h"
|
|
|
|
#include "BLI_math.h"
|
|
|
|
|
|
|
|
#include "BKE_movieclip.h"
|
|
|
|
#include "BKE_scene.h"
|
|
|
|
#include "BKE_sound.h"
|
|
|
|
|
2021-07-06 19:48:06 +02:00
|
|
|
#include "DNA_sound_types.h"
|
2020-11-16 05:02:30 +01:00
|
|
|
#include "IMB_imbuf.h"
|
|
|
|
|
2022-04-04 12:52:48 +02:00
|
|
|
#include "SEQ_channels.h"
|
VSE: Fix rendering inconsistency
Fix issue described in T87678, which was partially a bug and partially
change in intended(at least as far as I can tell) behaior.
Function `evaluate_seq_frame_gen` that was partially responsible for
filtering strips in stack for rendering wasn't working correctly.
Intended functionality seems to be removing all effect inputs from stack
as it is unlikely that user would want these to be blended in. However
there was logic to exclude effects placed into same input, which because
of weak implementation caused, that any effect input, that is effect as
well will be considered to be part of stack to be blended in.
This bug was apparently used to produce effects like glow over original
image.
Even though this is originally unintended, I have kept this logic, but
I have made it explicit.
Another change is request made in T87678 to make it possible to keep
effect inputs as part of stack when they are placed above the effect,
which would imply that blending is intended. This change is again
explicitly defined.
Whole implementation has been refactored, so logic is consolidated
and code should be as explicit as possible and more readable.
`must_render_strip function` may be still quite hard to read, not sure
if I can make it nicer.
Last change is for remove gaps feature code - it used same rendering
code, which may be reason why its logic was split in first place.
Now it uses sequencer iterator, which will definitely be faster than
original code, but I could have used `LISTBASE_FOREACH` in this case.
Reviewed By: sergey
Differential Revision: https://developer.blender.org/D11301
2021-05-19 22:59:33 +02:00
|
|
|
#include "SEQ_iterator.h"
|
2020-12-19 06:44:57 +01:00
|
|
|
#include "SEQ_render.h"
|
2020-11-16 05:02:30 +01:00
|
|
|
#include "SEQ_sequencer.h"
|
2020-12-19 06:44:57 +01:00
|
|
|
#include "SEQ_time.h"
|
2021-05-11 12:25:54 +02:00
|
|
|
#include "SEQ_transform.h"
|
2020-11-16 05:02:30 +01:00
|
|
|
|
|
|
|
#include "strip_time.h"
|
|
|
|
#include "utils.h"
|
|
|
|
|
|
|
|
float seq_give_frame_index(Sequence *seq, float timeline_frame)
|
|
|
|
{
|
|
|
|
float frame_index;
|
|
|
|
int sta = seq->start;
|
|
|
|
int end = seq->start + seq->len - 1;
|
|
|
|
|
|
|
|
if (seq->type & SEQ_TYPE_EFFECT) {
|
|
|
|
end = seq->enddisp;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (end < sta) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (seq->flag & SEQ_REVERSE_FRAMES) {
|
2021-06-26 21:35:18 +10:00
|
|
|
/* Reverse frame in this sequence. */
|
2020-11-16 05:02:30 +01:00
|
|
|
if (timeline_frame <= sta) {
|
|
|
|
frame_index = end - sta;
|
|
|
|
}
|
|
|
|
else if (timeline_frame >= end) {
|
|
|
|
frame_index = 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
frame_index = end - timeline_frame;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (timeline_frame <= sta) {
|
|
|
|
frame_index = 0;
|
|
|
|
}
|
|
|
|
else if (timeline_frame >= end) {
|
|
|
|
frame_index = end - sta;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
frame_index = timeline_frame - sta;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (seq->strobe < 1.0f) {
|
|
|
|
seq->strobe = 1.0f;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (seq->strobe > 1.0f) {
|
|
|
|
frame_index -= fmodf((double)frame_index, (double)seq->strobe);
|
|
|
|
}
|
|
|
|
|
|
|
|
return frame_index;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int metaseq_start(Sequence *metaseq)
|
|
|
|
{
|
|
|
|
return metaseq->start + metaseq->startofs;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int metaseq_end(Sequence *metaseq)
|
|
|
|
{
|
|
|
|
return metaseq->start + metaseq->len - metaseq->endofs;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void seq_update_sound_bounds_recursive_impl(Scene *scene,
|
|
|
|
Sequence *metaseq,
|
|
|
|
int start,
|
|
|
|
int end)
|
|
|
|
{
|
|
|
|
Sequence *seq;
|
|
|
|
|
2021-07-23 16:56:00 +10:00
|
|
|
/* For sound we go over full meta tree to update bounds of the sound strips,
|
|
|
|
* since sound is played outside of evaluating the imbufs. */
|
2020-11-16 05:02:30 +01:00
|
|
|
for (seq = metaseq->seqbase.first; seq; seq = seq->next) {
|
|
|
|
if (seq->type == SEQ_TYPE_META) {
|
|
|
|
seq_update_sound_bounds_recursive_impl(
|
|
|
|
scene, seq, max_ii(start, metaseq_start(seq)), min_ii(end, metaseq_end(seq)));
|
|
|
|
}
|
|
|
|
else if (ELEM(seq->type, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SCENE)) {
|
|
|
|
if (seq->scene_sound) {
|
|
|
|
int startofs = seq->startofs;
|
|
|
|
int endofs = seq->endofs;
|
|
|
|
if (seq->startofs + seq->start < start) {
|
|
|
|
startofs = start - seq->start;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (seq->start + seq->len - seq->endofs > end) {
|
|
|
|
endofs = seq->start + seq->len - end;
|
|
|
|
}
|
|
|
|
|
2021-10-16 01:25:27 +02:00
|
|
|
double offset_time = 0.0f;
|
|
|
|
if (seq->sound != NULL) {
|
|
|
|
offset_time = seq->sound->offset_time;
|
|
|
|
}
|
|
|
|
|
2020-11-16 05:02:30 +01:00
|
|
|
BKE_sound_move_scene_sound(scene,
|
|
|
|
seq->scene_sound,
|
|
|
|
seq->start + startofs,
|
|
|
|
seq->start + seq->len - endofs,
|
2021-07-06 19:48:06 +02:00
|
|
|
startofs + seq->anim_startofs,
|
2021-10-16 01:25:27 +02:00
|
|
|
offset_time);
|
2020-11-16 05:02:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void seq_update_sound_bounds_recursive(Scene *scene, Sequence *metaseq)
|
|
|
|
{
|
|
|
|
seq_update_sound_bounds_recursive_impl(
|
|
|
|
scene, metaseq, metaseq_start(metaseq), metaseq_end(metaseq));
|
|
|
|
}
|
|
|
|
|
2021-10-07 00:10:37 +02:00
|
|
|
static void seq_time_update_sequence_bounds(Scene *scene, Sequence *seq)
|
2020-11-16 05:02:30 +01:00
|
|
|
{
|
|
|
|
if (seq->startofs && seq->startstill) {
|
|
|
|
seq->startstill = 0;
|
|
|
|
}
|
|
|
|
if (seq->endofs && seq->endstill) {
|
|
|
|
seq->endstill = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
seq->startdisp = seq->start + seq->startofs - seq->startstill;
|
|
|
|
seq->enddisp = seq->start + seq->len - seq->endofs + seq->endstill;
|
|
|
|
|
|
|
|
if (seq->type == SEQ_TYPE_META) {
|
|
|
|
seq_update_sound_bounds_recursive(scene, seq);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-11 12:25:54 +02:00
|
|
|
static void seq_time_update_meta_strip(Scene *scene, Sequence *seq_meta)
|
|
|
|
{
|
|
|
|
if (BLI_listbase_is_empty(&seq_meta->seqbase)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int min = MAXFRAME * 2;
|
|
|
|
int max = -MAXFRAME * 2;
|
|
|
|
LISTBASE_FOREACH (Sequence *, seq, &seq_meta->seqbase) {
|
|
|
|
min = min_ii(seq->startdisp, min);
|
|
|
|
max = max_ii(seq->enddisp, max);
|
|
|
|
}
|
|
|
|
|
|
|
|
seq_meta->start = min + seq_meta->anim_startofs;
|
|
|
|
seq_meta->len = max - min;
|
|
|
|
seq_meta->len -= seq_meta->anim_startofs;
|
|
|
|
seq_meta->len -= seq_meta->anim_endofs;
|
|
|
|
|
|
|
|
seq_update_sound_bounds_recursive(scene, seq_meta);
|
|
|
|
}
|
|
|
|
|
2021-06-17 03:40:44 +02:00
|
|
|
void SEQ_time_update_meta_strip_range(Scene *scene, Sequence *seq_meta)
|
2021-05-11 12:25:54 +02:00
|
|
|
{
|
2021-12-21 05:27:46 +01:00
|
|
|
if (seq_meta == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-05-11 12:25:54 +02:00
|
|
|
seq_time_update_meta_strip(scene, seq_meta);
|
|
|
|
|
2021-05-14 17:35:22 +10:00
|
|
|
/* Prevent meta-strip to move in timeline. */
|
2021-05-11 12:25:54 +02:00
|
|
|
SEQ_transform_set_left_handle_frame(seq_meta, seq_meta->startdisp);
|
|
|
|
SEQ_transform_set_right_handle_frame(seq_meta, seq_meta->enddisp);
|
|
|
|
}
|
|
|
|
|
2021-10-07 00:10:37 +02:00
|
|
|
void SEQ_time_update_sequence(Scene *scene, ListBase *seqbase, Sequence *seq)
|
2020-11-16 05:02:30 +01:00
|
|
|
{
|
|
|
|
Sequence *seqm;
|
|
|
|
|
2021-05-14 17:35:22 +10:00
|
|
|
/* Check all meta-strips recursively. */
|
2020-11-16 05:02:30 +01:00
|
|
|
seqm = seq->seqbase.first;
|
|
|
|
while (seqm) {
|
|
|
|
if (seqm->seqbase.first) {
|
2021-10-07 00:10:37 +02:00
|
|
|
SEQ_time_update_sequence(scene, &seqm->seqbase, seqm);
|
2020-11-16 05:02:30 +01:00
|
|
|
}
|
|
|
|
seqm = seqm->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* effects and meta: automatic start and end */
|
|
|
|
if (seq->type & SEQ_TYPE_EFFECT) {
|
|
|
|
if (seq->seq1) {
|
|
|
|
seq->startofs = seq->endofs = seq->startstill = seq->endstill = 0;
|
|
|
|
if (seq->seq3) {
|
|
|
|
seq->start = seq->startdisp = max_iii(
|
|
|
|
seq->seq1->startdisp, seq->seq2->startdisp, seq->seq3->startdisp);
|
|
|
|
seq->enddisp = min_iii(seq->seq1->enddisp, seq->seq2->enddisp, seq->seq3->enddisp);
|
|
|
|
}
|
|
|
|
else if (seq->seq2) {
|
|
|
|
seq->start = seq->startdisp = max_ii(seq->seq1->startdisp, seq->seq2->startdisp);
|
|
|
|
seq->enddisp = min_ii(seq->seq1->enddisp, seq->seq2->enddisp);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
seq->start = seq->startdisp = seq->seq1->startdisp;
|
|
|
|
seq->enddisp = seq->seq1->enddisp;
|
|
|
|
}
|
2021-06-22 10:42:32 -07:00
|
|
|
/* we can't help if strips don't overlap, it won't give useful results.
|
2020-11-16 05:02:30 +01:00
|
|
|
* but at least ensure 'len' is never negative which causes bad bugs elsewhere. */
|
|
|
|
if (seq->enddisp < seq->startdisp) {
|
|
|
|
/* simple start/end swap */
|
|
|
|
seq->start = seq->enddisp;
|
|
|
|
seq->enddisp = seq->startdisp;
|
|
|
|
seq->startdisp = seq->start;
|
|
|
|
seq->flag |= SEQ_INVALID_EFFECT;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
seq->flag &= ~SEQ_INVALID_EFFECT;
|
|
|
|
}
|
|
|
|
|
|
|
|
seq->len = seq->enddisp - seq->startdisp;
|
|
|
|
}
|
|
|
|
else {
|
2021-10-07 00:10:37 +02:00
|
|
|
seq_time_update_sequence_bounds(scene, seq);
|
2020-11-16 05:02:30 +01:00
|
|
|
}
|
|
|
|
}
|
2021-10-07 00:10:37 +02:00
|
|
|
else if (seq->type == SEQ_TYPE_META) {
|
|
|
|
seq_time_update_meta_strip(scene, seq);
|
|
|
|
}
|
2020-11-16 05:02:30 +01:00
|
|
|
else {
|
2021-10-07 00:10:37 +02:00
|
|
|
seq_time_update_sequence_bounds(scene, seq);
|
|
|
|
}
|
2021-05-11 12:25:54 +02:00
|
|
|
|
2021-10-07 00:10:37 +02:00
|
|
|
Editing *ed = SEQ_editing_get(scene);
|
2021-05-11 12:25:54 +02:00
|
|
|
|
2021-10-07 00:10:37 +02:00
|
|
|
/* Strip is inside meta strip */
|
|
|
|
if (seqbase != &ed->seqbase) {
|
|
|
|
Sequence *meta = SEQ_get_meta_by_seqbase(&ed->seqbase, seqbase);
|
|
|
|
SEQ_time_update_meta_strip_range(scene, meta);
|
2020-11-16 05:02:30 +01:00
|
|
|
}
|
2021-10-07 00:10:37 +02:00
|
|
|
|
|
|
|
seq_time_update_sequence_bounds(scene, seq);
|
2020-11-16 05:02:30 +01:00
|
|
|
}
|
|
|
|
|
2021-11-15 20:23:57 +01:00
|
|
|
static bool update_changed_seq_recurs(Scene *scene, Sequence *seq, Sequence *changed_seq)
|
|
|
|
{
|
|
|
|
Sequence *subseq;
|
|
|
|
bool do_update = false;
|
|
|
|
|
|
|
|
/* recurse downwards to see if this seq depends on the changed seq */
|
|
|
|
|
|
|
|
if (seq == NULL) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (seq == changed_seq) {
|
|
|
|
do_update = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (subseq = seq->seqbase.first; subseq; subseq = subseq->next) {
|
|
|
|
if (update_changed_seq_recurs(scene, subseq, changed_seq)) {
|
|
|
|
do_update = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (seq->seq1) {
|
|
|
|
if (update_changed_seq_recurs(scene, seq->seq1, changed_seq)) {
|
|
|
|
do_update = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (seq->seq2 && (seq->seq2 != seq->seq1)) {
|
|
|
|
if (update_changed_seq_recurs(scene, seq->seq2, changed_seq)) {
|
|
|
|
do_update = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (seq->seq3 && (seq->seq3 != seq->seq1) && (seq->seq3 != seq->seq2)) {
|
|
|
|
if (update_changed_seq_recurs(scene, seq->seq3, changed_seq)) {
|
|
|
|
do_update = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (do_update) {
|
|
|
|
ListBase *seqbase = SEQ_active_seqbase_get(SEQ_editing_get(scene));
|
|
|
|
SEQ_time_update_sequence(scene, seqbase, seq);
|
|
|
|
}
|
|
|
|
|
|
|
|
return do_update;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SEQ_time_update_recursive(Scene *scene, Sequence *changed_seq)
|
|
|
|
{
|
|
|
|
Editing *ed = SEQ_editing_get(scene);
|
|
|
|
Sequence *seq;
|
|
|
|
|
|
|
|
if (ed == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (seq = ed->seqbase.first; seq; seq = seq->next) {
|
|
|
|
update_changed_seq_recurs(scene, seq, changed_seq);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-19 05:57:27 +01:00
|
|
|
int SEQ_time_find_next_prev_edit(Scene *scene,
|
|
|
|
int timeline_frame,
|
|
|
|
const short side,
|
|
|
|
const bool do_skip_mute,
|
|
|
|
const bool do_center,
|
|
|
|
const bool do_unselected)
|
2020-11-16 05:02:30 +01:00
|
|
|
{
|
2021-09-02 11:29:32 +10:00
|
|
|
Editing *ed = SEQ_editing_get(scene);
|
2022-04-04 12:52:48 +02:00
|
|
|
ListBase *channels = SEQ_channels_displayed_get(ed);
|
2020-11-16 05:02:30 +01:00
|
|
|
Sequence *seq;
|
|
|
|
|
|
|
|
int dist, best_dist, best_frame = timeline_frame;
|
|
|
|
int seq_frames[2], seq_frames_tot;
|
|
|
|
|
|
|
|
/* In case where both is passed,
|
|
|
|
* frame just finds the nearest end while frame_left the nearest start. */
|
|
|
|
|
|
|
|
best_dist = MAXFRAME * 2;
|
|
|
|
|
|
|
|
if (ed == NULL) {
|
|
|
|
return timeline_frame;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
|
|
|
|
int i;
|
|
|
|
|
2022-04-04 12:52:48 +02:00
|
|
|
if (do_skip_mute && SEQ_render_is_muted(channels, seq)) {
|
2020-11-16 05:02:30 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (do_unselected && (seq->flag & SELECT)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (do_center) {
|
|
|
|
seq_frames[0] = (seq->startdisp + seq->enddisp) / 2;
|
|
|
|
seq_frames_tot = 1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
seq_frames[0] = seq->startdisp;
|
|
|
|
seq_frames[1] = seq->enddisp;
|
|
|
|
|
|
|
|
seq_frames_tot = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < seq_frames_tot; i++) {
|
|
|
|
const int seq_frame = seq_frames[i];
|
|
|
|
|
|
|
|
dist = MAXFRAME * 2;
|
|
|
|
|
|
|
|
switch (side) {
|
|
|
|
case SEQ_SIDE_LEFT:
|
|
|
|
if (seq_frame < timeline_frame) {
|
|
|
|
dist = timeline_frame - seq_frame;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SEQ_SIDE_RIGHT:
|
|
|
|
if (seq_frame > timeline_frame) {
|
|
|
|
dist = seq_frame - timeline_frame;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SEQ_SIDE_BOTH:
|
|
|
|
dist = abs(seq_frame - timeline_frame);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dist < best_dist) {
|
|
|
|
best_frame = seq_frame;
|
|
|
|
best_dist = dist;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return best_frame;
|
|
|
|
}
|
|
|
|
|
2020-12-19 05:57:27 +01:00
|
|
|
float SEQ_time_sequence_get_fps(Scene *scene, Sequence *seq)
|
2020-11-16 05:02:30 +01:00
|
|
|
{
|
|
|
|
switch (seq->type) {
|
|
|
|
case SEQ_TYPE_MOVIE: {
|
|
|
|
seq_open_anim_file(scene, seq, true);
|
|
|
|
if (BLI_listbase_is_empty(&seq->anims)) {
|
|
|
|
return 0.0f;
|
|
|
|
}
|
|
|
|
StripAnim *strip_anim = seq->anims.first;
|
|
|
|
if (strip_anim->anim == NULL) {
|
|
|
|
return 0.0f;
|
|
|
|
}
|
|
|
|
short frs_sec;
|
|
|
|
float frs_sec_base;
|
|
|
|
if (IMB_anim_get_fps(strip_anim->anim, &frs_sec, &frs_sec_base, true)) {
|
|
|
|
return (float)frs_sec / frs_sec_base;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SEQ_TYPE_MOVIECLIP:
|
|
|
|
if (seq->clip != NULL) {
|
|
|
|
return BKE_movieclip_get_fps(seq->clip);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SEQ_TYPE_SCENE:
|
|
|
|
if (seq->scene != NULL) {
|
|
|
|
return (float)seq->scene->r.frs_sec / seq->scene->r.frs_sec_base;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0.0f;
|
|
|
|
}
|
2020-12-15 21:42:06 +01:00
|
|
|
|
2021-10-25 06:47:51 +02:00
|
|
|
void SEQ_timeline_init_boundbox(const Scene *scene, rctf *rect)
|
2020-12-15 21:42:06 +01:00
|
|
|
{
|
2020-12-17 02:11:22 +01:00
|
|
|
rect->xmin = scene->r.sfra;
|
|
|
|
rect->xmax = scene->r.efra + 1;
|
|
|
|
rect->ymin = 0.0f;
|
|
|
|
rect->ymax = 8.0f;
|
2021-10-25 06:47:51 +02:00
|
|
|
}
|
2020-12-17 02:11:22 +01:00
|
|
|
|
2021-10-25 06:47:51 +02:00
|
|
|
void SEQ_timeline_expand_boundbox(const ListBase *seqbase, rctf *rect)
|
|
|
|
{
|
2020-12-17 02:11:22 +01:00
|
|
|
if (seqbase == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
2020-12-15 21:42:06 +01:00
|
|
|
|
|
|
|
LISTBASE_FOREACH (Sequence *, seq, seqbase) {
|
2020-12-17 02:11:22 +01:00
|
|
|
if (rect->xmin > seq->startdisp - 1) {
|
|
|
|
rect->xmin = seq->startdisp - 1;
|
2020-12-15 21:42:06 +01:00
|
|
|
}
|
2020-12-17 02:11:22 +01:00
|
|
|
if (rect->xmax < seq->enddisp + 1) {
|
|
|
|
rect->xmax = seq->enddisp + 1;
|
2020-12-15 21:42:06 +01:00
|
|
|
}
|
2022-04-04 12:52:48 +02:00
|
|
|
if (rect->ymax < seq->machine) {
|
2020-12-17 02:11:22 +01:00
|
|
|
rect->ymax = seq->machine + 2;
|
2020-12-15 21:42:06 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-25 06:47:51 +02:00
|
|
|
void SEQ_timeline_boundbox(const Scene *scene, const ListBase *seqbase, rctf *rect)
|
|
|
|
{
|
|
|
|
SEQ_timeline_init_boundbox(scene, rect);
|
|
|
|
SEQ_timeline_expand_boundbox(seqbase, rect);
|
|
|
|
}
|
|
|
|
|
VSE: Fix rendering inconsistency
Fix issue described in T87678, which was partially a bug and partially
change in intended(at least as far as I can tell) behaior.
Function `evaluate_seq_frame_gen` that was partially responsible for
filtering strips in stack for rendering wasn't working correctly.
Intended functionality seems to be removing all effect inputs from stack
as it is unlikely that user would want these to be blended in. However
there was logic to exclude effects placed into same input, which because
of weak implementation caused, that any effect input, that is effect as
well will be considered to be part of stack to be blended in.
This bug was apparently used to produce effects like glow over original
image.
Even though this is originally unintended, I have kept this logic, but
I have made it explicit.
Another change is request made in T87678 to make it possible to keep
effect inputs as part of stack when they are placed above the effect,
which would imply that blending is intended. This change is again
explicitly defined.
Whole implementation has been refactored, so logic is consolidated
and code should be as explicit as possible and more readable.
`must_render_strip function` may be still quite hard to read, not sure
if I can make it nicer.
Last change is for remove gaps feature code - it used same rendering
code, which may be reason why its logic was split in first place.
Now it uses sequencer iterator, which will definitely be faster than
original code, but I could have used `LISTBASE_FOREACH` in this case.
Reviewed By: sergey
Differential Revision: https://developer.blender.org/D11301
2021-05-19 22:59:33 +02:00
|
|
|
static bool strip_exists_at_frame(SeqCollection *all_strips, const int timeline_frame)
|
|
|
|
{
|
|
|
|
Sequence *seq;
|
|
|
|
SEQ_ITERATOR_FOREACH (seq, all_strips) {
|
2021-06-02 21:41:38 +02:00
|
|
|
if (SEQ_time_strip_intersects_frame(seq, timeline_frame)) {
|
VSE: Fix rendering inconsistency
Fix issue described in T87678, which was partially a bug and partially
change in intended(at least as far as I can tell) behaior.
Function `evaluate_seq_frame_gen` that was partially responsible for
filtering strips in stack for rendering wasn't working correctly.
Intended functionality seems to be removing all effect inputs from stack
as it is unlikely that user would want these to be blended in. However
there was logic to exclude effects placed into same input, which because
of weak implementation caused, that any effect input, that is effect as
well will be considered to be part of stack to be blended in.
This bug was apparently used to produce effects like glow over original
image.
Even though this is originally unintended, I have kept this logic, but
I have made it explicit.
Another change is request made in T87678 to make it possible to keep
effect inputs as part of stack when they are placed above the effect,
which would imply that blending is intended. This change is again
explicitly defined.
Whole implementation has been refactored, so logic is consolidated
and code should be as explicit as possible and more readable.
`must_render_strip function` may be still quite hard to read, not sure
if I can make it nicer.
Last change is for remove gaps feature code - it used same rendering
code, which may be reason why its logic was split in first place.
Now it uses sequencer iterator, which will definitely be faster than
original code, but I could have used `LISTBASE_FOREACH` in this case.
Reviewed By: sergey
Differential Revision: https://developer.blender.org/D11301
2021-05-19 22:59:33 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-12-15 21:42:06 +01:00
|
|
|
void seq_time_gap_info_get(const Scene *scene,
|
|
|
|
ListBase *seqbase,
|
|
|
|
const int initial_frame,
|
|
|
|
GapInfo *r_gap_info)
|
|
|
|
{
|
|
|
|
rctf rectf;
|
|
|
|
/* Get first and last frame. */
|
|
|
|
SEQ_timeline_boundbox(scene, seqbase, &rectf);
|
|
|
|
const int sfra = (int)rectf.xmin;
|
|
|
|
const int efra = (int)rectf.xmax;
|
|
|
|
int timeline_frame = initial_frame;
|
|
|
|
r_gap_info->gap_exists = false;
|
|
|
|
|
VSE: Fix rendering inconsistency
Fix issue described in T87678, which was partially a bug and partially
change in intended(at least as far as I can tell) behaior.
Function `evaluate_seq_frame_gen` that was partially responsible for
filtering strips in stack for rendering wasn't working correctly.
Intended functionality seems to be removing all effect inputs from stack
as it is unlikely that user would want these to be blended in. However
there was logic to exclude effects placed into same input, which because
of weak implementation caused, that any effect input, that is effect as
well will be considered to be part of stack to be blended in.
This bug was apparently used to produce effects like glow over original
image.
Even though this is originally unintended, I have kept this logic, but
I have made it explicit.
Another change is request made in T87678 to make it possible to keep
effect inputs as part of stack when they are placed above the effect,
which would imply that blending is intended. This change is again
explicitly defined.
Whole implementation has been refactored, so logic is consolidated
and code should be as explicit as possible and more readable.
`must_render_strip function` may be still quite hard to read, not sure
if I can make it nicer.
Last change is for remove gaps feature code - it used same rendering
code, which may be reason why its logic was split in first place.
Now it uses sequencer iterator, which will definitely be faster than
original code, but I could have used `LISTBASE_FOREACH` in this case.
Reviewed By: sergey
Differential Revision: https://developer.blender.org/D11301
2021-05-19 22:59:33 +02:00
|
|
|
SeqCollection *collection = SEQ_query_all_strips(seqbase);
|
|
|
|
|
|
|
|
if (!strip_exists_at_frame(collection, initial_frame)) {
|
2020-12-15 21:42:06 +01:00
|
|
|
/* Search backward for gap_start_frame. */
|
|
|
|
for (; timeline_frame >= sfra; timeline_frame--) {
|
VSE: Fix rendering inconsistency
Fix issue described in T87678, which was partially a bug and partially
change in intended(at least as far as I can tell) behaior.
Function `evaluate_seq_frame_gen` that was partially responsible for
filtering strips in stack for rendering wasn't working correctly.
Intended functionality seems to be removing all effect inputs from stack
as it is unlikely that user would want these to be blended in. However
there was logic to exclude effects placed into same input, which because
of weak implementation caused, that any effect input, that is effect as
well will be considered to be part of stack to be blended in.
This bug was apparently used to produce effects like glow over original
image.
Even though this is originally unintended, I have kept this logic, but
I have made it explicit.
Another change is request made in T87678 to make it possible to keep
effect inputs as part of stack when they are placed above the effect,
which would imply that blending is intended. This change is again
explicitly defined.
Whole implementation has been refactored, so logic is consolidated
and code should be as explicit as possible and more readable.
`must_render_strip function` may be still quite hard to read, not sure
if I can make it nicer.
Last change is for remove gaps feature code - it used same rendering
code, which may be reason why its logic was split in first place.
Now it uses sequencer iterator, which will definitely be faster than
original code, but I could have used `LISTBASE_FOREACH` in this case.
Reviewed By: sergey
Differential Revision: https://developer.blender.org/D11301
2021-05-19 22:59:33 +02:00
|
|
|
if (strip_exists_at_frame(collection, timeline_frame)) {
|
2020-12-15 21:42:06 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
r_gap_info->gap_start_frame = timeline_frame + 1;
|
|
|
|
timeline_frame = initial_frame;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* Search forward for gap_start_frame. */
|
|
|
|
for (; timeline_frame <= efra; timeline_frame++) {
|
VSE: Fix rendering inconsistency
Fix issue described in T87678, which was partially a bug and partially
change in intended(at least as far as I can tell) behaior.
Function `evaluate_seq_frame_gen` that was partially responsible for
filtering strips in stack for rendering wasn't working correctly.
Intended functionality seems to be removing all effect inputs from stack
as it is unlikely that user would want these to be blended in. However
there was logic to exclude effects placed into same input, which because
of weak implementation caused, that any effect input, that is effect as
well will be considered to be part of stack to be blended in.
This bug was apparently used to produce effects like glow over original
image.
Even though this is originally unintended, I have kept this logic, but
I have made it explicit.
Another change is request made in T87678 to make it possible to keep
effect inputs as part of stack when they are placed above the effect,
which would imply that blending is intended. This change is again
explicitly defined.
Whole implementation has been refactored, so logic is consolidated
and code should be as explicit as possible and more readable.
`must_render_strip function` may be still quite hard to read, not sure
if I can make it nicer.
Last change is for remove gaps feature code - it used same rendering
code, which may be reason why its logic was split in first place.
Now it uses sequencer iterator, which will definitely be faster than
original code, but I could have used `LISTBASE_FOREACH` in this case.
Reviewed By: sergey
Differential Revision: https://developer.blender.org/D11301
2021-05-19 22:59:33 +02:00
|
|
|
if (!strip_exists_at_frame(collection, timeline_frame)) {
|
2020-12-15 21:42:06 +01:00
|
|
|
r_gap_info->gap_start_frame = timeline_frame;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Search forward for gap_end_frame. */
|
|
|
|
for (; timeline_frame <= efra; timeline_frame++) {
|
VSE: Fix rendering inconsistency
Fix issue described in T87678, which was partially a bug and partially
change in intended(at least as far as I can tell) behaior.
Function `evaluate_seq_frame_gen` that was partially responsible for
filtering strips in stack for rendering wasn't working correctly.
Intended functionality seems to be removing all effect inputs from stack
as it is unlikely that user would want these to be blended in. However
there was logic to exclude effects placed into same input, which because
of weak implementation caused, that any effect input, that is effect as
well will be considered to be part of stack to be blended in.
This bug was apparently used to produce effects like glow over original
image.
Even though this is originally unintended, I have kept this logic, but
I have made it explicit.
Another change is request made in T87678 to make it possible to keep
effect inputs as part of stack when they are placed above the effect,
which would imply that blending is intended. This change is again
explicitly defined.
Whole implementation has been refactored, so logic is consolidated
and code should be as explicit as possible and more readable.
`must_render_strip function` may be still quite hard to read, not sure
if I can make it nicer.
Last change is for remove gaps feature code - it used same rendering
code, which may be reason why its logic was split in first place.
Now it uses sequencer iterator, which will definitely be faster than
original code, but I could have used `LISTBASE_FOREACH` in this case.
Reviewed By: sergey
Differential Revision: https://developer.blender.org/D11301
2021-05-19 22:59:33 +02:00
|
|
|
if (strip_exists_at_frame(collection, timeline_frame)) {
|
2020-12-15 21:42:06 +01:00
|
|
|
const int gap_end_frame = timeline_frame;
|
|
|
|
r_gap_info->gap_length = gap_end_frame - r_gap_info->gap_start_frame;
|
|
|
|
r_gap_info->gap_exists = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-06-02 21:41:38 +02:00
|
|
|
|
2021-06-02 21:52:36 +02:00
|
|
|
bool SEQ_time_strip_intersects_frame(const Sequence *seq, const int timeline_frame)
|
2021-06-02 21:41:38 +02:00
|
|
|
{
|
|
|
|
return (seq->startdisp <= timeline_frame) && (seq->enddisp > timeline_frame);
|
|
|
|
}
|