diff options
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/space_clip/clip_ops.c | 36 | ||||
-rw-r--r-- | source/blender/editors/space_sequencer/sequencer_edit.c | 83 |
2 files changed, 62 insertions, 57 deletions
diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index 459f40c64a5..99ee4974659 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -845,7 +845,8 @@ typedef struct ProxyBuildJob { Scene *scene; struct Main *main; MovieClip *clip; - int clip_flag; + int clip_flag, stop; + struct IndexBuildContext *index_context; } ProxyJob; static void proxy_freejob(void *pjv) @@ -896,11 +897,13 @@ static void proxy_startjob(void *pjv, short *stop, short *do_update, float *prog build_undistort_count= proxy_bitflag_to_array(size_flag, build_undistort_sizes, 1); if(clip->source == MCLIP_SRC_MOVIE) { - if(clip->anim) - IMB_anim_index_rebuild(clip->anim, tc_flag, size_flag, quality, stop, do_update, progress); + if (pj->index_context) + IMB_anim_index_rebuild(pj->index_context, stop, do_update, progress); if(!build_undistort_count) { - BKE_movieclip_reload(clip); + if (*stop) + pj->stop = 1; + return; } else { @@ -928,7 +931,23 @@ static void proxy_startjob(void *pjv, short *stop, short *do_update, float *prog if(distortion) BKE_tracking_distortion_destroy(distortion); - BKE_movieclip_reload(clip); + if (*stop) + pj->stop = 1; +} + +static void proxy_endjob(void *pjv) +{ + ProxyJob *pj = pjv; + + if (pj->clip->anim) + IMB_close_anim_proxies(pj->clip->anim); + + if (pj->index_context) + IMB_anim_index_rebuild_finish(pj->index_context, pj->stop); + + BKE_movieclip_reload(pj->clip); + + WM_main_add_notifier(NC_MOVIECLIP|ND_DISPLAY, pj->clip); } static int clip_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op)) @@ -951,9 +970,14 @@ static int clip_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op)) pj->clip= clip; pj->clip_flag= clip->flag&MCLIP_TIMECODE_FLAGS; + if (clip->anim) { + pj->index_context = IMB_anim_index_rebuild_context(clip->anim, clip->proxy.build_tc_flag, + clip->proxy.build_size_flag, clip->proxy.quality); + } + WM_jobs_customdata(steve, pj, proxy_freejob); WM_jobs_timer(steve, 0.2, NC_MOVIECLIP|ND_DISPLAY, 0); - WM_jobs_callbacks(steve, proxy_startjob, NULL, NULL, NULL); + WM_jobs_callbacks(steve, proxy_startjob, NULL, NULL, proxy_endjob); G.afbreek= 0; WM_jobs_start(CTX_wm_manager(C), steve); diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 222be03b2fe..fad402a6787 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -56,6 +56,8 @@ #include "BKE_report.h" #include "BKE_sound.h" +#include "IMB_imbuf.h" + #include "WM_api.h" #include "WM_types.h" @@ -131,20 +133,14 @@ typedef struct ProxyBuildJob { Scene *scene; struct Main * main; ListBase queue; - ThreadMutex queue_lock; + int stop; } ProxyJob; static void proxy_freejob(void *pjv) { ProxyJob *pj= pjv; - Sequence * seq; - - for (seq = pj->queue.first; seq; seq = seq->next) { - BLI_remlink(&pj->queue, seq); - seq_free_sequence_recurse(pj->scene, seq); - } - BLI_mutex_end(&pj->queue_lock); + BLI_freelistN(&pj->queue); MEM_freeN(pj); } @@ -153,30 +149,17 @@ static void proxy_freejob(void *pjv) static void proxy_startjob(void *pjv, short *stop, short *do_update, float *progress) { ProxyJob *pj = pjv; + LinkData *link; - while (!*stop) { - Sequence * seq; - - BLI_mutex_lock(&pj->queue_lock); - - if (!pj->queue.first) { - BLI_mutex_unlock(&pj->queue_lock); - break; - } + for (link = pj->queue.first; link; link = link->next) { + struct SeqIndexBuildContext *context = link->data; - seq = pj->queue.first; - - BLI_remlink(&pj->queue, seq); - BLI_mutex_unlock(&pj->queue_lock); - - seq_proxy_rebuild(pj->main, pj->scene, seq, - stop, do_update, progress); - seq_free_sequence_recurse(pj->scene, seq); + seq_proxy_rebuild(context, stop, do_update, progress); } if (*stop) { - fprintf(stderr, - "Canceling proxy rebuild on users request...\n"); + pj->stop = 1; + fprintf(stderr, "Canceling proxy rebuild on users request...\n"); } } @@ -184,23 +167,29 @@ static void proxy_endjob(void *pjv) { ProxyJob *pj = pjv; Editing *ed = seq_give_editing(pj->scene, FALSE); + LinkData *link; + + for (link = pj->queue.first; link; link = link->next) { + seq_proxy_rebuild_finish(link->data, pj->stop); + } free_imbuf_seq(pj->scene, &ed->seqbase, FALSE, FALSE); WM_main_add_notifier(NC_SCENE|ND_SEQUENCER, pj->scene); } -static void seq_proxy_build_job(const bContext *C, Sequence * seq) +static void seq_proxy_build_job(const bContext *C) { wmJob * steve; ProxyJob *pj; Scene *scene= CTX_data_scene(C); + Editing *ed = seq_give_editing(scene, FALSE); ScrArea * sa= CTX_wm_area(C); + struct SeqIndexBuildContext *context; + LinkData *link; + Sequence * seq; - seq = seq_dupli_recursive(scene, scene, seq, 0); - - steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), - sa, "Building Proxies", WM_JOB_PROGRESS); + steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), sa, "Building Proxies", WM_JOB_PROGRESS); pj = WM_jobs_get_customdata(steve); @@ -210,18 +199,19 @@ static void seq_proxy_build_job(const bContext *C, Sequence * seq) pj->scene= scene; pj->main = CTX_data_main(C); - BLI_mutex_init(&pj->queue_lock); - WM_jobs_customdata(steve, pj, proxy_freejob); - WM_jobs_timer(steve, 0.1, NC_SCENE|ND_SEQUENCER, - NC_SCENE|ND_SEQUENCER); - WM_jobs_callbacks(steve, proxy_startjob, NULL, NULL, - proxy_endjob); + WM_jobs_timer(steve, 0.1, NC_SCENE|ND_SEQUENCER, NC_SCENE|ND_SEQUENCER); + WM_jobs_callbacks(steve, proxy_startjob, NULL, NULL, proxy_endjob); } - BLI_mutex_lock(&pj->queue_lock); - BLI_addtail(&pj->queue, seq); - BLI_mutex_unlock(&pj->queue_lock); + SEQP_BEGIN(ed, seq) { + if ((seq->flag & SELECT)) { + context = seq_proxy_rebuild_context(pj->main, pj->scene, seq); + link = BLI_genericNodeN(context); + BLI_addtail(&pj->queue, link); + } + } + SEQ_END if (!WM_jobs_is_running(steve)) { G.afbreek = 0; @@ -2822,17 +2812,8 @@ void SEQUENCER_OT_view_ghost_border(wmOperatorType *ot) /* rebuild_proxy operator */ static int sequencer_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op)) { - Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); - Sequence * seq; + seq_proxy_build_job(C); - SEQP_BEGIN(ed, seq) { - if ((seq->flag & SELECT)) { - seq_proxy_build_job(C, seq); - } - } - SEQ_END - return OPERATOR_FINISHED; } |