This repository has been archived on 2023-10-09. You can view files and clone it, but cannot push or open issues or pull requests.
Files
blender-archive/source/blender/sequencer/SEQ_iterator.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

98 lines
3.4 KiB
C++
Raw Normal View History

2020-12-19 06:44:57 +01:00
/*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2004 Blender Foundation.
* All rights reserved.
*/
#pragma once
/** \file
* \ingroup sequencer
*/
#ifdef __cplusplus
extern "C" {
#endif
VSE: New iterator design This iterator design provides means to create simple and flexible API to query and work with collection of strips. It should be used in cases when conditions require multiple stages of recursive iteration of all strips or similar complex scenarios. Quick API overview: Basic queries are standalone functions that return SeqCollection Use SEQ_collection_create() and SEQ_collection_free() to construct such query functions. Use these functions to get strips of known conditions, like selected strips, movie strips, muted strips and so on. Use SEQ_reference_query() when querying strips with relation to some reference strip. For example to get its effects, strips that have same type or use same input file and so on. These aren't standalone functions because often you need to query strips relative to each strip in collection. Use SEQ_collection_expand() to query strips relative to each strip in collection. These will be merged to original collection. Use SEQ_collection_merge() to merge 2 collections To iterate collection elements use macro SEQ_ITERATOR_FOREACH() This API is quite specific, but I think it is best suited for tasks that are usualy solved in sequencer codebase. Old sequencer iterator has been completely removed. SEQ_ALL_BEGIN and SEQ_ALL_END macros re-use new iterator design. As initial use for this iterator select_grouped_effect_link() function has been rewritten. It was not only broken, but also it used DNA fields to aid iterating strips. Reviewed By: sergey Differential Revision: https://developer.blender.org/D10337
2021-05-07 10:25:13 +02:00
#include "BLI_ghash.h"
2020-12-19 06:44:57 +01:00
struct Editing;
2021-01-04 12:03:34 +11:00
struct Sequence;
VSE: New iterator design This iterator design provides means to create simple and flexible API to query and work with collection of strips. It should be used in cases when conditions require multiple stages of recursive iteration of all strips or similar complex scenarios. Quick API overview: Basic queries are standalone functions that return SeqCollection Use SEQ_collection_create() and SEQ_collection_free() to construct such query functions. Use these functions to get strips of known conditions, like selected strips, movie strips, muted strips and so on. Use SEQ_reference_query() when querying strips with relation to some reference strip. For example to get its effects, strips that have same type or use same input file and so on. These aren't standalone functions because often you need to query strips relative to each strip in collection. Use SEQ_collection_expand() to query strips relative to each strip in collection. These will be merged to original collection. Use SEQ_collection_merge() to merge 2 collections To iterate collection elements use macro SEQ_ITERATOR_FOREACH() This API is quite specific, but I think it is best suited for tasks that are usualy solved in sequencer codebase. Old sequencer iterator has been completely removed. SEQ_ALL_BEGIN and SEQ_ALL_END macros re-use new iterator design. As initial use for this iterator select_grouped_effect_link() function has been rewritten. It was not only broken, but also it used DNA fields to aid iterating strips. Reviewed By: sergey Differential Revision: https://developer.blender.org/D10337
2021-05-07 10:25:13 +02:00
struct GSet;
struct GSetIterator;
2020-12-19 06:44:57 +01:00
VSE: New iterator design This iterator design provides means to create simple and flexible API to query and work with collection of strips. It should be used in cases when conditions require multiple stages of recursive iteration of all strips or similar complex scenarios. Quick API overview: Basic queries are standalone functions that return SeqCollection Use SEQ_collection_create() and SEQ_collection_free() to construct such query functions. Use these functions to get strips of known conditions, like selected strips, movie strips, muted strips and so on. Use SEQ_reference_query() when querying strips with relation to some reference strip. For example to get its effects, strips that have same type or use same input file and so on. These aren't standalone functions because often you need to query strips relative to each strip in collection. Use SEQ_collection_expand() to query strips relative to each strip in collection. These will be merged to original collection. Use SEQ_collection_merge() to merge 2 collections To iterate collection elements use macro SEQ_ITERATOR_FOREACH() This API is quite specific, but I think it is best suited for tasks that are usualy solved in sequencer codebase. Old sequencer iterator has been completely removed. SEQ_ALL_BEGIN and SEQ_ALL_END macros re-use new iterator design. As initial use for this iterator select_grouped_effect_link() function has been rewritten. It was not only broken, but also it used DNA fields to aid iterating strips. Reviewed By: sergey Differential Revision: https://developer.blender.org/D10337
2021-05-07 10:25:13 +02:00
#define SEQ_ITERATOR_FOREACH(var, collection) \
for (SeqIterator iter = {{{NULL}}}; \
SEQ_iterator_ensure(collection, &iter, &var) && var != NULL; \
VSE: New iterator design This iterator design provides means to create simple and flexible API to query and work with collection of strips. It should be used in cases when conditions require multiple stages of recursive iteration of all strips or similar complex scenarios. Quick API overview: Basic queries are standalone functions that return SeqCollection Use SEQ_collection_create() and SEQ_collection_free() to construct such query functions. Use these functions to get strips of known conditions, like selected strips, movie strips, muted strips and so on. Use SEQ_reference_query() when querying strips with relation to some reference strip. For example to get its effects, strips that have same type or use same input file and so on. These aren't standalone functions because often you need to query strips relative to each strip in collection. Use SEQ_collection_expand() to query strips relative to each strip in collection. These will be merged to original collection. Use SEQ_collection_merge() to merge 2 collections To iterate collection elements use macro SEQ_ITERATOR_FOREACH() This API is quite specific, but I think it is best suited for tasks that are usualy solved in sequencer codebase. Old sequencer iterator has been completely removed. SEQ_ALL_BEGIN and SEQ_ALL_END macros re-use new iterator design. As initial use for this iterator select_grouped_effect_link() function has been rewritten. It was not only broken, but also it used DNA fields to aid iterating strips. Reviewed By: sergey Differential Revision: https://developer.blender.org/D10337
2021-05-07 10:25:13 +02:00
var = SEQ_iterator_yield(&iter))
2020-12-19 06:44:57 +01:00
VSE: New iterator design This iterator design provides means to create simple and flexible API to query and work with collection of strips. It should be used in cases when conditions require multiple stages of recursive iteration of all strips or similar complex scenarios. Quick API overview: Basic queries are standalone functions that return SeqCollection Use SEQ_collection_create() and SEQ_collection_free() to construct such query functions. Use these functions to get strips of known conditions, like selected strips, movie strips, muted strips and so on. Use SEQ_reference_query() when querying strips with relation to some reference strip. For example to get its effects, strips that have same type or use same input file and so on. These aren't standalone functions because often you need to query strips relative to each strip in collection. Use SEQ_collection_expand() to query strips relative to each strip in collection. These will be merged to original collection. Use SEQ_collection_merge() to merge 2 collections To iterate collection elements use macro SEQ_ITERATOR_FOREACH() This API is quite specific, but I think it is best suited for tasks that are usualy solved in sequencer codebase. Old sequencer iterator has been completely removed. SEQ_ALL_BEGIN and SEQ_ALL_END macros re-use new iterator design. As initial use for this iterator select_grouped_effect_link() function has been rewritten. It was not only broken, but also it used DNA fields to aid iterating strips. Reviewed By: sergey Differential Revision: https://developer.blender.org/D10337
2021-05-07 10:25:13 +02:00
#define SEQ_ALL_BEGIN(ed, var) \
2020-12-19 06:44:57 +01:00
{ \
2021-05-07 12:43:43 +02:00
if (ed != NULL) { \
SeqCollection *all_strips = SEQ_query_all_strips_recursive(&ed->seqbase); \
GSetIterator gsi; \
GSET_ITER (gsi, all_strips->set) { \
var = (Sequence *)(BLI_gsetIterator_getKey(&gsi));
2020-12-19 06:44:57 +01:00
#define SEQ_ALL_END \
} \
VSE: New iterator design This iterator design provides means to create simple and flexible API to query and work with collection of strips. It should be used in cases when conditions require multiple stages of recursive iteration of all strips or similar complex scenarios. Quick API overview: Basic queries are standalone functions that return SeqCollection Use SEQ_collection_create() and SEQ_collection_free() to construct such query functions. Use these functions to get strips of known conditions, like selected strips, movie strips, muted strips and so on. Use SEQ_reference_query() when querying strips with relation to some reference strip. For example to get its effects, strips that have same type or use same input file and so on. These aren't standalone functions because often you need to query strips relative to each strip in collection. Use SEQ_collection_expand() to query strips relative to each strip in collection. These will be merged to original collection. Use SEQ_collection_merge() to merge 2 collections To iterate collection elements use macro SEQ_ITERATOR_FOREACH() This API is quite specific, but I think it is best suited for tasks that are usualy solved in sequencer codebase. Old sequencer iterator has been completely removed. SEQ_ALL_BEGIN and SEQ_ALL_END macros re-use new iterator design. As initial use for this iterator select_grouped_effect_link() function has been rewritten. It was not only broken, but also it used DNA fields to aid iterating strips. Reviewed By: sergey Differential Revision: https://developer.blender.org/D10337
2021-05-07 10:25:13 +02:00
SEQ_collection_free(all_strips); \
2020-12-19 06:44:57 +01:00
} \
2021-05-07 12:43:43 +02:00
} \
2020-12-19 06:44:57 +01:00
((void)0)
VSE: New iterator design This iterator design provides means to create simple and flexible API to query and work with collection of strips. It should be used in cases when conditions require multiple stages of recursive iteration of all strips or similar complex scenarios. Quick API overview: Basic queries are standalone functions that return SeqCollection Use SEQ_collection_create() and SEQ_collection_free() to construct such query functions. Use these functions to get strips of known conditions, like selected strips, movie strips, muted strips and so on. Use SEQ_reference_query() when querying strips with relation to some reference strip. For example to get its effects, strips that have same type or use same input file and so on. These aren't standalone functions because often you need to query strips relative to each strip in collection. Use SEQ_collection_expand() to query strips relative to each strip in collection. These will be merged to original collection. Use SEQ_collection_merge() to merge 2 collections To iterate collection elements use macro SEQ_ITERATOR_FOREACH() This API is quite specific, but I think it is best suited for tasks that are usualy solved in sequencer codebase. Old sequencer iterator has been completely removed. SEQ_ALL_BEGIN and SEQ_ALL_END macros re-use new iterator design. As initial use for this iterator select_grouped_effect_link() function has been rewritten. It was not only broken, but also it used DNA fields to aid iterating strips. Reviewed By: sergey Differential Revision: https://developer.blender.org/D10337
2021-05-07 10:25:13 +02:00
typedef struct SeqCollection {
struct SeqCollection *next, *prev;
struct GSet *set;
} SeqCollection;
typedef struct SeqIterator {
GSetIterator gsi;
SeqCollection *collection;
bool iterator_initialized;
} SeqIterator;
bool SEQ_iterator_ensure(SeqCollection *collection,
SeqIterator *iterator,
struct Sequence **r_seq);
struct Sequence *SEQ_iterator_yield(SeqIterator *iterator);
SeqCollection *SEQ_collection_create(void);
bool SEQ_collection_append_strip(struct Sequence *seq, SeqCollection *data);
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
bool SEQ_collection_remove_strip(struct Sequence *seq, SeqCollection *data);
void SEQ_collection_free(SeqCollection *collection);
VSE: New iterator design This iterator design provides means to create simple and flexible API to query and work with collection of strips. It should be used in cases when conditions require multiple stages of recursive iteration of all strips or similar complex scenarios. Quick API overview: Basic queries are standalone functions that return SeqCollection Use SEQ_collection_create() and SEQ_collection_free() to construct such query functions. Use these functions to get strips of known conditions, like selected strips, movie strips, muted strips and so on. Use SEQ_reference_query() when querying strips with relation to some reference strip. For example to get its effects, strips that have same type or use same input file and so on. These aren't standalone functions because often you need to query strips relative to each strip in collection. Use SEQ_collection_expand() to query strips relative to each strip in collection. These will be merged to original collection. Use SEQ_collection_merge() to merge 2 collections To iterate collection elements use macro SEQ_ITERATOR_FOREACH() This API is quite specific, but I think it is best suited for tasks that are usualy solved in sequencer codebase. Old sequencer iterator has been completely removed. SEQ_ALL_BEGIN and SEQ_ALL_END macros re-use new iterator design. As initial use for this iterator select_grouped_effect_link() function has been rewritten. It was not only broken, but also it used DNA fields to aid iterating strips. Reviewed By: sergey Differential Revision: https://developer.blender.org/D10337
2021-05-07 10:25:13 +02:00
void SEQ_collection_merge(SeqCollection *collection_dst, SeqCollection *collection_src);
void SEQ_collection_expand(struct ListBase *seqbase,
SeqCollection *collection,
void query_func(struct Sequence *seq_reference,
struct ListBase *seqbase,
SeqCollection *collection));
SeqCollection *SEQ_query_by_reference(struct Sequence *seq_reference,
struct ListBase *seqbase,
void seq_query_func(struct Sequence *seq_reference,
struct ListBase *seqbase,
SeqCollection *collection));
SeqCollection *SEQ_query_selected_strips(struct ListBase *seqbase);
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 *SEQ_query_all_strips(ListBase *seqbase);
VSE: New iterator design This iterator design provides means to create simple and flexible API to query and work with collection of strips. It should be used in cases when conditions require multiple stages of recursive iteration of all strips or similar complex scenarios. Quick API overview: Basic queries are standalone functions that return SeqCollection Use SEQ_collection_create() and SEQ_collection_free() to construct such query functions. Use these functions to get strips of known conditions, like selected strips, movie strips, muted strips and so on. Use SEQ_reference_query() when querying strips with relation to some reference strip. For example to get its effects, strips that have same type or use same input file and so on. These aren't standalone functions because often you need to query strips relative to each strip in collection. Use SEQ_collection_expand() to query strips relative to each strip in collection. These will be merged to original collection. Use SEQ_collection_merge() to merge 2 collections To iterate collection elements use macro SEQ_ITERATOR_FOREACH() This API is quite specific, but I think it is best suited for tasks that are usualy solved in sequencer codebase. Old sequencer iterator has been completely removed. SEQ_ALL_BEGIN and SEQ_ALL_END macros re-use new iterator design. As initial use for this iterator select_grouped_effect_link() function has been rewritten. It was not only broken, but also it used DNA fields to aid iterating strips. Reviewed By: sergey Differential Revision: https://developer.blender.org/D10337
2021-05-07 10:25:13 +02:00
SeqCollection *SEQ_query_all_strips_recursive(ListBase *seqbase);
void SEQ_query_strip_effect_chain(struct Sequence *seq_reference,
struct ListBase *seqbase,
SeqCollection *collection);
2020-12-19 06:44:57 +01:00
#ifdef __cplusplus
}
#endif