Blender V5.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
8
9#include "DNA_scene_types.h"
10
11#include "BLI_listbase.hh"
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
25#include "RNA_define.hh"
26
27#include "ED_screen.hh"
28
29#include "sequencer_intern.hh"
30
31namespace blender::ed::vse {
32
33/* -------------------------------------------------------------------- */
36
37static void seq_proxy_build_job(const bContext *C, ReportList *reports)
38{
40 Editing *ed = seq::editing_get(scene);
41 ScrArea *area = CTX_wm_area(C);
42
43 if (ed == nullptr) {
44 return;
45 }
46
49
50 Set<std::string> processed_paths;
51 bool selected = false; /* Check for no selected strips */
52
53 for (Strip &strip : *seq::active_seqbase_get(ed)) {
54 if (!ELEM(strip.type, STRIP_TYPE_MOVIE, STRIP_TYPE_IMAGE) || (strip.flag & SEQ_SELECT) == 0) {
55 continue;
56 }
57
58 selected = true;
59 if (!(strip.flag & SEQ_USE_PROXY)) {
60 BKE_reportf(reports, RPT_WARNING, "Proxy is not enabled for %s, skipping", strip.name);
61 continue;
62 }
63 if (strip.data->proxy->build_size_flags == 0) {
64 BKE_reportf(reports, RPT_WARNING, "Resolution is not selected for %s, skipping", strip.name);
65 continue;
66 }
67
68 bool success = seq::proxy_build_start(
69 pj->main, pj->scene, &strip, &processed_paths, false, pj->queue);
70
71 if (!success && (strip.data->proxy->build_flags & SEQ_PROXY_SKIP_EXISTING) != 0) {
72 BKE_reportf(reports, RPT_WARNING, "Overwrite is not checked for %s, skipping", strip.name);
73 }
74 }
75
76 if (!selected) {
77 BKE_reportf(reports, RPT_WARNING, "Select movie or image strips");
78 return;
79 }
80
81 if (!WM_jobs_is_running(wm_job)) {
82 G.is_break = false;
84 }
85
87}
88
90 wmOperator *op,
91 const wmEvent * /*event*/)
92{
94
95 return OPERATOR_FINISHED;
96}
97
99{
100 Main *bmain = CTX_data_main(C);
102 Editing *ed = seq::editing_get(scene);
103
104 if (ed == nullptr) {
105 return OPERATOR_CANCELLED;
106 }
107
108 Set<std::string> processed_paths;
109
110 for (Strip &strip : *seq::active_seqbase_get(ed)) {
111 if (strip.flag & SEQ_SELECT) {
113
114 seq::proxy_build_start(bmain, scene, &strip, &processed_paths, false, queue);
115
116 bool should_stop = false, has_updated = false;
117 for (seq::ProxyBuildContext *context : queue) {
118 seq::proxy_build_process(context, &should_stop, &has_updated, nullptr);
120 }
121 seq::relations_free_imbuf(scene, &ed->seqbase, false);
122 }
123 }
125
126 return OPERATOR_FINISHED;
127}
128
130{
131 /* Identifiers. */
132 ot->name = "Rebuild Proxy";
133 ot->idname = "SEQUENCER_OT_rebuild_proxy";
134 ot->description = "Rebuild all selected proxies";
135
136 /* API callbacks. */
140
141 /* Flags. */
142 ot->flag = OPTYPE_REGISTER;
143}
144
146
147/* -------------------------------------------------------------------- */
150
152 wmOperator *op,
153 const wmEvent * /*event*/)
154{
156 C, op, 200, IFACE_("Set Selected Strip Proxies"), IFACE_("Set"));
157}
158
160{
162 Editing *ed = seq::editing_get(scene);
163 bool proxy_25 = RNA_boolean_get(op->ptr, "proxy_25");
164 bool proxy_50 = RNA_boolean_get(op->ptr, "proxy_50");
165 bool proxy_75 = RNA_boolean_get(op->ptr, "proxy_75");
166 bool proxy_100 = RNA_boolean_get(op->ptr, "proxy_100");
167 bool overwrite = RNA_boolean_get(op->ptr, "overwrite");
168 bool turnon = true;
169
170 if (ed == nullptr || !(proxy_25 || proxy_50 || proxy_75 || proxy_100)) {
171 turnon = false;
172 }
173
174 for (Strip &strip : *seq::active_seqbase_get(ed)) {
175 if (strip.flag & SEQ_SELECT) {
176 if (ELEM(strip.type, STRIP_TYPE_MOVIE, STRIP_TYPE_IMAGE)) {
177 seq::proxy_set(&strip, turnon);
178 if (strip.data->proxy == nullptr) {
179 continue;
180 }
181
182 if (proxy_25) {
183 strip.data->proxy->build_size_flags |= SEQ_PROXY_IMAGE_SIZE_25;
184 }
185 else {
186 strip.data->proxy->build_size_flags &= ~SEQ_PROXY_IMAGE_SIZE_25;
187 }
188
189 if (proxy_50) {
190 strip.data->proxy->build_size_flags |= SEQ_PROXY_IMAGE_SIZE_50;
191 }
192 else {
193 strip.data->proxy->build_size_flags &= ~SEQ_PROXY_IMAGE_SIZE_50;
194 }
195
196 if (proxy_75) {
197 strip.data->proxy->build_size_flags |= SEQ_PROXY_IMAGE_SIZE_75;
198 }
199 else {
200 strip.data->proxy->build_size_flags &= ~SEQ_PROXY_IMAGE_SIZE_75;
201 }
202
203 if (proxy_100) {
204 strip.data->proxy->build_size_flags |= SEQ_PROXY_IMAGE_SIZE_100;
205 }
206 else {
207 strip.data->proxy->build_size_flags &= ~SEQ_PROXY_IMAGE_SIZE_100;
208 }
209
210 if (!overwrite) {
211 strip.data->proxy->build_flags |= SEQ_PROXY_SKIP_EXISTING;
212 }
213 else {
214 strip.data->proxy->build_flags &= ~SEQ_PROXY_SKIP_EXISTING;
215 }
216 }
217 }
218 }
219
221
222 return OPERATOR_FINISHED;
223}
224
226{
227 /* Identifiers. */
228 ot->name = "Set Selected Strip Proxies";
229 ot->idname = "SEQUENCER_OT_enable_proxies";
230 ot->description = "Enable selected proxies on all selected Movie and Image strips";
231
232 /* API callbacks. */
236
237 /* Flags. */
238 ot->flag = OPTYPE_REGISTER;
239
240 RNA_def_boolean(ot->srna, "proxy_25", false, "25%", "Build proxy at 25% resolution");
241 RNA_def_boolean(ot->srna, "proxy_50", false, "50%", "Build proxy at 50% resolution");
242 RNA_def_boolean(ot->srna, "proxy_75", false, "75%", "Build proxy at 75% resolution");
243 RNA_def_boolean(ot->srna, "proxy_100", false, "100%", "Build proxy at 100% resolution");
244 RNA_def_boolean(ot->srna, "overwrite", false, "Overwrite", "Overwrite existing proxy files");
245}
246
248
249} // namespace blender::ed::vse
#define IFACE_(msgid)
#define C
Definition RandGen.cpp:29
#define ND_SEQUENCER
Definition WM_types.hh:456
#define NC_SCENE
Definition WM_types.hh:391
#define ELEM(...)
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)
bool proxy_build_start(Main *bmain, Scene *scene, Strip *strip, Set< std::string > *processed_paths, bool build_only_on_bad_performance, Vector< ProxyBuildContext * > &r_queue)
Definition proxy.cc:455
ListBaseT< Strip > * active_seqbase_get(const Editing *ed)
Definition sequencer.cc:463
void relations_free_imbuf(Scene *scene, ListBaseT< Strip > *seqbase, bool for_render)
void proxy_build_finish(ProxyBuildContext *context)
Definition proxy.cc:763
void proxy_build_process(ProxyBuildContext *context, const bool *should_stop, bool *has_updated, const FunctionRef< void(float progress)> set_progress_fn)
Definition proxy.cc:743
Editing * editing_get(const Scene *scene)
Definition sequencer.cc:304
void proxy_set(Strip *strip, bool value)
Definition proxy.cc:771
ProxyJob * ED_seq_proxy_job_get(const bContext *C, wmJob *wm_job)
Definition proxy_job.cc:71
wmJob * ED_seq_proxy_wm_job_get(const bContext *C)
Definition proxy_job.cc:86
void cache_cleanup(Scene *scene, CacheCleanup mode)
ScrArea * CTX_wm_area(const bContext *C)
@ RPT_WARNING
Definition BKE_report.hh:40
Scene * CTX_data_sequencer_scene(const bContext *C)
void WM_jobs_start(wmWindowManager *wm, wmJob *wm_job)
Definition wm_jobs.cc:498
Global G
Definition blender.cc:57
wmWindowManager * CTX_wm_manager(const bContext *C)
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, const bool show_icon)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
Definition report.cc:191
Main * CTX_data_main(const bContext *C)
@ OPTYPE_REGISTER
Definition WM_types.hh:188
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
bool WM_jobs_is_running(const wmJob *wm_job)
Definition wm_jobs.cc:358
void ED_area_tag_redraw(ScrArea *area)
Definition area.cc:784
Vector< ProxyBuildContext * > queue
Definition SEQ_proxy.hh:63
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1125
const char * description
Definition WM_types.hh:1115
bool(*) poll(bContext *C) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1165
wmOperatorStatus(*) invoke(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1141
struct ReportList * reports