diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-02-29 16:08:26 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-02-29 16:08:26 +0400 |
commit | d8bdd4497eec824a522062c4a8b597ef25395d63 (patch) | |
tree | c797600b9e618ff184cdf16c36d59a9196d9cc7d /source/blender/blenkernel/intern/sequencer.c | |
parent | 31cd0521ae64e95982bd4bd4f8685b7cf96d4248 (diff) |
Refactor of proxies build operators
Split proxy build operator into three parts:
- Prepare context (IMB_anim_index_rebuild_context) which prepares all
needed data and stores it in an anonymous structure used by specific
builder lately.
- Build proxies/timecodes into temporary files (IMB_anim_index_rebuild)
This function will build all selected proxies/timecodes into a temporary
files so old proxies will be still available during building.
- Finish building proxies (IMB_anim_index_rebuild_finish) which copies
temporary files over old proxies filed and releases all resources used
by a context.
Context creation and finishing building happens in a main thread so
it's easy and safe to close all opened handles of proxies files and
refresh cache after rebuilding is finished.
This should finally fix #30315: Temporary proxy files are not erased and old proxys are not updated if the proxy is built more then once (windows)
Diffstat (limited to 'source/blender/blenkernel/intern/sequencer.c')
-rw-r--r-- | source/blender/blenkernel/intern/sequencer.c | 101 |
1 files changed, 73 insertions, 28 deletions
diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 1c3cc44c585..92199eadf5b 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1140,6 +1140,18 @@ static int get_shown_sequences( ListBase * seqbasep, int cfra, int chanshown, Se proxy management ********************************************************************** */ +typedef struct SeqIndexBuildContext { + struct IndexBuildContext *index_context; + + int tc_flags; + int size_flags; + int quality; + + Main *bmain; + Scene *scene; + Sequence *seq, *orig_seq; +} SeqIndexBuildContext; + #define PROXY_MAXFILE (2*FILE_MAXDIR+FILE_MAXFILE) static IMB_Proxy_Size seq_rendersize_to_proxysize(int size) @@ -1345,35 +1357,56 @@ static void seq_proxy_build_frame(SeqRenderData context, IMB_freeImBuf(ibuf); } -void seq_proxy_rebuild(struct Main * bmain, Scene *scene, Sequence * seq, - short *stop, short *do_update, float *progress) +struct SeqIndexBuildContext *seq_proxy_rebuild_context(Main *bmain, Scene *scene, Sequence *seq) { - SeqRenderData context; - int cfra; - int tc_flags; - int size_flags; - int quality; + SeqIndexBuildContext *context; + Sequence *nseq; if (!seq->strip || !seq->strip->proxy) { - return; + return NULL; } if (!(seq->flag & SEQ_USE_PROXY)) { - return; + return NULL; } - tc_flags = seq->strip->proxy->build_tc_flags; - size_flags = seq->strip->proxy->build_size_flags; - quality = seq->strip->proxy->quality; + context = MEM_callocN(sizeof(SeqIndexBuildContext), "seq proxy rebuild context"); - if (seq->type == SEQ_MOVIE) { - seq_open_anim_file(seq); + nseq = seq_dupli_recursive(scene, scene, seq, 0); - if (seq->anim) { - IMB_anim_index_rebuild( - seq->anim, tc_flags, size_flags, quality, - stop, do_update, progress); + context->tc_flags = nseq->strip->proxy->build_tc_flags; + context->size_flags = nseq->strip->proxy->build_size_flags; + context->quality = nseq->strip->proxy->quality; + + context->bmain = bmain; + context->scene = scene; + context->orig_seq = seq; + context->seq = nseq; + + if (nseq->type == SEQ_MOVIE) { + seq_open_anim_file(nseq); + + if (nseq->anim) { + context->index_context = IMB_anim_index_rebuild_context(nseq->anim, + context->tc_flags, context->size_flags, context->quality); + } + } + + return context; +} + +void seq_proxy_rebuild(SeqIndexBuildContext *context, short *stop, short *do_update, float *progress) +{ + SeqRenderData render_context; + Sequence *seq = context->seq; + Scene *scene = context->scene; + int cfra; + + if (seq->type == SEQ_MOVIE) { + if (context->index_context) { + IMB_anim_index_rebuild(context->index_context, stop, do_update, progress); } + return; } @@ -1388,25 +1421,25 @@ void seq_proxy_rebuild(struct Main * bmain, Scene *scene, Sequence * seq, /* fail safe code */ - context = seq_new_render_data( - bmain, scene, + render_context = seq_new_render_data( + context->bmain, context->scene, (scene->r.size * (float) scene->r.xsch) / 100.0f + 0.5f, (scene->r.size * (float) scene->r.ysch) / 100.0f + 0.5f, 100); for (cfra = seq->startdisp + seq->startstill; cfra < seq->enddisp - seq->endstill; cfra++) { - if (size_flags & IMB_PROXY_25) { - seq_proxy_build_frame(context, seq, cfra, 25); + if (context->size_flags & IMB_PROXY_25) { + seq_proxy_build_frame(render_context, seq, cfra, 25); } - if (size_flags & IMB_PROXY_50) { - seq_proxy_build_frame(context, seq, cfra, 50); + if (context->size_flags & IMB_PROXY_50) { + seq_proxy_build_frame(render_context, seq, cfra, 50); } - if (size_flags & IMB_PROXY_75) { - seq_proxy_build_frame(context, seq, cfra, 75); + if (context->size_flags & IMB_PROXY_75) { + seq_proxy_build_frame(render_context, seq, cfra, 75); } - if (size_flags & IMB_PROXY_100) { - seq_proxy_build_frame(context, seq, cfra, 100); + if (context->size_flags & IMB_PROXY_100) { + seq_proxy_build_frame(render_context, seq, cfra, 100); } *progress= (float)cfra/(seq->enddisp - seq->endstill @@ -1418,6 +1451,18 @@ void seq_proxy_rebuild(struct Main * bmain, Scene *scene, Sequence * seq, } } +void seq_proxy_rebuild_finish(SeqIndexBuildContext *context, short stop) +{ + if (context->index_context) { + IMB_close_anim_proxies(context->seq->anim); + IMB_close_anim_proxies(context->orig_seq->anim); + IMB_anim_index_rebuild_finish(context->index_context, stop); + } + + seq_free_sequence_recurse(context->scene, context->seq); + + MEM_freeN(context); +} /* ********************************************************************** color balance |