Blender V5.0
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
8
9#include "DNA_scene_types.h"
10
11#include "BLI_listbase.h"
12
13#include "BKE_context.hh"
14#include "BKE_global.hh"
15#include "BKE_report.hh"
16
17#include "BLT_translation.hh"
18
19#include "SEQ_proxy.hh"
20#include "SEQ_relations.hh"
21#include "SEQ_sequencer.hh"
22
23#include "WM_api.hh"
24#include "WM_types.hh"
25
26#include "RNA_define.hh"
27
28/* For menu, popup, icons, etc. */
29#include "ED_screen.hh"
30
31/* Own include. */
32#include "sequencer_intern.hh"
33
34namespace blender::ed::vse {
35
36/* -------------------------------------------------------------------- */
39
40static void seq_proxy_build_job(const bContext *C, ReportList *reports)
41{
43 Editing *ed = seq::editing_get(scene);
44 ScrArea *area = CTX_wm_area(C);
45
46 if (ed == nullptr) {
47 return;
48 }
49
52
53 blender::Set<std::string> processed_paths;
54 bool selected = false; /* Check for no selected strips */
55
57 if (!ELEM(strip->type, STRIP_TYPE_MOVIE, STRIP_TYPE_IMAGE) || (strip->flag & SELECT) == 0) {
58 continue;
59 }
60
61 selected = true;
62 if (!(strip->flag & SEQ_USE_PROXY)) {
63 BKE_reportf(reports, RPT_WARNING, "Proxy is not enabled for %s, skipping", strip->name);
64 continue;
65 }
66 if (strip->data->proxy->build_size_flags == 0) {
68 reports, RPT_WARNING, "Resolution is not selected for %s, skipping", strip->name);
69 continue;
70 }
71
72 bool success = seq::proxy_rebuild_context(
73 pj->main, pj->depsgraph, pj->scene, strip, &processed_paths, &pj->queue, false);
74
75 if (!success && (strip->data->proxy->build_flags & SEQ_PROXY_SKIP_EXISTING) != 0) {
76 BKE_reportf(reports, RPT_WARNING, "Overwrite is not checked for %s, skipping", strip->name);
77 }
78 }
79
80 if (!selected) {
81 BKE_reportf(reports, RPT_WARNING, "Select movie or image strips");
82 return;
83 }
84
85 if (!WM_jobs_is_running(wm_job)) {
86 G.is_break = false;
88 }
89
91}
92
94 wmOperator *op,
95 const wmEvent * /*event*/)
96{
98
99 return OPERATOR_FINISHED;
100}
101
103{
104 Main *bmain = CTX_data_main(C);
107 Editing *ed = seq::editing_get(scene);
108
109 if (ed == nullptr) {
110 return OPERATOR_CANCELLED;
111 }
112
113 blender::Set<std::string> processed_paths;
114
116 if (strip->flag & SELECT) {
117 ListBase queue = {nullptr, nullptr};
118
119 seq::proxy_rebuild_context(bmain, depsgraph, scene, strip, &processed_paths, &queue, false);
120
121 wmJobWorkerStatus worker_status = {};
122 LISTBASE_FOREACH (LinkData *, link, &queue) {
123 seq::IndexBuildContext *context = static_cast<seq::IndexBuildContext *>(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 return OPERATOR_FINISHED;
132}
133
135{
136 /* Identifiers. */
137 ot->name = "Rebuild Proxy and Timecode Indices";
138 ot->idname = "SEQUENCER_OT_rebuild_proxy";
139 ot->description = "Rebuild all selected proxies and timecode indices";
140
141 /* API callbacks. */
144 ot->poll = sequencer_edit_poll;
145
146 /* Flags. */
147 ot->flag = OPTYPE_REGISTER;
148}
149
151
152/* -------------------------------------------------------------------- */
155
157 wmOperator *op,
158 const wmEvent * /*event*/)
159{
161 C, op, 200, IFACE_("Set Selected Strip Proxies"), IFACE_("Set"));
162}
163
165{
167 Editing *ed = seq::editing_get(scene);
168 bool proxy_25 = RNA_boolean_get(op->ptr, "proxy_25");
169 bool proxy_50 = RNA_boolean_get(op->ptr, "proxy_50");
170 bool proxy_75 = RNA_boolean_get(op->ptr, "proxy_75");
171 bool proxy_100 = RNA_boolean_get(op->ptr, "proxy_100");
172 bool overwrite = RNA_boolean_get(op->ptr, "overwrite");
173 bool turnon = true;
174
175 if (ed == nullptr || !(proxy_25 || proxy_50 || proxy_75 || proxy_100)) {
176 turnon = false;
177 }
178
180 if (strip->flag & SELECT) {
181 if (ELEM(strip->type, STRIP_TYPE_MOVIE, STRIP_TYPE_IMAGE)) {
182 seq::proxy_set(strip, turnon);
183 if (strip->data->proxy == nullptr) {
184 continue;
185 }
186
187 if (proxy_25) {
188 strip->data->proxy->build_size_flags |= SEQ_PROXY_IMAGE_SIZE_25;
189 }
190 else {
191 strip->data->proxy->build_size_flags &= ~SEQ_PROXY_IMAGE_SIZE_25;
192 }
193
194 if (proxy_50) {
195 strip->data->proxy->build_size_flags |= SEQ_PROXY_IMAGE_SIZE_50;
196 }
197 else {
198 strip->data->proxy->build_size_flags &= ~SEQ_PROXY_IMAGE_SIZE_50;
199 }
200
201 if (proxy_75) {
202 strip->data->proxy->build_size_flags |= SEQ_PROXY_IMAGE_SIZE_75;
203 }
204 else {
205 strip->data->proxy->build_size_flags &= ~SEQ_PROXY_IMAGE_SIZE_75;
206 }
207
208 if (proxy_100) {
209 strip->data->proxy->build_size_flags |= SEQ_PROXY_IMAGE_SIZE_100;
210 }
211 else {
212 strip->data->proxy->build_size_flags &= ~SEQ_PROXY_IMAGE_SIZE_100;
213 }
214
215 if (!overwrite) {
216 strip->data->proxy->build_flags |= SEQ_PROXY_SKIP_EXISTING;
217 }
218 else {
219 strip->data->proxy->build_flags &= ~SEQ_PROXY_SKIP_EXISTING;
220 }
221 }
222 }
223 }
224
226
227 return OPERATOR_FINISHED;
228}
229
231{
232 /* Identifiers. */
233 ot->name = "Set Selected Strip Proxies";
234 ot->idname = "SEQUENCER_OT_enable_proxies";
235 ot->description = "Enable selected proxies on all selected Movie and Image strips";
236
237 /* API callbacks. */
240 ot->poll = sequencer_edit_poll;
241
242 /* Flags. */
243 ot->flag = OPTYPE_REGISTER;
244
245 RNA_def_boolean(ot->srna, "proxy_25", false, "25%", "");
246 RNA_def_boolean(ot->srna, "proxy_50", false, "50%", "");
247 RNA_def_boolean(ot->srna, "proxy_75", false, "75%", "");
248 RNA_def_boolean(ot->srna, "proxy_100", false, "100%", "");
249 RNA_def_boolean(ot->srna, "overwrite", false, "Overwrite", "");
250}
251
253
254} // namespace blender::ed::vse
Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
ScrArea * CTX_wm_area(const bContext *C)
Main * CTX_data_main(const bContext *C)
wmWindowManager * CTX_wm_manager(const bContext *C)
Scene * CTX_data_sequencer_scene(const bContext *C)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
@ RPT_WARNING
Definition BKE_report.hh:38
#define LISTBASE_FOREACH(type, var, list)
#define ELEM(...)
#define IFACE_(msgid)
@ STRIP_TYPE_IMAGE
@ STRIP_TYPE_MOVIE
@ SEQ_PROXY_IMAGE_SIZE_100
@ SEQ_PROXY_IMAGE_SIZE_25
@ SEQ_PROXY_IMAGE_SIZE_50
@ SEQ_PROXY_IMAGE_SIZE_75
@ SEQ_USE_PROXY
@ SEQ_PROXY_SKIP_EXISTING
@ OPERATOR_CANCELLED
@ OPERATOR_FINISHED
void ED_area_tag_redraw(ScrArea *area)
Definition area.cc:693
#define C
Definition RandGen.cpp:29
#define ND_SEQUENCER
Definition WM_types.hh:437
#define NC_SCENE
Definition WM_types.hh:378
@ OPTYPE_REGISTER
Definition WM_types.hh:180
BPy_StructRNA * depsgraph
#define SELECT
#define G(x, y, z)
static wmOperatorStatus sequencer_rebuild_proxy_exec(bContext *C, wmOperator *)
bool sequencer_edit_poll(bContext *C)
void SEQUENCER_OT_enable_proxies(wmOperatorType *ot)
static wmOperatorStatus sequencer_enable_proxies_invoke(bContext *C, wmOperator *op, const wmEvent *)
static wmOperatorStatus sequencer_rebuild_proxy_invoke(bContext *C, wmOperator *op, const wmEvent *)
static wmOperatorStatus sequencer_enable_proxies_exec(bContext *C, wmOperator *op)
void SEQUENCER_OT_rebuild_proxy(wmOperatorType *ot)
static void seq_proxy_build_job(const bContext *C, ReportList *reports)
void proxy_rebuild(IndexBuildContext *context, wmJobWorkerStatus *worker_status)
Definition proxy.cc:516
Editing * editing_get(const Scene *scene)
Definition sequencer.cc:286
bool proxy_rebuild_context(Main *bmain, Depsgraph *depsgraph, Scene *scene, Strip *strip, blender::Set< std::string > *processed_paths, ListBase *queue, bool build_only_on_bad_performance)
Definition proxy.cc:431
void proxy_set(Strip *strip, bool value)
Definition proxy.cc:613
ProxyJob * ED_seq_proxy_job_get(const bContext *C, wmJob *wm_job)
Definition proxy_job.cc:70
void proxy_rebuild_finish(IndexBuildContext *context, bool stop)
Definition proxy.cc:598
ListBase * active_seqbase_get(const Editing *ed)
Definition sequencer.cc:433
void relations_free_imbuf(Scene *scene, ListBase *seqbase, bool for_render)
wmJob * ED_seq_proxy_wm_job_get(const bContext *C)
Definition proxy_job.cc:87
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)
Depsgraph * depsgraph
Definition SEQ_proxy.hh:48
struct ReportList * reports
struct PointerRNA * ptr
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
wmOperatorType * ot
Definition wm_files.cc:4237
bool WM_jobs_is_running(const wmJob *wm_job)
Definition wm_jobs.cc:341
void WM_jobs_start(wmWindowManager *wm, wmJob *wm_job)
Definition wm_jobs.cc:479
wmOperatorStatus 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, std::optional< std::string > message)