VSE: Optimize away some pointless image copies when applying modifiers
SEQ_modifier_apply_stack is called from exactly one place, and it always was throwing away the input image, and taking the newly produced image. Which means, we can stop copying it. Just run the modifiers on the input image. In a test file that is HD (1080p) resolution, two EXR image sequences, adjustment layer with Color Balance, and a text strip on top, playback framerate (Ryzen 5950X, Win10/VS2022) goes 20.8 -> 22.1 fps Pull Request: https://projects.blender.org/blender/blender/pulls/127346
This commit is contained in:
committed by
Aras Pranckevicius
parent
0b5e878ae1
commit
577630d24f
@@ -51,10 +51,10 @@ void SEQ_modifier_clear(Sequence *seq);
|
||||
void SEQ_modifier_free(SequenceModifierData *smd);
|
||||
void SEQ_modifier_unique_name(Sequence *seq, SequenceModifierData *smd);
|
||||
SequenceModifierData *SEQ_modifier_find_by_name(Sequence *seq, const char *name);
|
||||
ImBuf *SEQ_modifier_apply_stack(const SeqRenderData *context,
|
||||
Sequence *seq,
|
||||
ImBuf *ibuf,
|
||||
int timeline_frame);
|
||||
void SEQ_modifier_apply_stack(const SeqRenderData *context,
|
||||
const Sequence *seq,
|
||||
ImBuf *ibuf,
|
||||
int timeline_frame);
|
||||
void SEQ_modifier_list_copy(Sequence *seqn, Sequence *seq);
|
||||
int SEQ_sequence_supports_modifiers(Sequence *seq);
|
||||
|
||||
|
||||
@@ -1406,16 +1406,13 @@ static bool skip_modifier(Scene *scene, const SequenceModifierData *smd, int tim
|
||||
return strip_has_ended_skip || missing_data_skip;
|
||||
}
|
||||
|
||||
ImBuf *SEQ_modifier_apply_stack(const SeqRenderData *context,
|
||||
Sequence *seq,
|
||||
ImBuf *ibuf,
|
||||
int timeline_frame)
|
||||
void SEQ_modifier_apply_stack(const SeqRenderData *context,
|
||||
const Sequence *seq,
|
||||
ImBuf *ibuf,
|
||||
int timeline_frame)
|
||||
{
|
||||
ImBuf *processed_ibuf = ibuf;
|
||||
|
||||
if (seq->modifiers.first && (seq->flag & SEQ_USE_LINEAR_MODIFIERS)) {
|
||||
processed_ibuf = IMB_dupImBuf(ibuf);
|
||||
SEQ_render_imbuf_from_sequencer_space(context->scene, processed_ibuf);
|
||||
SEQ_render_imbuf_from_sequencer_space(context->scene, ibuf);
|
||||
}
|
||||
|
||||
LISTBASE_FOREACH (SequenceModifierData *, smd, &seq->modifiers) {
|
||||
@@ -1443,11 +1440,7 @@ ImBuf *SEQ_modifier_apply_stack(const SeqRenderData *context,
|
||||
ImBuf *mask = modifier_mask_get(
|
||||
smd, context, timeline_frame, frame_offset, ibuf->float_buffer.data != nullptr);
|
||||
|
||||
if (processed_ibuf == ibuf) {
|
||||
processed_ibuf = IMB_dupImBuf(ibuf);
|
||||
}
|
||||
|
||||
smti->apply(smd, processed_ibuf, mask);
|
||||
smti->apply(smd, ibuf, mask);
|
||||
|
||||
if (mask) {
|
||||
IMB_freeImBuf(mask);
|
||||
@@ -1456,10 +1449,8 @@ ImBuf *SEQ_modifier_apply_stack(const SeqRenderData *context,
|
||||
}
|
||||
|
||||
if (seq->modifiers.first && (seq->flag & SEQ_USE_LINEAR_MODIFIERS)) {
|
||||
seq_imbuf_to_sequencer_space(context->scene, processed_ibuf, false);
|
||||
seq_imbuf_to_sequencer_space(context->scene, ibuf, false);
|
||||
}
|
||||
|
||||
return processed_ibuf;
|
||||
}
|
||||
|
||||
void SEQ_modifier_list_copy(Sequence *seqn, Sequence *seq)
|
||||
|
||||
@@ -718,13 +718,7 @@ static ImBuf *input_preprocess(const SeqRenderData *context,
|
||||
}
|
||||
|
||||
if (seq->modifiers.first) {
|
||||
ImBuf *ibuf_new = SEQ_modifier_apply_stack(context, seq, preprocessed_ibuf, timeline_frame);
|
||||
|
||||
if (ibuf_new != preprocessed_ibuf) {
|
||||
IMB_metadata_copy(ibuf_new, preprocessed_ibuf);
|
||||
IMB_freeImBuf(preprocessed_ibuf);
|
||||
preprocessed_ibuf = ibuf_new;
|
||||
}
|
||||
SEQ_modifier_apply_stack(context, seq, preprocessed_ibuf, timeline_frame);
|
||||
}
|
||||
|
||||
return preprocessed_ibuf;
|
||||
|
||||
Reference in New Issue
Block a user