From c07bd1439a3f026b8603c52662c3e7ccc364321a Mon Sep 17 00:00:00 2001 From: Peter Schlaile Date: Sun, 28 Aug 2011 14:46:03 +0000 Subject: == Sequencer == This patch adds: * support for proxy building again (missing feature from Blender 2.49) additionally to the way, Blender 2.49 worked, you can select several strips at once and make Blender build proxies in the background (using the job system) Also a new thing: movie proxies are now build into AVI files, and the proxy system is moved into ImBuf-library, so that other parts of blender can also benefit from it. * Timecode support: to fix seeking issues with files, that have a) varying frame rates b) very large GOP lengths c) are broken inbetween d) use different time code tracks the proxy builder can now also build timecode indices, which are used (optionally) for seeking. For the first time, it is possible, to do frame exact seeking on all file types. * Support for different video-streams in one video file (can be selected in sequencer, other parts of blender can also use it, but UI has to be added accordingly) * IMPORTANT: this patch *requires* ffmpeg 0.7 or newer, since older versions don't support the pkt_pts field, that is essential for building timecode indices. Windows and Mac libs are already updated, Linux-users have to build their own ffmpeg verions until distros keep up. --- source/blender/editors/space_sequencer/SConscript | 3 + .../editors/space_sequencer/sequencer_edit.c | 137 +++++++++++++++++++++ .../editors/space_sequencer/sequencer_intern.h | 2 + .../editors/space_sequencer/sequencer_ops.c | 1 + 4 files changed, 143 insertions(+) (limited to 'source/blender/editors/space_sequencer') diff --git a/source/blender/editors/space_sequencer/SConscript b/source/blender/editors/space_sequencer/SConscript index 65bbf900556..3430c10b766 100644 --- a/source/blender/editors/space_sequencer/SConscript +++ b/source/blender/editors/space_sequencer/SConscript @@ -8,4 +8,7 @@ incs += ' ../../windowmanager #/intern/guardedalloc #/extern/glew/include' incs += ' ../../makesrna ../../blenloader' incs += ' #/intern/audaspace/intern' +if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc'): + incs += ' ' + env['BF_PTHREADS_INC'] + env.BlenderLib ( 'bf_editors_space_sequencer', sources, Split(incs), [], libtype=['core'], priority=[100] ) diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index e876da41bd9..18ff33fd8a9 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -47,6 +47,7 @@ #include "BLI_math.h" #include "BLI_storage_types.h" #include "BLI_utildefines.h" +#include "BLI_threads.h" #include "DNA_scene_types.h" #include "DNA_userdef_types.h" @@ -125,6 +126,111 @@ typedef struct TransSeq { int len; } TransSeq; +/* ********************************************************************** */ + +/* ***************** proxy job manager ********************** */ + +typedef struct ProxyBuildJob { + Scene *scene; + struct Main * main; + ListBase queue; + ThreadMutex queue_lock; +} 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); + + MEM_freeN(pj); +} + +/* only this runs inside thread */ +static void proxy_startjob(void *pjv, short *stop, short *do_update, float *progress) +{ + ProxyJob *pj = pjv; + + while (!*stop) { + Sequence * seq; + + BLI_mutex_lock(&pj->queue_lock); + + if (!pj->queue.first) { + BLI_mutex_unlock(&pj->queue_lock); + break; + } + + 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); + } + + if (*stop) { + fprintf(stderr, + "Canceling proxy rebuild on users request...\n"); + } +} + +static void proxy_endjob(void *UNUSED(customdata)) +{ + +} + +void seq_proxy_build_job(const bContext *C, Sequence * seq) +{ + wmJob * steve; + ProxyJob *pj; + Scene *scene= CTX_data_scene(C); + ScrArea * sa= CTX_wm_area(C); + + 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); + + pj = WM_jobs_get_customdata(steve); + + if (!pj) { + pj = MEM_callocN(sizeof(ProxyJob), "proxy rebuild job"); + + 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); + } + + BLI_mutex_lock(&pj->queue_lock); + BLI_addtail(&pj->queue, seq); + BLI_mutex_unlock(&pj->queue_lock); + + if (!WM_jobs_is_running(steve)) { + G.afbreek = 0; + WM_jobs_start(CTX_wm_manager(C), steve); + } + + ED_area_tag_redraw(CTX_wm_area(C)); +} + +/* ********************************************************************** */ + void seq_rectf(Sequence *seq, rctf *rectf) { if(seq->startstill) rectf->xmin= seq->start; @@ -2690,6 +2796,37 @@ void SEQUENCER_OT_view_ghost_border(wmOperatorType *ot) WM_operator_properties_gesture_border(ot, FALSE); } +/* 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; + + SEQP_BEGIN(ed, seq) { + if ((seq->flag & SELECT)) { + seq_proxy_build_job(C, seq); + } + } + SEQ_END + + return OPERATOR_FINISHED; +} + +void SEQUENCER_OT_rebuild_proxy(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Rebuild Proxy and Timecode Indices"; + ot->idname= "SEQUENCER_OT_rebuild_proxy"; + ot->description="Rebuild all selected proxies and timecode indeces using the job system"; + + /* api callbacks */ + ot->exec= sequencer_rebuild_proxy_exec; + ot->poll= ED_operator_sequencer_active; + + /* flags */ + ot->flag= OPTYPE_REGISTER; +} /* change ops */ diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h index 7ab76f9b6d7..89e9a22c9a1 100644 --- a/source/blender/editors/space_sequencer/sequencer_intern.h +++ b/source/blender/editors/space_sequencer/sequencer_intern.h @@ -118,6 +118,8 @@ void SEQUENCER_OT_change_path(struct wmOperatorType *ot); void SEQUENCER_OT_copy(struct wmOperatorType *ot); void SEQUENCER_OT_paste(struct wmOperatorType *ot); +void SEQUENCER_OT_rebuild_proxy(struct wmOperatorType *ot); + /* preview specific operators */ void SEQUENCER_OT_view_all_preview(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_sequencer/sequencer_ops.c b/source/blender/editors/space_sequencer/sequencer_ops.c index df33ce73b9c..5c13b57cca8 100644 --- a/source/blender/editors/space_sequencer/sequencer_ops.c +++ b/source/blender/editors/space_sequencer/sequencer_ops.c @@ -87,6 +87,7 @@ void sequencer_operatortypes(void) WM_operatortype_append(SEQUENCER_OT_view_zoom_ratio); WM_operatortype_append(SEQUENCER_OT_view_ghost_border); + WM_operatortype_append(SEQUENCER_OT_rebuild_proxy); WM_operatortype_append(SEQUENCER_OT_change_effect_input); WM_operatortype_append(SEQUENCER_OT_change_effect_type); WM_operatortype_append(SEQUENCER_OT_change_path); -- cgit v1.2.3