VSE: Build proxies only for slow movies
This change applies only for automatic proxy building, when strip is added to timeline. Manual building process is not affected. Don't build proxy file if movie is already fast enough to seek. To determine seek performance, check if whole GOP can be decoded in 100 milliseconds. To consider some variation in GOP size, large number of packets are read, assuming that each packet will produce 1 frame. While this is not technically correct, it does give quite accurate estimate of maximum GOP size. This test will ensure consistent performance on wide array of machines. Check should be done in order of few milliseconds. Reviewed By: sergey Differential Revision: https://developer.blender.org/D11671
This commit is contained in:
@@ -59,6 +59,7 @@
|
||||
|
||||
#include "SEQ_add.h"
|
||||
#include "SEQ_effects.h"
|
||||
#include "SEQ_iterator.h"
|
||||
#include "SEQ_proxy.h"
|
||||
#include "SEQ_relations.h"
|
||||
#include "SEQ_render.h"
|
||||
@@ -601,29 +602,28 @@ static IMB_Proxy_Size seq_get_proxy_size_flags(bContext *C)
|
||||
return proxy_sizes;
|
||||
}
|
||||
|
||||
static void seq_build_proxy(bContext *C, Sequence *seq)
|
||||
static void seq_build_proxy(bContext *C, SeqCollection *movie_strips)
|
||||
{
|
||||
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);
|
||||
|
||||
Sequence *seq;
|
||||
SEQ_ITERATOR_FOREACH (seq, movie_strips) {
|
||||
/* 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;
|
||||
SEQ_proxy_rebuild_context(pj->main, pj->depsgraph, pj->scene, seq, NULL, &pj->queue, true);
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
@@ -642,7 +642,8 @@ static void sequencer_add_movie_clamp_sound_strip_length(Scene *scene,
|
||||
|
||||
static void sequencer_add_movie_multiple_strips(bContext *C,
|
||||
wmOperator *op,
|
||||
SeqLoadData *load_data)
|
||||
SeqLoadData *load_data,
|
||||
SeqCollection *r_movie_strips)
|
||||
{
|
||||
Main *bmain = CTX_data_main(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
@@ -705,13 +706,16 @@ static void sequencer_add_movie_multiple_strips(bContext *C,
|
||||
sequencer_add_movie_clamp_sound_strip_length(scene, ed->seqbasep, seq_movie, seq_sound);
|
||||
seq_load_apply_generic_options(C, op, seq_sound);
|
||||
seq_load_apply_generic_options(C, op, seq_movie);
|
||||
seq_build_proxy(C, seq_movie);
|
||||
SEQ_collection_append_strip(seq_movie, r_movie_strips);
|
||||
}
|
||||
}
|
||||
RNA_END;
|
||||
}
|
||||
|
||||
static bool sequencer_add_movie_single_strip(bContext *C, wmOperator *op, SeqLoadData *load_data)
|
||||
static bool sequencer_add_movie_single_strip(bContext *C,
|
||||
wmOperator *op,
|
||||
SeqLoadData *load_data,
|
||||
SeqCollection *r_movie_strips)
|
||||
{
|
||||
Main *bmain = CTX_data_main(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
@@ -757,7 +761,7 @@ static bool sequencer_add_movie_single_strip(bContext *C, wmOperator *op, SeqLoa
|
||||
sequencer_add_movie_clamp_sound_strip_length(scene, ed->seqbasep, seq_movie, seq_sound);
|
||||
seq_load_apply_generic_options(C, op, seq_sound);
|
||||
seq_load_apply_generic_options(C, op, seq_movie);
|
||||
seq_build_proxy(C, seq_movie);
|
||||
SEQ_collection_append_strip(seq_movie, r_movie_strips);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -774,21 +778,25 @@ static int sequencer_add_movie_strip_exec(bContext *C, wmOperator *op)
|
||||
ED_sequencer_deselect_all(scene);
|
||||
}
|
||||
|
||||
SeqCollection *movie_strips = SEQ_collection_create(__func__);
|
||||
const int tot_files = RNA_property_collection_length(op->ptr,
|
||||
RNA_struct_find_property(op->ptr, "files"));
|
||||
if (tot_files > 1) {
|
||||
sequencer_add_movie_multiple_strips(C, op, &load_data);
|
||||
sequencer_add_movie_multiple_strips(C, op, &load_data, movie_strips);
|
||||
}
|
||||
else {
|
||||
if (!sequencer_add_movie_single_strip(C, op, &load_data)) {
|
||||
sequencer_add_cancel(C, op);
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
sequencer_add_movie_single_strip(C, op, &load_data, movie_strips);
|
||||
}
|
||||
|
||||
if (SEQ_collection_len(movie_strips) == 0) {
|
||||
SEQ_collection_free(movie_strips);
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
/* Free custom data. */
|
||||
sequencer_add_cancel(C, op);
|
||||
|
||||
seq_build_proxy(C, movie_strips);
|
||||
DEG_relations_tag_update(bmain);
|
||||
DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS);
|
||||
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
|
||||
|
||||
@@ -85,7 +85,7 @@ static void seq_proxy_build_job(const bContext *C, ReportList *reports)
|
||||
}
|
||||
|
||||
bool success = SEQ_proxy_rebuild_context(
|
||||
pj->main, pj->depsgraph, pj->scene, seq, file_list, &pj->queue);
|
||||
pj->main, pj->depsgraph, pj->scene, seq, file_list, &pj->queue, false);
|
||||
|
||||
if (!success && (seq->strip->proxy->build_flags & SEQ_PROXY_SKIP_EXISTING) != 0) {
|
||||
BKE_reportf(reports, RPT_WARNING, "Overwrite is not checked for %s, skipping", seq->name);
|
||||
@@ -137,7 +137,7 @@ static int sequencer_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
short stop = 0, do_update;
|
||||
float progress;
|
||||
|
||||
SEQ_proxy_rebuild_context(bmain, depsgraph, scene, seq, file_list, &queue);
|
||||
SEQ_proxy_rebuild_context(bmain, depsgraph, scene, seq, file_list, &queue, false);
|
||||
|
||||
for (link = queue.first; link; link = link->next) {
|
||||
struct SeqIndexBuildContext *context = link->data;
|
||||
|
||||
Reference in New Issue
Block a user