Fix T49027: Sequence uses too much memory when rendering scene with lots of movie strips

Now we free sequencer cache and close all unneeded FFmpeg handles when rendering.
This is the same logic as image sequence memory freeding.
This commit is contained in:
Sergey Sharybin 2016-08-09 14:33:00 +02:00
parent f990518041
commit 1647d89cf1
Notes: blender-bot 2023-09-13 08:48:34 +02:00
Referenced by issue #49027, Possible memory allocation problem while rendering
3 changed files with 31 additions and 0 deletions

View File

@ -477,4 +477,6 @@ struct ImBuf *BKE_sequencer_render_mask_input(
int cfra, int fra_offset, bool make_float);
void BKE_sequencer_color_balance_apply(struct StripColorBalance *cb, struct ImBuf *ibuf, float mul, bool make_float, struct ImBuf *mask_input);
void BKE_sequencer_all_free_anim_ibufs(int cfra);
#endif /* __BKE_SEQUENCER_H__ */

View File

@ -5595,3 +5595,31 @@ int BKE_sequencer_find_next_prev_edit(
return best_frame;
}
static void sequencer_all_free_anim_ibufs(ListBase *seqbase, int cfra)
{
for (Sequence *seq = seqbase->first; seq != NULL; seq = seq->next) {
if (seq->enddisp < cfra || seq->startdisp > cfra) {
BKE_sequence_free_anim(seq);
}
if (seq->type == SEQ_TYPE_META) {
sequencer_all_free_anim_ibufs(&seq->seqbase, cfra);
}
}
}
void BKE_sequencer_all_free_anim_ibufs(int cfra)
{
BKE_sequencer_cache_cleanup();
for (Scene *scene = G.main->scene.first;
scene != NULL;
scene = scene->id.next)
{
Editing *ed = BKE_sequencer_editing_get(scene, false);
if (ed == NULL) {
/* Ignore scenes without sequencer. */
continue;
}
sequencer_all_free_anim_ibufs(&ed->seqbase, cfra);
}
}

View File

@ -2785,6 +2785,7 @@ static void do_render_all_options(Render *re)
/* ensure no images are in memory from previous animated sequences */
BKE_image_all_free_anim_ibufs(re->r.cfra);
BKE_sequencer_all_free_anim_ibufs(re->r.cfra);
if (RE_engine_render(re, 1)) {
/* in this case external render overrides all */