Blender V5.3
render.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 "MEM_guardedalloc.h"
12
13#include "DNA_mask_types.h"
14#include "DNA_scene_types.h"
15#include "DNA_sequence_types.h"
16#include "DNA_space_types.h"
17#include "DNA_world_types.h"
18
19#include "BLI_listbase.hh"
20#include "BLI_math_geom_c.hh"
21#include "BLI_math_matrix.hh"
22#include "BLI_math_vector.hh"
23#include "BLI_path_utils.hh"
24#include "BLI_rect.hh"
25#include "BLI_task.hh"
26
27#include "BKE_anim_data.hh"
28#include "BKE_animsys.hh"
29#include "BKE_compositor.hh"
30#include "BKE_global.hh"
31#include "BKE_image.hh"
32#include "BKE_layer.hh"
33#include "BKE_lib_id.hh"
34#include "BKE_main.hh"
35#include "BKE_mask.hh"
36#include "BKE_movieclip.hh"
37#include "BKE_scene.hh"
38#include "BKE_scene_runtime.hh"
39
40#include "DEG_depsgraph.hh"
44
45#include "DRW_engine.hh"
46
47#include "GPU_context.hh"
48
50#include "IMB_imbuf.hh"
51#include "IMB_imbuf_types.hh"
52#include "IMB_metadata.hh"
53
54#include "PRF_profile.hh"
55
56#include "MOV_read.hh"
57
58#include "RE_engine.h"
59#include "RE_pipeline.h"
60
61#include "SEQ_channels.hh"
62#include "SEQ_effects.hh"
63#include "SEQ_iterator.hh"
64#include "SEQ_offscreen.hh"
65#include "SEQ_proxy.hh"
66#include "SEQ_relations.hh"
67#include "SEQ_render.hh"
68#include "SEQ_sequencer.hh"
70#include "SEQ_time.hh"
71#include "SEQ_transform.hh"
72#include "SEQ_utils.hh"
73
74#include "WM_api.hh"
75
80#include "effects/effects.hh"
81#include "intern/movie_read.hh"
82#include "modifiers/modifier.hh"
83#include "multiview.hh"
84#include "prefetch.hh"
85#include "proxy.hh"
86#include "render.hh"
87#include "utils.hh"
88
89#include <algorithm>
90#include <utility>
91
92namespace blender::seq {
93
94static SeqResult seq_render_strip_stack(const RenderData *context,
96 ListBaseT<SeqTimelineChannel> *channels,
97 ListBaseT<Strip> *seqbasep,
98 float timeline_frame,
99 int chanshown);
100
102DrawViewFn view3d_fn = nullptr; /* nullptr in background mode */
103
104/* -------------------------------------------------------------------- */
107
109{
110 const char *name = scene->sequencer_colorspace_settings.name;
111 if (ibuf->float_data() != nullptr) {
113 }
114 if (ibuf->byte_data() != nullptr) {
116 }
117}
118
119static void ensure_ibuf_is_color_space(ImBuf *ibuf, bool make_float, const char *to_colorspace)
120{
121 BLI_assert(ibuf != nullptr);
122 /* No pixels: nothing to do. */
123 if (ibuf->float_data() == nullptr && ibuf->byte_data() == nullptr) {
124 return;
125 }
126
127 if (ibuf->float_data() == nullptr) {
128 /* Input image contains byte pixels. */
129 /* Not requested to become float and already in the needed colorspace: nothing to do. */
130 const char *from_colorspace = IMB_colormanagement_get_byte_colorspace(ibuf);
131 if (!make_float && STREQ(from_colorspace, to_colorspace)) {
132 return;
133 }
134
135 /* Turn into a float and convert colorspace. */
136 IMB_alloc_float_pixels(ibuf, 4, false);
138 ibuf->byte_data(),
139 ibuf->x,
140 ibuf->y,
141 ibuf->channels,
142 from_colorspace,
143 to_colorspace);
146 }
147 else {
148 /* Input image contains float pixels. */
149 const char *from_colorspace = IMB_colormanagement_get_float_colorspace(ibuf);
150 /* Unknown input color space, can't perform conversion. */
151 if (from_colorspace == nullptr || from_colorspace[0] == '\0') {
152 return;
153 }
154
155 /* Discard byte pixels if there are any. */
156 if (ibuf->byte_data() != nullptr) {
158 }
160 ibuf->x,
161 ibuf->y,
162 ibuf->channels,
163 from_colorspace,
164 to_colorspace,
165 true);
167 }
168}
169
170void ensure_ibuf_is_sequencer_space(const Scene *scene, ImBuf *ibuf, bool make_float)
171{
172 const char *to_colorspace = scene->sequencer_colorspace_settings.name;
173 ensure_ibuf_is_color_space(ibuf, make_float, to_colorspace);
174}
175
176void ensure_ibuf_is_linear_space(ImBuf *ibuf, bool make_float)
177{
178 /* Not requested to make float, and only have byte pixels: do nothing. */
179 if (!make_float && !ibuf->float_data()) {
180 return;
181 }
182
183 const char *to_colorspace = IMB_colormanagement_role_colorspace_name_get(
185 ensure_ibuf_is_color_space(ibuf, make_float, to_colorspace);
186}
187
189
190/* -------------------------------------------------------------------- */
193
195 Depsgraph *depsgraph,
196 Scene *scene,
197 int rectx,
198 int recty,
199 eSpaceSeq_Proxy_RenderSize preview_render_size,
200 Render *render,
201 RenderData *r_context)
202{
203 r_context->bmain = bmain;
204 r_context->depsgraph = depsgraph;
205 r_context->scene = scene;
206 r_context->rectx = rectx;
207 r_context->recty = recty;
208 r_context->preview_render_size = preview_render_size;
209 r_context->ignore_missing_media = false;
210 r_context->render = render;
211 r_context->motion_blur_samples = 0;
212 r_context->motion_blur_shutter = 0;
213 r_context->skip_cache = false;
214 r_context->view_id = 0;
215 r_context->gpu_offscreen = nullptr;
216 r_context->gpu_viewport = nullptr;
217 r_context->is_prefetch_render = false;
218}
219
220StripElem *render_give_stripelem(const Scene *scene, const Strip *strip, int timeline_frame)
221{
222 StripElem *se = strip->data->stripdata;
223
224 if (strip->type == STRIP_TYPE_IMAGE) {
225 /* only IMAGE strips use the whole array, MOVIE strips use only the first element,
226 * all other strips don't use this...
227 */
228
229 int frame_index = round_fl_to_int(give_frame_index(scene, strip, timeline_frame));
230
231 if (frame_index == -1 || se == nullptr) {
232 return nullptr;
233 }
234
235 se += frame_index + strip->anim_startofs;
236 }
237 return se;
238}
239
241{
242 Scene *scene = context->scene;
243 const int x = context->rectx;
244 const int y = context->recty;
245 const float2 offset{x * 0.5f, y * 0.5f};
246
247 Array<float2> quad = image_transform_quad_get(scene, strip);
248 const float scale = get_render_scale_factor(*context);
249 return StripScreenQuad{float2(quad[0] * scale + offset),
250 float2(quad[1] * scale + offset),
251 float2(quad[2] * scale + offset),
252 float2(quad[3] * scale + offset)};
253}
254
255/* Is quad `a` fully contained (i.e. covered by) quad `b`? For that to happen,
256 * all corners of `a` have to be inside `b`. */
258{
259 return isect_point_quad_v2(a.v0, b.v0, b.v1, b.v2, b.v3) &&
260 isect_point_quad_v2(a.v1, b.v0, b.v1, b.v2, b.v3) &&
261 isect_point_quad_v2(a.v2, b.v0, b.v1, b.v2, b.v3) &&
262 isect_point_quad_v2(a.v3, b.v0, b.v1, b.v2, b.v3);
263}
264
265/* Tracking of "known to be opaque" strip quad coordinates, along with their
266 * order index within visible strips during rendering. */
267
272
275
276 /* Determine if the input strip is completely behind opaque strips that are
277 * above it. Current implementation is simple and only checks if strip is
278 * completely covered by any other strip. It does not detect case where
279 * a strip is not covered by a single strip, but is behind of the union
280 * of the strips above. */
281 bool is_occluded(const RenderData *context, const Strip *strip, int order_index) const
282 {
283 StripScreenQuad quad = get_strip_screen_quad(context, strip);
284 if (quad.is_empty()) {
285 /* Strip size is not initialized/valid, we can't know if it is occluded. */
286 return false;
287 }
288 for (const OpaqueQuad &q : opaques) {
289 if (q.order_index > order_index && is_quad_a_inside_b(quad, q.quad)) {
290 return true;
291 }
292 }
293 return false;
294 }
295
296 void add_occluder(const RenderData *context, const Strip *strip, int order_index)
297 {
298 StripScreenQuad quad = get_strip_screen_quad(context, strip);
299 if (!quad.is_empty()) {
300 opaques.append({quad, order_index});
301 }
302 }
303};
304
306
307/* -------------------------------------------------------------------- */
327
328static bool sequencer_use_transform(const Strip *strip)
329{
330 const StripTransform *transform = strip->data->transform;
331
332 if (transform->xofs != 0 || transform->yofs != 0 || transform->scale_x != 1 ||
333 transform->scale_y != 1 || transform->rotation != 0)
334 {
335 return true;
336 }
337
338 return false;
339}
340
341static bool sequencer_use_crop(const Strip *strip)
342{
343 const StripCrop *crop = strip->data->crop;
344 if (crop->left > 0 || crop->right > 0 || crop->top > 0 || crop->bottom > 0) {
345 return true;
346 }
347
348 return false;
349}
350
351static bool seq_input_have_to_preprocess(const Strip *strip)
352{
353 float mul;
354
355 if ((strip->flag & (SEQ_DEINTERLACE | SEQ_FLIPX | SEQ_FLIPY | SEQ_MAKE_FLOAT)) ||
357 {
358 return true;
359 }
360
361 mul = strip->mul;
362
363 if (strip->blend_mode == STRIP_BLEND_REPLACE) {
364 mul *= strip->blend_opacity / 100.0f;
365 }
366
367 if (mul != 1.0f) {
368 return true;
369 }
370
371 if (strip->sat != 1.0f) {
372 return true;
373 }
374
375 if (strip->modifiers.first_) {
376 return true;
377 }
378
379 return false;
380}
381
388static bool seq_need_scale_to_render_size(const Strip *strip, bool is_proxy_image)
389{
390 if (is_proxy_image) {
391 return false;
392 }
393 if ((strip->is_effect() && strip->type != STRIP_TYPE_COLOR) || strip->type == STRIP_TYPE_MASK ||
394 strip->type == STRIP_TYPE_META ||
395 (strip->type == STRIP_TYPE_SCENE && ((strip->flag & SEQ_SCENE_STRIPS) != 0)))
396 {
397 return false;
398 }
399 return true;
400}
401
418 const Strip *strip,
419 const int2 in_size,
420 const int2 out_size,
421 const float image_scale_factor,
422 const float preview_scale_factor)
423{
424 /* Step 1: Convert image coordinates from (0,0) bottom-left to (0,0) image center. */
425 const float3x3 center_image = math::from_location<float3x3>(-float2(in_size) / 2.0f);
426
427 /* Step 2: Resize image about its center if needed. */
428 const float3x3 resize = math::from_scale<float3x3>(float2(image_scale_factor));
429
430 /* Step 3: Apply user scale/rotate/translate about the remapped origin. */
431 const StripTransform *transform = strip->data->transform;
432 const float2 origin_mapped = math::transform_point(
433 resize * center_image, float2(in_size) * image_transform_origin_get(scene, strip));
434 const float2 translation(transform->xofs * preview_scale_factor,
435 transform->yofs * preview_scale_factor);
436 const float rotation = transform->rotation;
437 const float2 scale(transform->scale_x, transform->scale_y);
438
439 const float3x3 user_transforms = math::from_origin_transform(
440 math::from_loc_rot_scale<float3x3>(translation, rotation, scale), origin_mapped);
441
442 /* Step 4: Map input image center to output canvas center, where (0,0) is canvas bottom-left. */
443 /* TODO(@john): Existing tests expect no interpolation of untransformed images that cannot
444 * cleanly center themselves in the canvas. However, this is arguably incorrect as it results in
445 * positional error (de-centering). Uncomment this line for future PR that updates tests, and for
446 * now, use a workaround that should pixel-perfect reproduce old behavior. */
447
448 /* const float3x3 center_in_canvas = math::from_location<float3x3>(float2(out_size) / 2.0f); */
449 const float3x3 center_in_canvas = math::from_location<float3x3>(
450 float2(in_size) / 2.0f + float2((out_size - in_size) / 2));
451
452 /* Apply all the steps from right to left as matrix multiplication. */
453 return center_in_canvas * user_transforms * resize * center_image;
454}
455
456static void sequencer_image_crop_init(const Strip *strip,
457 const ImBuf *in,
458 float crop_scale_factor,
459 rctf *r_crop)
460{
461 const StripCrop *c = strip->data->crop;
462 const int left = c->left * crop_scale_factor;
463 const int right = c->right * crop_scale_factor;
464 const int top = c->top * crop_scale_factor;
465 const int bottom = c->bottom * crop_scale_factor;
466
467 BLI_rctf_init(r_crop, left, in->x - right, bottom, in->y - top);
468}
469
470/* Check bounds used by strip occlusion against the actual cropped and transformed image. */
472 const Strip *strip,
473 const ImBuf *image,
474 const float3x3 &matrix,
475 const float crop_scale_factor)
476{
477 rctf crop;
478 sequencer_image_crop_init(strip, image, crop_scale_factor, &crop);
479 const rctf image_bounds{0.0f, float(image->x), 0.0f, float(image->y)};
480 BLI_rctf_isect(&crop, &image_bounds, &crop);
481 if (BLI_rctf_is_empty(&crop)) {
482 return false;
483 }
484
485 const float2 center(context->rectx * 0.5f, context->recty * 0.5f);
486 const float2 display_scale = image_transform_mirror_factor_get(strip) *
487 float2(context->scene->r.xasp / context->scene->r.yasp, 1.0f);
488 const auto to_screen = [&](const float2 point) {
489 return (math::transform_point(matrix, point) - center) * display_scale + center;
490 };
491 const StripScreenQuad actual_quad{to_screen(float2(crop.xmin, crop.ymin)),
492 to_screen(float2(crop.xmax, crop.ymin)),
493 to_screen(float2(crop.xmax, crop.ymax)),
494 to_screen(float2(crop.xmin, crop.ymax))};
495 if (math::cross(actual_quad.v1 - actual_quad.v0, actual_quad.v3 - actual_quad.v0) == 0.0f) {
496 /* Zero area quad. */
497 return false;
498 }
499 const StripScreenQuad strip_quad = get_strip_screen_quad(context, strip);
500 return !strip_quad.is_empty() && is_quad_a_inside_b(strip_quad, actual_quad);
501}
502
503static bool is_strip_covering_screen(const RenderData *context, const Strip *strip)
504{
505 /* The check is done by checking whether all corners of viewport fit inside
506 * of the transformed strip. If they do not, the strip does not cover
507 * whole screen. */
508 float x0 = 0.0f;
509 float y0 = 0.0f;
510 float x1 = float(context->rectx);
511 float y1 = float(context->recty);
512 float x_aspect = context->scene->r.xasp / context->scene->r.yasp;
513 if (x_aspect != 1.0f) {
514 float xmid = (x0 + x1) * 0.5f;
515 x0 = xmid - (xmid - x0) * x_aspect;
516 x1 = xmid + (x1 - xmid) * x_aspect;
517 }
518 StripScreenQuad quad = get_strip_screen_quad(context, strip);
519 if (quad.is_empty()) {
520 return false; /* Strip is zero size. */
521 }
522 StripScreenQuad screen{float2(x0, y0), float2(x1, y0), float2(x0, y1), float2(x1, y1)};
523
524 return is_quad_a_inside_b(screen, quad);
525}
526
527/* Automatic filter:
528 * - No scale, no rotation and non-fractional position: nearest.
529 * - Scale up by more than 2x: cubic mitchell.
530 * - Scale down by more than 2x: box.
531 * - Otherwise: bilinear. */
533{
534 const float sx = fabsf(transform->scale_x);
535 const float sy = fabsf(transform->scale_y);
536 if (sx > 2.0f && sy > 2.0f) {
538 }
539 if (sx < 0.5f && sy < 0.5f) {
540 return IMB_FILTER_BOX;
541 }
542 const float px = transform->xofs;
543 const float py = transform->yofs;
544 const float rot = transform->rotation;
545 if (sx == 1.0f && sy == 1.0f && roundf(px) == px && roundf(py) == py && rot == 0.0f) {
546 return IMB_FILTER_NEAREST;
547 }
548 return IMB_FILTER_BILINEAR;
549}
550
552 ImBuf *out,
553 const RenderData *context,
554 Strip *strip,
555 const float3x3 &matrix,
556 const bool scale_crop_values,
557 const float preview_scale_factor)
558{
559 /* Proxy image is smaller, so crop values must be corrected by proxy scale factor.
560 * Proxy scale factor always matches preview_scale_factor. */
561 rctf source_crop;
562 const float crop_scale_factor = scale_crop_values ? preview_scale_factor : 1.0f;
563 sequencer_image_crop_init(strip, in, crop_scale_factor, &source_crop);
564
565 const StripTransform *transform = strip->data->transform;
567 switch (transform->filter) {
569 filter = get_auto_filter(strip->data->transform);
570 break;
573 break;
576 break;
579 break;
582 break;
585 break;
586 }
587
588 IMB_transform(in, out, IMB_TRANSFORM_MODE_CROP_SRC, filter, matrix, &source_crop);
589
590 if (is_strip_covering_screen(context, strip)) {
591 out->color_mode = in->color_mode;
592 }
593 else {
594 /* Strip is not covering full viewport, which means areas with transparency
595 * are introduced for sure. */
596 out->color_mode = ImColorMode::RGBA;
597 }
598}
599
600static void multiply_ibuf(ImBuf *ibuf, const float fmul, const bool multiply_alpha)
601{
602 BLI_assert_msg(ibuf->channels == 0 || ibuf->channels == 4,
603 "Sequencer only supports 4 channel images");
604 const size_t pixel_count = IMB_get_pixel_count(ibuf);
605 if (uchar *byte_data = ibuf->byte_data_for_write()) {
606 threading::parallel_for(IndexRange(pixel_count), 64 * 1024, [&](IndexRange range) {
607 uchar *ptr = byte_data + range.first() * 4;
608 const int imul = int(256.0f * fmul);
609 for ([[maybe_unused]] const int64_t i : range) {
610 ptr[0] = min_ii((imul * ptr[0]) >> 8, 255);
611 ptr[1] = min_ii((imul * ptr[1]) >> 8, 255);
612 ptr[2] = min_ii((imul * ptr[2]) >> 8, 255);
613 if (multiply_alpha) {
614 ptr[3] = min_ii((imul * ptr[3]) >> 8, 255);
615 }
616 ptr += 4;
617 }
618 });
619 }
620
621 if (float *float_data = ibuf->float_data_for_write()) {
622 threading::parallel_for(IndexRange(pixel_count), 64 * 1024, [&](IndexRange range) {
623 float *ptr = float_data + range.first() * 4;
624 for ([[maybe_unused]] const int64_t i : range) {
625 ptr[0] *= fmul;
626 ptr[1] *= fmul;
627 ptr[2] *= fmul;
628 if (multiply_alpha) {
629 ptr[3] *= fmul;
630 }
631 ptr += 4;
632 }
633 });
634 }
635}
636
639 Strip *strip,
640 float timeline_frame,
641 const SeqResult &input,
642 const bool is_proxy_image)
643{
645
646 BLI_assert(input.is_valid());
647
648 SeqResult result = input;
649
650 Scene *scene = context->scene;
651
652 /* Deinterlace. */
653 if ((strip->flag & SEQ_DEINTERLACE) &&
655 {
656 PRF_scope_with_name("SeqStripDeinterlace", ProfileCategory::Draw);
657 result.image = IMB_makeSingleUser(result.image);
658 IMB_filtery(result.image);
659 }
660
661 const bool make_float = strip->flag & SEQ_MAKE_FLOAT;
662
663 if (strip->sat != 1.0f) {
664 PRF_scope_with_name("SeqStripSaturation", ProfileCategory::Draw);
665 result.image = IMB_makeSingleUser(result.image);
666 ensure_ibuf_is_sequencer_space(scene, result.image, make_float);
667 IMB_saturation(result.image, strip->sat);
668 }
669
670 if (make_float) {
671 PRF_scope_with_name("SeqStripMakeFloat", ProfileCategory::Draw);
672 if (!result.image->float_data()) {
673 result.image = IMB_makeSingleUser(result.image);
674 ensure_ibuf_is_sequencer_space(scene, result.image, true);
675 }
676 if (result.image->byte_data()) {
678 }
679 }
680
681 float mul = strip->mul;
682 if (strip->blend_mode == STRIP_BLEND_REPLACE) {
683 mul *= strip->blend_opacity / 100.0f;
684 }
685
686 if (mul != 1.0f) {
687 PRF_scope_with_name("SeqStripMultiply", ProfileCategory::Draw);
688 result.image = IMB_makeSingleUser(result.image);
689 ensure_ibuf_is_sequencer_space(scene, result.image, make_float);
690 const bool multiply_alpha = (strip->flag & SEQ_MULTIPLY_ALPHA);
691 multiply_ibuf(result.image, mul, multiply_alpha);
692 if (multiply_alpha && mul < 1.0f) {
693 result.image->color_mode = ImColorMode::RGBA;
694 }
695 }
696
697 const float preview_scale_factor = get_render_scale_factor(*context);
698 const bool do_scale_to_render_size = seq_need_scale_to_render_size(strip, is_proxy_image);
699 const float image_scale_factor = do_scale_to_render_size ? preview_scale_factor : 1.0f;
700
701 if (strip->modifiers.first_) {
702 result.image = IMB_makeSingleUser(result.image);
704 strip,
705 int2(result.image->x, result.image->y),
706 int2(context->rectx, context->recty),
707 image_scale_factor,
708 preview_scale_factor);
710 scene, strip, int2(0), int2(0), image_scale_factor, preview_scale_factor);
711 matrix_comp = math::invert(matrix_comp);
712 ModifierApplyContext mod_context(
713 *context, *state, *strip, matrix, matrix_comp, timeline_frame, result);
714 modifier_apply_stack(mod_context);
715 }
716
717 const bool do_transform = sequencer_use_crop(strip) || sequencer_use_transform(strip) ||
718 context->rectx != result.image->x ||
719 context->recty != result.image->y ||
720 (strip->is_effect() && image_scale_factor != 1.0f) ||
721 result.translation != float2(0, 0);
722 /* Modifiers can change image dimensions and translation. Use the final transform for both
723 * coverage validation and image processing, including preview/proxy scaling and centering. */
724 const float3x3 matrix = do_transform ?
726 strip,
727 int2(result.image->x, result.image->y),
728 int2(context->rectx, context->recty),
729 image_scale_factor,
730 preview_scale_factor) *
733
734 /* Only use opaque source content as an occluder if it covers the assumed strip bounds. */
735 result.is_opaque_before_transform = !result.image->can_contain_alpha() &&
737 context,
738 strip,
739 result.image,
740 matrix,
741 do_scale_to_render_size ? 1.0f : preview_scale_factor);
742
743 if (do_transform) {
744 PRF_scope_with_name("SeqStripTransform", ProfileCategory::Draw);
745
746 const int x = context->rectx;
747 const int y = context->recty;
748 ImBuf *transformed_ibuf = IMB_allocImBuf(
749 x, y, result.image->float_data() ? ImBufFlags::FloatData : ImBufFlags::ByteData);
750
752 transformed_ibuf,
753 context,
754 strip,
755 math::invert(matrix),
756 !do_scale_to_render_size,
757 preview_scale_factor);
758 if (!result.is_opaque_before_transform) {
759 transformed_ibuf->color_mode = ImColorMode::RGBA;
760 }
761 transformed_ibuf->byte_buffer.colorspace = result.image->byte_buffer.colorspace;
762 transformed_ibuf->float_buffer.colorspace = result.image->float_buffer.colorspace;
763 IMB_metadata_copy(transformed_ibuf, result.image);
764 IMB_freeImBuf(result.image);
765 result.image = transformed_ibuf;
766 }
767
768 if (strip->flag & SEQ_FLIPX) {
770 result.image = IMB_makeSingleUser(result.image);
771 IMB_flipx(result.image);
772 }
773
774 if (strip->flag & SEQ_FLIPY) {
776 result.image = IMB_makeSingleUser(result.image);
777 IMB_flipy(result.image);
778 }
779
780 return result;
781}
782
785 Strip *strip,
786 const SeqResult &input,
787 float timeline_frame,
788 bool use_preprocess,
789 const bool is_proxy_image)
790{
791 BLI_assert(input.is_valid());
792 if (input.image->x != context->rectx || input.image->y != context->recty ||
793 input.translation != float2(0, 0))
794 {
795 use_preprocess = true;
796 }
797
798 /* Proxies and non-generator effect strips are not stored in cache. */
799 const bool is_effect_with_inputs = strip->is_effect_with_inputs() ||
800 strip->type == STRIP_TYPE_ADJUSTMENT;
801 if (!is_proxy_image && !is_effect_with_inputs) {
802 Scene *orig_scene = prefetch_get_original_scene(context);
803 if (orig_scene->ed->cache_flag & SEQ_CACHE_STORE_RAW) {
804 source_image_cache_put(context, strip, timeline_frame, input);
805 }
806 }
807
808 if (!use_preprocess) {
809 return input;
810 }
811
812 return input_preprocess(context, state, strip, timeline_frame, input, is_proxy_image);
813}
814
817 Strip *strip,
818 float timeline_frame)
819{
821
822 Scene *scene = context->scene;
824 SeqResult ibuf[2] = {};
825 Strip *input[2] = {strip->input1, strip->input2};
827
828 if (!sh.execute) {
829 /* effect not supported in this version... */
830 out.image = IMB_allocImBuf(context->rectx, context->recty, ImBufFlags::ByteData);
831 return out;
832 }
833
834 float fac = effect_fader_calc(scene, strip, timeline_frame, state->is_current_frame);
835
836 StripEarlyOut early_out = sh.early_out(strip, fac);
837
838 switch (early_out) {
840 out = sh.execute(context, state, strip, timeline_frame, fac, {}, {});
841 break;
843 for (int i = 0; i < 2; i++) {
844 /* Speed effect requires time remapping of `timeline_frame` for input(s). */
845 if (input[0] && strip->type == STRIP_TYPE_SPEED) {
846 float target_frame = strip_speed_effect_target_frame_get(
847 scene, strip, timeline_frame, i);
848
849 /* Only convert to int when interpolation is not used. */
850 SpeedControlVars *s = reinterpret_cast<SpeedControlVars *>(strip->effectdata);
851 if ((s->flags & SEQ_SPEED_USE_INTERPOLATION) != 0) {
852 target_frame = std::floor(target_frame);
853 }
854
855 intra_frame_cache_set_cur_frame(context->scene,
856 target_frame,
857 context->view_id,
858 context->rectx,
859 context->recty,
860 context->render != nullptr);
861 ibuf[i] = seq_render_strip(context, state, input[0], target_frame);
862 }
863 else { /* Other effects. */
864 if (input[i]) {
865 ibuf[i] = seq_render_strip(context, state, input[i], timeline_frame);
866 }
867 }
868 }
869
870 if (ibuf[0].is_valid() && (ibuf[1].is_valid() || strip->effect_num_inputs_get() == 1)) {
871 out = sh.execute(context, state, strip, timeline_frame, fac, ibuf[0], ibuf[1]);
872 }
873 break;
875 if (input[0]) {
876 out = seq_render_strip(context, state, input[0], timeline_frame);
877 }
878 break;
880 if (input[1]) {
881 out = seq_render_strip(context, state, input[1], timeline_frame);
882 }
883 break;
884 }
885
886 for (int i = 0; i < 2; i++) {
887 IMB_freeImBuf(ibuf[i].image);
888 }
889
890 if (!out.is_valid()) {
891 out.image = IMB_allocImBuf(context->rectx, context->recty, ImBufFlags::ByteData);
892 }
893
894 return out;
895}
896
898
899/* -------------------------------------------------------------------- */
902
904{
905 if (ibuf == nullptr) {
906 return;
907 }
908
909 /* Combined layer might be non-4 channels, however the rest
910 * of sequencer assumes RGBA everywhere. Convert to 4 channel if needed. */
911 if (ibuf->float_data() != nullptr && ibuf->channels != 4) {
912 float *dst = MEM_new_array_uninitialized<float>(4 * size_t(ibuf->x) * size_t(ibuf->y),
913 __func__);
914 IMB_buffer_float_rgba_from_float(dst, ibuf->float_data(), ibuf->channels, ibuf->x, ibuf->y);
915 ibuf->assign_float_data(dst);
916 ibuf->channels = 4;
917 }
918}
919
924 const RenderData *context, Strip *strip, const char *filepath, const char *prefix, int view_id)
925{
926 ImBuf *ibuf = nullptr;
927
929 if (strip->alpha_mode == SEQ_ALPHA_PREMUL) {
931 }
932
933 if (prefix[0] == '\0') {
934 ibuf = IMB_load_image_from_filepath(filepath, flag, &strip->data->colorspace_settings);
935 }
936 else {
937 char filepath_view[FILE_MAX];
939 *context->scene, filepath, view_id, filepath_view, sizeof(filepath_view), nullptr))
940 {
941 return nullptr;
942 }
943 ibuf = IMB_load_image_from_filepath(filepath_view, flag, &strip->data->colorspace_settings);
944 }
945
946 if (ibuf == nullptr) {
947 return nullptr;
948 }
950
951 /* We don't need both (speed reasons)! */
952 if (ibuf->float_data() != nullptr && ibuf->byte_data() != nullptr) {
954 }
955
956 return ibuf;
957}
958
960 const Strip *strip,
961 const char *filepath,
962 char *r_prefix)
963{
964 r_prefix[0] = '\0';
965
966 if ((strip->flag & SEQ_USE_VIEWS) == 0 || (scene->r.scemode & R_MULTIVIEW) == 0 ||
968 {
969 return false;
970 }
971
972 if (strip->views_format != R_IMF_VIEWS_INDIVIDUAL) {
973 /* Strips interpreted as a single stereo file always force multiview. */
974 return true;
975 }
976
977 /* For "Individual" view, if strip's file suffix does not match any view suffix,
978 * (implying no common prefix), fallback to mono render. */
979 const char *ext = nullptr;
980 BKE_scene_multiview_view_prefix_get(scene, filepath, r_prefix, &ext);
981 return r_prefix[0] != '\0';
982}
983
984static ImBuf *create_missing_media_image(const RenderData *context, int width, int height)
985{
986 if (context->ignore_missing_media) {
987 return nullptr;
988 }
989 if (context->scene == nullptr || context->scene->ed == nullptr ||
990 (context->scene->ed->show_missing_media_flag & SEQ_EDIT_SHOW_MISSING_MEDIA) == 0)
991 {
992 return nullptr;
993 }
994
995 ImBuf *ibuf = IMB_allocImBuf(max_ii(width, 1), max_ii(height, 1), ImBufFlags::ByteData);
996 float col[4] = {0.85f, 0.0f, 0.75f, 1.0f};
997 IMB_rectfill(ibuf, col);
998 return ibuf;
999}
1000
1002 Strip *strip,
1003 int timeline_frame,
1004 bool *r_is_proxy_image)
1005{
1006 PRF_scope_with_name("SeqRenderImage", ProfileCategory::Draw);
1007
1008 char filepath[FILE_MAX];
1009 char prefix[FILE_MAX];
1010 ImBuf *ibuf = nullptr;
1011
1012 StripElem *s_elem = render_give_stripelem(context->scene, strip, timeline_frame);
1013 if (s_elem == nullptr) {
1014 return nullptr;
1015 }
1016
1017 BLI_path_join(filepath, sizeof(filepath), strip->data->dirpath, s_elem->filename);
1018 BLI_path_abs(filepath, ID_BLEND_PATH_FROM_GLOBAL(&context->scene->id));
1019
1020 /* Try to get a proxy image. */
1021 ibuf = seq_proxy_fetch(context, strip, timeline_frame);
1022 if (ibuf != nullptr) {
1023 *r_is_proxy_image = true;
1024 return ibuf;
1025 }
1026
1027 /* Proxy not found, render original. */
1028 const bool do_multiview_render = seq_strip_do_multiview_render(
1029 context->scene, strip, filepath, prefix);
1030
1031 if (do_multiview_render) {
1032 const int totfiles = seq_multiview_num_files_get(context->scene, strip->views_format);
1033 const int totviews = BKE_scene_multiview_num_views_get(&context->scene->r);
1034 Array<ImBuf *> ibufs_arr(totviews, nullptr);
1035
1036 for (int view_id = 0; view_id < totfiles; view_id++) {
1037 ibufs_arr[view_id] = seq_render_image_strip_view(context, strip, filepath, prefix, view_id);
1038 }
1039
1040 if (ibufs_arr[0] == nullptr) {
1041 return nullptr;
1042 }
1043
1044 if (strip->views_format == R_IMF_VIEWS_STEREO_3D) {
1045 IMB_ImBufFromStereo3d(strip->stereo3d_format,
1046 ibufs_arr[0],
1047 &ibufs_arr[0], // NOLINT(readability-container-data-pointer)
1048 &ibufs_arr[1]);
1049 }
1050
1051 /* Return the requested image; release the others. */
1052 ibuf = ibufs_arr[context->view_id];
1053 for (ImBuf *ib : ibufs_arr) {
1054 if (ib != ibuf) {
1055 IMB_freeImBuf(ib);
1056 }
1057 }
1058 }
1059 else {
1060 ibuf = seq_render_image_strip_view(context, strip, filepath, prefix, context->view_id);
1061 }
1062
1063 media_presence_set_missing(context->scene, strip, ibuf == nullptr);
1064 if (ibuf == nullptr) {
1065 return create_missing_media_image(context, s_elem->orig_width, s_elem->orig_height);
1066 }
1067
1068 s_elem->orig_width = ibuf->x;
1069 s_elem->orig_height = ibuf->y;
1070
1071 return ibuf;
1072}
1073
1075 Strip *strip,
1076 int timeline_frame)
1077{
1078 char filepath[PROXY_MAXFILE];
1079 StripProxy *proxy = strip->data->proxy;
1080
1081 if (proxy->anim == nullptr) {
1082 if (seq_proxy_get_custom_file_filepath(strip, filepath, context->view_id)) {
1083 /* Sequencer takes care of colorspace conversion of the result. The input is the best to be
1084 * kept unchanged for the performance reasons. */
1085 proxy->anim = openanim(
1086 filepath, ImBufFlags::Zero, 0, true, &strip->data->colorspace_settings);
1087 }
1088 if (proxy->anim == nullptr) {
1089 return nullptr;
1090 }
1091 }
1092
1093 int frameno = round_fl_to_int(give_frame_index(context->scene, strip, timeline_frame)) +
1094 strip->anim_startofs;
1095 return MOV_decode_frame(proxy->anim, frameno, IMB_PROXY_NONE);
1096}
1097
1102 Strip *strip,
1103 float timeline_frame,
1104 MovieReaderAccessor &reader,
1105 bool *r_is_proxy_image)
1106{
1107 ImBuf *ibuf = nullptr;
1108 IMB_Proxy_Size psize = rendersize_to_proxysize(context->preview_render_size);
1109 const int frame_index = round_fl_to_int(give_frame_index(context->scene, strip, timeline_frame));
1110
1111 if (can_use_proxy(context, strip, psize)) {
1112 /* Try to get a proxy image.
1113 * Movie proxies are handled by ImBuf module with exception of `custom file` setting. */
1114 if (context->scene->ed->proxy_storage != SEQ_EDIT_PROXY_DIR_STORAGE &&
1115 strip->data->proxy->storage & SEQ_STORAGE_PROXY_CUSTOM_FILE)
1116 {
1117 ibuf = seq_render_movie_strip_custom_file_proxy(context, strip, timeline_frame);
1118 }
1119 else {
1120 ibuf = reader.decode_frame(frame_index + strip->anim_startofs, psize);
1121 }
1122
1123 if (ibuf != nullptr) {
1124 *r_is_proxy_image = true;
1125 }
1126 }
1127
1128 /* Fetching for requested proxy size failed, try fetching the original instead. */
1129 if (ibuf == nullptr) {
1130 ibuf = reader.decode_frame(frame_index + strip->anim_startofs, IMB_PROXY_NONE);
1131 }
1132 if (ibuf == nullptr) {
1133 return nullptr;
1134 }
1135
1136 /* We don't need both (speed reasons)! */
1137 if (ibuf->float_data() != nullptr && ibuf->byte_data() != nullptr) {
1139 }
1140
1141 return ibuf;
1142}
1143
1145 Strip *strip,
1146 float timeline_frame,
1147 bool *r_is_proxy_image)
1148{
1149 PRF_scope_with_name("SeqRenderMovie", ProfileCategory::Draw);
1150
1151 ImBuf *ibuf = nullptr;
1152 const bool use_multiview = (strip->flag & SEQ_USE_VIEWS) != 0 &&
1153 (context->scene->r.scemode & R_MULTIVIEW) != 0;
1154 const int totfiles = use_multiview ?
1155 seq_multiview_num_files_get(context->scene, strip->views_format) :
1156 1;
1157
1158 const int frame_index = round_fl_to_int(
1159 give_frame_index(context->scene, strip, timeline_frame)) +
1160 strip->anim_startofs;
1161 /* Prefetch renders a scene copy, but movie readers should still get cached into
1162 * the original scene. This way invalidation & cleanup affects entries cached
1163 * by prefetch too. */
1164 Scene &cache_scene = *prefetch_get_original_scene(context);
1165 float source_fps = 0.0f;
1166
1168 bool do_multiview_render = false;
1169 if (use_multiview && totfiles > 0) {
1170 readers.append(
1171 movie_reader_cache_acquire_view(cache_scene, *context->scene, *strip, 0, frame_index));
1172
1173 do_multiview_render = strip->views_format == R_IMF_VIEWS_STEREO_3D ||
1174 readers[0].uses_multiview_filepath();
1175
1176 /* Opening individual multiview files is all-or-nothing. Fall back to the original filepath if
1177 * any view cannot be opened. */
1178 if (do_multiview_render && strip->views_format == R_IMF_VIEWS_INDIVIDUAL) {
1179 bool all_readers_open = bool(readers[0]);
1180 for (int view_id = 1; view_id < totfiles && all_readers_open; view_id++) {
1182 cache_scene, *context->scene, *strip, view_id, frame_index));
1183 all_readers_open = bool(readers.last());
1184 }
1185 if (!all_readers_open) {
1186 readers.clear();
1187 do_multiview_render = false;
1188 }
1189 }
1190 }
1191
1192 if (do_multiview_render) {
1193 const int totviews = BKE_scene_multiview_num_views_get(&context->scene->r);
1194 Array<ImBuf *> ibuf_arr(totviews, nullptr);
1195
1196 for (const int64_t ibuf_view_id : readers.index_range()) {
1197 MovieReaderAccessor &reader = readers[ibuf_view_id];
1198 if (reader) {
1199 ibuf_arr[ibuf_view_id] = seq_render_movie_strip_view(
1200 context, strip, timeline_frame, reader, r_is_proxy_image);
1201 if (ibuf_view_id == 0) {
1202 source_fps = MOV_get_fps(reader.reader());
1203 }
1204 }
1205 }
1206
1207 if (strip->views_format == R_IMF_VIEWS_STEREO_3D) {
1208 if (ibuf_arr[0] == nullptr) {
1209 /* Probably proxy hasn't been created yet. */
1210 return nullptr;
1211 }
1212
1213 IMB_ImBufFromStereo3d(strip->stereo3d_format,
1214 ibuf_arr[0],
1215 &ibuf_arr[0], // NOLINT(readability-container-data-pointer)
1216 &ibuf_arr[1]);
1217 }
1218
1219 /* Return the requested image; release the others. */
1220 ibuf = ibuf_arr[context->view_id];
1221 for (ImBuf *ib : ibuf_arr) {
1222 if (ib != ibuf) {
1223 IMB_freeImBuf(ib);
1224 }
1225 }
1226 }
1227 else {
1228 MovieReaderAccessor reader;
1229 if (readers.is_empty()) {
1230 reader = movie_reader_cache_acquire(cache_scene, *context->scene, *strip, frame_index);
1231 }
1232 else {
1233 reader = std::move(readers[0]);
1234 }
1235 if (reader) {
1236 ibuf = seq_render_movie_strip_view(context, strip, timeline_frame, reader, r_is_proxy_image);
1237 source_fps = MOV_get_fps(reader.reader());
1238 }
1239 }
1240
1241 media_presence_set_missing(context->scene, strip, ibuf == nullptr);
1242 if (ibuf == nullptr) {
1244 context, strip->data->stripdata->orig_width, strip->data->stripdata->orig_height);
1245 }
1246
1247 if (*r_is_proxy_image == false) {
1248 if (source_fps != 0.0f) {
1249 strip->data->stripdata->orig_fps = source_fps;
1250 }
1251 strip->data->stripdata->orig_width = ibuf->x;
1252 strip->data->stripdata->orig_height = ibuf->y;
1253 }
1254
1255 return ibuf;
1256}
1257
1259{
1260 ImBuf *ibuf = nullptr;
1261 float tloc[2], tscale, tangle;
1262 if (strip->clip_flag & SEQ_MOVIECLIP_RENDER_STABILIZED) {
1264 strip->clip, &user, MovieClipPostprocFlag::None, tloc, &tscale, &tangle);
1265 }
1266 else {
1268 strip->clip, &user, MovieClipFlag(strip->clip->flag), MovieClipCacheFlag::SkipCache);
1269 }
1270 return ibuf;
1271}
1272
1274 Strip *strip,
1275 float frame_index,
1276 bool *r_is_proxy_image)
1277{
1278 PRF_scope_with_name("SeqRenderMovieClip", ProfileCategory::Draw);
1279
1280 ImBuf *ibuf = nullptr;
1281 MovieClipUser user = {};
1282 IMB_Proxy_Size psize = rendersize_to_proxysize(context->preview_render_size);
1283
1284 if (!strip->clip) {
1285 return nullptr;
1286 }
1287
1289 frame_index + strip->anim_startofs + strip->clip->start_frame);
1290
1292 switch (psize) {
1293 case IMB_PROXY_NONE:
1295 break;
1296 case IMB_PROXY_100:
1298 break;
1299 case IMB_PROXY_75:
1301 break;
1302 case IMB_PROXY_50:
1304 break;
1305 case IMB_PROXY_25:
1307 break;
1308 }
1309
1310 if (strip->clip_flag & SEQ_MOVIECLIP_RENDER_UNDISTORTED) {
1312 }
1313
1314 /* Try to get a proxy image. */
1315 ibuf = seq_get_movieclip_ibuf(strip, user);
1316
1317 /* If clip doesn't use proxies, it will fall back to full size render of original file. */
1318 if (ibuf != nullptr && psize != IMB_PROXY_NONE && BKE_movieclip_proxy_enabled(strip->clip)) {
1319 *r_is_proxy_image = true;
1320 }
1321
1322 /* If proxy is not found, grab full-size frame. */
1323 if (ibuf == nullptr) {
1325 ibuf = seq_get_movieclip_ibuf(strip, user);
1326 }
1327
1328 return ibuf;
1329}
1330
1331ImBuf *seq_render_mask(Depsgraph *depsgraph,
1332 int width,
1333 int height,
1334 const Mask *mask,
1335 float frame_index,
1336 bool make_float)
1337{
1338 if (!mask) {
1339 return nullptr;
1340 }
1341
1342 Mask *mask_temp = id_cast<Mask *>(
1344
1345 BKE_mask_evaluate(mask_temp, mask->sfra + frame_index, true);
1346
1347 /* anim-data */
1348 AnimData *adt = BKE_animdata_from_id(&mask->id);
1350 depsgraph, mask->sfra + frame_index);
1351 BKE_animsys_evaluate_animdata(&mask_temp->id, adt, &anim_eval_context, ADT_RECALC_ANIM, false);
1352
1354
1355 BKE_maskrasterize_handle_init(mr_handle, mask_temp, width, height, true, true, true);
1356
1357 BKE_id_free(nullptr, &mask_temp->id);
1358
1359 /* Evaluate mask over the resulting image. */
1360 ImBuf *ibuf = IMB_allocImBuf(width,
1361 height,
1364 const float x_inv = 1.0f / float(width);
1365 const float y_inv = 1.0f / float(height);
1366 const float x_px_ofs = x_inv * 0.5f;
1367 const float y_px_ofs = y_inv * 0.5f;
1368 float *dst_float = ibuf->float_data_for_write();
1369 uchar *dst_byte = ibuf->byte_data_for_write();
1370 threading::parallel_for(IndexRange(height), 16, [&](const IndexRange y_range) {
1371 const int64_t pixel_offset = y_range.first() * width * 4;
1372 float *ptr_float = dst_float + pixel_offset;
1373 uchar *ptr_byte = dst_byte + pixel_offset;
1374 for (int64_t y : y_range) {
1375 float2 coord;
1376 coord.y = y * y_inv + y_px_ofs;
1377 for (int x = 0; x < width; x++) {
1378 coord.x = x * x_inv + x_px_ofs;
1379 float value = BKE_maskrasterize_handle_sample(mr_handle, coord);
1380 if (make_float) {
1381 ptr_float[0] = ptr_float[1] = ptr_float[2] = value;
1382 ptr_float[3] = 1.0f;
1383 }
1384 else {
1385 ptr_byte[0] = ptr_byte[1] = ptr_byte[2] = uchar(value * 255.0f);
1386 ptr_byte[3] = 255;
1387 }
1388 ptr_float += 4;
1389 ptr_byte += 4;
1390 }
1391 }
1392 });
1393
1395
1396 return ibuf;
1397}
1398
1399static ImBuf *seq_render_mask_strip(const RenderData *context, Strip *strip, float frame_index)
1400{
1402
1403 bool make_float = (strip->flag & SEQ_MAKE_FLOAT) != 0;
1404
1405 return seq_render_mask(
1406 context->depsgraph, context->rectx, context->recty, strip->mask, frame_index, make_float);
1407}
1408
1410{
1411 if (strip->scene_view_layer_name != nullptr) {
1412 if (ViewLayer *view_layer = BKE_view_layer_find(scene, strip->scene_view_layer_name)) {
1413 return view_layer;
1414 }
1415 }
1416 return BKE_view_layer_default_render(scene);
1417}
1418
1419static Depsgraph *get_depsgraph_for_scene_strip(Main *bmain, Scene *scene, ViewLayer *view_layer)
1420{
1421 Depsgraph *depsgraph = scene->runtime->sequencer.depsgraph;
1422 if (!depsgraph) {
1423 /* Create a new depsgraph for the sequencer preview. Use viewport evaluation, because this
1424 * depsgraph is not used during final render. */
1426 bmain, scene, view_layer, DAG_EVAL_VIEWPORT);
1427 depsgraph = scene->runtime->sequencer.depsgraph;
1428 DEG_debug_name_set(depsgraph, "SEQ_SCENE_STRIP");
1429 }
1430
1431 if (DEG_get_input_view_layer(depsgraph) != view_layer) {
1432 DEG_graph_replace_owners(depsgraph, bmain, scene, view_layer);
1434 }
1435
1436 return depsgraph;
1437}
1438
1439/* Render a scene strip through the offscreen viewport path (used for preview and thumbnails).
1440 * `scene` is the strip's scene; `display_scene` is the scene that drives the shading
1441 * (timeline edit scene). */
1442static ImBuf *render_scene_strip_viewport(const Scene *display_scene,
1443 Scene *scene,
1444 const Strip *strip,
1445 Depsgraph *depsgraph,
1446 Object *camera,
1447 eDrawType draw_type,
1448 int width,
1449 int height,
1450 int view_id,
1451 GPUOffScreen *gpu_offscreen,
1452 GPUViewport *gpu_viewport)
1453{
1454 const bool use_gpencil = (strip->flag & SEQ_SCENE_NO_ANNOTATION) == 0;
1455 const bool use_scene_settings = (display_scene->r.seq_flag & R_SEQ_OVERRIDE_SCENE_SETTINGS) != 0;
1456
1457 uint draw_flags = V3D_OFSDRAW_NONE;
1458 draw_flags |= (use_gpencil) ? V3D_OFSDRAW_SHOW_ANNOTATION : 0;
1459 draw_flags |= (use_scene_settings) ? (V3D_OFSDRAW_OVERRIDE_SCENE_SETTINGS |
1461 0;
1462
1463 View3DShading scene_shading = display_scene->display.shading;
1464 if (use_scene_settings) {
1465 /* Allow to render with the scene world color. */
1466 if (display_scene->world != nullptr) {
1467 copy_v3_v3(&scene_shading.background_color[0], &display_scene->world->horr);
1468 }
1469 else {
1470 copy_v3_fl(&scene_shading.background_color[0], 0.0f);
1471 }
1473 }
1474
1475 const char *viewname = BKE_scene_multiview_render_view_name_get(&scene->r, view_id);
1476
1478 Object *camera_eval = DEG_get_evaluated(depsgraph, camera);
1479 Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
1480
1481 char err_out[256] = "unknown";
1482 ImBuf *ibuf = view3d_fn(depsgraph,
1483 scene_eval,
1484 &scene_shading,
1485 draw_type,
1486 camera_eval,
1487 width,
1488 height,
1490 eV3DOffscreenDrawFlag(draw_flags),
1491 scene->r.alphamode,
1492 viewname,
1493 gpu_offscreen,
1494 gpu_viewport,
1495 err_out);
1496 if (ibuf == nullptr) {
1497 fprintf(stderr, "VSE failed to render scene strip image: %s\n", err_out);
1498 }
1499 return ibuf;
1500}
1501
1506
1508 : scene(scene),
1509 scemode(scene->r.scemode),
1510 cfra(scene->r.cfra),
1511 mode(scene->r.mode),
1513 {
1514 }
1515
1517 {
1518 scene->r.scemode = this->scemode;
1519 scene->r.cfra = this->cfra;
1520 scene->r.subframe = this->subframe;
1521 scene->r.mode &= this->mode | ~R_NO_CAMERA_SWITCH;
1522 }
1523};
1524
1526 Strip *strip,
1527 float frame_index,
1528 float timeline_frame)
1529{
1530 ImBuf *ibuf = nullptr;
1531 Object *camera;
1532
1533 /* Rendering from UI (through sequencer_preview_area_draw) can crash in
1534 * very many cases since other renders (material preview, an actual render etc.)
1535 * can be started while this sequence preview render is running. The only proper
1536 * solution is to make the sequencer preview render a proper job, which can be
1537 * stopped when needed. This would also give a nice progress bar for the preview
1538 * space so that users know there's something happening.
1539 *
1540 * As a result the active scene now only uses viewport rendering for the sequencer
1541 * preview. This is far from nice, but is the only way to prevent crashes at this
1542 * time.
1543 */
1544
1545 Scene *scene = strip->scene;
1546 BLI_assert(scene != nullptr);
1547
1548 /* Prevent rendering scene recursively. */
1549 if (scene == context->scene) {
1550 return nullptr;
1551 }
1552
1553 const bool is_rendering = G.is_rendering;
1554 const bool is_preview = !context->render && (context->scene->r.seq_prev_type) != OB_RENDER;
1555 const float frame = float(scene->r.sfra) + frame_index + float(strip->anim_startofs);
1556
1557 ViewLayer *view_layer = get_view_layer_for_scene_strip(scene, strip);
1558 Depsgraph *depsgraph = get_depsgraph_for_scene_strip(context->bmain, scene, view_layer);
1559
1560 BKE_scene_frame_set(scene, frame);
1561
1562 if (strip->scene_camera) {
1563 camera = strip->scene_camera;
1564 }
1565 else {
1567 camera = scene->camera;
1568 }
1569
1570#if 0 /* UNUSED */
1571 bool have_seq = (scene->r.scemode & R_DOSEQ) && scene->ed && scene->ed->seqbase.first;
1572#endif
1573 const bool is_viewport_render = view3d_fn && is_preview && camera;
1574 const bke::compositor::ExecutionMode execution_mode =
1575 is_viewport_render ? bke::compositor::ExecutionMode::Preview :
1577 const bool have_comp = bke::compositor::is_enabled(*scene, execution_mode);
1578
1579 if (have_comp == false && camera == nullptr) {
1580 return nullptr;
1581 }
1582
1583 /* Prevent eternal loop. */
1584 scene->r.scemode &= ~R_DOSEQ;
1585
1586 /* Temporarily disable camera switching to enforce using `camera`. */
1587 scene->r.mode |= R_NO_CAMERA_SWITCH;
1588
1589 if (is_viewport_render) {
1590 int width, height;
1591 BKE_render_resolution(&scene->r, false, &width, &height);
1592
1593 /* for old scene this can be uninitialized,
1594 * should probably be added to do_versions at some point if the functionality stays */
1595 if (context->scene->r.seq_prev_type == 0) {
1596 context->scene->r.seq_prev_type = OB_SOLID;
1597 }
1598
1599 ibuf = render_scene_strip_viewport(context->scene,
1600 scene,
1601 strip,
1602 depsgraph,
1603 camera,
1604 eDrawType(context->scene->r.seq_prev_type),
1605 width,
1606 height,
1607 context->view_id,
1608 context->gpu_offscreen,
1609 context->gpu_viewport);
1610 }
1611 else {
1612 Render *re = RE_GetSceneRender(scene);
1613 const int totviews = BKE_scene_multiview_num_views_get(&scene->r);
1614
1615 /*
1616 * XXX: this if can be removed when sequence preview rendering uses the job system
1617 *
1618 * Disable rendered preview for sequencer while rendering - invoked render job will
1619 * conflict with already running render
1620 *
1621 * When rendering from command line renderer is called from main thread, in this
1622 * case it's always safe to render scene here
1623 */
1624
1625 if (is_preview && (is_rendering && !G.background)) {
1626 return ibuf;
1627 }
1628
1629 Array<SeqResult> ibufs_arr(totviews);
1630
1631 if (re == nullptr) {
1632 re = RE_NewSceneRender(scene);
1633 }
1634
1635 const float subframe = frame - floorf(frame);
1636
1637 RE_display_share(re, context->render);
1638
1639 RE_RenderFrame(re,
1640 context->bmain,
1641 scene,
1642 have_comp ? nullptr : view_layer,
1643 camera,
1644 floorf(frame),
1645 subframe,
1646 false);
1647
1648 RE_display_free(re);
1649
1650 /* restore previous state after it was toggled on & off by RE_RenderFrame */
1651 G.is_rendering = is_rendering;
1652
1653 for (int view_id = 0; view_id < totviews; view_id++) {
1654 RenderData localcontext = *context;
1655 RenderResult rres;
1656
1657 localcontext.view_id = view_id;
1658
1659 RE_AcquireResultImage(re, &rres, view_id);
1660
1661 if (rres.ibuf && rres.ibuf->float_data()) {
1662 ibufs_arr[view_id].image = IMB_allocImBuf(rres.rectx, rres.recty, ImBufFlags::Zero);
1663 ibufs_arr[view_id].image->float_buffer = rres.ibuf->float_buffer;
1664 }
1665 else if (rres.ibuf && rres.ibuf->byte_data()) {
1666 ibufs_arr[view_id].image = IMB_allocImBuf(rres.rectx, rres.recty, ImBufFlags::Zero);
1667 ibufs_arr[view_id].image->byte_buffer = rres.ibuf->byte_buffer;
1668 }
1669 else {
1670 ibufs_arr[view_id].image = IMB_allocImBuf(rres.rectx, rres.recty, ImBufFlags::ByteData);
1671 }
1672
1673 if (view_id != context->view_id) {
1674 Scene *orig_scene = prefetch_get_original_scene(context);
1675 if (orig_scene->ed->cache_flag & SEQ_CACHE_STORE_RAW) {
1676 source_image_cache_put(&localcontext, strip, timeline_frame, ibufs_arr[view_id]);
1677 }
1678 }
1679
1681 }
1682
1683 /* Return the requested image; release the others. */
1684 ibuf = ibufs_arr[context->view_id].image;
1685 for (SeqResult &res : ibufs_arr) {
1686 if (res.image != ibuf) {
1687 IMB_freeImBuf(res.image);
1688 }
1689 }
1690 }
1691
1692 return ibuf;
1693}
1694
1696 Main *bmain, Scene *timeline_scene, const Strip *strip, float frame_index, int size)
1697{
1698 if (view3d_fn == nullptr || G.is_rendering) {
1699 return nullptr;
1700 }
1701 Scene *scene = strip->scene;
1702 if (ELEM(scene, nullptr, timeline_scene)) {
1703 return nullptr; /* No scene, or recursion with sequencer scene. */
1704 }
1705
1706 /* Render at thumbnail size. */
1707 int width, height;
1708 BKE_render_resolution(&scene->r, false, &width, &height);
1709 if (width <= 0 || height <= 0) {
1710 return nullptr;
1711 }
1712 image_size_to_thumb_size(width, height, size);
1713
1714 ViewLayer *view_layer = get_view_layer_for_scene_strip(scene, strip);
1715 Depsgraph *depsgraph = get_depsgraph_for_scene_strip(bmain, scene, view_layer);
1716
1717 SceneStripSavedState save_state(scene);
1718
1719 /* Note: passed frame index already includes `strip->anim_startofs`. */
1720 const float frame = float(scene->r.sfra) + frame_index;
1721 BKE_scene_frame_set(scene, frame);
1722
1723 Object *camera;
1724 if (strip->scene_camera) {
1725 camera = strip->scene_camera;
1726 }
1727 else {
1729 camera = scene->camera;
1730 }
1731 if (camera == nullptr) {
1732 return nullptr;
1733 }
1734
1735 /* Prevent rendering this scene's own sequencer, and enforce specific camera. */
1736 scene->r.scemode &= ~R_DOSEQ;
1737 scene->r.mode |= R_NO_CAMERA_SWITCH;
1738
1739 ImBuf *ibuf = render_scene_strip_viewport(timeline_scene,
1740 scene,
1741 strip,
1742 depsgraph,
1743 camera,
1744 OB_SOLID,
1745 width,
1746 height,
1747 0,
1748 nullptr,
1749 nullptr);
1750
1751 return ibuf;
1752}
1753
1755 Strip *strip,
1756 float frame_index,
1757 float timeline_frame)
1758{
1759 PRF_scope_with_name("SeqRenderScene", ProfileCategory::Draw);
1760
1761 SeqResult out;
1762 if (strip->scene == nullptr) {
1763 out.image = create_missing_media_image(context, context->rectx, context->recty);
1764 return out;
1765 }
1766
1767 SceneStripSavedState save_state(strip->scene);
1768 out.image = seq_render_scene_strip_ex(context, strip, frame_index, timeline_frame);
1769 if (out.image && !out.image->can_contain_alpha()) {
1770 out.is_opaque_before_transform = true;
1771 }
1772 return out;
1773}
1774
1780 Strip *strip,
1781 float frame_index)
1782{
1783 SeqResult out;
1784 ListBaseT<Strip> *seqbase = nullptr;
1785 ListBaseT<SeqTimelineChannel> *channels = nullptr;
1786 int offset;
1787
1788 seqbase = get_seqbase_from_strip(strip, &channels, &offset);
1789
1790 if (seqbase && !seqbase->is_empty()) {
1791
1792 frame_index += offset;
1793
1794 if (strip->flag & SEQ_SCENE_STRIPS && strip->scene) {
1795 if (AnimData *adt = BKE_animdata_from_id(&strip->scene->id)) {
1797 context->depsgraph, frame_index);
1798 BKE_animsys_evaluate_animdata(&strip->scene->id,
1799 adt,
1800 &anim_eval_context,
1802 DEG_is_active(context->depsgraph));
1803 }
1804 }
1805
1806 intra_frame_cache_set_cur_frame(context->scene,
1807 frame_index,
1808 context->view_id,
1809 context->rectx,
1810 context->recty,
1811 context->render != nullptr);
1812 out = seq_render_strip_stack(context,
1813 state,
1814 channels,
1815 seqbase,
1816 /* scene strips don't have their start taken into account */
1817 frame_index,
1818 0);
1819 }
1820
1821 return out;
1822}
1823
1825
1826/* -------------------------------------------------------------------- */
1829
1832 Strip *strip,
1833 float timeline_frame,
1834 bool *r_is_proxy_image)
1835{
1836 SeqResult out;
1837 float frame_index = give_frame_index(context->scene, strip, timeline_frame);
1838 if (strip->type == STRIP_TYPE_META) {
1839 out = do_render_strip_seqbase(context, state, strip, frame_index);
1840 out.is_opaque_before_transform = out.image && !out.image->can_contain_alpha();
1841 }
1842 else if (strip->type == STRIP_TYPE_SCENE) {
1843 /* Recursive check. */
1844 if (!state->scenes_in_progress.contains(strip->scene)) {
1845 state->scenes_in_progress.add(context->scene);
1846
1847 if (strip->flag & SEQ_SCENE_STRIPS) {
1848 if (strip->scene && (context->scene != strip->scene)) {
1849 /* Use the Scene sequence-strip's scene for the context when rendering the
1850 * scene's sequences (necessary for multi-cam selector among others). */
1851 RenderData local_context = *context;
1852 local_context.scene = strip->scene;
1853 local_context.skip_cache = true;
1854
1855 out = do_render_strip_seqbase(&local_context, state, strip, frame_index);
1856 }
1857 }
1858 else {
1859 /* scene can be nullptr after deletions */
1860 out = seq_render_scene_strip(context, strip, frame_index, timeline_frame);
1861 }
1862
1863 /* End recursive check. */
1864 state->scenes_in_progress.remove(context->scene);
1865 }
1866 }
1867 else if (strip->is_effect()) {
1868 out = seq_render_effect_strip_impl(context, state, strip, timeline_frame);
1869 }
1870 else if (strip->type == STRIP_TYPE_IMAGE) {
1871 out.image = seq_render_image_strip(context, strip, timeline_frame, r_is_proxy_image);
1872 if (out.image && !out.image->can_contain_alpha()) {
1873 out.is_opaque_before_transform = true;
1874 }
1875 }
1876 else if (strip->type == STRIP_TYPE_MOVIE) {
1877 out.image = seq_render_movie_strip(context, strip, timeline_frame, r_is_proxy_image);
1878 if (out.image && !out.image->can_contain_alpha()) {
1879 out.is_opaque_before_transform = true;
1880 }
1881 }
1882 else if (strip->type == STRIP_TYPE_MOVIECLIP) {
1884 context, strip, round_fl_to_int(frame_index), r_is_proxy_image);
1885 if (out.image && !out.image->can_contain_alpha()) {
1886 out.is_opaque_before_transform = true;
1887 }
1888
1889 if (out.image) {
1890 /* duplicate frame so movie cache wouldn't be confused by sequencer's stuff */
1891 ImBuf *i = IMB_dupImBuf(out.image);
1892 IMB_freeImBuf(out.image);
1893 out.image = i;
1894 }
1895 }
1896 else if (strip->type == STRIP_TYPE_MASK) {
1897 out.image = seq_render_mask_strip(context, strip, frame_index);
1898 }
1899
1900 return out;
1901}
1902
1905 Strip *strip,
1906 float timeline_frame)
1907{
1908 PRF_scope_with_name("SeqRenderStrip", ProfileCategory::Draw);
1909
1910 bool use_preprocess = false;
1911 bool is_proxy_image = false;
1912
1913 SeqResult res = intra_frame_cache_get_preprocessed(context->scene, strip);
1914 if (res.is_valid()) {
1915 return res;
1916 }
1917
1918 /* Proxies are not stored in cache. */
1919 if (!can_use_proxy(context, strip, rendersize_to_proxysize(context->preview_render_size))) {
1920 res = source_image_cache_get(context, strip, timeline_frame);
1921 }
1922
1923 if (!res.is_valid()) {
1924 res = do_render_strip_uncached(context, state, strip, timeline_frame, &is_proxy_image);
1925 }
1926
1927 if (res.is_valid()) {
1928 use_preprocess = seq_input_have_to_preprocess(strip);
1930 context, state, strip, res, timeline_frame, use_preprocess, is_proxy_image);
1931 intra_frame_cache_put_preprocessed(context->scene, strip, res);
1932 }
1933
1934 if (!res.is_valid()) {
1935 res.image = IMB_allocImBuf(context->rectx, context->recty, ImBufFlags::ByteData);
1936 }
1937
1938 return res;
1939}
1940
1942{
1943 return ELEM(strip->blend_mode, STRIP_BLEND_ALPHAOVER, STRIP_BLEND_ALPHAUNDER);
1944}
1945
1947{
1949 float fac = strip->blend_opacity / 100.0f;
1950 StripEarlyOut early_out = sh.early_out(strip, fac);
1951
1953 return early_out;
1954 }
1955
1957 if (early_out == StripEarlyOut::UseInput2) {
1959 }
1960 if (early_out == StripEarlyOut::UseInput1) {
1962 }
1963 }
1964 return early_out;
1965}
1966
1969 Strip *strip,
1970 float timeline_frame,
1971 const SeqResult &src1,
1972 const SeqResult &src2)
1973{
1975 BLI_assert(sh.execute != nullptr);
1976 float fac = strip->blend_opacity / 100.0f;
1977 bool swap_input = seq_must_swap_input_in_blend_mode(strip);
1978
1979 SeqResult out = sh.execute(context,
1980 state,
1981 strip,
1982 timeline_frame,
1983 fac,
1984 swap_input ? src2 : src1,
1985 swap_input ? src1 : src2);
1986 return out;
1987}
1988
1989static bool is_opaque_alpha_over(const Strip *strip, const RenderData *context)
1990{
1991 if (strip->blend_mode != STRIP_BLEND_ALPHAOVER) {
1992 return false;
1993 }
1994 if (strip->blend_opacity < 100.0f) {
1995 return false;
1996 }
1997 if (strip->mul < 1.0f && (strip->flag & SEQ_MULTIPLY_ALPHA) != 0) {
1998 return false;
1999 }
2000 for (StripModifierData &smd : strip->modifiers) {
2001 const bool modifier_enabled = (context->render && !(smd.flag & STRIP_MODIFIER_FLAG_MUTE)) ||
2002 (!context->render &&
2004 /* Assume result is not opaque if there is an enabled Mask modifier, which could
2005 * introduce alpha. */
2006 if (modifier_enabled && smd.type == eSeqModifierType_Mask) {
2007 return false;
2008 }
2009 }
2010 return true;
2011}
2012
2015 ListBaseT<SeqTimelineChannel> *channels,
2016 ListBaseT<Strip> *seqbasep,
2017 float timeline_frame,
2018 int chanshown)
2019{
2020 PRF_scope_with_name("SeqRenderStrips", ProfileCategory::Draw);
2022 context->scene, channels, seqbasep, timeline_frame, chanshown);
2023 if (strips.is_empty()) {
2024 return {};
2025 }
2026
2027 OpaqueQuadTracker opaques;
2028
2029 int64_t i;
2030 SeqResult out;
2031 for (i = strips.size() - 1; i >= 0; i--) {
2032 Strip *strip = strips[i];
2033
2034 out = intra_frame_cache_get_composite(context->scene, strip);
2035 if (out.is_valid()) {
2036 break;
2037 }
2038 if (strip->blend_mode == STRIP_BLEND_REPLACE) {
2039 out = seq_render_strip(context, state, strip, timeline_frame);
2040 break;
2041 }
2042
2044
2045 if (early_out == StripEarlyOut::DoEffect && opaques.is_occluded(context, strip, i)) {
2046 early_out = StripEarlyOut::UseInput1;
2047 }
2048
2049 /* "Alpha over" is default for all strips, and it can be optimized in some cases:
2050 * - If the whole image has no transparency, there's no need to do actual blending.
2051 * - Likewise, if we are at the bottom of the stack; the input can be used as-is.
2052 * - If we are rendering a strip that is known to be opaque, we mark it as an occluder,
2053 * so that strips below can check if they are completely hidden. */
2054 if (!out.is_valid() && early_out == StripEarlyOut::DoEffect &&
2055 is_opaque_alpha_over(strip, context))
2056 {
2057 SeqResult test = seq_render_strip(context, state, strip, timeline_frame);
2058 BLI_assert(test.is_valid());
2059 if (!test.image->can_contain_alpha() || i == 0) {
2060 early_out = StripEarlyOut::UseInput2;
2061 }
2062 else {
2063 early_out = StripEarlyOut::DoEffect;
2064 }
2065 /* Free the image. It is stored in cache, so this doesn't affect performance. */
2066 IMB_freeImBuf(test.image);
2067
2068 /* Check whether the strip (before transform) content was opaque. */
2069 if (test.is_opaque_before_transform) {
2070 opaques.add_occluder(context, strip, i);
2071 }
2072 }
2073
2074 switch (early_out) {
2077 out = seq_render_strip(context, state, strip, timeline_frame);
2078 break;
2080 if (i == 0) {
2081 out.image = IMB_allocImBuf(context->rectx, context->recty, ImBufFlags::ByteData);
2082 }
2083 break;
2085 if (i == 0) {
2086 /* This is an effect at the bottom of the stack, so one of the inputs does not exist yet:
2087 * create one that is transparent black. Extra optimization for an alpha over strip at
2088 * the bottom, we can just return it instead of blending with black. */
2089 SeqResult ibuf2 = seq_render_strip(context, state, strip, timeline_frame);
2090 const bool use_float = ibuf2.is_valid() && ibuf2.image->float_data();
2091 SeqResult ibuf1;
2092 ibuf1.image = IMB_allocImBuf(context->rectx,
2093 context->recty,
2095 seq_imbuf_assign_sequencer_space(context->scene, ibuf1.image);
2096
2098 context, state, strip, timeline_frame, ibuf1, ibuf2);
2099 IMB_metadata_copy(out.image, ibuf2.image);
2100
2101 intra_frame_cache_put_composite(context->scene, strip, out);
2102
2103 IMB_freeImBuf(ibuf1.image);
2104 IMB_freeImBuf(ibuf2.image);
2105 }
2106 break;
2107 }
2108
2109 if (out.is_valid()) {
2110 break;
2111 }
2112 }
2113
2114 i++;
2115 for (; i < strips.size(); i++) {
2116 Strip *strip = strips[i];
2117
2118 if (opaques.is_occluded(context, strip, i)) {
2119 continue;
2120 }
2121
2123 SeqResult ibuf1 = out;
2124 SeqResult ibuf2 = seq_render_strip(context, state, strip, timeline_frame);
2125
2127 context, state, strip, timeline_frame, ibuf1, ibuf2);
2128
2129 IMB_freeImBuf(ibuf1.image);
2130 IMB_freeImBuf(ibuf2.image);
2131 }
2132
2133 intra_frame_cache_put_composite(context->scene, strip, out);
2134 }
2135
2136 return out;
2137}
2138
2139ImBuf *render_give_ibuf(const RenderData *context, float timeline_frame, int chanshown)
2140{
2141 Scene *scene = context->scene;
2142 Editing *ed = editing_get(scene);
2143 ListBaseT<Strip> *seqbasep;
2144 ListBaseT<SeqTimelineChannel> *channels;
2145
2146 if (ed == nullptr) {
2147 return nullptr;
2148 }
2149
2150 if ((chanshown < 0) && !ed->metastack.is_empty()) {
2151 int count = ed->metastack.count();
2152 count = max_ii(count + chanshown, 0);
2153 MetaStack *ms = static_cast<MetaStack *>(BLI_findlink(&ed->metastack, count));
2154 seqbasep = &ms->old_strip->seqbase;
2155 channels = &ms->old_strip->channels;
2156 chanshown = 0;
2157 }
2158 else {
2159 seqbasep = ed->current_strips();
2160 channels = ed->current_channels();
2161 }
2162
2164 timeline_frame,
2165 context->view_id,
2166 context->rectx,
2167 context->recty,
2168 context->render != nullptr);
2169
2170 Scene *orig_scene = prefetch_get_original_scene(context);
2171 ImBuf *out = nullptr;
2172 if (!context->skip_cache) {
2173 out = final_image_cache_get(orig_scene,
2174 timeline_frame,
2175 context->view_id,
2176 chanshown,
2177 {context->rectx, context->recty},
2178 context->render != nullptr);
2179 }
2180
2182 scene, channels, seqbasep, timeline_frame, chanshown);
2183
2185 state.is_current_frame = timeline_frame == BKE_scene_frame_get(scene);
2186
2187 if (!strips.is_empty() && !out) {
2188 std::scoped_lock lock(seq_render_mutex);
2190 /* Try to make space before we add any new frames to the cache if it is full.
2191 * If we do this after we have added the new cache, we risk removing what we just added. */
2192 evict_caches_if_full(orig_scene);
2193
2194 out = seq_render_strip_stack(context, &state, channels, seqbasep, timeline_frame, chanshown)
2195 .image;
2196
2197 if (out && (orig_scene->ed->cache_flag & SEQ_CACHE_STORE_FINAL_OUT) && !context->skip_cache) {
2198 final_image_cache_put(orig_scene,
2199 timeline_frame,
2200 context->view_id,
2201 chanshown,
2202 {context->rectx, context->recty},
2203 context->render != nullptr,
2204 out);
2205 }
2206 }
2207
2208 seq_prefetch_start(context, timeline_frame);
2209
2210 return out;
2211}
2212
2215 float timeline_frame,
2216 int chan_shown,
2217 ListBaseT<SeqTimelineChannel> *channels,
2218 ListBaseT<Strip> *seqbasep)
2219{
2220
2221 return seq_render_strip_stack(context, state, channels, seqbasep, timeline_frame, chan_shown);
2222}
2223
2224ImBuf *render_give_ibuf_direct(const RenderData *context, float timeline_frame, Strip *strip)
2225{
2227 state.is_current_frame = timeline_frame == BKE_scene_frame_get(context->scene);
2228
2230
2231 intra_frame_cache_set_cur_frame(context->scene,
2232 timeline_frame,
2233 context->view_id,
2234 context->rectx,
2235 context->recty,
2236 context->render != nullptr);
2237 ImBuf *ibuf = seq_render_strip(context, &state, strip, timeline_frame).image;
2238 return ibuf;
2239}
2240
2241bool render_is_muted(const ListBaseT<SeqTimelineChannel> *channels, const Strip *strip)
2242{
2243 SeqTimelineChannel *channel = channel_get_by_index(channels, strip->channel);
2244 return strip->flag & SEQ_MUTE || channel->is_muted();
2245}
2246
2248
2249float get_render_scale_factor(eSpaceSeq_Proxy_RenderSize render_size, short scene_render_scale)
2250{
2251 return render_size == SEQ_RENDER_SIZE_SCENE ? scene_render_scale / 100.0f :
2252 rendersize_to_scale_factor(render_size);
2253}
2254
2256{
2257 return get_render_scale_factor(context.preview_render_size, context.scene->r.size);
2258}
2259
2261{
2262 GPUContext *active_ctx = GPU_context_active_get();
2263 if (active_ctx != nullptr) {
2266 }
2267
2268 /* Use GPU context from VSE render data (e.g. prefetch render). */
2269 if (rd.gpu_context.ghost_context != nullptr) {
2273 }
2274
2275 /* Use main GPU context (regular preview area drawing, or "render sequence preview" operator). */
2276 if (BLI_thread_is_main() || rd.render == nullptr) {
2279 }
2280
2281 /* Use GPU context from Render. */
2282 GHOST_IContext *render_ghost_context = RE_system_gpu_context_get(rd.render);
2283 if (!render_ghost_context) {
2285 }
2286
2287 WM_system_gpu_context_activate(render_ghost_context);
2288 void *render_gpu_context = RE_blender_gpu_context_ensure(rd.render);
2290 GPU_context_active_set(static_cast<GPUContext *>(render_gpu_context));
2292}
2293
2295{
2297 return;
2298 }
2301 return;
2302 }
2303
2304 /* Use GPU context from VSE render data (e.g. prefetch render). */
2305 if (rd.gpu_context.ghost_context != nullptr) {
2308 return;
2309 }
2310
2311 /* Use main GPU context (regular preview area drawing, or "render sequence preview" operator). */
2312 if (BLI_thread_is_main() || rd.render == nullptr) {
2314 return;
2315 }
2316
2317 /* Use GPU context from Render. */
2318 GHOST_IContext *render_ghost_context = RE_system_gpu_context_get(rd.render);
2319 BLI_assert(render_ghost_context != nullptr);
2320 GPU_context_active_set(nullptr);
2322 WM_system_gpu_context_release(render_ghost_context);
2323}
2324
2325} // namespace blender::seq
#define FILE_MAX
#define BLI_path_join(...)
#define ID_BLEND_PATH_FROM_GLOBAL(_id)
Definition DNA_ID.h:691
Read Blender memory allocation and freeing.
#define PRF_scope_with_name(ui_name, category)
volatile int lock
#define ELEM(...)
#define BLI_assert_msg(a, msg)
#define STREQ(a, b)
constexpr int64_t first() const
constexpr IndexRange()=default
int64_t size() const
void append(const T &value)
const T & last(const int64_t n=0) const
bool is_empty() const
IndexRange index_range() const
const T & data(const Action &owning_action) const
ImBuf * decode_frame(int frame_index, IMB_Proxy_Size proxy_size)
#define roundf(x)
#define rot(x, k)
void camera(KernelGlobals &kg, const ShadingData &sd, float3 &outview, float &outdepth, float &outdist)
float3x3 scale(float3x3 mat, float2 scale)
const int state
bool is_enabled(const Scene &scene, ExecutionMode mode)
void GPU_activate_secondary_context(const GPUSecondaryContextData &data)
void GPU_deactivate_secondary_context(const GPUSecondaryContextData &data)
CartesianBasis invert(const CartesianBasis &basis)
AxisSigned cross(const AxisSigned a, const AxisSigned b)
MatT from_scale(const VecBase< typename MatT::base_type, ScaleDim > &scale)
MatT from_origin_transform(const MatT &transform, const VectorT origin)
MatT from_location(const typename MatT::loc_type &location)
MatT from_loc_rot_scale(const typename MatT::loc_type &location, const RotationT &rotation, const VecBase< typename MatT::base_type, ScaleDim > &scale)
VecBase< T, 3 > transform_point(const CartesianBasis &basis, const VecBase< T, 3 > &v)
void ensure_ibuf_is_sequencer_space(const Scene *scene, ImBuf *ibuf, bool make_float)
Definition render.cc:170
static ImBuf * seq_render_image_strip_view(const RenderData *context, Strip *strip, const char *filepath, const char *prefix, int view_id)
Definition render.cc:923
EffectHandle strip_blend_mode_handle_get(Strip *strip)
Definition effects.cc:293
void source_image_cache_put(const RenderData *context, const Strip *strip, float timeline_frame, const SeqResult &image)
SeqResult intra_frame_cache_get_preprocessed(Scene *scene, const Strip *strip)
static ImBuf * seq_render_movie_strip(const RenderData *context, Strip *strip, float timeline_frame, bool *r_is_proxy_image)
Definition render.cc:1144
MovieReaderAccessor movie_reader_cache_acquire_view(Scene &cache_scene, const Scene &key_scene, const Strip &strip, const int view_id, const int frame_index)
bool seq_strip_do_multiview_render(const Scene *scene, const Strip *strip, const char *filepath, char *r_prefix)
Definition render.cc:959
ImBuf *(*)(Depsgraph *, Scene *, View3DShading *, eDrawType, Object *, int, int, ImBufFlags, eV3DOffscreenDrawFlag, int, const char *, GPUOffScreen *, GPUViewport *, char *) DrawViewFn
float2 image_transform_mirror_factor_get(const Strip *strip)
void ensure_ibuf_is_rgba(ImBuf *ibuf)
Definition render.cc:903
static SeqResult seq_render_strip_stack_apply_effect(const RenderData *context, SeqRenderState *state, Strip *strip, float timeline_frame, const SeqResult &src1, const SeqResult &src2)
Definition render.cc:1967
EffectHandle strip_effect_handle_get(Strip *strip)
Definition effects.cc:284
static SeqResult seq_render_effect_strip_impl(const RenderData *context, SeqRenderState *state, Strip *strip, float timeline_frame)
Definition render.cc:815
ImBuf * render_scene_strip_thumbnail(Main *bmain, Scene *timeline_scene, const Strip *strip, float frame_index, int size)
Definition render.cc:1695
ImBuf * render_give_ibuf(const RenderData *context, float timeline_frame, int chanshown)
Definition render.cc:2139
void movie_reader_cache_timestamp_bump()
void intra_frame_cache_put_composite(Scene *scene, const Strip *strip, const SeqResult &result)
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
static SeqResult seq_render_strip_stack(const RenderData *context, SeqRenderState *state, ListBaseT< SeqTimelineChannel > *channels, ListBaseT< Strip > *seqbasep, float timeline_frame, int chanshown)
Definition render.cc:2013
float give_frame_index(const Scene *scene, const Strip *strip, float timeline_frame)
Definition strip_time.cc:43
static SeqResult seq_render_scene_strip(const RenderData *context, Strip *strip, float frame_index, float timeline_frame)
Definition render.cc:1754
Array< float2 > image_transform_quad_get(const Scene *scene, const Strip *strip)
static bool is_opaque_alpha_over(const Strip *strip, const RenderData *context)
Definition render.cc:1989
bool render_is_muted(const ListBaseT< SeqTimelineChannel > *channels, const Strip *strip)
Definition render.cc:2241
static bool seq_must_swap_input_in_blend_mode(Strip *strip)
Definition render.cc:1941
Editing * editing_get(const Scene *scene)
Definition sequencer.cc:304
static void ensure_ibuf_is_color_space(ImBuf *ibuf, bool make_float, const char *to_colorspace)
Definition render.cc:119
static ImBuf * seq_render_image_strip(const RenderData *context, Strip *strip, int timeline_frame, bool *r_is_proxy_image)
Definition render.cc:1001
static Depsgraph * get_depsgraph_for_scene_strip(Main *bmain, Scene *scene, ViewLayer *view_layer)
Definition render.cc:1419
SeqResult seq_render_strip(const RenderData *context, SeqRenderState *state, Strip *strip, float timeline_frame)
Definition render.cc:1903
ImBuf * seq_proxy_fetch(const RenderData *context, Strip *strip, int timeline_frame)
Definition proxy.cc:291
float get_render_scale_factor(eSpaceSeq_Proxy_RenderSize render_size, short scene_render_scale)
Definition render.cc:2249
static ImBuf * seq_get_movieclip_ibuf(Strip *strip, MovieClipUser user)
Definition render.cc:1258
static void multiply_ibuf(ImBuf *ibuf, const float fmul, const bool multiply_alpha)
Definition render.cc:600
static bool is_quad_a_inside_b(const StripScreenQuad &a, const StripScreenQuad &b)
Definition render.cc:257
void intra_frame_cache_set_cur_frame(Scene *scene, float frame, int view_id, int width, int height, bool is_render)
void seq_prefetch_start(const RenderData *context, float timeline_frame)
Definition prefetch.cc:686
static ImBuf * create_missing_media_image(const RenderData *context, int width, int height)
Definition render.cc:984
static SeqResult seq_render_preprocess_ibuf(const RenderData *context, SeqRenderState *state, Strip *strip, const SeqResult &input, float timeline_frame, bool use_preprocess, const bool is_proxy_image)
Definition render.cc:783
Vector< Strip * > query_rendered_strips_sorted(const Scene *scene, ListBaseT< SeqTimelineChannel > *channels, ListBaseT< Strip > *seqbase, const int timeline_frame, const int chanshown)
Definition iterator.cc:253
void intra_frame_cache_put_preprocessed(Scene *scene, const Strip *strip, const SeqResult &result)
int seq_multiview_num_files_get(const Scene *scene, eImageFormat_ViewsFormat views_format)
Definition multiview.cc:29
SeqResult seq_render_give_ibuf_seqbase(const RenderData *context, SeqRenderState *state, float timeline_frame, int chan_shown, ListBaseT< SeqTimelineChannel > *channels, ListBaseT< Strip > *seqbasep)
Definition render.cc:2213
static ImBuf * seq_render_movie_strip_custom_file_proxy(const RenderData *context, Strip *strip, int timeline_frame)
Definition render.cc:1074
static ImBuf * seq_render_mask_strip(const RenderData *context, Strip *strip, float frame_index)
Definition render.cc:1399
void render_new_render_data(Main *bmain, Depsgraph *depsgraph, Scene *scene, int rectx, int recty, eSpaceSeq_Proxy_RenderSize preview_render_size, Render *render, RenderData *r_context)
Definition render.cc:194
static ImBuf * render_scene_strip_viewport(const Scene *display_scene, Scene *scene, const Strip *strip, Depsgraph *depsgraph, Object *camera, eDrawType draw_type, int width, int height, int view_id, GPUOffScreen *gpu_offscreen, GPUViewport *gpu_viewport)
Definition render.cc:1442
static bool is_strip_covering_screen(const RenderData *context, const Strip *strip)
Definition render.cc:503
static float3x3 calc_strip_transform_matrix(const Scene *scene, const Strip *strip, const int2 in_size, const int2 out_size, const float image_scale_factor, const float preview_scale_factor)
Definition render.cc:417
float strip_speed_effect_target_frame_get(Scene *scene, Strip *strip_speed, float timeline_frame, int input)
static bool strip_result_covers_strip_quad(const RenderData *context, const Strip *strip, const ImBuf *image, const float3x3 &matrix, const float crop_scale_factor)
Definition render.cc:471
void render_end_gpu(const RenderData &rd, GpuContextState state)
Definition render.cc:2294
ImBuf * final_image_cache_get(Scene *scene, float timeline_frame, int view_id, int display_channel, int2 image_size, bool is_render)
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
StripScreenQuad get_strip_screen_quad(const RenderData *context, const Strip *strip)
Definition render.cc:240
static StripEarlyOut strip_get_early_out_for_blend_mode(Strip *strip)
Definition render.cc:1946
DrawViewFn view3d_fn
Definition render.cc:102
SeqResult source_image_cache_get(const RenderData *context, const Strip *strip, float timeline_frame)
float2 image_transform_origin_get(const Scene *scene, const Strip *strip)
SeqTimelineChannel * channel_get_by_index(const ListBaseT< SeqTimelineChannel > *channels, const int channel_index)
Definition channels.cc:59
static bool seq_input_have_to_preprocess(const Strip *strip)
Definition render.cc:351
void final_image_cache_put(Scene *scene, float timeline_frame, int view_id, int display_channel, int2 image_size, bool is_render, ImBuf *image)
static Mutex seq_render_mutex
Definition render.cc:101
void image_size_to_thumb_size(int &r_width, int &r_height, int size)
static ImBuf * seq_render_scene_strip_ex(const RenderData *context, Strip *strip, float frame_index, float timeline_frame)
Definition render.cc:1525
static SeqResult do_render_strip_uncached(const RenderData *context, SeqRenderState *state, Strip *strip, float timeline_frame, bool *r_is_proxy_image)
Definition render.cc:1830
GpuContextState render_begin_gpu(const RenderData &rd)
Definition render.cc:2260
void modifier_apply_stack(ModifierApplyContext &context)
bool evict_caches_if_full(Scene *scene)
float rendersize_to_scale_factor(eSpaceSeq_Proxy_RenderSize render_size)
Definition proxy.cc:153
static void sequencer_preprocess_transform_crop(ImBuf *in, ImBuf *out, const RenderData *context, Strip *strip, const float3x3 &matrix, const bool scale_crop_values, const float preview_scale_factor)
Definition render.cc:551
static ViewLayer * get_view_layer_for_scene_strip(Scene *scene, const Strip *strip)
Definition render.cc:1409
void media_presence_set_missing(Scene *scene, const Strip *strip, bool missing)
static eIMBInterpolationFilterMode get_auto_filter(const StripTransform *transform)
Definition render.cc:532
static bool sequencer_use_crop(const Strip *strip)
Definition render.cc:341
static SeqResult input_preprocess(const RenderData *context, SeqRenderState *state, Strip *strip, float timeline_frame, const SeqResult &input, const bool is_proxy_image)
Definition render.cc:637
ListBaseT< Strip > * get_seqbase_from_strip(Strip *strip, ListBaseT< SeqTimelineChannel > **r_channels, int *r_offset)
ImBuf * seq_render_mask(Depsgraph *depsgraph, int width, int height, const Mask *mask, float frame_index, bool make_float)
Definition render.cc:1331
static void sequencer_image_crop_init(const Strip *strip, const ImBuf *in, float crop_scale_factor, rctf *r_crop)
Definition render.cc:456
static ImBuf * seq_render_movie_strip_view(const RenderData *context, Strip *strip, float timeline_frame, MovieReaderAccessor &reader, bool *r_is_proxy_image)
Definition render.cc:1101
MovieReaderAccessor movie_reader_cache_acquire(Scene &cache_scene, const Scene &key_scene, const Strip &strip, const int frame_index)
SeqResult intra_frame_cache_get_composite(Scene *scene, const Strip *strip)
bool can_use_proxy(const RenderData *context, const Strip *strip, IMB_Proxy_Size psize)
Definition proxy.cc:280
void ensure_ibuf_is_linear_space(ImBuf *ibuf, bool make_float)
Definition render.cc:176
static bool sequencer_use_transform(const Strip *strip)
Definition render.cc:328
static ImBuf * seq_render_movieclip_strip(const RenderData *context, Strip *strip, float frame_index, bool *r_is_proxy_image)
Definition render.cc:1273
Scene * prefetch_get_original_scene(const RenderData *context)
Definition prefetch.cc:176
float effect_fader_calc(Scene *scene, Strip *strip, float timeline_frame, const bool is_current_frame)
Definition effects.cc:318
static SeqResult do_render_strip_seqbase(const RenderData *context, SeqRenderState *state, Strip *strip, float frame_index)
Definition render.cc:1778
StripElem * render_give_stripelem(const Scene *scene, const Strip *strip, int timeline_frame)
Definition render.cc:220
static bool seq_need_scale_to_render_size(const Strip *strip, bool is_proxy_image)
Definition render.cc:388
void seq_imbuf_assign_sequencer_space(const Scene *scene, ImBuf *ibuf)
Definition render.cc:108
ImBuf * render_give_ibuf_direct(const RenderData *context, float timeline_frame, Strip *strip)
Definition render.cc:2224
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
Definition BLI_task.hh:69
void IMB_colormanagement_transform_byte_to_float(float *float_buffer, const unsigned char *byte_buffer, int width, int height, int channels, const char *from_colorspace, const char *to_colorspace)
void DRW_gpu_context_enable()
void * RE_blender_gpu_context_ensure(Render *re)
void DEG_graph_tag_relations_update(Depsgraph *graph)
void IMB_colormanagement_assign_float_colorspace(ImBuf *ibuf, const char *name)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
@ SEQ_RENDER_SIZE_SCENE
void RE_RenderFrame(Render *re, Main *bmain, Scene *scene, ViewLayer *single_layer, Object *camera_override, const int frame, const float subframe, const bool write_still)
void BKE_scene_graph_update_for_newframe(Depsgraph *depsgraph)
Definition scene.cc:2953
__int64 int64_t
Definition BKE_text.h:90
ImBuf * IMB_makeSingleUser(ImBuf *ibuf)
void IMB_free_byte_pixels(ImBuf *ibuf)
@ ADT_RECALC_ANIM
void IMB_saturation(ImBuf *ibuf, float sat)
const char * BKE_scene_multiview_render_view_name_get(const RenderData *rd, int view_id)
Definition scene.cc:3324
MaskRasterHandle * BKE_maskrasterize_handle_new()
MINLINE void copy_v3_v3(float r[3], const float a[3])
unsigned int uint
Definition BKE_text.h:55
void * MEM_new_array_uninitialized(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
bool BLI_path_abs(char path[FILE_MAX], const char *basepath) ATTR_NONNULL(1
bool DEG_is_active(const Depsgraph *depsgraph)
Definition depsgraph.cc:324
MINLINE int round_fl_to_int(float a)
size_t IMB_get_pixel_count(const ImBuf *ibuf)
Get the length of the data of the given image buffer in pixels.
float BKE_maskrasterize_handle_sample(MaskRasterHandle *mr_handle, const float xy[2])
@ SEQ_STORAGE_PROXY_CUSTOM_FILE
bool BKE_movieclip_proxy_enabled(MovieClip *clip)
void IMB_rectfill(ImBuf *drect, const float col[4])
Definition rectop.cc:1165
Depsgraph * DEG_graph_new(Main *bmain, Scene *scene, ViewLayer *view_layer, eEvaluationMode mode)
Definition depsgraph.cc:279
ImBuf * MOV_decode_frame(MovieReader *anim, int frame_index, IMB_Proxy_Size preview_size)
@ V3D_OFSDRAW_OVERRIDE_SCENE_SETTINGS
@ V3D_OFSDRAW_NO_WORLD_BACKGROUND_OVERRIDE
@ V3D_OFSDRAW_SHOW_ANNOTATION
void WM_system_gpu_context_release(GHOST_IContext *context)
const char * IMB_colormanagement_get_byte_colorspace(const ImBuf *ibuf)
MINLINE int max_ii(int a, int b)
void GPU_render_begin()
void GPU_context_active_set(GPUContext *)
int BKE_scene_multiview_num_views_get(const RenderData *rd)
Definition scene.cc:3193
@ MCLIP_PROXY_RENDER_UNDISTORT
@ MCLIP_PROXY_RENDER_USE_FALLBACK_RENDER
@ STRIP_MODIFIER_FLAG_SHOW_PREVIEW
@ MCLIP_PROXY_RENDER_SIZE_FULL
@ MCLIP_PROXY_RENDER_SIZE_100
void BKE_mask_evaluate(Mask *mask, float ctime, bool do_newframe)
@ LIB_ID_COPY_LOCALIZE
@ LIB_ID_COPY_NO_ANIMDATA
bool DRW_gpu_context_is_enabled()
void BKE_scene_frame_set(Scene *scene, float frame)
Definition scene.cc:2600
void BKE_render_resolution(const RenderData *r, const bool use_crop, int *r_width, int *r_height)
Definition scene.cc:3168
ImBuf * IMB_dupImBuf(const ImBuf *ibuf1)
AnimationEvalContext BKE_animsys_eval_context_construct(Depsgraph *depsgraph, float eval_time) ATTR_WARN_UNUSED_RESULT
Definition anim_sys.cc:602
Global G
Definition blender.cc:57
AnimData * BKE_animdata_from_id(const ID *id)
Definition anim_data.cc:93
ImBuf * IMB_load_image_from_filepath(const char *filepath, ImBufFlags flags, ColorManagedColorspaceSettings *colorspace_settings=nullptr)
Definition readimage.cc:201
void * BLI_findlink(const ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:541
void IMB_transform(const ImBuf *src, ImBuf *dst, eIMBTransformMode mode, eIMBInterpolationFilterMode filter, const float3x3 &transform_matrix, const rctf *src_crop)
Transform source image buffer onto destination image buffer using a transform matrix.
void DRW_gpu_context_disable()
Render * RE_GetSceneRender(const Scene *scene)
bool BLI_rctf_is_empty(const struct rctf *rect)
ViewLayer * DEG_get_input_view_layer(const Depsgraph *graph)
void IMB_freeImBuf(ImBuf *ibuf)
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
unsigned char uchar
Definition BKE_text.h:58
void GPU_render_end()
float BKE_scene_frame_get(const Scene *scene)
Definition scene.cc:2595
const char * IMB_colormanagement_role_colorspace_name_get(int role)
T * DEG_get_evaluated(const Depsgraph *depsgraph, T *id)
void DEG_graph_replace_owners(Depsgraph *depsgraph, Main *bmain, Scene *scene, ViewLayer *view_layer)
Definition depsgraph.cc:286
void IMB_flipx(ImBuf *ibuf)
void IMB_flipy(ImBuf *ibuf)
void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle, Mask *mask, int width, int height, bool do_aspect_correct, bool do_mask_aa, bool do_feather)
ImBuf * BKE_movieclip_get_stable_ibuf(MovieClip *clip, const MovieClipUser *user, MovieClipPostprocFlag postprocess_flag, float r_loc[2], float *r_scale, float *r_angle)
void BKE_maskrasterize_handle_free(MaskRasterHandle *mr_handle)
void DEG_debug_name_set(Depsgraph *depsgraph, const char *name)
@ DAG_EVAL_VIEWPORT
MovieReader * openanim(const char *filepath, ImBufFlags ibuf_flags, int streamindex, bool keep_original_colorspace, ColorManagedColorspaceSettings *colorspace_settings)
int BLI_thread_is_main()
Definition threads.cc:184
void IMB_buffer_float_rgba_from_float(float *dest, const float *src, int src_channels, int width, int height)
int isect_point_quad_v2(const float p[2], const float v1[2], const float v2[2], const float v3[2], const float v4[2])
eIMBInterpolationFilterMode
Definition IMB_imbuf.hh:337
@ IMB_FILTER_NEAREST
Definition IMB_imbuf.hh:338
@ IMB_FILTER_BOX
Definition IMB_imbuf.hh:342
@ IMB_FILTER_CUBIC_BSPLINE
Definition IMB_imbuf.hh:340
@ IMB_FILTER_CUBIC_MITCHELL
Definition IMB_imbuf.hh:341
@ IMB_FILTER_BILINEAR
Definition IMB_imbuf.hh:339
void WM_system_gpu_context_activate(GHOST_IContext *context)
@ R_SEQ_OVERRIDE_SCENE_SETTINGS
MatBase< float, 3, 3 > float3x3
void BKE_id_free(Main *bmain, void *idv)
@ SEQ_SPEED_USE_INTERPOLATION
void IMB_colormanagement_assign_byte_colorspace(ImBuf *ibuf, const char *name)
void BKE_movieclip_user_set_frame(MovieClipUser *user, int framenr)
ImBuf * IMB_allocImBuf(unsigned int x, unsigned int y, ImBufFlags flags)
void RE_display_share(Render *re, const Render *parent_re)
void BKE_animsys_evaluate_animdata(ID *id, AnimData *adt, const AnimationEvalContext *anim_eval_context, eAnimData_Recalc recalc, bool flush_to_original)
Definition anim_sys.cc:3716
@ V3D_SHADING_BACKGROUND_VIEWPORT
ViewLayer * BKE_view_layer_find(const Scene *scene, const char *layer_name)
void IMB_ImBufFromStereo3d(const Stereo3dFormat *s3d, ImBuf *ibuf_stereo3d, ImBuf **r_ibuf_left, ImBuf **r_ibuf_right)
MINLINE void copy_v3_fl(float r[3], float f)
ImBuf * BKE_movieclip_get_ibuf_flag(MovieClip *clip, const MovieClipUser *user, MovieClipFlag flag, MovieClipCacheFlag cache_flag)
@ SEQ_EDIT_SHOW_MISSING_MEDIA
@ SEQ_MOVIECLIP_RENDER_STABILIZED
@ SEQ_MOVIECLIP_RENDER_UNDISTORTED
bool BKE_scene_camera_switch_update(Scene *scene)
Definition scene.cc:2480
void IMB_metadata_copy(ImBuf *ibuf_dst, const ImBuf *ibuf_src)
bool BLI_rctf_isect(const struct rctf *src1, const struct rctf *src2, struct rctf *dest)
std::mutex Mutex
Definition BLI_mutex.hh:51
Render * RE_NewSceneRender(const Scene *scene)
float MOV_get_fps(const MovieReader *anim)
@ R_IMF_VIEWS_INDIVIDUAL
@ R_IMF_VIEWS_STEREO_3D
@ SEQ_TRANSFORM_FILTER_CUBIC_MITCHELL
@ SEQ_TRANSFORM_FILTER_BILINEAR
@ SEQ_TRANSFORM_FILTER_CUBIC_BSPLINE
@ SEQ_TRANSFORM_FILTER_NEAREST
ID * BKE_id_copy_ex(Main *bmain, const ID *id, ID **new_id_p, int flag)
Definition lib_id.cc:851
bool IMB_alloc_float_pixels(ImBuf *ibuf, unsigned int channels, bool initialize_pixels=true)
Scene * DEG_get_evaluated_scene(const Depsgraph *graph)
ViewLayer * BKE_view_layer_default_render(const Scene *scene)
void IMB_colormanagement_transform_float(float *buffer, int width, int height, int channels, const char *from_colorspace, const char *to_colorspace, bool predivide)
MINLINE int min_ii(int a, int b)
void BKE_scene_multiview_view_prefix_get(const Scene *scene, const char *filepath, char *r_prefix, const char **r_ext)
Definition scene.cc:3417
void IMB_filtery(ImBuf *ibuf)
Definition filter.cc:65
const char * IMB_colormanagement_get_float_colorspace(const ImBuf *ibuf)
GHOST_IContext * RE_system_gpu_context_get(Render *re)
void RE_AcquireResultImage(Render *re, RenderResult *rr, const int view_id)
GPUContext * GPU_context_active_get()
@ IMB_TRANSFORM_MODE_CROP_SRC
Crop the source buffer.
Definition IMB_imbuf.hh:580
void BLI_rctf_init(struct rctf *rect, float xmin, float xmax, float ymin, float ymax)
Definition rct.cc:418
#define PROXY_MAXFILE
Definition proxy.hh:22
#define floorf
#define fabsf
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
eEditingCacheFlag cache_flag
ListBaseT< Strip > seqbase
const ColorSpace * colorspace
const ColorSpace * colorspace
ImBufFloatBuffer float_buffer
ImBufByteBuffer byte_buffer
const uint8_t * byte_data() const
uint8_t * byte_data_for_write()
Definition allocimbuf.cc:60
const float * float_data() const
ImColorMode color_mode
float * float_data_for_write()
Definition allocimbuf.cc:79
bool can_contain_alpha() const
void assign_float_data(float *data)
eMovieClipProxy_RenderFlag render_flag
eMovieClipProxy_RenderSize render_size
struct ImBuf * ibuf
struct World * world
struct Editing * ed
struct SceneDisplay display
struct Object * camera
bke::SceneRuntime * runtime
ColorManagedColorspaceSettings sequencer_colorspace_settings
struct RenderData r
eEffectSpeedControlFlags flags
struct MovieReader * anim
eV3DShadingBackgroundType background_type
StripEarlyOut(*) early_out(const Strip *strip, float fac)
Definition effects.hh:49
SeqResult(*) execute(const RenderData *context, SeqRenderState *state, Strip *strip, float timeline_frame, float fac, const SeqResult &input1, const SeqResult &input2)
Definition effects.hh:52
bool is_occluded(const RenderData *context, const Strip *strip, int order_index) const
Definition render.cc:281
void add_occluder(const RenderData *context, const Strip *strip, int order_index)
Definition render.cc:296
Vector< OpaqueQuad, 4 > opaques
Definition render.cc:274
StripScreenQuad quad
Definition render.cc:269
GPUOffScreen * gpu_offscreen
Definition SEQ_render.hh:51
gpu::GPUSecondaryContextData gpu_context
Definition SEQ_render.hh:59
eSpaceSeq_Proxy_RenderSize preview_render_size
Definition SEQ_render.hh:36
GPUViewport * gpu_viewport
Definition SEQ_render.hh:52
bool is_valid() const
Definition render.hh:54
bool is_opaque_before_transform
Definition render.hh:62