VSE: Automatic proxy building
Build proxies automatically when added to sequencer timeline and when switching preview size. This behavior can be disabled in user preferences. Reviewed By: sergey, fsiddi Differential Revision: https://developer.blender.org/D10363
This commit is contained in:
parent
e4f3477833
commit
04e1feb830
Notes:
blender-bot
2023-02-14 11:21:43 +01:00
Referenced by commit8777a44ccb
, VSE: Fix crash when building proxy Referenced by commita19aa090d2
, VSE: Fix building image proxies Referenced by issue #85469, VSE 2.0: Proxy system
|
@ -226,6 +226,7 @@ const UserDef U_default = {
|
|||
.sequencer_disk_cache_compression = 0,
|
||||
.sequencer_disk_cache_size_limit = 100,
|
||||
.sequencer_disk_cache_flag = 0,
|
||||
.sequencer_proxy_setup = USER_SEQ_PROXY_SETUP_AUTOMATIC,
|
||||
|
||||
.collection_instance_empty_size = 1.0f,
|
||||
|
||||
|
|
|
@ -655,6 +655,10 @@ class USERPREF_PT_system_video_sequencer(SystemPanel, CenterAlignMixIn, Panel):
|
|||
col.prop(system, "sequencer_disk_cache_size_limit", text="Cache Limit")
|
||||
col.prop(system, "sequencer_disk_cache_compression", text="Compression")
|
||||
|
||||
layout.separator()
|
||||
|
||||
layout.prop(system, "sequencer_proxy_setup")
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Viewport Panels
|
||||
|
|
|
@ -845,6 +845,14 @@ void blo_do_versions_userdef(UserDef *userdef)
|
|||
userdef->experimental.use_asset_browser = true;
|
||||
}
|
||||
|
||||
if (!USER_VERSION_ATLEAST(293, 12)) {
|
||||
if (userdef->gizmo_size_navigate_v3d == 0) {
|
||||
userdef->gizmo_size_navigate_v3d = 80;
|
||||
}
|
||||
|
||||
userdef->sequencer_proxy_setup = USER_SEQ_PROXY_SETUP_AUTOMATIC;
|
||||
}
|
||||
|
||||
/**
|
||||
* Versioning code until next subversion bump goes here.
|
||||
*
|
||||
|
@ -856,9 +864,6 @@ void blo_do_versions_userdef(UserDef *userdef)
|
|||
*/
|
||||
{
|
||||
/* Keep this block, even when empty. */
|
||||
if (userdef->gizmo_size_navigate_v3d == 0) {
|
||||
userdef->gizmo_size_navigate_v3d = 80;
|
||||
}
|
||||
}
|
||||
|
||||
LISTBASE_FOREACH (bTheme *, btheme, &userdef->themes) {
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
#include "BLI_ghash.h"
|
||||
#include "BLI_math.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
|
@ -37,8 +38,10 @@
|
|||
#include "DNA_mask_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_sound_types.h"
|
||||
#include "DNA_space_types.h"
|
||||
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_lib_id.h"
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_mask.h"
|
||||
|
@ -55,6 +58,7 @@
|
|||
|
||||
#include "SEQ_add.h"
|
||||
#include "SEQ_effects.h"
|
||||
#include "SEQ_proxy.h"
|
||||
#include "SEQ_relations.h"
|
||||
#include "SEQ_render.h"
|
||||
#include "SEQ_select.h"
|
||||
|
@ -548,6 +552,55 @@ static bool sequencer_add_draw_check_fn(PointerRNA *UNUSED(ptr),
|
|||
return !(STR_ELEM(prop_id, "filepath", "directory", "filename"));
|
||||
}
|
||||
|
||||
/* Strips are added in context of timeline which has different preview size than actual preview. We
|
||||
* must search for preview area. In most cases there will be only one preview area, but there can
|
||||
* be more with different preview sizes. */
|
||||
static IMB_Proxy_Size seq_get_proxy_size_flags(bContext *C)
|
||||
{
|
||||
bScreen *screen = CTX_wm_screen(C);
|
||||
IMB_Proxy_Size proxy_sizes = 0;
|
||||
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
|
||||
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
|
||||
switch (sl->spacetype) {
|
||||
case SPACE_SEQ: {
|
||||
SpaceSeq *sseq = (SpaceSeq *)sl;
|
||||
if (!ELEM(sseq->view, SEQ_VIEW_PREVIEW, SEQ_VIEW_SEQUENCE_PREVIEW)) {
|
||||
continue;
|
||||
}
|
||||
proxy_sizes |= SEQ_rendersize_to_proxysize(sseq->render_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return proxy_sizes;
|
||||
}
|
||||
|
||||
static void seq_build_proxy(bContext *C, Sequence *seq)
|
||||
{
|
||||
if (U.sequencer_proxy_setup == USER_SEQ_PROXY_SETUP_AUTOMATIC) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Enable and set proxy size. */
|
||||
SEQ_proxy_set(seq, true);
|
||||
seq->strip->proxy->build_size_flags = seq_get_proxy_size_flags(C);
|
||||
seq->strip->proxy->build_flags |= SEQ_PROXY_SKIP_EXISTING;
|
||||
|
||||
/* Build proxy. */
|
||||
GSet *file_list = BLI_gset_new(BLI_ghashutil_strhash_p, BLI_ghashutil_strcmp, "file list");
|
||||
wmJob *wm_job = ED_seq_proxy_wm_job_get(C);
|
||||
ProxyJob *pj = ED_seq_proxy_job_get(C, wm_job);
|
||||
SEQ_proxy_rebuild_context(pj->main, pj->depsgraph, pj->scene, seq, file_list, &pj->queue);
|
||||
BLI_gset_free(file_list, MEM_freeN);
|
||||
|
||||
if (!WM_jobs_is_running(wm_job)) {
|
||||
G.is_break = false;
|
||||
WM_jobs_start(CTX_wm_manager(C), wm_job);
|
||||
}
|
||||
|
||||
ED_area_tag_redraw(CTX_wm_area(C));
|
||||
}
|
||||
|
||||
static void sequencer_add_movie_multiple_strips(bContext *C,
|
||||
wmOperator *op,
|
||||
SeqLoadData *load_data)
|
||||
|
@ -578,6 +631,7 @@ static void sequencer_add_movie_multiple_strips(bContext *C,
|
|||
load_data->start_frame += seq_movie->enddisp - seq_movie->startdisp;
|
||||
seq_load_apply_generic_options(C, op, seq_sound);
|
||||
seq_load_apply_generic_options(C, op, seq_movie);
|
||||
seq_build_proxy(C, seq_movie);
|
||||
}
|
||||
}
|
||||
RNA_END;
|
||||
|
@ -604,6 +658,7 @@ static bool sequencer_add_movie_single_strip(bContext *C, wmOperator *op, SeqLoa
|
|||
}
|
||||
seq_load_apply_generic_options(C, op, seq_sound);
|
||||
seq_load_apply_generic_options(C, op, seq_movie);
|
||||
seq_build_proxy(C, seq_movie);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -49,98 +49,25 @@
|
|||
/* Own include. */
|
||||
#include "sequencer_intern.h"
|
||||
|
||||
/*--------------------------------------------------------------------*/
|
||||
/** \name Proxy Job Manager
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Rebuild Proxy and Timecode Indices Operator
|
||||
* \{ */
|
||||
|
||||
typedef struct ProxyBuildJob {
|
||||
struct Main *main;
|
||||
struct Depsgraph *depsgraph;
|
||||
Scene *scene;
|
||||
ListBase queue;
|
||||
int stop;
|
||||
} ProxyJob;
|
||||
|
||||
static void proxy_freejob(void *pjv)
|
||||
{
|
||||
ProxyJob *pj = pjv;
|
||||
|
||||
BLI_freelistN(&pj->queue);
|
||||
|
||||
MEM_freeN(pj);
|
||||
}
|
||||
|
||||
/* Only this runs inside thread. */
|
||||
static void proxy_startjob(void *pjv, short *stop, short *do_update, float *progress)
|
||||
{
|
||||
ProxyJob *pj = pjv;
|
||||
LinkData *link;
|
||||
|
||||
for (link = pj->queue.first; link; link = link->next) {
|
||||
struct SeqIndexBuildContext *context = link->data;
|
||||
|
||||
SEQ_proxy_rebuild(context, stop, do_update, progress);
|
||||
|
||||
if (*stop) {
|
||||
pj->stop = 1;
|
||||
fprintf(stderr, "Canceling proxy rebuild on users request...\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void proxy_endjob(void *pjv)
|
||||
{
|
||||
ProxyJob *pj = pjv;
|
||||
Editing *ed = SEQ_editing_get(pj->scene, false);
|
||||
LinkData *link;
|
||||
|
||||
for (link = pj->queue.first; link; link = link->next) {
|
||||
SEQ_proxy_rebuild_finish(link->data, pj->stop);
|
||||
}
|
||||
|
||||
SEQ_relations_free_imbuf(pj->scene, &ed->seqbase, false);
|
||||
|
||||
WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, pj->scene);
|
||||
}
|
||||
|
||||
static void seq_proxy_build_job(const bContext *C, ReportList *reports)
|
||||
{
|
||||
wmJob *wm_job;
|
||||
ProxyJob *pj;
|
||||
struct Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
Editing *ed = SEQ_editing_get(scene, false);
|
||||
ScrArea *area = CTX_wm_area(C);
|
||||
Sequence *seq;
|
||||
GSet *file_list;
|
||||
|
||||
if (ed == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
wm_job = WM_jobs_get(CTX_wm_manager(C),
|
||||
CTX_wm_window(C),
|
||||
scene,
|
||||
"Building Proxies",
|
||||
WM_JOB_PROGRESS,
|
||||
WM_JOB_TYPE_SEQ_BUILD_PROXY);
|
||||
wmJob *wm_job = ED_seq_proxy_wm_job_get(C);
|
||||
ProxyJob *pj = ED_seq_proxy_job_get(C, wm_job);
|
||||
|
||||
pj = WM_jobs_customdata_get(wm_job);
|
||||
|
||||
if (!pj) {
|
||||
pj = MEM_callocN(sizeof(ProxyJob), "proxy rebuild job");
|
||||
|
||||
pj->depsgraph = depsgraph;
|
||||
pj->scene = scene;
|
||||
pj->main = CTX_data_main(C);
|
||||
|
||||
WM_jobs_customdata_set(wm_job, pj, proxy_freejob);
|
||||
WM_jobs_timer(wm_job, 0.1, NC_SCENE | ND_SEQUENCER, NC_SCENE | ND_SEQUENCER);
|
||||
WM_jobs_callbacks(wm_job, proxy_startjob, NULL, NULL, proxy_endjob);
|
||||
}
|
||||
|
||||
file_list = BLI_gset_new(BLI_ghashutil_strhash_p, BLI_ghashutil_strcmp, "file list");
|
||||
GSet *file_list = BLI_gset_new(BLI_ghashutil_strhash_p, BLI_ghashutil_strcmp, "file list");
|
||||
bool selected = false; /* Check for no selected strips */
|
||||
|
||||
SEQ_CURRENT_BEGIN (ed, seq) {
|
||||
|
@ -182,12 +109,6 @@ static void seq_proxy_build_job(const bContext *C, ReportList *reports)
|
|||
ED_area_tag_redraw(area);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Rebuild Proxy and Timecode Indices Operator
|
||||
* \{ */
|
||||
|
||||
static int sequencer_rebuild_proxy_invoke(bContext *C,
|
||||
wmOperator *op,
|
||||
const wmEvent *UNUSED(event))
|
||||
|
|
|
@ -921,7 +921,7 @@ typedef struct UserDef {
|
|||
int sequencer_disk_cache_compression; /* eUserpref_DiskCacheCompression */
|
||||
int sequencer_disk_cache_size_limit;
|
||||
short sequencer_disk_cache_flag;
|
||||
char _pad5[2];
|
||||
short sequencer_proxy_setup; /* eUserpref_SeqProxySetup */
|
||||
|
||||
float collection_instance_empty_size;
|
||||
char _pad10[3];
|
||||
|
@ -1386,6 +1386,11 @@ typedef enum eUserpref_DiskCacheCompression {
|
|||
USER_SEQ_DISK_CACHE_COMPRESSION_HIGH = 2,
|
||||
} eUserpref_DiskCacheCompression;
|
||||
|
||||
typedef enum eUserpref_SeqProxySetup {
|
||||
USER_SEQ_PROXY_SETUP_MANUAL = 0,
|
||||
USER_SEQ_PROXY_SETUP_AUTOMATIC = 1,
|
||||
} eUserpref_SeqProxySetup;
|
||||
|
||||
/* Locale Ids. Auto will try to get local from OS. Our default is English though. */
|
||||
/** #UserDef.language */
|
||||
enum {
|
||||
|
|
|
@ -56,7 +56,9 @@
|
|||
|
||||
#include "rna_internal.h"
|
||||
|
||||
#include "SEQ_proxy.h"
|
||||
#include "SEQ_relations.h"
|
||||
#include "SEQ_sequencer.h"
|
||||
|
||||
#include "WM_api.h"
|
||||
#include "WM_types.h"
|
||||
|
@ -2236,6 +2238,48 @@ static void rna_SequenceEditor_update_cache(Main *UNUSED(bmain),
|
|||
SEQ_cache_cleanup(scene);
|
||||
}
|
||||
|
||||
static void seq_build_proxy(bContext *C, PointerRNA *ptr)
|
||||
{
|
||||
if (U.sequencer_proxy_setup != USER_SEQ_PROXY_SETUP_AUTOMATIC) {
|
||||
return;
|
||||
}
|
||||
|
||||
SpaceSeq *sseq = ptr->data;
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
ListBase *seqbase = SEQ_active_seqbase_get(SEQ_editing_get(scene, false));
|
||||
|
||||
GSet *file_list = BLI_gset_new(BLI_ghashutil_strhash_p, BLI_ghashutil_strcmp, "file list");
|
||||
wmJob *wm_job = ED_seq_proxy_wm_job_get(C);
|
||||
ProxyJob *pj = ED_seq_proxy_job_get(C, wm_job);
|
||||
|
||||
LISTBASE_FOREACH (Sequence *, seq, seqbase) {
|
||||
if (seq->type != SEQ_TYPE_MOVIE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Add new proxy size. */
|
||||
seq->strip->proxy->build_size_flags |= SEQ_rendersize_to_proxysize(sseq->render_size);
|
||||
|
||||
/* Build proxy. */
|
||||
SEQ_proxy_rebuild_context(pj->main, pj->depsgraph, pj->scene, seq, file_list, &pj->queue);
|
||||
}
|
||||
|
||||
BLI_gset_free(file_list, MEM_freeN);
|
||||
|
||||
if (!WM_jobs_is_running(wm_job)) {
|
||||
G.is_break = false;
|
||||
WM_jobs_start(CTX_wm_manager(C), wm_job);
|
||||
}
|
||||
|
||||
ED_area_tag_redraw(CTX_wm_area(C));
|
||||
}
|
||||
|
||||
static void rna_SequenceEditor_render_size_update(bContext *C, PointerRNA *ptr)
|
||||
{
|
||||
seq_build_proxy(C, ptr);
|
||||
rna_SequenceEditor_update_cache(CTX_data_main(C), CTX_data_scene(C), ptr);
|
||||
}
|
||||
|
||||
static void rna_Sequencer_view_type_update(Main *UNUSED(bmain),
|
||||
Scene *UNUSED(scene),
|
||||
PointerRNA *ptr)
|
||||
|
@ -5325,8 +5369,12 @@ static void rna_def_space_sequencer(BlenderRNA *brna)
|
|||
prop = RNA_def_property(srna, "proxy_render_size", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_sdna(prop, NULL, "render_size");
|
||||
RNA_def_property_enum_items(prop, proxy_render_size_items);
|
||||
RNA_def_property_ui_text(prop, "Preview Size", "");
|
||||
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, "rna_SequenceEditor_update_cache");
|
||||
RNA_def_property_ui_text(prop,
|
||||
"Proxy Render Size",
|
||||
"Display preview using full resolution or different proxy resolutions");
|
||||
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
|
||||
RNA_def_property_update(
|
||||
prop, NC_SPACE | ND_SPACE_SEQUENCER, "rna_SequenceEditor_render_size_update");
|
||||
|
||||
prop = RNA_def_property(srna, "use_proxies", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_USE_PROXIES);
|
||||
|
|
|
@ -5378,6 +5378,16 @@ static void rna_def_userdef_system(BlenderRNA *brna)
|
|||
{0, NULL, 0, NULL, NULL},
|
||||
};
|
||||
|
||||
static const EnumPropertyItem seq_proxy_setup_options[] = {
|
||||
{USER_SEQ_PROXY_SETUP_MANUAL, "MANUAL", 0, "Manual", "Set up proxies manually"},
|
||||
{USER_SEQ_PROXY_SETUP_AUTOMATIC,
|
||||
"AUTOMATIC",
|
||||
0,
|
||||
"Automatic",
|
||||
"Build proxies for added movie and image strips in each preview size"},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
};
|
||||
|
||||
srna = RNA_def_struct(brna, "PreferencesSystem", NULL);
|
||||
RNA_def_struct_sdna(srna, "UserDef");
|
||||
RNA_def_struct_nested(brna, srna, "Preferences");
|
||||
|
@ -5445,6 +5455,13 @@ static void rna_def_userdef_system(BlenderRNA *brna)
|
|||
"Disk Cache Compression Level",
|
||||
"Smaller compression will result in larger files, but less decoding overhead");
|
||||
|
||||
/* Sequencer proxy setup */
|
||||
|
||||
prop = RNA_def_property(srna, "sequencer_proxy_setup", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_items(prop, seq_proxy_setup_options);
|
||||
RNA_def_property_enum_sdna(prop, NULL, "sequencer_proxy_setup");
|
||||
RNA_def_property_ui_text(prop, "Proxy setup", "When and how proxies are created");
|
||||
|
||||
prop = RNA_def_property(srna, "scrollback", PROP_INT, PROP_UNSIGNED);
|
||||
RNA_def_property_int_sdna(prop, NULL, "scrollback");
|
||||
RNA_def_property_range(prop, 32, 32768);
|
||||
|
|
|
@ -72,6 +72,7 @@ set(SRC
|
|||
intern/multiview.h
|
||||
intern/prefetch.c
|
||||
intern/prefetch.h
|
||||
intern/proxy_job.c
|
||||
intern/proxy.c
|
||||
intern/proxy.h
|
||||
intern/render.c
|
||||
|
|
|
@ -53,6 +53,17 @@ bool SEQ_can_use_proxy(const struct SeqRenderData *context, struct Sequence *seq
|
|||
int SEQ_rendersize_to_proxysize(int render_size);
|
||||
double SEQ_rendersize_to_scale_factor(int size);
|
||||
|
||||
typedef struct ProxyBuildJob {
|
||||
struct Main *main;
|
||||
struct Depsgraph *depsgraph;
|
||||
struct Scene *scene;
|
||||
struct ListBase queue;
|
||||
int stop;
|
||||
} ProxyJob;
|
||||
|
||||
struct wmJob *ED_seq_proxy_wm_job_get(const struct bContext *C);
|
||||
ProxyJob *ED_seq_proxy_job_get(const struct bContext *C, struct wmJob *wm_job);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
#include "IMB_metadata.h"
|
||||
|
||||
#include "SEQ_proxy.h"
|
||||
#include "SEQ_relations.h"
|
||||
#include "SEQ_render.h"
|
||||
#include "SEQ_sequencer.h"
|
||||
|
||||
|
@ -395,6 +396,17 @@ static int seq_proxy_context_count(Sequence *seq, Scene *scene)
|
|||
return num_views;
|
||||
}
|
||||
|
||||
static bool seq_proxy_need_rebuild(Sequence *seq, struct anim *anim)
|
||||
{
|
||||
if ((seq->strip->proxy->build_flags & SEQ_PROXY_SKIP_EXISTING) == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
IMB_Proxy_Size required_proxies = seq->strip->proxy->build_size_flags;
|
||||
IMB_Proxy_Size built_proxies = IMB_anim_proxy_get_existing(anim);
|
||||
return (required_proxies & built_proxies) != required_proxies;
|
||||
}
|
||||
|
||||
bool SEQ_proxy_rebuild_context(Main *bmain,
|
||||
Depsgraph *depsgraph,
|
||||
Scene *scene,
|
||||
|
@ -423,6 +435,16 @@ bool SEQ_proxy_rebuild_context(Main *bmain,
|
|||
continue;
|
||||
}
|
||||
|
||||
/* Check if proxies are already built here, because actually opening anims takes a lot of
|
||||
* time. */
|
||||
seq_open_anim_file(scene, seq, false);
|
||||
StripAnim *sanim = BLI_findlink(&seq->anims, i);
|
||||
if (sanim->anim && !seq_proxy_need_rebuild(seq, sanim->anim)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
SEQ_relations_sequence_free_anim(seq);
|
||||
|
||||
context = MEM_callocN(sizeof(SeqIndexBuildContext), "seq proxy rebuild context");
|
||||
|
||||
nseq = SEQ_sequence_dupli_recursive(scene, scene, NULL, seq, 0);
|
||||
|
@ -441,28 +463,25 @@ bool SEQ_proxy_rebuild_context(Main *bmain,
|
|||
context->view_id = i; /* only for images */
|
||||
|
||||
if (nseq->type == SEQ_TYPE_MOVIE) {
|
||||
StripAnim *sanim;
|
||||
|
||||
seq_open_anim_file(scene, nseq, true);
|
||||
sanim = BLI_findlink(&nseq->anims, i);
|
||||
|
||||
if (sanim->anim) {
|
||||
context->index_context = IMB_anim_index_rebuild_context(sanim->anim,
|
||||
context->tc_flags,
|
||||
context->size_flags,
|
||||
context->quality,
|
||||
context->overwrite,
|
||||
file_list);
|
||||
}
|
||||
if (!context->index_context) {
|
||||
MEM_freeN(context);
|
||||
return false;
|
||||
}
|
||||
context->index_context = IMB_anim_index_rebuild_context(sanim->anim,
|
||||
context->tc_flags,
|
||||
context->size_flags,
|
||||
context->quality,
|
||||
context->overwrite,
|
||||
file_list);
|
||||
}
|
||||
if (!context->index_context) {
|
||||
SEQ_proxy_rebuild_finish(context, false);
|
||||
return false;
|
||||
}
|
||||
|
||||
link = BLI_genericNodeN(context);
|
||||
BLI_addtail(queue, link);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,121 @@
|
|||
/*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
||||
* All rights reserved.
|
||||
*
|
||||
* - Blender Foundation, 2003-2009
|
||||
* - Peter Schlaile <peter [at] schlaile [dot] de> 2005/2006
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \ingroup bke
|
||||
*/
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
#include "BLI_ghash.h"
|
||||
#include "BLI_timecode.h"
|
||||
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_sequence_types.h"
|
||||
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_report.h"
|
||||
|
||||
#include "SEQ_iterator.h"
|
||||
#include "SEQ_proxy.h"
|
||||
#include "SEQ_relations.h"
|
||||
#include "SEQ_sequencer.h"
|
||||
|
||||
#include "WM_api.h"
|
||||
#include "WM_types.h"
|
||||
|
||||
#include "RNA_define.h"
|
||||
|
||||
static void proxy_freejob(void *pjv)
|
||||
{
|
||||
ProxyJob *pj = pjv;
|
||||
|
||||
BLI_freelistN(&pj->queue);
|
||||
|
||||
MEM_freeN(pj);
|
||||
}
|
||||
|
||||
/* Only this runs inside thread. */
|
||||
static void proxy_startjob(void *pjv, short *stop, short *do_update, float *progress)
|
||||
{
|
||||
ProxyJob *pj = pjv;
|
||||
LinkData *link;
|
||||
|
||||
for (link = pj->queue.first; link; link = link->next) {
|
||||
struct SeqIndexBuildContext *context = link->data;
|
||||
|
||||
SEQ_proxy_rebuild(context, stop, do_update, progress);
|
||||
|
||||
if (*stop) {
|
||||
pj->stop = 1;
|
||||
fprintf(stderr, "Canceling proxy rebuild on users request...\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void proxy_endjob(void *pjv)
|
||||
{
|
||||
ProxyJob *pj = pjv;
|
||||
Editing *ed = SEQ_editing_get(pj->scene, false);
|
||||
LinkData *link;
|
||||
|
||||
for (link = pj->queue.first; link; link = link->next) {
|
||||
SEQ_proxy_rebuild_finish(link->data, pj->stop);
|
||||
}
|
||||
|
||||
SEQ_relations_free_imbuf(pj->scene, &ed->seqbase, false);
|
||||
|
||||
WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, pj->scene);
|
||||
}
|
||||
|
||||
ProxyJob *ED_seq_proxy_job_get(const bContext *C, wmJob *wm_job)
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
struct Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
|
||||
ProxyJob *pj = WM_jobs_customdata_get(wm_job);
|
||||
if (!pj) {
|
||||
pj = MEM_callocN(sizeof(ProxyJob), "proxy rebuild job");
|
||||
pj->depsgraph = depsgraph;
|
||||
pj->scene = scene;
|
||||
pj->main = CTX_data_main(C);
|
||||
WM_jobs_customdata_set(wm_job, pj, proxy_freejob);
|
||||
WM_jobs_timer(wm_job, 0.1, NC_SCENE | ND_SEQUENCER, NC_SCENE | ND_SEQUENCER);
|
||||
WM_jobs_callbacks(wm_job, proxy_startjob, NULL, NULL, proxy_endjob);
|
||||
}
|
||||
return pj;
|
||||
}
|
||||
|
||||
struct wmJob *ED_seq_proxy_wm_job_get(const bContext *C)
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
wmJob *wm_job = WM_jobs_get(CTX_wm_manager(C),
|
||||
CTX_wm_window(C),
|
||||
scene,
|
||||
"Building Proxies",
|
||||
WM_JOB_PROGRESS,
|
||||
WM_JOB_TYPE_SEQ_BUILD_PROXY);
|
||||
return wm_job;
|
||||
}
|
Loading…
Reference in New Issue