2023-05-31 16:19:06 +02:00
|
|
|
/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2020-11-19 09:54:40 +01:00
|
|
|
|
|
|
|
|
/** \file
|
|
|
|
|
* \ingroup spseq
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
|
|
#include "BLI_blenlib.h"
|
|
|
|
|
#include "BLI_ghash.h"
|
|
|
|
|
|
|
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
|
|
|
|
|
|
#include "BKE_context.h"
|
|
|
|
|
#include "BKE_global.h"
|
|
|
|
|
#include "BKE_main.h"
|
|
|
|
|
#include "BKE_report.h"
|
|
|
|
|
|
2020-12-19 06:44:57 +01:00
|
|
|
#include "SEQ_iterator.h"
|
|
|
|
|
#include "SEQ_proxy.h"
|
|
|
|
|
#include "SEQ_relations.h"
|
2020-11-19 09:54:40 +01:00
|
|
|
#include "SEQ_sequencer.h"
|
|
|
|
|
|
2023-08-04 23:11:22 +02:00
|
|
|
#include "WM_api.hh"
|
|
|
|
|
#include "WM_types.hh"
|
2020-11-19 09:54:40 +01:00
|
|
|
|
2023-08-10 22:40:27 +02:00
|
|
|
#include "RNA_define.hh"
|
2020-11-19 09:54:40 +01:00
|
|
|
|
|
|
|
|
/* For menu, popup, icons, etc. */
|
2023-08-04 23:11:22 +02:00
|
|
|
#include "ED_screen.hh"
|
2020-11-19 09:54:40 +01:00
|
|
|
|
|
|
|
|
/* Own include. */
|
2023-09-08 08:23:01 -04:00
|
|
|
#include "sequencer_intern.hh"
|
2020-11-19 09:54:40 +01:00
|
|
|
|
2021-03-16 18:47:23 +01:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Rebuild Proxy and Timecode Indices Operator
|
2020-11-19 11:04:30 +01:00
|
|
|
* \{ */
|
2020-11-19 09:54:40 +01:00
|
|
|
|
|
|
|
|
static void seq_proxy_build_job(const bContext *C, ReportList *reports)
|
|
|
|
|
{
|
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
2021-09-02 11:29:32 +10:00
|
|
|
Editing *ed = SEQ_editing_get(scene);
|
2020-11-19 09:54:40 +01:00
|
|
|
ScrArea *area = CTX_wm_area(C);
|
|
|
|
|
|
2023-06-14 18:36:17 +02:00
|
|
|
if (ed == nullptr) {
|
2020-11-19 09:54:40 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-16 18:47:23 +01:00
|
|
|
wmJob *wm_job = ED_seq_proxy_wm_job_get(C);
|
|
|
|
|
ProxyJob *pj = ED_seq_proxy_job_get(C, wm_job);
|
2020-11-19 09:54:40 +01:00
|
|
|
|
2021-03-16 18:47:23 +01:00
|
|
|
GSet *file_list = BLI_gset_new(BLI_ghashutil_strhash_p, BLI_ghashutil_strcmp, "file list");
|
2020-11-19 09:54:40 +01:00
|
|
|
bool selected = false; /* Check for no selected strips */
|
|
|
|
|
|
2021-03-31 09:27:31 +02:00
|
|
|
LISTBASE_FOREACH (Sequence *, seq, SEQ_active_seqbase_get(ed)) {
|
2021-01-25 04:42:46 +01:00
|
|
|
if (!ELEM(seq->type, SEQ_TYPE_MOVIE, SEQ_TYPE_IMAGE) || (seq->flag & SELECT) == 0) {
|
2020-11-19 09:54:40 +01:00
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
selected = true;
|
|
|
|
|
if (!(seq->flag & SEQ_USE_PROXY)) {
|
|
|
|
|
BKE_reportf(reports, RPT_WARNING, "Proxy is not enabled for %s, skipping", seq->name);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (seq->strip->proxy->build_size_flags == 0) {
|
|
|
|
|
BKE_reportf(reports, RPT_WARNING, "Resolution is not selected for %s, skipping", seq->name);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool success = SEQ_proxy_rebuild_context(
|
2022-01-25 21:39:56 +01:00
|
|
|
pj->main, pj->depsgraph, pj->scene, seq, file_list, &pj->queue, false);
|
2020-11-19 09:54:40 +01:00
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-26 17:33:03 +01:00
|
|
|
BLI_gset_free(file_list, MEM_freeN);
|
|
|
|
|
|
2020-11-19 09:54:40 +01:00
|
|
|
if (!selected) {
|
|
|
|
|
BKE_reportf(reports, RPT_WARNING, "Select movie or image strips");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-10 01:55:44 +10:00
|
|
|
if (!WM_jobs_is_running(wm_job)) {
|
2020-11-19 09:54:40 +01:00
|
|
|
G.is_break = false;
|
|
|
|
|
WM_jobs_start(CTX_wm_manager(C), wm_job);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ED_area_tag_redraw(area);
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-14 18:36:17 +02:00
|
|
|
static int sequencer_rebuild_proxy_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
|
2020-11-19 09:54:40 +01:00
|
|
|
{
|
|
|
|
|
seq_proxy_build_job(C, op->reports);
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-14 18:36:17 +02:00
|
|
|
static int sequencer_rebuild_proxy_exec(bContext *C, wmOperator * /*o*/)
|
2020-11-19 09:54:40 +01:00
|
|
|
{
|
|
|
|
|
Main *bmain = CTX_data_main(C);
|
2023-06-14 18:36:17 +02:00
|
|
|
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
|
2020-11-19 09:54:40 +01:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
2021-09-02 11:29:32 +10:00
|
|
|
Editing *ed = SEQ_editing_get(scene);
|
2020-11-19 09:54:40 +01:00
|
|
|
GSet *file_list;
|
|
|
|
|
|
2023-06-14 18:36:17 +02:00
|
|
|
if (ed == nullptr) {
|
2020-11-19 09:54:40 +01:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
file_list = BLI_gset_new(BLI_ghashutil_strhash_p, BLI_ghashutil_strcmp, "file list");
|
|
|
|
|
|
2021-03-31 09:27:31 +02:00
|
|
|
LISTBASE_FOREACH (Sequence *, seq, SEQ_active_seqbase_get(ed)) {
|
2021-08-05 16:48:29 +10:00
|
|
|
if (seq->flag & SELECT) {
|
2023-06-14 18:36:17 +02:00
|
|
|
ListBase queue = {nullptr, nullptr};
|
2020-11-19 09:54:40 +01:00
|
|
|
|
2022-01-25 21:39:56 +01:00
|
|
|
SEQ_proxy_rebuild_context(bmain, depsgraph, scene, seq, file_list, &queue, false);
|
2020-11-19 09:54:40 +01:00
|
|
|
|
2023-10-06 13:06:02 +02:00
|
|
|
wmJobWorkerStatus worker_status = {};
|
2023-06-14 18:36:17 +02:00
|
|
|
LISTBASE_FOREACH (LinkData *, link, &queue) {
|
|
|
|
|
SeqIndexBuildContext *context = static_cast<SeqIndexBuildContext *>(link->data);
|
2023-10-06 13:06:02 +02:00
|
|
|
SEQ_proxy_rebuild(context, &worker_status);
|
2022-11-04 18:37:25 +11:00
|
|
|
SEQ_proxy_rebuild_finish(context, false);
|
2020-11-19 09:54:40 +01:00
|
|
|
}
|
2020-12-19 05:57:27 +01:00
|
|
|
SEQ_relations_free_imbuf(scene, &ed->seqbase, false);
|
2020-11-19 09:54:40 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BLI_gset_free(file_list, MEM_freeN);
|
|
|
|
|
|
|
|
|
|
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 indices using the job system";
|
|
|
|
|
|
|
|
|
|
/* Api callbacks. */
|
|
|
|
|
ot->invoke = sequencer_rebuild_proxy_invoke;
|
|
|
|
|
ot->exec = sequencer_rebuild_proxy_exec;
|
|
|
|
|
|
|
|
|
|
/* Flags. */
|
|
|
|
|
ot->flag = OPTYPE_REGISTER;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Set Selected Strip Proxies Operator
|
|
|
|
|
* \{ */
|
|
|
|
|
|
2023-06-14 18:36:17 +02:00
|
|
|
static int sequencer_enable_proxies_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
|
2020-11-19 09:54:40 +01:00
|
|
|
{
|
|
|
|
|
return WM_operator_props_dialog_popup(C, op, 200);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int sequencer_enable_proxies_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
2021-09-02 11:29:32 +10:00
|
|
|
Editing *ed = SEQ_editing_get(scene);
|
2020-11-19 09:54:40 +01:00
|
|
|
bool proxy_25 = RNA_boolean_get(op->ptr, "proxy_25");
|
|
|
|
|
bool proxy_50 = RNA_boolean_get(op->ptr, "proxy_50");
|
|
|
|
|
bool proxy_75 = RNA_boolean_get(op->ptr, "proxy_75");
|
|
|
|
|
bool proxy_100 = RNA_boolean_get(op->ptr, "proxy_100");
|
|
|
|
|
bool overwrite = RNA_boolean_get(op->ptr, "overwrite");
|
|
|
|
|
bool turnon = true;
|
|
|
|
|
|
2023-06-14 18:36:17 +02:00
|
|
|
if (ed == nullptr || !(proxy_25 || proxy_50 || proxy_75 || proxy_100)) {
|
2020-11-19 09:54:40 +01:00
|
|
|
turnon = false;
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-31 09:27:31 +02:00
|
|
|
LISTBASE_FOREACH (Sequence *, seq, SEQ_active_seqbase_get(ed)) {
|
2021-08-05 16:48:29 +10:00
|
|
|
if (seq->flag & SELECT) {
|
2021-01-25 04:42:46 +01:00
|
|
|
if (ELEM(seq->type, SEQ_TYPE_MOVIE, SEQ_TYPE_IMAGE)) {
|
2020-11-19 09:54:40 +01:00
|
|
|
SEQ_proxy_set(seq, turnon);
|
2023-06-14 18:36:17 +02:00
|
|
|
if (seq->strip->proxy == nullptr) {
|
2020-11-19 09:54:40 +01:00
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (proxy_25) {
|
|
|
|
|
seq->strip->proxy->build_size_flags |= SEQ_PROXY_IMAGE_SIZE_25;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
seq->strip->proxy->build_size_flags &= ~SEQ_PROXY_IMAGE_SIZE_25;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (proxy_50) {
|
|
|
|
|
seq->strip->proxy->build_size_flags |= SEQ_PROXY_IMAGE_SIZE_50;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
seq->strip->proxy->build_size_flags &= ~SEQ_PROXY_IMAGE_SIZE_50;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (proxy_75) {
|
|
|
|
|
seq->strip->proxy->build_size_flags |= SEQ_PROXY_IMAGE_SIZE_75;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
seq->strip->proxy->build_size_flags &= ~SEQ_PROXY_IMAGE_SIZE_75;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (proxy_100) {
|
|
|
|
|
seq->strip->proxy->build_size_flags |= SEQ_PROXY_IMAGE_SIZE_100;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
seq->strip->proxy->build_size_flags &= ~SEQ_PROXY_IMAGE_SIZE_100;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!overwrite) {
|
|
|
|
|
seq->strip->proxy->build_flags |= SEQ_PROXY_SKIP_EXISTING;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
seq->strip->proxy->build_flags &= ~SEQ_PROXY_SKIP_EXISTING;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SEQUENCER_OT_enable_proxies(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* Identifiers. */
|
|
|
|
|
ot->name = "Set Selected Strip Proxies";
|
|
|
|
|
ot->idname = "SEQUENCER_OT_enable_proxies";
|
2021-01-25 04:42:46 +01:00
|
|
|
ot->description = "Enable selected proxies on all selected Movie and Image strips";
|
2020-11-19 09:54:40 +01:00
|
|
|
|
|
|
|
|
/* Api callbacks. */
|
|
|
|
|
ot->invoke = sequencer_enable_proxies_invoke;
|
|
|
|
|
ot->exec = sequencer_enable_proxies_exec;
|
|
|
|
|
|
|
|
|
|
/* Flags. */
|
|
|
|
|
ot->flag = OPTYPE_REGISTER;
|
|
|
|
|
|
|
|
|
|
RNA_def_boolean(ot->srna, "proxy_25", false, "25%", "");
|
|
|
|
|
RNA_def_boolean(ot->srna, "proxy_50", false, "50%", "");
|
|
|
|
|
RNA_def_boolean(ot->srna, "proxy_75", false, "75%", "");
|
|
|
|
|
RNA_def_boolean(ot->srna, "proxy_100", false, "100%", "");
|
|
|
|
|
RNA_def_boolean(ot->srna, "overwrite", false, "Overwrite", "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** \} */
|