Blender V5.3
proxy.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
2 * SPDX-FileCopyrightText: 2003-2026 Blender Authors
3 * SPDX-FileCopyrightText: 2005-2006 Peter Schlaile <peter [at] schlaile [dot] de>
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later */
6
10
11#include <algorithm>
12#include <utility>
13
14#include "MEM_guardedalloc.h"
15
16#include "DNA_scene_types.h"
17#include "DNA_sequence_types.h"
18
19#include "BLI_fileops.hh"
20#include "BLI_math_base_c.hh"
21#include "BLI_path_utils.hh"
22#include "BLI_string.hh"
23
24#ifdef WIN32
25# include "BLI_winstuff.hh"
26#else
27# include <unistd.h>
28#endif
29
30#include "BKE_global.hh"
31#include "BKE_image.hh"
32#include "BKE_main.hh"
33#include "BKE_scene.hh"
34
35#include "WM_types.hh"
36
37#include "IMB_imbuf.hh"
38#include "IMB_imbuf_types.hh"
39
40#include "MOV_read.hh"
41
42#include "SEQ_proxy.hh"
43#include "SEQ_render.hh"
44#include "SEQ_sequencer.hh"
45#include "SEQ_time.hh"
46
48#include "multiview.hh"
49#include "proxy.hh"
50#include "render.hh"
51#include "sequencer.hh"
52#include "utils.hh"
53
54namespace blender::seq {
55
57 MovieProxyBuilder *movie_proxy_builder = nullptr;
59
60 int size_flags = 0;
61 int quality = 0;
62 bool overwrite = false;
63 int view_id = 0;
64
65 Scene *scene = nullptr;
66 Strip *strip = nullptr;
67};
68
69static MovieReader *movie_reader_open(Strip &strip, const char *filepath, const bool open_file)
70{
71 /* Sequencer performs colorspace conversion, so keep the decoded input unchanged. */
72 const ImBufFlags flags = (strip.flag & SEQ_DEINTERLACE) ? ImBufFlags::Deinterlace :
74 if (open_file) {
75 return openanim(filepath, flags, strip.streamindex, true, &strip.data->colorspace_settings);
76 }
77 return openanim_noload(
78 filepath, flags, strip.streamindex, true, &strip.data->colorspace_settings);
79}
80
81static void movie_reader_proxy_dir_set(const Editing &ed, const Strip &strip, MovieReader *reader)
82{
83 if (reader == nullptr) {
84 return;
85 }
86
87 char proxy_dirpath[FILE_MAX];
88 if (seq_proxy_get_custom_dir(ed, strip, proxy_dirpath)) {
89 seq_proxy_index_dir_set(reader, proxy_dirpath);
90 }
91}
92
94static Vector<MovieReaderPtr> movie_readers_open(Scene &scene, Strip &strip, const bool open_file)
95{
97 Editing &ed = *scene.ed;
98 char filepath[FILE_MAX];
99 BLI_path_join(filepath, sizeof(filepath), strip.data->dirpath, strip.data->stripdata->filename);
100 BLI_path_abs(filepath, ID_BLEND_PATH_FROM_GLOBAL(&scene.id));
101
102 const bool use_multiview = (strip.flag & SEQ_USE_VIEWS) != 0 &&
103 (scene.r.scemode & R_MULTIVIEW) != 0;
104 if (use_multiview && strip.views_format == R_IMF_VIEWS_INDIVIDUAL) {
105 const int files_num = seq_multiview_num_files_get(&scene, strip.views_format);
106 for (int view_id = 0; view_id < files_num; view_id++) {
107 char filepath_view[FILE_MAX];
108 const char *suffix = nullptr;
110 scene, filepath, view_id, filepath_view, sizeof(filepath_view), &suffix))
111 {
112 readers.clear();
113 break;
114 }
115
116 /* Multiview files must be loaded, otherwise it is not possible to detect failure. */
117 MovieReaderPtr reader(movie_reader_open(strip, filepath_view, true));
118 if (reader == nullptr) {
119 readers.clear();
120 break;
121 }
122
123 movie_reader_proxy_dir_set(ed, strip, reader.get());
124 MOV_set_multiview_suffix(reader.get(), suffix);
125 readers.append(std::move(reader));
126 }
127 }
128
129 if (readers.is_empty()) {
130 MovieReaderPtr reader(movie_reader_open(strip, filepath, open_file));
131 movie_reader_proxy_dir_set(ed, strip, reader.get());
132 readers.append(std::move(reader));
133 }
134 return readers;
135}
136
138{
139 switch (render_size) {
141 return IMB_PROXY_25;
143 return IMB_PROXY_50;
145 return IMB_PROXY_75;
147 return IMB_PROXY_100;
148 default:
149 return IMB_PROXY_NONE;
150 }
151}
152
154{
155 switch (render_size) {
157 return 0.25f;
159 return 0.5f;
161 return 0.75f;
162 default:
163 return 1.0f;
164 }
165}
166
167bool seq_proxy_get_custom_file_filepath(const Strip *strip, char *filepath, const int view_id)
168{
169 /* Ideally this would be #PROXY_MAXFILE however BLI_path_abs clamps to #FILE_MAX. */
170 char filepath_temp[FILE_MAX];
171 char suffix[24];
172 StripProxy *proxy = strip->data->proxy;
173
174 if (proxy == nullptr) {
175 return false;
176 }
177
178 BLI_path_join(filepath_temp, sizeof(filepath_temp), proxy->dirpath, proxy->filename);
180
181 if (view_id > 0) {
182 SNPRINTF(suffix, "_%d", view_id);
183 /* This will actually append suffix after extension
184 * which is weird but how was originally coded in multi-view branch. */
185 BLI_snprintf(filepath, PROXY_MAXFILE, "%s_%s", filepath_temp, suffix);
186 }
187 else {
188 BLI_strncpy(filepath, filepath_temp, PROXY_MAXFILE);
189 }
190
191 return true;
192}
193
194bool seq_proxy_get_custom_dir(const Editing &ed, const Strip &strip, char r_dirpath[FILE_MAX])
195{
196 const StripProxy *proxy = strip.data->proxy;
197 if (proxy == nullptr || ((proxy->storage & SEQ_STORAGE_PROXY_CUSTOM_DIR) == 0 &&
198 ed.proxy_storage != SEQ_EDIT_PROXY_DIR_STORAGE))
199 {
200 return false;
201 }
202
203 if (ed.proxy_storage == SEQ_EDIT_PROXY_DIR_STORAGE) {
204 BLI_strncpy(r_dirpath, ed.proxy_dir[0] ? ed.proxy_dir : "//BL_proxy", FILE_MAX);
205 }
206 else {
207 BLI_strncpy(r_dirpath, proxy->dirpath, FILE_MAX);
208 }
210 return true;
211}
212
213static bool seq_proxy_get_filepath_for_elem(const Scene *scene,
214 const Strip &strip,
215 const StripElem &strip_elem,
216 eSpaceSeq_Proxy_RenderSize render_size,
217 char *filepath,
218 const int view_id)
219{
220 char dirpath[PROXY_MAXFILE];
221 char suffix[24] = {'\0'};
222 Editing *ed = editing_get(scene);
223 StripProxy *proxy = strip.data->proxy;
224
225 if (proxy == nullptr) {
226 return false;
227 }
228
229 /* Multi-view suffix. */
230 if (view_id > 0) {
231 SNPRINTF(suffix, "_%d", view_id);
232 }
233
234 /* Per strip with Custom file situation is handled separately. */
236 ed->proxy_storage != SEQ_EDIT_PROXY_DIR_STORAGE)
237 {
238 if (seq_proxy_get_custom_file_filepath(&strip, filepath, view_id)) {
239 return true;
240 }
241 }
242
243 if (!seq_proxy_get_custom_dir(*ed, strip, dirpath)) {
244 /* Per strip default. */
245 SNPRINTF(dirpath, "%s" SEP_STR "BL_proxy", strip.data->dirpath);
246 }
247
248 /* Proxy size number to be used in path. */
249 int proxy_size_number = rendersize_to_scale_factor(render_size) * 100;
250
251 BLI_snprintf(filepath,
253 "%s" SEP_STR "images" SEP_STR "%d" SEP_STR "%s_proxy%s.jpg",
254 dirpath,
255 proxy_size_number,
256 strip_elem.filename,
257 suffix);
259 return true;
260}
261
262static bool seq_proxy_get_filepath(Scene *scene,
263 Strip *strip,
264 int timeline_frame,
265 eSpaceSeq_Proxy_RenderSize render_size,
266 char *filepath,
267 const int view_id)
268{
269 if (strip->data->proxy == nullptr) {
270 return false;
271 }
273 *strip,
274 *render_give_stripelem(scene, strip, timeline_frame),
275 render_size,
276 filepath,
277 view_id);
278}
279
280bool can_use_proxy(const RenderData *context, const Strip *strip, IMB_Proxy_Size psize)
281{
282 if (strip->data->proxy == nullptr || !context->use_proxies) {
283 return false;
284 }
285
286 short size_flags = strip->data->proxy->build_size_flags;
287 return (strip->flag & SEQ_USE_PROXY) != 0 && psize != IMB_PROXY_NONE &&
288 (size_flags & psize) != 0;
289}
290
291ImBuf *seq_proxy_fetch(const RenderData *context, Strip *strip, int timeline_frame)
292{
293 char filepath[PROXY_MAXFILE];
294 StripProxy *proxy = strip->data->proxy;
296 context->preview_render_size);
297
298 /* only use proxies, if they are enabled (even if present!) */
299 if (!can_use_proxy(context, strip, rendersize_to_proxysize(psize))) {
300 return nullptr;
301 }
302
304 int frameno = round_fl_to_int(give_frame_index(context->scene, strip, timeline_frame)) +
305 strip->anim_startofs;
306 if (proxy->anim == nullptr) {
308 context->scene, strip, timeline_frame, psize, filepath, context->view_id) == 0)
309 {
310 return nullptr;
311 }
312
313 /* Sequencer takes care of colorspace conversion of the result. The input is the best to be
314 * kept unchanged for the performance reasons. */
315 proxy->anim = openanim(
316 filepath, ImBufFlags::Zero, 0, true, &strip->data->colorspace_settings);
317 }
318 if (proxy->anim == nullptr) {
319 return nullptr;
320 }
321
322 return MOV_decode_frame(proxy->anim, frameno, IMB_PROXY_NONE);
323 }
324
326 context->scene, strip, timeline_frame, psize, filepath, context->view_id) == 0)
327 {
328 return nullptr;
329 }
330
331 if (BLI_exists(filepath)) {
332 /* Proxies are already be in the sequencer colorspace for fast loading, don't perform
333 * conversion of float to scene linear that would usually be done. */
334 ColorManagedColorspaceSettings colorspace_settings =
335 context->scene->sequencer_colorspace_settings;
336 return IMB_load_image_from_filepath(filepath,
339 &colorspace_settings);
340 }
341
342 return nullptr;
343}
344
352
364 Scene *scene,
365 const int view_id,
366 MultiViewPrefixVars *prefix_vars)
367{
368 if ((scene->r.scemode & R_MULTIVIEW) == 0) {
369 return false;
370 }
371
372 if ((strip->type == STRIP_TYPE_IMAGE) && (strip->views_format == R_IMF_VIEWS_INDIVIDUAL)) {
373 if (view_id == 0) {
374 /* Clear on first use. */
375 prefix_vars->prefix[0] = '\0';
376 prefix_vars->ext[0] = '\0';
377
378 char filepath[FILE_MAX];
380 filepath, sizeof(filepath), strip->data->dirpath, strip->data->stripdata->filename);
381 BLI_path_abs(filepath, ID_BLEND_PATH_FROM_GLOBAL(&scene->id));
382 const char *ext_ptr = nullptr;
383 BKE_scene_multiview_view_prefix_get(scene, filepath, prefix_vars->prefix, &ext_ptr);
384 if (ext_ptr != nullptr) {
385 STRNCPY(prefix_vars->ext, ext_ptr);
386 }
387 }
388
389 if (prefix_vars->prefix[0] == '\0') {
390 return view_id != 0;
391 }
392
393 char filepath[FILE_MAX];
394 seq_multiview_name(scene, view_id, prefix_vars->prefix, prefix_vars->ext, filepath, FILE_MAX);
395 if (BLI_access(filepath, R_OK) == 0) {
396 return false;
397 }
398
399 return view_id != 0;
400 }
401 return false;
402}
403
407static int seq_proxy_context_count(Strip *strip, Scene *scene)
408{
409 int num_views = 1;
410
411 if ((scene->r.scemode & R_MULTIVIEW) == 0) {
412 return 1;
413 }
414
415 switch (strip->type) {
416 case STRIP_TYPE_MOVIE: {
417 const bool use_multiview = (strip->flag & SEQ_USE_VIEWS) != 0;
418 num_views = use_multiview ? seq_multiview_num_files_get(scene, strip->views_format) : 1;
419 break;
420 }
421 case STRIP_TYPE_IMAGE: {
422 switch (strip->views_format) {
424 num_views = BKE_scene_multiview_num_views_get(&scene->r);
425 break;
427 num_views = 2;
428 break;
430 /* not supported at the moment */
431 /* pass through */
432 default:
433 num_views = 1;
434 }
435 break;
436 }
437 default:
438 break;
439 }
440
441 return num_views;
442}
443
444static bool seq_proxy_need_rebuild(Strip *strip, MovieReader *anim)
445{
446 if ((strip->data->proxy->build_flags & SEQ_PROXY_SKIP_EXISTING) == 0) {
447 return true;
448 }
449
450 IMB_Proxy_Size required_proxies = IMB_Proxy_Size(strip->data->proxy->build_size_flags);
451 int built_proxies = MOV_get_existing_proxies(anim);
452 return (required_proxies & built_proxies) != required_proxies;
453}
454
456 Scene *scene,
457 Strip *strip,
458 Set<std::string> *processed_paths,
459 bool build_only_on_bad_performance,
461{
462 if (!strip->data || !strip->data->proxy) {
463 return true;
464 }
465
466 if (!(strip->flag & SEQ_USE_PROXY)) {
467 return true;
468 }
469
470 int num_files = seq_proxy_context_count(strip, scene);
471 Vector<MovieReaderPtr> probe_readers;
472 Vector<MovieReaderPtr> build_readers;
473 bool build_readers_opened = false;
474 if (strip->type == STRIP_TYPE_MOVIE) {
475 probe_readers = movie_readers_open(*scene, *strip, false);
476 num_files = std::min(num_files, int(probe_readers.size()));
477 }
478
479 MultiViewPrefixVars prefix_vars; /* Initialized by #seq_proxy_multiview_context_invalid. */
480 for (int i = 0; i < num_files; i++) {
481 if (seq_proxy_multiview_context_invalid(strip, scene, i, &prefix_vars)) {
482 continue;
483 }
484
485 /* Check if proxies are already built here, because fully opening readers takes a lot of time.
486 */
487 MovieReader *anim = probe_readers.index_range().contains(i) ? probe_readers[i].get() : nullptr;
488 if (anim && !seq_proxy_need_rebuild(strip, anim)) {
489 continue;
490 }
491
492 ProxyBuildContext *context = MEM_new<ProxyBuildContext>("strip proxy rebuild context");
493
494 Strip *strip_new = strip_duplicate_recursive(
495 bmain, scene, scene, nullptr, strip, StripDuplicate::Selected);
496
497 context->size_flags = strip_new->data->proxy->build_size_flags;
498 context->quality = strip_new->data->proxy->quality;
499 context->overwrite = (strip_new->data->proxy->build_flags & SEQ_PROXY_SKIP_EXISTING) == 0;
500
501 context->scene = scene;
502 context->strip = strip_new;
503
504 context->view_id = i; /* only for images */
505
506 if (strip_new->type == STRIP_TYPE_MOVIE) {
507 if (!build_readers_opened) {
508 build_readers = movie_readers_open(*scene, *strip_new, true);
509 build_readers_opened = true;
510 }
511 if (build_readers.index_range().contains(i)) {
512 context->movie_reader = std::move(build_readers[i]);
513 }
514 anim = context->movie_reader.get();
515 if (anim) {
516 context->movie_proxy_builder = MOV_proxy_builder_start(anim,
517 context->size_flags,
518 context->quality,
519 context->overwrite,
520 processed_paths,
521 build_only_on_bad_performance);
522 }
523 if (!context->movie_proxy_builder) {
524 seq_free_strip_recurse(nullptr, context->strip, true);
525 MEM_delete(context);
526 return false;
527 }
528 }
529
530 r_queue.append(context);
531 }
532
533 return true;
534}
535
536static void seq_proxy_build_frame(const Scene *scene,
537 const int view_id,
538 ImBuf *ibuf_full,
539 const Strip &strip,
540 const StripElem &strip_elem,
541 int proxy_render_size,
542 const bool overwrite)
543{
544 char filepath[PROXY_MAXFILE];
545
547 strip,
548 strip_elem,
549 eSpaceSeq_Proxy_RenderSize(proxy_render_size),
550 filepath,
551 view_id))
552 {
553 return;
554 }
555
556 if (!overwrite && BLI_exists(filepath)) {
557 return;
558 }
559
560 const int rectx = (proxy_render_size * ibuf_full->x) / 100;
561 const int recty = (proxy_render_size * ibuf_full->y) / 100;
562
563 ImBuf *ibuf = ibuf_full;
564 if (ibuf_full->x != rectx || ibuf_full->y != recty) {
565 ibuf = IMB_scale_into_new(ibuf_full, rectx, recty, IMBScaleFilter::Nearest, true);
566 }
567
568 const int quality = strip.data->proxy->quality;
569 const bool save_float = ibuf->float_data() != nullptr;
570 ibuf->foptions.quality = quality;
571 if (save_float) {
572 /* Float image: save as EXR with FP16 data and DWAA compression. */
573 ibuf->ftype = IMB_FTYPE_OPENEXR;
575 }
576 else {
577 /* Byte image: save as JPG. */
578 ibuf->ftype = IMB_FTYPE_JPG;
579 if (ibuf->can_contain_alpha()) {
580 ibuf->color_mode = ImColorMode::RGB; /* JPGs do not support alpha. */
581 }
582 }
584
585 const bool ok = IMB_save_image(
586 ibuf, filepath, save_float ? ImBufFlags::FloatData : ImBufFlags::ByteData);
587 if (ok == false) {
588 perror(filepath);
589 }
590
591 if (ibuf != ibuf_full) {
592 IMB_freeImBuf(ibuf);
593 }
594}
595
597 const Strip &strip,
598 const char *filepath,
599 const char *prefix,
600 int view_id)
601{
602 ImBuf *ibuf = nullptr;
603
605 if (strip.alpha_mode == SEQ_ALPHA_PREMUL) {
607 }
608
609 if (prefix[0] == '\0') {
610 ibuf = IMB_load_image_from_filepath(filepath, flag, &strip.data->colorspace_settings);
611 }
612 else {
613 char filepath_view[FILE_MAX];
615 *context.scene, filepath, view_id, filepath_view, sizeof(filepath_view), nullptr))
616 {
617 return nullptr;
618 }
619 ibuf = IMB_load_image_from_filepath(filepath_view, flag, &strip.data->colorspace_settings);
620 }
621 if (ibuf == nullptr) {
622 return nullptr;
623 }
624
626 if (ibuf->float_data() != nullptr && ibuf->byte_data() != nullptr) {
627 IMB_free_byte_pixels(ibuf); /* If both float & byte exist, free byte buffer. */
628 }
629 ensure_ibuf_is_sequencer_space(context.scene, ibuf, false);
630 return ibuf;
631}
632
634 const bool *job_stop,
635 bool *job_update_ui,
636 const FunctionRef<void(float progress)> set_progress_fn)
637{
638 if (!context.strip || !context.strip->data) {
639 return;
640 }
641 const Strip &strip = *context.strip;
642 if (!(strip.flag & SEQ_USE_PROXY)) {
643 return;
644 }
645
646 /* If proxy is set to user-specified custom file, no need to rebuild anything. */
647 /* that's why it is called custom... */
648 if (strip.data->proxy && (strip.data->proxy->storage & SEQ_STORAGE_PROXY_CUSTOM_FILE)) {
649 return;
650 }
651
652 const char *base_path = ID_BLEND_PATH_FROM_GLOBAL(&context.scene->id);
653 const int tot_views = BKE_scene_multiview_num_views_get(&context.scene->r);
654
655 for (int elem_index = 0; elem_index < strip.content_length(); elem_index++) {
656 const StripElem &s_elem = strip.data->stripdata[elem_index];
657
658 char filepath[FILE_MAX];
659 char prefix[FILE_MAX];
660
661 ImBuf *ibuf = nullptr;
662
663 BLI_path_join(filepath, sizeof(filepath), strip.data->dirpath, s_elem.filename);
664 BLI_path_abs(filepath, base_path);
665
666 const bool do_multiview_render = seq_strip_do_multiview_render(
667 context.scene, &strip, filepath, prefix);
668
669 if (do_multiview_render) {
670 const int totfiles = seq_multiview_num_files_get(context.scene, strip.views_format);
671 Array<ImBuf *> ibufs_arr(tot_views, nullptr);
672
673 for (int view_id = 0; view_id < totfiles; view_id++) {
674 ibufs_arr[view_id] = render_image_strip_frame(context, strip, filepath, prefix, view_id);
675 }
676
677 if (ibufs_arr[0] != nullptr) {
678 if (strip.views_format == R_IMF_VIEWS_STEREO_3D) {
679 IMB_ImBufFromStereo3d(strip.stereo3d_format,
680 ibufs_arr[0],
681 &ibufs_arr[0], // NOLINT(readability-container-data-pointer)
682 &ibufs_arr[1]);
683 }
684
685 /* Return the requested image; release the others. */
686 ibuf = ibufs_arr[context.view_id];
687 for (ImBuf *ib : ibufs_arr) {
688 if (ib != ibuf) {
689 IMB_freeImBuf(ib);
690 }
691 }
692 }
693 }
694 else {
695 ibuf = render_image_strip_frame(context, strip, filepath, prefix, context.view_id);
696 }
697
698 if (ibuf != nullptr) {
699 if (context.size_flags & IMB_PROXY_25) {
701 context.scene, context.view_id, ibuf, strip, s_elem, 25, context.overwrite);
702 }
703 if (context.size_flags & IMB_PROXY_50) {
705 context.scene, context.view_id, ibuf, strip, s_elem, 50, context.overwrite);
706 }
707 if (context.size_flags & IMB_PROXY_75) {
709 context.scene, context.view_id, ibuf, strip, s_elem, 75, context.overwrite);
710 }
711 if (context.size_flags & IMB_PROXY_100) {
713 context.scene, context.view_id, ibuf, strip, s_elem, 100, context.overwrite);
714 }
715
716 if (set_progress_fn) {
717 float progress = float(elem_index) / float(strip.content_length());
718 set_progress_fn(progress);
719 }
720
721 *job_update_ui = true;
722
723 IMB_freeImBuf(ibuf);
724 }
725
726 if (*job_stop || G.is_break) {
727 break;
728 }
729 }
730}
731
732static void close_movie_proxy_builder(ProxyBuildContext *context, bool stop)
733{
734 if (context->movie_proxy_builder == nullptr) {
735 return;
736 }
737 MOV_close_proxies(context->movie_reader.get());
738 MOV_proxy_builder_finish(context->movie_proxy_builder, stop);
739 context->movie_proxy_builder = nullptr;
740 context->movie_reader.reset();
741}
742
744 const bool *should_stop,
745 bool *has_updated,
746 const FunctionRef<void(float progress)> set_progress_fn)
747{
748 if (context->strip->type == STRIP_TYPE_MOVIE) {
749 if (context->movie_proxy_builder) {
751 context->movie_proxy_builder, should_stop, has_updated, set_progress_fn);
752 close_movie_proxy_builder(context, *should_stop);
753 }
754 return;
755 }
756
757 if (context->strip->type == STRIP_TYPE_IMAGE) {
758 image_proxy_builder_process(*context, should_stop, has_updated, set_progress_fn);
759 return;
760 }
761}
762
764{
765 close_movie_proxy_builder(context, false);
766 seq_free_strip_recurse(nullptr, context->strip, true);
767
768 MEM_delete(context);
769}
770
771void proxy_set(Strip *strip, bool value)
772{
773 if (value) {
774 strip->flag |= SEQ_USE_PROXY;
775 if (strip->data->proxy == nullptr) {
776 strip->data->proxy = seq_strip_proxy_alloc();
777 }
778 }
779 else {
780 strip->flag &= ~SEQ_USE_PROXY;
781 }
782}
783
784void seq_proxy_index_dir_set(MovieReader *anim, const char *base_dir)
785{
786 char dirname[FILE_MAX];
788
790 BLI_path_join(dirname, sizeof(dirname), base_dir, filename);
792}
793
795{
796 if (strip->data && strip->data->proxy && strip->data->proxy->anim) {
797 MOV_close(strip->data->proxy->anim);
798 strip->data->proxy->anim = nullptr;
799 }
800}
801
802} // namespace blender::seq
File and directory operations.
#define FILE_MAXFILE
#define FILE_MAX
#define BLI_path_join(...)
#define SNPRINTF(dst, format,...)
Compatibility-like things for windows.
const char * dirname(char *path)
#define ID_BLEND_PATH_FROM_GLOBAL(_id)
Definition DNA_ID.h:691
Read Blender memory allocation and freeing.
constexpr bool contains(int64_t value) const
int64_t size() const
void append(const T &value)
bool is_empty() const
IndexRange index_range() const
const T & data(const Action &owning_action) const
#define OPENEXR_HALF
std::string filename(const std::string_view &str, size_t pos)
void ensure_ibuf_is_sequencer_space(const Scene *scene, ImBuf *ibuf, bool make_float)
Definition render.cc:170
bool seq_strip_do_multiview_render(const Scene *scene, const Strip *strip, const char *filepath, char *r_prefix)
Definition render.cc:959
void ensure_ibuf_is_rgba(ImBuf *ibuf)
Definition render.cc:903
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
static void image_proxy_builder_process(ProxyBuildContext &context, const bool *job_stop, bool *job_update_ui, const FunctionRef< void(float progress)> set_progress_fn)
Definition proxy.cc:633
void seq_multiview_name(const Scene *scene, const int view_id, const char *prefix, const char *ext, char *r_path, size_t r_path_maxncpy)
Definition multiview.cc:43
bool seq_proxy_get_custom_file_filepath(const Strip *strip, char *filepath, const int view_id)
Definition proxy.cc:167
IMB_Proxy_Size rendersize_to_proxysize(eSpaceSeq_Proxy_RenderSize render_size)
Definition proxy.cc:137
float give_frame_index(const Scene *scene, const Strip *strip, float timeline_frame)
Definition strip_time.cc:43
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
static int seq_proxy_context_count(Strip *strip, Scene *scene)
Definition proxy.cc:407
Editing * editing_get(const Scene *scene)
Definition sequencer.cc:304
StripProxy * seq_strip_proxy_alloc()
Definition sequencer.cc:85
static bool seq_proxy_get_filepath_for_elem(const Scene *scene, const Strip &strip, const StripElem &strip_elem, eSpaceSeq_Proxy_RenderSize render_size, char *filepath, const int view_id)
Definition proxy.cc:213
ImBuf * seq_proxy_fetch(const RenderData *context, Strip *strip, int timeline_frame)
Definition proxy.cc:291
static void close_movie_proxy_builder(ProxyBuildContext *context, bool stop)
Definition proxy.cc:732
void seq_free_strip_recurse(Scene *scene, Strip *strip, const bool do_id_user)
Definition sequencer.cc:270
static void seq_proxy_build_frame(const Scene *scene, const int view_id, ImBuf *ibuf_full, const Strip &strip, const StripElem &strip_elem, int proxy_render_size, const bool overwrite)
Definition proxy.cc:536
std::unique_ptr< MovieReader, MovieReaderDeleter > MovieReaderPtr
void proxy_set(Strip *strip, bool value)
Definition proxy.cc:771
int seq_multiview_num_files_get(const Scene *scene, eImageFormat_ViewsFormat views_format)
Definition multiview.cc:29
void seq_proxy_index_dir_set(MovieReader *anim, const char *base_dir)
Definition proxy.cc:784
static bool seq_proxy_multiview_context_invalid(Strip *strip, Scene *scene, const int view_id, MultiViewPrefixVars *prefix_vars)
Definition proxy.cc:363
static bool seq_proxy_get_filepath(Scene *scene, Strip *strip, int timeline_frame, eSpaceSeq_Proxy_RenderSize render_size, char *filepath, const int view_id)
Definition proxy.cc:262
static void movie_reader_proxy_dir_set(const Editing &ed, const Strip &strip, MovieReader *reader)
Definition proxy.cc:81
bool seq_multiview_view_filepath_get(const Scene &scene, const char *filepath, const int view_id, char *r_filepath, const size_t r_filepath_maxncpy, const char **r_suffix)
Definition multiview.cc:55
static Vector< MovieReaderPtr > movie_readers_open(Scene &scene, Strip &strip, const bool open_file)
Definition proxy.cc:94
void free_strip_proxy(Strip *strip)
Definition proxy.cc:794
Strip * strip_duplicate_recursive(Main *bmain, const Scene *scene_src, Scene *scene_dst, ListBaseT< Strip > *seqbase_dst, Strip *strip, const StripDuplicate dupe_flag)
Definition sequencer.cc:822
bool seq_proxy_get_custom_dir(const Editing &ed, const Strip &strip, char r_dirpath[FILE_MAX])
Definition proxy.cc:194
static bool seq_proxy_need_rebuild(Strip *strip, MovieReader *anim)
Definition proxy.cc:444
float rendersize_to_scale_factor(eSpaceSeq_Proxy_RenderSize render_size)
Definition proxy.cc:153
static MovieReader * movie_reader_open(Strip &strip, const char *filepath, const bool open_file)
Definition proxy.cc:69
static ImBuf * render_image_strip_frame(const ProxyBuildContext &context, const Strip &strip, const char *filepath, const char *prefix, int view_id)
Definition proxy.cc:596
bool can_use_proxy(const RenderData *context, const Strip *strip, IMB_Proxy_Size psize)
Definition proxy.cc:280
StripElem * render_give_stripelem(const Scene *scene, const Strip *strip, int timeline_frame)
Definition render.cc:220
@ SEQ_RENDER_SIZE_PROXY_75
@ SEQ_RENDER_SIZE_PROXY_50
@ SEQ_RENDER_SIZE_PROXY_100
@ SEQ_RENDER_SIZE_PROXY_25
size_t BLI_snprintf(char *__restrict dst, size_t dst_maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
char * STRNCPY(char(&dst)[N], const char *src)
void IMB_free_byte_pixels(ImBuf *ibuf)
MovieProxyBuilder * MOV_proxy_builder_start(MovieReader *anim, int proxy_sizes_in_use, int quality, const bool overwrite, Set< std::string > *processed_paths, bool build_only_on_bad_performance)
bool BLI_path_abs(char path[FILE_MAX], const char *basepath) ATTR_NONNULL(1
MINLINE int round_fl_to_int(float a)
void MOV_close(MovieReader *anim)
Definition movie_read.cc:70
bool BLI_exists(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition storage.cc:404
@ SEQ_STORAGE_PROXY_CUSTOM_DIR
@ SEQ_STORAGE_PROXY_CUSTOM_FILE
ImBuf * MOV_decode_frame(MovieReader *anim, int frame_index, IMB_Proxy_Size preview_size)
const char * BKE_main_blendfile_path_from_global()
Definition main.cc:1063
void MOV_set_multiview_suffix(MovieReader *anim, const char *suffix)
int BKE_scene_multiview_num_views_get(const RenderData *rd)
Definition scene.cc:3193
void MOV_proxy_builder_finish(MovieProxyBuilder *context, const bool stop)
Global G
Definition blender.cc:57
bool IMB_save_image(ImBuf *ibuf, const char *filepath, ImBufFlags flags)
Definition writeimage.cc:40
ImBuf * IMB_load_image_from_filepath(const char *filepath, ImBufFlags flags, ColorManagedColorspaceSettings *colorspace_settings=nullptr)
Definition readimage.cc:201
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
void IMB_freeImBuf(ImBuf *ibuf)
int BLI_access(const char *filepath, int mode) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
MovieReader * openanim(const char *filepath, ImBufFlags ibuf_flags, int streamindex, bool keep_original_colorspace, ColorManagedColorspaceSettings *colorspace_settings)
void IMB_ImBufFromStereo3d(const Stereo3dFormat *s3d, ImBuf *ibuf_stereo3d, ImBuf **r_ibuf_left, ImBuf **r_ibuf_right)
@ R_IMF_VIEWS_MULTIVIEW
@ R_IMF_VIEWS_INDIVIDUAL
@ R_IMF_VIEWS_STEREO_3D
int MOV_get_existing_proxies(const MovieReader *anim)
void MOV_set_custom_proxy_dir(MovieReader *anim, const char *dir)
ImBuf * IMB_scale_into_new(const ImBuf *ibuf, int2 new_size, IMBScaleFilter filter, bool threaded=true)
Definition scaling.cc:531
void MOV_close_proxies(MovieReader *anim)
void BKE_scene_multiview_view_prefix_get(const Scene *scene, const char *filepath, char *r_prefix, const char **r_ext)
Definition scene.cc:3417
bool BLI_file_ensure_parent_dir_exists(const char *filepath) ATTR_NONNULL(1)
Definition fileops_c.cc:454
void MOV_get_filename(const MovieReader *anim, char *filename, int filename_maxncpy)
Definition movie_read.cc:85
MovieReader * openanim_noload(const char *filepath, ImBufFlags flags, int streamindex, bool keep_original_colorspace, ColorManagedColorspaceSettings *colorspace_settings)
void MOV_proxy_builder_process(MovieProxyBuilder *context, const bool *stop, bool *do_update, const FunctionRef< void(float progress)> set_progress_fn)
#define PROXY_MAXFILE
Definition proxy.hh:22
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
ImbFormatOptions foptions
const uint8_t * byte_data() const
const float * float_data() const
ImColorMode color_mode
eImbFileType ftype
bool can_contain_alpha() const
struct Editing * ed
struct RenderData r
eStripProxyStorageFlag storage
struct MovieReader * anim
MovieReaderPtr movie_reader
Definition proxy.cc:58
MovieProxyBuilder * movie_proxy_builder
Definition proxy.cc:57
#define SEP_STR
Definition unit.cc:41