Blender V4.3
sequencer_proxy.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#include "MEM_guardedalloc.h"
10
11#include "BLI_ghash.h"
12
13#include "DNA_scene_types.h"
14
15#include "BKE_context.hh"
16#include "BKE_global.hh"
17#include "BKE_report.hh"
18
19#include "BLT_translation.hh"
20
21#include "SEQ_proxy.hh"
22#include "SEQ_relations.hh"
23#include "SEQ_sequencer.hh"
24
25#include "WM_api.hh"
26#include "WM_types.hh"
27
28#include "RNA_define.hh"
29
30/* For menu, popup, icons, etc. */
31#include "ED_screen.hh"
32
33/* Own include. */
34#include "sequencer_intern.hh"
35
36/* -------------------------------------------------------------------- */
40static void seq_proxy_build_job(const bContext *C, ReportList *reports)
41{
42 Scene *scene = CTX_data_scene(C);
43 Editing *ed = SEQ_editing_get(scene);
44 ScrArea *area = CTX_wm_area(C);
45
46 if (ed == nullptr) {
47 return;
48 }
49
50 wmJob *wm_job = ED_seq_proxy_wm_job_get(C);
51 ProxyJob *pj = ED_seq_proxy_job_get(C, wm_job);
52
54 bool selected = false; /* Check for no selected strips */
55
57 if (!ELEM(seq->type, SEQ_TYPE_MOVIE, SEQ_TYPE_IMAGE) || (seq->flag & SELECT) == 0) {
58 continue;
59 }
60
61 selected = true;
62 if (!(seq->flag & SEQ_USE_PROXY)) {
63 BKE_reportf(reports, RPT_WARNING, "Proxy is not enabled for %s, skipping", seq->name);
64 continue;
65 }
66 if (seq->strip->proxy->build_size_flags == 0) {
67 BKE_reportf(reports, RPT_WARNING, "Resolution is not selected for %s, skipping", seq->name);
68 continue;
69 }
70
71 bool success = SEQ_proxy_rebuild_context(
72 pj->main, pj->depsgraph, pj->scene, seq, file_list, &pj->queue, false);
73
74 if (!success && (seq->strip->proxy->build_flags & SEQ_PROXY_SKIP_EXISTING) != 0) {
75 BKE_reportf(reports, RPT_WARNING, "Overwrite is not checked for %s, skipping", seq->name);
76 }
77 }
78
79 BLI_gset_free(file_list, MEM_freeN);
80
81 if (!selected) {
82 BKE_reportf(reports, RPT_WARNING, "Select movie or image strips");
83 return;
84 }
85
86 if (!WM_jobs_is_running(wm_job)) {
87 G.is_break = false;
88 WM_jobs_start(CTX_wm_manager(C), wm_job);
89 }
90
92}
93
94static int sequencer_rebuild_proxy_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
95{
97
98 return OPERATOR_FINISHED;
99}
100
102{
103 Main *bmain = CTX_data_main(C);
105 Scene *scene = CTX_data_scene(C);
106 Editing *ed = SEQ_editing_get(scene);
107 GSet *file_list;
108
109 if (ed == nullptr) {
110 return OPERATOR_CANCELLED;
111 }
112
114
116 if (seq->flag & SELECT) {
117 ListBase queue = {nullptr, nullptr};
118
119 SEQ_proxy_rebuild_context(bmain, depsgraph, scene, seq, file_list, &queue, false);
120
121 wmJobWorkerStatus worker_status = {};
122 LISTBASE_FOREACH (LinkData *, link, &queue) {
123 SeqIndexBuildContext *context = static_cast<SeqIndexBuildContext *>(link->data);
124 SEQ_proxy_rebuild(context, &worker_status);
125 SEQ_proxy_rebuild_finish(context, false);
126 }
127 SEQ_relations_free_imbuf(scene, &ed->seqbase, false);
128 }
129 }
130
131 BLI_gset_free(file_list, MEM_freeN);
132
133 return OPERATOR_FINISHED;
134}
135
137{
138 /* Identifiers. */
139 ot->name = "Rebuild Proxy and Timecode Indices";
140 ot->idname = "SEQUENCER_OT_rebuild_proxy";
141 ot->description = "Rebuild all selected proxies and timecode indices using the job system";
142
143 /* Api callbacks. */
146
147 /* Flags. */
149}
150
153/* -------------------------------------------------------------------- */
157static int sequencer_enable_proxies_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
158{
160 C, op, 200, IFACE_("Set Selected Strip Proxies"), IFACE_("Set"));
161}
162
164{
165 Scene *scene = CTX_data_scene(C);
166 Editing *ed = SEQ_editing_get(scene);
167 bool proxy_25 = RNA_boolean_get(op->ptr, "proxy_25");
168 bool proxy_50 = RNA_boolean_get(op->ptr, "proxy_50");
169 bool proxy_75 = RNA_boolean_get(op->ptr, "proxy_75");
170 bool proxy_100 = RNA_boolean_get(op->ptr, "proxy_100");
171 bool overwrite = RNA_boolean_get(op->ptr, "overwrite");
172 bool turnon = true;
173
174 if (ed == nullptr || !(proxy_25 || proxy_50 || proxy_75 || proxy_100)) {
175 turnon = false;
176 }
177
179 if (seq->flag & SELECT) {
180 if (ELEM(seq->type, SEQ_TYPE_MOVIE, SEQ_TYPE_IMAGE)) {
181 SEQ_proxy_set(seq, turnon);
182 if (seq->strip->proxy == nullptr) {
183 continue;
184 }
185
186 if (proxy_25) {
187 seq->strip->proxy->build_size_flags |= SEQ_PROXY_IMAGE_SIZE_25;
188 }
189 else {
190 seq->strip->proxy->build_size_flags &= ~SEQ_PROXY_IMAGE_SIZE_25;
191 }
192
193 if (proxy_50) {
194 seq->strip->proxy->build_size_flags |= SEQ_PROXY_IMAGE_SIZE_50;
195 }
196 else {
197 seq->strip->proxy->build_size_flags &= ~SEQ_PROXY_IMAGE_SIZE_50;
198 }
199
200 if (proxy_75) {
201 seq->strip->proxy->build_size_flags |= SEQ_PROXY_IMAGE_SIZE_75;
202 }
203 else {
204 seq->strip->proxy->build_size_flags &= ~SEQ_PROXY_IMAGE_SIZE_75;
205 }
206
207 if (proxy_100) {
208 seq->strip->proxy->build_size_flags |= SEQ_PROXY_IMAGE_SIZE_100;
209 }
210 else {
211 seq->strip->proxy->build_size_flags &= ~SEQ_PROXY_IMAGE_SIZE_100;
212 }
213
214 if (!overwrite) {
215 seq->strip->proxy->build_flags |= SEQ_PROXY_SKIP_EXISTING;
216 }
217 else {
218 seq->strip->proxy->build_flags &= ~SEQ_PROXY_SKIP_EXISTING;
219 }
220 }
221 }
222 }
223
225
226 return OPERATOR_FINISHED;
227}
228
230{
231 /* Identifiers. */
232 ot->name = "Set Selected Strip Proxies";
233 ot->idname = "SEQUENCER_OT_enable_proxies";
234 ot->description = "Enable selected proxies on all selected Movie and Image strips";
235
236 /* Api callbacks. */
239
240 /* Flags. */
242
243 RNA_def_boolean(ot->srna, "proxy_25", false, "25%", "");
244 RNA_def_boolean(ot->srna, "proxy_50", false, "50%", "");
245 RNA_def_boolean(ot->srna, "proxy_75", false, "75%", "");
246 RNA_def_boolean(ot->srna, "proxy_100", false, "100%", "");
247 RNA_def_boolean(ot->srna, "overwrite", false, "Overwrite", "");
248}
249
Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
ScrArea * CTX_wm_area(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
Main * CTX_data_main(const bContext *C)
wmWindowManager * CTX_wm_manager(const bContext *C)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
struct GSet GSet
Definition BLI_ghash.h:341
bool BLI_ghashutil_strcmp(const void *a, const void *b)
unsigned int BLI_ghashutil_strhash_p(const void *ptr)
GSet * BLI_gset_new(GSetHashFP hashfp, GSetCmpFP cmpfp, const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
Definition BLI_ghash.c:944
void BLI_gset_free(GSet *gs, GSetKeyFreeFP keyfreefp)
Definition BLI_ghash.c:1034
#define LISTBASE_FOREACH(type, var, list)
#define ELEM(...)
#define IFACE_(msgid)
@ SEQ_TYPE_IMAGE
@ SEQ_TYPE_MOVIE
@ SEQ_PROXY_SKIP_EXISTING
@ SEQ_PROXY_IMAGE_SIZE_100
@ SEQ_PROXY_IMAGE_SIZE_25
@ SEQ_PROXY_IMAGE_SIZE_50
@ SEQ_PROXY_IMAGE_SIZE_75
@ SEQ_USE_PROXY
void ED_area_tag_redraw(ScrArea *area)
Definition area.cc:708
Read Guarded memory(de)allocation.
#define ND_SEQUENCER
Definition WM_types.hh:404
@ OPTYPE_REGISTER
Definition WM_types.hh:160
#define NC_SCENE
Definition WM_types.hh:345
#define SELECT
const Depsgraph * depsgraph
void MEM_freeN(void *vmemh)
Definition mallocn.cc:105
#define G(x, y, z)
bool SEQ_proxy_rebuild_context(Main *bmain, Depsgraph *depsgraph, Scene *scene, Sequence *seq, GSet *file_list, ListBase *queue, bool build_only_on_bad_performance)
Definition proxy.cc:420
void SEQ_proxy_set(Sequence *seq, bool value)
Definition proxy.cc:591
void SEQ_proxy_rebuild_finish(SeqIndexBuildContext *context, bool stop)
Definition proxy.cc:576
void SEQ_proxy_rebuild(SeqIndexBuildContext *context, wmJobWorkerStatus *worker_status)
Definition proxy.cc:506
ProxyJob * ED_seq_proxy_job_get(const bContext *C, wmJob *wm_job)
Definition proxy_job.cc:66
wmJob * ED_seq_proxy_wm_job_get(const bContext *C)
Definition proxy_job.cc:83
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
ListBase * SEQ_active_seqbase_get(const Editing *ed)
Definition sequencer.cc:416
Editing * SEQ_editing_get(const Scene *scene)
Definition sequencer.cc:262
void SEQUENCER_OT_enable_proxies(wmOperatorType *ot)
void SEQUENCER_OT_rebuild_proxy(wmOperatorType *ot)
static int sequencer_enable_proxies_invoke(bContext *C, wmOperator *op, const wmEvent *)
static int sequencer_enable_proxies_exec(bContext *C, wmOperator *op)
static void seq_proxy_build_job(const bContext *C, ReportList *reports)
static int sequencer_rebuild_proxy_exec(bContext *C, wmOperator *)
static int sequencer_rebuild_proxy_invoke(bContext *C, wmOperator *op, const wmEvent *)
void SEQ_relations_free_imbuf(Scene *scene, ListBase *seqbase, bool for_render)
ListBase seqbase
Main * main
Definition clip_ops.cc:1177
Depsgraph * depsgraph
Definition SEQ_proxy.hh:38
Scene * scene
Definition clip_ops.cc:1176
ListBase queue
Definition SEQ_proxy.hh:40
const char * name
Definition WM_types.hh:990
const char * idname
Definition WM_types.hh:992
int(* invoke)(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1022
int(* exec)(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1006
const char * description
Definition WM_types.hh:996
StructRNA * srna
Definition WM_types.hh:1080
struct ReportList * reports
struct PointerRNA * ptr
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
wmOperatorType * ot
Definition wm_files.cc:4125
bool WM_jobs_is_running(const wmJob *wm_job)
Definition wm_jobs.cc:317
void WM_jobs_start(wmWindowManager *wm, wmJob *wm_job)
Definition wm_jobs.cc:455
int WM_operator_props_dialog_popup(bContext *C, wmOperator *op, int width, std::optional< std::string > title, std::optional< std::string > confirm_text, const bool cancel_default)