Blender  V3.3
render.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2001-2002 NaN Holding BV. All rights reserved.
3  * 2003-2009 Blender Foundation.
4  * 2005-2006 Peter Schlaile <peter [at] schlaile [dot] de> */
5 
10 #include <time.h>
11 
12 #include "MEM_guardedalloc.h"
13 
14 #include "DNA_anim_types.h"
15 #include "DNA_defaults.h"
16 #include "DNA_mask_types.h"
17 #include "DNA_scene_types.h"
18 #include "DNA_sequence_types.h"
19 #include "DNA_space_types.h"
20 
21 #include "BLI_linklist.h"
22 #include "BLI_listbase.h"
23 #include "BLI_path_util.h"
24 #include "BLI_rect.h"
25 
26 #include "BKE_anim_data.h"
27 #include "BKE_animsys.h"
28 #include "BKE_fcurve.h"
29 #include "BKE_global.h"
30 #include "BKE_image.h"
31 #include "BKE_layer.h"
32 #include "BKE_lib_id.h"
33 #include "BKE_main.h"
34 #include "BKE_mask.h"
35 #include "BKE_movieclip.h"
36 #include "BKE_scene.h"
38 
39 #include "DEG_depsgraph.h"
40 #include "DEG_depsgraph_query.h"
41 
42 #include "IMB_colormanagement.h"
43 #include "IMB_imbuf.h"
44 #include "IMB_imbuf_types.h"
45 #include "IMB_metadata.h"
46 
47 #include "RNA_access.h"
48 #include "RNA_prototypes.h"
49 
50 #include "RE_engine.h"
51 #include "RE_pipeline.h"
52 
53 #include "SEQ_channels.h"
54 #include "SEQ_effects.h"
55 #include "SEQ_iterator.h"
56 #include "SEQ_modifier.h"
57 #include "SEQ_proxy.h"
58 #include "SEQ_relations.h"
59 #include "SEQ_render.h"
60 #include "SEQ_sequencer.h"
61 #include "SEQ_time.h"
62 #include "SEQ_transform.h"
63 #include "SEQ_utils.h"
64 
65 #include "effects.h"
66 #include "image_cache.h"
67 #include "multiview.h"
68 #include "prefetch.h"
69 #include "proxy.h"
70 #include "render.h"
71 #include "strip_time.h"
72 #include "utils.h"
73 
77  ListBase *seqbasep,
78  float timeline_frame,
79  int chanshown);
80 
82 SequencerDrawView sequencer_view3d_fn = NULL; /* NULL in background mode */
83 
84 /* -------------------------------------------------------------------- */
89 {
90 #if 0
91  /* Bute buffer is supposed to be in sequencer working space already. */
92  if (ibuf->rect != NULL) {
94  }
95 #endif
96  if (ibuf->rect_float != NULL) {
98  }
99 }
100 
101 void seq_imbuf_to_sequencer_space(Scene *scene, ImBuf *ibuf, bool make_float)
102 {
103  /* Early output check: if both buffers are NULL we have nothing to convert. */
104  if (ibuf->rect_float == NULL && ibuf->rect == NULL) {
105  return;
106  }
107  /* Get common conversion settings. */
108  const char *to_colorspace = scene->sequencer_colorspace_settings.name;
109  /* Perform actual conversion logic. */
110  if (ibuf->rect_float == NULL) {
111  /* We are not requested to give float buffer and byte buffer is already
112  * in thee required colorspace. Can skip doing anything here.
113  */
114  const char *from_colorspace = IMB_colormanagement_get_rect_colorspace(ibuf);
115  if (!make_float && STREQ(from_colorspace, to_colorspace)) {
116  return;
117  }
118  if (false) {
119  /* The idea here is to provide as fast playback as possible and
120  * enforcing float buffer here (a) uses more cache memory (b) might
121  * make some other effects slower to apply.
122  *
123  * However, this might also have negative effect by adding weird
124  * artifacts which will then not happen in final render.
125  */
126  IMB_colormanagement_transform_byte_threaded((unsigned char *)ibuf->rect,
127  ibuf->x,
128  ibuf->y,
129  ibuf->channels,
130  from_colorspace,
131  to_colorspace);
132  }
133  else {
134  /* We perform conversion to a float buffer so we don't worry about
135  * precision loss.
136  */
137  imb_addrectfloatImBuf(ibuf, 4);
139  (unsigned char *)ibuf->rect,
140  ibuf->x,
141  ibuf->y,
142  ibuf->channels,
143  from_colorspace,
144  to_colorspace);
145  /* We don't need byte buffer anymore. */
146  imb_freerectImBuf(ibuf);
147  }
148  }
149  else {
150  const char *from_colorspace = IMB_colormanagement_get_float_colorspace(ibuf);
151  /* Unknown input color space, can't perform conversion. */
152  if (from_colorspace == NULL || from_colorspace[0] == '\0') {
153  return;
154  }
155  /* We don't want both byte and float buffers around: they'll either run
156  * out of sync or conversion of byte buffer will lose precision in there.
157  */
158  if (ibuf->rect != NULL) {
159  imb_freerectImBuf(ibuf);
160  }
162  ibuf->rect_float, ibuf->x, ibuf->y, ibuf->channels, from_colorspace, to_colorspace, true);
163  }
165 }
166 
168 {
169  const char *from_colorspace = scene->sequencer_colorspace_settings.name;
170  const char *to_colorspace = IMB_colormanagement_role_colorspace_name_get(
172 
173  if (!ibuf->rect_float) {
174  return;
175  }
176 
177  if (to_colorspace && to_colorspace[0] != '\0') {
179  ibuf->rect_float, ibuf->x, ibuf->y, ibuf->channels, from_colorspace, to_colorspace, true);
180  IMB_colormanagement_assign_float_colorspace(ibuf, to_colorspace);
181  }
182 }
183 
185 {
186  const char *from_colorspace = scene->sequencer_colorspace_settings.name;
187  const char *to_colorspace = IMB_colormanagement_role_colorspace_name_get(
189 
190  if (to_colorspace && to_colorspace[0] != '\0') {
191  IMB_colormanagement_transform_v4(pixel, from_colorspace, to_colorspace);
192  }
193  else {
194  /* if no color management enables fallback to legacy conversion */
195  srgb_to_linearrgb_v4(pixel, pixel);
196  }
197 }
198 
201 /* -------------------------------------------------------------------- */
206  struct Depsgraph *depsgraph,
207  Scene *scene,
208  int rectx,
209  int recty,
210  int preview_render_size,
211  int for_render,
212  SeqRenderData *r_context)
213 {
214  r_context->bmain = bmain;
215  r_context->depsgraph = depsgraph;
216  r_context->scene = scene;
217  r_context->rectx = rectx;
218  r_context->recty = recty;
219  r_context->preview_render_size = preview_render_size;
220  r_context->for_render = for_render;
221  r_context->motion_blur_samples = 0;
222  r_context->motion_blur_shutter = 0;
223  r_context->skip_cache = false;
224  r_context->is_proxy_render = false;
225  r_context->view_id = 0;
226  r_context->gpu_offscreen = NULL;
227  r_context->task_id = SEQ_TASK_MAIN_RENDER;
228  r_context->is_prefetch_render = false;
229 }
230 
232 {
233  state->scene_parents = NULL;
234 }
235 
236 StripElem *SEQ_render_give_stripelem(const Scene *scene, Sequence *seq, int timeline_frame)
237 {
238  StripElem *se = seq->strip->stripdata;
239 
240  if (seq->type == SEQ_TYPE_IMAGE) {
241  /* only IMAGE strips use the whole array, MOVIE strips use only the first element,
242  * all other strips don't use this...
243  */
244 
245  int frame_index = (int)seq_give_frame_index(scene, seq, timeline_frame);
246 
247  if (frame_index == -1 || se == NULL) {
248  return NULL;
249  }
250 
251  se += frame_index + seq->anim_startofs;
252  }
253  return se;
254 }
255 
256 static int seq_channel_cmp_fn(const void *a, const void *b)
257 {
258  return (*(Sequence **)a)->machine - (*(Sequence **)b)->machine;
259 }
260 
263  ListBase *seqbase,
264  const int timeline_frame,
265  const int chanshown,
266  Sequence **r_seq_arr)
267 {
269  scene, channels, seqbase, timeline_frame, chanshown);
270  const int strip_count = BLI_gset_len(collection->set);
271 
272  if (strip_count > MAXSEQ) {
273  BLI_assert_msg(0, "Too many strips, this shouldn't happen");
274  return 0;
275  }
276 
277  /* Copy collection elements into array. */
278  memset(r_seq_arr, 0, sizeof(Sequence *) * (MAXSEQ + 1));
279  Sequence *seq;
280  int index = 0;
281  SEQ_ITERATOR_FOREACH (seq, collection) {
282  r_seq_arr[index] = seq;
283  index++;
284  }
285  SEQ_collection_free(collection);
286 
287  /* Sort array by channel. */
288  qsort(r_seq_arr, strip_count, sizeof(Sequence *), seq_channel_cmp_fn);
289 
290  return strip_count;
291 }
292 
295 /* -------------------------------------------------------------------- */
315 static bool sequencer_use_transform(const Sequence *seq)
316 {
317  const StripTransform *transform = seq->strip->transform;
318 
319  if (transform->xofs != 0 || transform->yofs != 0 || transform->scale_x != 1 ||
320  transform->scale_y != 1 || transform->rotation != 0) {
321  return true;
322  }
323 
324  return false;
325 }
326 
327 static bool sequencer_use_crop(const Sequence *seq)
328 {
329  const StripCrop *crop = seq->strip->crop;
330  if (crop->left > 0 || crop->right > 0 || crop->top > 0 || crop->bottom > 0) {
331  return true;
332  }
333 
334  return false;
335 }
336 
338  Sequence *seq,
339  float UNUSED(timeline_frame))
340 {
341  float mul;
342 
343  if (context && context->is_proxy_render) {
344  return false;
345  }
346 
347  if ((seq->flag & (SEQ_FILTERY | SEQ_FLIPX | SEQ_FLIPY | SEQ_MAKE_FLOAT)) ||
349  return true;
350  }
351 
352  mul = seq->mul;
353 
354  if (seq->blend_mode == SEQ_BLEND_REPLACE) {
355  mul *= seq->blend_opacity / 100.0f;
356  }
357 
358  if (mul != 1.0f) {
359  return true;
360  }
361 
362  if (seq->sat != 1.0f) {
363  return true;
364  }
365 
366  if (seq->modifiers.first) {
367  return true;
368  }
369 
370  return false;
371 }
372 
379 static bool seq_need_scale_to_render_size(const Sequence *seq, bool is_proxy_image)
380 {
381  if (is_proxy_image) {
382  return true;
383  }
384  if ((seq->type & SEQ_TYPE_EFFECT) != 0 || seq->type == SEQ_TYPE_MASK ||
385  seq->type == SEQ_TYPE_META ||
386  (seq->type == SEQ_TYPE_SCENE && ((seq->flag & SEQ_SCENE_STRIPS) != 0))) {
387  return true;
388  }
389  return false;
390 }
391 
393  const ImBuf *in,
394  const ImBuf *out,
395  const float image_scale_factor,
396  const float preview_scale_factor,
397  float r_transform_matrix[4][4])
398 {
399  const StripTransform *transform = seq->strip->transform;
400  const float scale_x = transform->scale_x * image_scale_factor;
401  const float scale_y = transform->scale_y * image_scale_factor;
402  const float image_center_offs_x = (out->x - in->x) / 2;
403  const float image_center_offs_y = (out->y - in->y) / 2;
404  const float translate_x = transform->xofs * preview_scale_factor + image_center_offs_x;
405  const float translate_y = transform->yofs * preview_scale_factor + image_center_offs_y;
406  const float pivot[3] = {in->x * transform->origin[0], in->y * transform->origin[1], 0.0f};
407 
408  float rotation_matrix[3][3];
409  axis_angle_to_mat3_single(rotation_matrix, 'Z', transform->rotation);
410  loc_rot_size_to_mat4(r_transform_matrix,
411  (const float[]){translate_x, translate_y, 0.0f},
412  rotation_matrix,
413  (const float[]){scale_x, scale_y, 1.0f});
414  transform_pivot_set_m4(r_transform_matrix, pivot);
415  invert_m4(r_transform_matrix);
416 }
417 
418 static void sequencer_image_crop_init(const Sequence *seq,
419  const ImBuf *in,
420  float crop_scale_factor,
421  rctf *r_crop)
422 {
423  const StripCrop *c = seq->strip->crop;
424  const int left = c->left * crop_scale_factor;
425  const int right = c->right * crop_scale_factor;
426  const int top = c->top * crop_scale_factor;
427  const int bottom = c->bottom * crop_scale_factor;
428 
429  BLI_rctf_init(r_crop, left, in->x - right, bottom, in->y - top);
430 }
431 
433 {
434  float image_scale_factor = (float)out->x / in->x;
435  float transform_matrix[4][4];
436 
437  /* Set to keep same loc,scale,rot but change scale to thumb size limit. */
438  const float scale_x = 1 * image_scale_factor;
439  const float scale_y = 1 * image_scale_factor;
440  const float image_center_offs_x = (out->x - in->x) / 2;
441  const float image_center_offs_y = (out->y - in->y) / 2;
442  const float pivot[3] = {in->x / 2, in->y / 2, 0.0f};
443 
444  float rotation_matrix[3][3];
445  unit_m3(rotation_matrix);
446  loc_rot_size_to_mat4(transform_matrix,
447  (const float[]){image_center_offs_x, image_center_offs_y, 0.0f},
448  rotation_matrix,
449  (const float[]){scale_x, scale_y, 1.0f});
450  transform_pivot_set_m4(transform_matrix, pivot);
451  invert_m4(transform_matrix);
452 
454 }
455 
456 /* Check whether transform introduces transparent ares in the result (happens when the transformed
457  * image does not fully cover the render frame).
458  *
459  * The check is done by checking whether all corners of viewport fit inside of the transformed
460  * image. If they do not the image will have transparent areas. */
462 {
463  Scene *scene = context->scene;
464  const int x = context->rectx;
465  const int y = context->recty;
466 
467  float seq_image_quad[4][2];
468  SEQ_image_transform_final_quad_get(scene, seq, seq_image_quad);
469  for (int i = 0; i < 4; i++) {
470  add_v2_v2(seq_image_quad[i], (float[]){x / 2, y / 2});
471  }
472 
473  return !isect_point_quad_v2((float[]){x, y},
474  seq_image_quad[0],
475  seq_image_quad[1],
476  seq_image_quad[2],
477  seq_image_quad[3]) ||
478  !isect_point_quad_v2((float[]){0, y},
479  seq_image_quad[0],
480  seq_image_quad[1],
481  seq_image_quad[2],
482  seq_image_quad[3]) ||
483  !isect_point_quad_v2((float[]){x, 0},
484  seq_image_quad[0],
485  seq_image_quad[1],
486  seq_image_quad[2],
487  seq_image_quad[3]) ||
488  !isect_point_quad_v2((float[]){0, 0},
489  seq_image_quad[0],
490  seq_image_quad[1],
491  seq_image_quad[2],
492  seq_image_quad[3]);
493 }
494 
496  ImBuf *in, ImBuf *out, const SeqRenderData *context, Sequence *seq, const bool is_proxy_image)
497 {
498  const Scene *scene = context->scene;
499  const float preview_scale_factor = context->preview_render_size == SEQ_RENDER_SIZE_SCENE ?
500  (float)scene->r.size / 100 :
502  context->preview_render_size);
503  const bool do_scale_to_render_size = seq_need_scale_to_render_size(seq, is_proxy_image);
504  const float image_scale_factor = do_scale_to_render_size ? 1.0f : preview_scale_factor;
505 
506  float transform_matrix[4][4];
508  seq, in, out, image_scale_factor, preview_scale_factor, transform_matrix);
509 
510  /* Proxy image is smaller, so crop values must be corrected by proxy scale factor.
511  * Proxy scale factor always matches preview_scale_factor. */
512  rctf source_crop;
513  const float crop_scale_factor = do_scale_to_render_size ? preview_scale_factor : 1.0f;
514  sequencer_image_crop_init(seq, in, crop_scale_factor, &source_crop);
515 
517  const StripTransform *transform = seq->strip->transform;
518  if (transform->filter == SEQ_TRANSFORM_FILTER_NEAREST) {
520  }
521  else {
523  }
524 
525  IMB_transform(in, out, IMB_TRANSFORM_MODE_CROP_SRC, filter, transform_matrix, &source_crop);
526 
528  out->planes = in->planes;
529  }
530  else {
531  out->planes = R_IMF_PLANES_RGBA;
532  }
533 }
534 
535 static void multibuf(ImBuf *ibuf, const float fmul)
536 {
537  char *rt;
538  float *rt_float;
539 
540  int a;
541 
542  rt = (char *)ibuf->rect;
543  rt_float = ibuf->rect_float;
544 
545  if (rt) {
546  const int imul = (int)(256.0f * fmul);
547  a = ibuf->x * ibuf->y;
548  while (a--) {
549  rt[0] = min_ii((imul * rt[0]) >> 8, 255);
550  rt[1] = min_ii((imul * rt[1]) >> 8, 255);
551  rt[2] = min_ii((imul * rt[2]) >> 8, 255);
552  rt[3] = min_ii((imul * rt[3]) >> 8, 255);
553 
554  rt += 4;
555  }
556  }
557  if (rt_float) {
558  a = ibuf->x * ibuf->y;
559  while (a--) {
560  rt_float[0] *= fmul;
561  rt_float[1] *= fmul;
562  rt_float[2] *= fmul;
563  rt_float[3] *= fmul;
564 
565  rt_float += 4;
566  }
567  }
568 
569  if (ELEM(ibuf->planes, R_IMF_PLANES_BW, R_IMF_PLANES_RGB) && fmul < 1.0f) {
570  ibuf->planes = R_IMF_PLANES_RGBA;
571  }
572 }
573 
575  Sequence *seq,
576  float timeline_frame,
577  ImBuf *ibuf,
578  const bool is_proxy_image)
579 {
580  Scene *scene = context->scene;
581  ImBuf *preprocessed_ibuf = NULL;
582 
583  /* Deinterlace. */
584  if ((seq->flag & SEQ_FILTERY) && !ELEM(seq->type, SEQ_TYPE_MOVIE, SEQ_TYPE_MOVIECLIP)) {
585  /* Change original image pointer to avoid another duplication in SEQ_USE_TRANSFORM. */
586  preprocessed_ibuf = IMB_makeSingleUser(ibuf);
587  ibuf = preprocessed_ibuf;
588 
589  IMB_filtery(preprocessed_ibuf);
590  }
591 
592  if (sequencer_use_crop(seq) || sequencer_use_transform(seq) || context->rectx != ibuf->x ||
593  context->recty != ibuf->y) {
594  const int x = context->rectx;
595  const int y = context->recty;
596  preprocessed_ibuf = IMB_allocImBuf(x, y, 32, ibuf->rect_float ? IB_rectfloat : IB_rect);
597 
598  sequencer_preprocess_transform_crop(ibuf, preprocessed_ibuf, context, seq, is_proxy_image);
599 
600  seq_imbuf_assign_spaces(scene, preprocessed_ibuf);
601  IMB_metadata_copy(preprocessed_ibuf, ibuf);
602  IMB_freeImBuf(ibuf);
603  }
604 
605  /* Duplicate ibuf if we still have original. */
606  if (preprocessed_ibuf == NULL) {
607  preprocessed_ibuf = IMB_makeSingleUser(ibuf);
608  }
609 
610  if (seq->flag & SEQ_FLIPX) {
611  IMB_flipx(preprocessed_ibuf);
612  }
613 
614  if (seq->flag & SEQ_FLIPY) {
615  IMB_flipy(preprocessed_ibuf);
616  }
617 
618  if (seq->sat != 1.0f) {
619  IMB_saturation(preprocessed_ibuf, seq->sat);
620  }
621 
622  if (seq->flag & SEQ_MAKE_FLOAT) {
623  if (!preprocessed_ibuf->rect_float) {
624  seq_imbuf_to_sequencer_space(scene, preprocessed_ibuf, true);
625  }
626 
627  if (preprocessed_ibuf->rect) {
628  imb_freerectImBuf(preprocessed_ibuf);
629  }
630  }
631 
632  float mul = seq->mul;
633  if (seq->blend_mode == SEQ_BLEND_REPLACE) {
634  mul *= seq->blend_opacity / 100.0f;
635  }
636 
637  if (mul != 1.0f) {
638  multibuf(preprocessed_ibuf, mul);
639  }
640 
641  if (seq->modifiers.first) {
642  ImBuf *ibuf_new = SEQ_modifier_apply_stack(context, seq, preprocessed_ibuf, timeline_frame);
643 
644  if (ibuf_new != preprocessed_ibuf) {
645  IMB_metadata_copy(ibuf_new, preprocessed_ibuf);
646  IMB_freeImBuf(preprocessed_ibuf);
647  preprocessed_ibuf = ibuf_new;
648  }
649  }
650 
651  return preprocessed_ibuf;
652 }
653 
655  Sequence *seq,
656  ImBuf *ibuf,
657  float timeline_frame,
658  bool use_preprocess,
659  const bool is_proxy_image)
660 {
661  if (context->is_proxy_render == false &&
662  (ibuf->x != context->rectx || ibuf->y != context->recty)) {
663  use_preprocess = true;
664  }
665 
666  /* Proxies and effect strips are not stored in cache. */
667  if (!is_proxy_image && (seq->type & SEQ_TYPE_EFFECT) == 0) {
668  seq_cache_put(context, seq, timeline_frame, SEQ_CACHE_STORE_RAW, ibuf);
669  }
670 
671  if (use_preprocess) {
672  ibuf = input_preprocess(context, seq, timeline_frame, ibuf, is_proxy_image);
673  }
674 
675  seq_cache_put(context, seq, timeline_frame, SEQ_CACHE_STORE_PREPROCESSED, ibuf);
676  return ibuf;
677 }
678 
679 typedef struct RenderEffectInitData {
685 
688 
689 typedef struct RenderEffectThread {
695 
699 
700 static void render_effect_execute_init_handle(void *handle_v,
701  int start_line,
702  int tot_line,
703  void *init_data_v)
704 {
705  RenderEffectThread *handle = (RenderEffectThread *)handle_v;
707 
708  handle->sh = init_data->sh;
709  handle->context = init_data->context;
710  handle->seq = init_data->seq;
711  handle->timeline_frame = init_data->timeline_frame;
712  handle->fac = init_data->fac;
713  handle->ibuf1 = init_data->ibuf1;
714  handle->ibuf2 = init_data->ibuf2;
715  handle->ibuf3 = init_data->ibuf3;
716  handle->out = init_data->out;
717 
718  handle->start_line = start_line;
719  handle->tot_line = tot_line;
720 }
721 
722 static void *render_effect_execute_do_thread(void *thread_data_v)
723 {
724  RenderEffectThread *thread_data = (RenderEffectThread *)thread_data_v;
725 
726  thread_data->sh->execute_slice(thread_data->context,
727  thread_data->seq,
728  thread_data->timeline_frame,
729  thread_data->fac,
730  thread_data->ibuf1,
731  thread_data->ibuf2,
732  thread_data->ibuf3,
733  thread_data->start_line,
734  thread_data->tot_line,
735  thread_data->out);
736 
737  return NULL;
738 }
739 
741  const SeqRenderData *context,
742  Sequence *seq,
743  float timeline_frame,
744  float fac,
745  ImBuf *ibuf1,
746  ImBuf *ibuf2,
747  ImBuf *ibuf3)
748 {
750  ImBuf *out = sh->init_execution(context, ibuf1, ibuf2, ibuf3);
751 
752  init_data.sh = sh;
753  init_data.context = context;
754  init_data.seq = seq;
755  init_data.timeline_frame = timeline_frame;
756  init_data.fac = fac;
757  init_data.ibuf1 = ibuf1;
758  init_data.ibuf2 = ibuf2;
759  init_data.ibuf3 = ibuf3;
760  init_data.out = out;
761 
763  sizeof(RenderEffectThread),
764  &init_data,
767 
768  return out;
769 }
770 
773  Sequence *seq,
774  float timeline_frame)
775 {
776  Scene *scene = context->scene;
777  float fac;
778  int early_out;
779  int i;
781  FCurve *fcu = NULL;
782  ImBuf *ibuf[3];
783  Sequence *input[3];
784  ImBuf *out = NULL;
785 
786  ibuf[0] = ibuf[1] = ibuf[2] = NULL;
787 
788  input[0] = seq->seq1;
789  input[1] = seq->seq2;
790  input[2] = seq->seq3;
791 
792  if (!sh.execute && !(sh.execute_slice && sh.init_execution)) {
793  /* effect not supported in this version... */
794  out = IMB_allocImBuf(context->rectx, context->recty, 32, IB_rect);
795  return out;
796  }
797 
798  if (seq->flag & SEQ_USE_EFFECT_DEFAULT_FADE) {
799  sh.get_default_fac(scene, seq, timeline_frame, &fac);
800  }
801  else {
802  fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "effect_fader", 0, NULL);
803  if (fcu) {
804  fac = evaluate_fcurve(fcu, timeline_frame);
805  }
806  else {
807  fac = seq->effect_fader;
808  }
809  }
810 
811  early_out = sh.early_out(seq, fac);
812 
813  switch (early_out) {
814  case EARLY_NO_INPUT:
815  out = sh.execute(context, seq, timeline_frame, fac, NULL, NULL, NULL);
816  break;
817  case EARLY_DO_EFFECT:
818  for (i = 0; i < 3; i++) {
819  /* Speed effect requires time remapping of `timeline_frame` for input(s). */
820  if (input[0] && seq->type == SEQ_TYPE_SPEED) {
821  float target_frame = seq_speed_effect_target_frame_get(scene, seq, timeline_frame, i);
822  ibuf[i] = seq_render_strip(context, state, input[0], target_frame);
823  }
824  else { /* Other effects. */
825  if (input[i]) {
826  ibuf[i] = seq_render_strip(context, state, input[i], timeline_frame);
827  }
828  }
829  }
830 
831  if (ibuf[0] && (ibuf[1] || SEQ_effect_get_num_inputs(seq->type) == 1)) {
832  if (sh.multithreaded) {
834  &sh, context, seq, timeline_frame, fac, ibuf[0], ibuf[1], ibuf[2]);
835  }
836  else {
837  out = sh.execute(context, seq, timeline_frame, fac, ibuf[0], ibuf[1], ibuf[2]);
838  }
839  }
840  break;
841  case EARLY_USE_INPUT_1:
842  if (input[0]) {
843  out = seq_render_strip(context, state, input[0], timeline_frame);
844  }
845  break;
846  case EARLY_USE_INPUT_2:
847  if (input[1]) {
848  out = seq_render_strip(context, state, input[1], timeline_frame);
849  }
850  break;
851  }
852 
853  for (i = 0; i < 3; i++) {
854  IMB_freeImBuf(ibuf[i]);
855  }
856 
857  if (out == NULL) {
858  out = IMB_allocImBuf(context->rectx, context->recty, 32, IB_rect);
859  }
860 
861  return out;
862 }
863 
866 /* -------------------------------------------------------------------- */
874  Sequence *seq,
875  char *name,
876  char *prefix,
877  const char *ext,
878  int view_id)
879 {
880 
881  ImBuf *ibuf = NULL;
882 
883  int flag = IB_rect | IB_metadata;
884  if (seq->alpha_mode == SEQ_ALPHA_PREMUL) {
885  flag |= IB_alphamode_premul;
886  }
887 
888  if (prefix[0] == '\0') {
889  ibuf = IMB_loadiffname(name, flag, seq->strip->colorspace_settings.name);
890  }
891  else {
892  char str[FILE_MAX];
893  BKE_scene_multiview_view_prefix_get(context->scene, name, prefix, &ext);
894  seq_multiview_name(context->scene, view_id, prefix, ext, str, FILE_MAX);
895  ibuf = IMB_loadiffname(str, flag, seq->strip->colorspace_settings.name);
896  }
897 
898  if (ibuf == NULL) {
899  return NULL;
900  }
901 
902  /* We don't need both (speed reasons)! */
903  if (ibuf->rect_float != NULL && ibuf->rect != NULL) {
904  imb_freerectImBuf(ibuf);
905  }
906 
907  /* All sequencer color is done in SRGB space, linear gives odd cross-fades. */
908  seq_imbuf_to_sequencer_space(context->scene, ibuf, false);
909 
910  return ibuf;
911 }
912 
914  Scene *scene, Sequence *seq, int totfiles, char *name, char *r_prefix, const char *r_ext)
915 {
916  if (totfiles > 1) {
917  BKE_scene_multiview_view_prefix_get(scene, name, r_prefix, &r_ext);
918  if (r_prefix[0] == '\0') {
919  return false;
920  }
921  }
922  else {
923  r_prefix[0] = '\0';
924  }
925 
926  return (seq->flag & SEQ_USE_VIEWS) != 0 && (scene->r.scemode & R_MULTIVIEW) != 0;
927 }
928 
930  Sequence *seq,
931  float UNUSED(frame_index),
932  float timeline_frame,
933  bool *r_is_proxy_image)
934 {
935  char name[FILE_MAX];
936  const char *ext = NULL;
937  char prefix[FILE_MAX];
938  ImBuf *ibuf = NULL;
939 
940  StripElem *s_elem = SEQ_render_give_stripelem(context->scene, seq, timeline_frame);
941  if (s_elem == NULL) {
942  return NULL;
943  }
944 
945  BLI_join_dirfile(name, sizeof(name), seq->strip->dir, s_elem->name);
947 
948  /* Try to get a proxy image. */
949  ibuf = seq_proxy_fetch(context, seq, timeline_frame);
950  if (ibuf != NULL) {
951  *r_is_proxy_image = true;
952  return ibuf;
953  }
954 
955  /* Proxy not found, render original. */
956  const int totfiles = seq_num_files(context->scene, seq->views_format, true);
957  bool is_multiview_render = seq_image_strip_is_multiview_render(
958  context->scene, seq, totfiles, name, prefix, ext);
959 
960  if (is_multiview_render) {
961  int totviews = BKE_scene_multiview_num_views_get(&context->scene->r);
962  ImBuf **ibufs_arr = MEM_callocN(sizeof(ImBuf *) * totviews, "Sequence Image Views Imbufs");
963 
964  for (int view_id = 0; view_id < totfiles; view_id++) {
965  ibufs_arr[view_id] = seq_render_image_strip_view(context, seq, name, prefix, ext, view_id);
966  }
967 
968  if (ibufs_arr[0] == NULL) {
969  return NULL;
970  }
971 
972  if (seq->views_format == R_IMF_VIEWS_STEREO_3D) {
973  IMB_ImBufFromStereo3d(seq->stereo3d_format, ibufs_arr[0], &ibufs_arr[0], &ibufs_arr[1]);
974  }
975 
976  for (int view_id = 0; view_id < totviews; view_id++) {
977  SeqRenderData localcontext = *context;
978  localcontext.view_id = view_id;
979 
980  if (view_id != context->view_id) {
981  ibufs_arr[view_id] = seq_render_preprocess_ibuf(
982  &localcontext, seq, ibufs_arr[view_id], timeline_frame, true, false);
983  }
984  }
985 
986  /* Return the original requested ImBuf. */
987  ibuf = ibufs_arr[context->view_id];
988 
989  /* Remove the others (decrease their refcount). */
990  for (int view_id = 0; view_id < totviews; view_id++) {
991  if (ibufs_arr[view_id] != ibuf) {
992  IMB_freeImBuf(ibufs_arr[view_id]);
993  }
994  }
995 
996  MEM_freeN(ibufs_arr);
997  }
998  else {
999  ibuf = seq_render_image_strip_view(context, seq, name, prefix, ext, context->view_id);
1000  }
1001 
1002  if (ibuf == NULL) {
1003  return NULL;
1004  }
1005 
1006  s_elem->orig_width = ibuf->x;
1007  s_elem->orig_height = ibuf->y;
1008 
1009  return ibuf;
1010 }
1011 
1013  Sequence *seq,
1014  int timeline_frame)
1015 {
1016  char name[PROXY_MAXFILE];
1017  StripProxy *proxy = seq->strip->proxy;
1018 
1019  if (proxy->anim == NULL) {
1020  if (seq_proxy_get_custom_file_fname(seq, name, context->view_id)) {
1021  proxy->anim = openanim(name, IB_rect, 0, seq->strip->colorspace_settings.name);
1022  }
1023  if (proxy->anim == NULL) {
1024  return NULL;
1025  }
1026  }
1027 
1028  int frameno = (int)seq_give_frame_index(context->scene, seq, timeline_frame) +
1029  seq->anim_startofs;
1030  return IMB_anim_absolute(proxy->anim, frameno, IMB_TC_NONE, IMB_PROXY_NONE);
1031 }
1032 
1037  Sequence *seq,
1038  float frame_index,
1039  float timeline_frame,
1040  StripAnim *sanim,
1041  bool *r_is_proxy_image)
1042 {
1043  ImBuf *ibuf = NULL;
1044  IMB_Proxy_Size psize = SEQ_rendersize_to_proxysize(context->preview_render_size);
1045 
1046  if (SEQ_can_use_proxy(context, seq, psize)) {
1047  /* Try to get a proxy image.
1048  * Movie proxies are handled by ImBuf module with exception of `custom file` setting. */
1049  if (context->scene->ed->proxy_storage != SEQ_EDIT_PROXY_DIR_STORAGE &&
1051  ibuf = seq_render_movie_strip_custom_file_proxy(context, seq, timeline_frame);
1052  }
1053  else {
1054  ibuf = IMB_anim_absolute(sanim->anim,
1055  frame_index + seq->anim_startofs,
1056  seq->strip->proxy ? seq->strip->proxy->tc : IMB_TC_RECORD_RUN,
1057  psize);
1058  }
1059 
1060  if (ibuf != NULL) {
1061  *r_is_proxy_image = true;
1062  }
1063  }
1064 
1065  /* Fetching for requested proxy size failed, try fetching the original instead. */
1066  if (ibuf == NULL) {
1067  ibuf = IMB_anim_absolute(sanim->anim,
1068  frame_index + seq->anim_startofs,
1069  seq->strip->proxy ? seq->strip->proxy->tc : IMB_TC_RECORD_RUN,
1070  IMB_PROXY_NONE);
1071  }
1072  if (ibuf == NULL) {
1073  return NULL;
1074  }
1075 
1076  seq_imbuf_to_sequencer_space(context->scene, ibuf, false);
1077 
1078  /* We don't need both (speed reasons)! */
1079  if (ibuf->rect_float != NULL && ibuf->rect != NULL) {
1080  imb_freerectImBuf(ibuf);
1081  }
1082 
1083  return ibuf;
1084 }
1085 
1087  Sequence *seq,
1088  float frame_index,
1089  float timeline_frame,
1090  bool *r_is_proxy_image)
1091 {
1092  /* Load all the videos. */
1093  seq_open_anim_file(context->scene, seq, false);
1094 
1095  ImBuf *ibuf = NULL;
1096  StripAnim *sanim = seq->anims.first;
1097  const int totfiles = seq_num_files(context->scene, seq->views_format, true);
1098  bool is_multiview_render = (seq->flag & SEQ_USE_VIEWS) != 0 &&
1099  (context->scene->r.scemode & R_MULTIVIEW) != 0 &&
1100  BLI_listbase_count_at_most(&seq->anims, totfiles + 1) == totfiles;
1101 
1102  if (is_multiview_render) {
1103  ImBuf **ibuf_arr;
1104  int totviews = BKE_scene_multiview_num_views_get(&context->scene->r);
1105  ibuf_arr = MEM_callocN(sizeof(ImBuf *) * totviews, "Sequence Image Views Imbufs");
1106  int ibuf_view_id;
1107 
1108  for (ibuf_view_id = 0, sanim = seq->anims.first; sanim; sanim = sanim->next, ibuf_view_id++) {
1109  if (sanim->anim) {
1110  ibuf_arr[ibuf_view_id] = seq_render_movie_strip_view(
1111  context, seq, frame_index, timeline_frame, sanim, r_is_proxy_image);
1112  }
1113  }
1114 
1115  if (seq->views_format == R_IMF_VIEWS_STEREO_3D) {
1116  if (ibuf_arr[0] == NULL) {
1117  /* Probably proxy hasn't been created yet. */
1118  MEM_freeN(ibuf_arr);
1119  return NULL;
1120  }
1121 
1122  IMB_ImBufFromStereo3d(seq->stereo3d_format, ibuf_arr[0], &ibuf_arr[0], &ibuf_arr[1]);
1123  }
1124 
1125  for (int view_id = 0; view_id < totviews; view_id++) {
1126  SeqRenderData localcontext = *context;
1127  localcontext.view_id = view_id;
1128 
1129  if (view_id != context->view_id) {
1130  ibuf_arr[view_id] = seq_render_preprocess_ibuf(
1131  &localcontext, seq, ibuf_arr[view_id], timeline_frame, true, false);
1132  }
1133  }
1134 
1135  /* Return the original requested ImBuf. */
1136  ibuf = ibuf_arr[context->view_id];
1137 
1138  /* Remove the others (decrease their refcount). */
1139  for (int view_id = 0; view_id < totviews; view_id++) {
1140  if (ibuf_arr[view_id] != ibuf) {
1141  IMB_freeImBuf(ibuf_arr[view_id]);
1142  }
1143  }
1144 
1145  MEM_freeN(ibuf_arr);
1146  }
1147  else {
1149  context, seq, frame_index, timeline_frame, sanim, r_is_proxy_image);
1150  }
1151 
1152  if (ibuf == NULL) {
1153  return NULL;
1154  }
1155 
1156  if (*r_is_proxy_image == false) {
1157  if (sanim && sanim->anim) {
1158  short fps_denom;
1159  float fps_num;
1160  IMB_anim_get_fps(sanim->anim, &fps_denom, &fps_num, true);
1161  seq->strip->stripdata->orig_fps = fps_denom / fps_num;
1162  }
1163  seq->strip->stripdata->orig_width = ibuf->x;
1164  seq->strip->stripdata->orig_height = ibuf->y;
1165  }
1166 
1167  return ibuf;
1168 }
1169 
1171 {
1172  ImBuf *ibuf = NULL;
1173  float tloc[2], tscale, tangle;
1175  ibuf = BKE_movieclip_get_stable_ibuf(seq->clip, &user, tloc, &tscale, &tangle, 0);
1176  }
1177  else {
1178  ibuf = BKE_movieclip_get_ibuf_flag(seq->clip, &user, seq->clip->flag, MOVIECLIP_CACHE_SKIP);
1179  }
1180  return ibuf;
1181 }
1182 
1184  Sequence *seq,
1185  float frame_index,
1186  bool *r_is_proxy_image)
1187 {
1188  ImBuf *ibuf = NULL;
1190  IMB_Proxy_Size psize = SEQ_rendersize_to_proxysize(context->preview_render_size);
1191 
1192  if (!seq->clip) {
1193  return NULL;
1194  }
1195 
1196  BKE_movieclip_user_set_frame(&user, frame_index + seq->anim_startofs + seq->clip->start_frame);
1197 
1199  switch (psize) {
1200  case IMB_PROXY_NONE:
1202  break;
1203  case IMB_PROXY_100:
1205  break;
1206  case IMB_PROXY_75:
1208  break;
1209  case IMB_PROXY_50:
1211  break;
1212  case IMB_PROXY_25:
1214  break;
1215  }
1216 
1219  }
1220 
1221  /* Try to get a proxy image. */
1222  ibuf = seq_get_movieclip_ibuf(seq, user);
1223 
1224  /* If clip doesn't use proxies, it will fallback to full size render of original file. */
1225  if (ibuf != NULL && psize != IMB_PROXY_NONE && BKE_movieclip_proxy_enabled(seq->clip)) {
1226  *r_is_proxy_image = true;
1227  }
1228 
1229  /* If proxy is not found, grab full-size frame. */
1230  if (ibuf == NULL) {
1232  ibuf = seq_get_movieclip_ibuf(seq, user);
1233  }
1234 
1235  return ibuf;
1236 }
1237 
1239  Mask *mask,
1240  float frame_index,
1241  bool make_float)
1242 {
1243  /* TODO: add option to rasterize to alpha imbuf? */
1244  ImBuf *ibuf = NULL;
1245  float *maskbuf;
1246  int i;
1247 
1248  if (!mask) {
1249  return NULL;
1250  }
1251 
1252  AnimData *adt;
1253  Mask *mask_temp;
1254  MaskRasterHandle *mr_handle;
1255 
1256  mask_temp = (Mask *)BKE_id_copy_ex(
1258 
1259  BKE_mask_evaluate(mask_temp, mask->sfra + frame_index, true);
1260 
1261  /* anim-data */
1262  adt = BKE_animdata_from_id(&mask->id);
1263  const AnimationEvalContext anim_eval_context = BKE_animsys_eval_context_construct(
1264  context->depsgraph, mask->sfra + frame_index);
1265  BKE_animsys_evaluate_animdata(&mask_temp->id, adt, &anim_eval_context, ADT_RECALC_ANIM, false);
1266 
1267  maskbuf = MEM_mallocN(sizeof(float) * context->rectx * context->recty, __func__);
1268 
1269  mr_handle = BKE_maskrasterize_handle_new();
1270 
1272  mr_handle, mask_temp, context->rectx, context->recty, true, true, true);
1273 
1274  BKE_id_free(NULL, &mask_temp->id);
1275 
1276  BKE_maskrasterize_buffer(mr_handle, context->rectx, context->recty, maskbuf);
1277 
1278  BKE_maskrasterize_handle_free(mr_handle);
1279 
1280  if (make_float) {
1281  /* pixels */
1282  const float *fp_src;
1283  float *fp_dst;
1284 
1285  ibuf = IMB_allocImBuf(context->rectx, context->recty, 32, IB_rectfloat);
1286 
1287  fp_src = maskbuf;
1288  fp_dst = ibuf->rect_float;
1289  i = context->rectx * context->recty;
1290  while (--i) {
1291  fp_dst[0] = fp_dst[1] = fp_dst[2] = *fp_src;
1292  fp_dst[3] = 1.0f;
1293 
1294  fp_src += 1;
1295  fp_dst += 4;
1296  }
1297  }
1298  else {
1299  /* pixels */
1300  const float *fp_src;
1301  unsigned char *ub_dst;
1302 
1303  ibuf = IMB_allocImBuf(context->rectx, context->recty, 32, IB_rect);
1304 
1305  fp_src = maskbuf;
1306  ub_dst = (unsigned char *)ibuf->rect;
1307  i = context->rectx * context->recty;
1308  while (--i) {
1309  ub_dst[0] = ub_dst[1] = ub_dst[2] = (unsigned char)(*fp_src * 255.0f); /* already clamped */
1310  ub_dst[3] = 255;
1311 
1312  fp_src += 1;
1313  ub_dst += 4;
1314  }
1315  }
1316 
1317  MEM_freeN(maskbuf);
1318 
1319  return ibuf;
1320 }
1321 
1322 static ImBuf *seq_render_mask_strip(const SeqRenderData *context, Sequence *seq, float frame_index)
1323 {
1324  bool make_float = (seq->flag & SEQ_MAKE_FLOAT) != 0;
1325 
1326  return seq_render_mask(context, seq->mask, frame_index, make_float);
1327 }
1328 
1330  Sequence *seq,
1331  float frame_index,
1332  float timeline_frame)
1333 {
1334  ImBuf *ibuf = NULL;
1335  double frame;
1336  Object *camera;
1337 
1338  struct {
1339  int scemode;
1340  int timeline_frame;
1341  float subframe;
1342 
1343 #ifdef DURIAN_CAMERA_SWITCH
1344  int mode;
1345 #endif
1346  } orig_data;
1347 
1348  /* Old info:
1349  * Hack! This function can be called from do_render_seq(), in that case
1350  * the seq->scene can already have a Render initialized with same name,
1351  * so we have to use a default name. (compositor uses scene name to
1352  * find render).
1353  * However, when called from within the UI (image preview in sequencer)
1354  * we do want to use scene Render, that way the render result is defined
1355  * for display in render/imagewindow
1356  *
1357  * Hmm, don't see, why we can't do that all the time,
1358  * and since G.is_rendering is uhm, gone... (Peter)
1359  */
1360 
1361  /* New info:
1362  * Using the same name for the renders works just fine as the do_render_seq()
1363  * render is not used while the scene strips are rendered.
1364  *
1365  * However rendering from UI (through sequencer_preview_area_draw) can crash in
1366  * very many cases since other renders (material preview, an actual render etc.)
1367  * can be started while this sequence preview render is running. The only proper
1368  * solution is to make the sequencer preview render a proper job, which can be
1369  * stopped when needed. This would also give a nice progress bar for the preview
1370  * space so that users know there's something happening.
1371  *
1372  * As a result the active scene now only uses OpenGL rendering for the sequencer
1373  * preview. This is far from nice, but is the only way to prevent crashes at this
1374  * time.
1375  *
1376  * -jahka
1377  */
1378 
1379  const bool is_rendering = G.is_rendering;
1380  const bool is_background = G.background;
1381  const bool do_seq_gl = is_rendering ? 0 : (context->scene->r.seq_prev_type) != OB_RENDER;
1382  bool have_comp = false;
1383  bool use_gpencil = true;
1384  /* do we need to re-evaluate the frame after rendering? */
1385  bool is_frame_update = false;
1386  Scene *scene;
1387  int is_thread_main = BLI_thread_is_main();
1388 
1389  /* don't refer to seq->scene above this point!, it can be NULL */
1390  if (seq->scene == NULL) {
1391  return NULL;
1392  }
1393 
1394  /* Prevent rendering scene recursively. */
1395  if (seq->scene == context->scene) {
1396  return NULL;
1397  }
1398 
1399  scene = seq->scene;
1400  frame = (double)scene->r.sfra + (double)frame_index + (double)seq->anim_startofs;
1401 
1402 #if 0 /* UNUSED */
1403  have_seq = (scene->r.scemode & R_DOSEQ) && scene->ed && scene->ed->seqbase.first);
1404 #endif
1405  have_comp = (scene->r.scemode & R_DOCOMP) && scene->use_nodes && scene->nodetree;
1406 
1407  /* Get view layer for the strip. */
1409  /* Depsgraph will be NULL when doing rendering. */
1411 
1412  orig_data.scemode = scene->r.scemode;
1413  orig_data.timeline_frame = scene->r.cfra;
1414  orig_data.subframe = scene->r.subframe;
1415 #ifdef DURIAN_CAMERA_SWITCH
1416  orig_data.mode = scene->r.mode;
1417 #endif
1418 
1419  BKE_scene_frame_set(scene, frame);
1420 
1421  if (seq->scene_camera) {
1422  camera = seq->scene_camera;
1423  }
1424  else {
1426  camera = scene->camera;
1427  }
1428 
1429  if (have_comp == false && camera == NULL) {
1430  goto finally;
1431  }
1432 
1433  if (seq->flag & SEQ_SCENE_NO_ANNOTATION) {
1434  use_gpencil = false;
1435  }
1436 
1437  /* prevent eternal loop */
1438  scene->r.scemode &= ~R_DOSEQ;
1439 
1440 #ifdef DURIAN_CAMERA_SWITCH
1441  /* stooping to new low's in hackyness :( */
1443 #endif
1444 
1445  is_frame_update = (orig_data.timeline_frame != scene->r.cfra) ||
1446  (orig_data.subframe != scene->r.subframe);
1447 
1448  if ((sequencer_view3d_fn && do_seq_gl && camera) && is_thread_main) {
1449  char err_out[256] = "unknown";
1450  int width, height;
1451  BKE_render_resolution(&scene->r, false, &width, &height);
1452  const char *viewname = BKE_scene_multiview_render_view_name_get(&scene->r, context->view_id);
1453 
1454  unsigned int draw_flags = V3D_OFSDRAW_NONE;
1455  draw_flags |= (use_gpencil) ? V3D_OFSDRAW_SHOW_ANNOTATION : 0;
1456  draw_flags |= (context->scene->r.seq_flag & R_SEQ_OVERRIDE_SCENE_SETTINGS) ?
1458  0;
1459 
1460  /* for old scene this can be uninitialized,
1461  * should probably be added to do_versions at some point if the functionality stays */
1462  if (context->scene->r.seq_prev_type == 0) {
1463  context->scene->r.seq_prev_type = 3 /* == OB_SOLID */;
1464  }
1465 
1466  /* opengl offscreen render */
1467  depsgraph = BKE_scene_ensure_depsgraph(context->bmain, scene, view_layer);
1470  ibuf = sequencer_view3d_fn(
1471  /* set for OpenGL render (NULL when scrubbing) */
1472  depsgraph,
1473  scene,
1474  &context->scene->display.shading,
1475  context->scene->r.seq_prev_type,
1476  camera_eval,
1477  width,
1478  height,
1479  IB_rect,
1480  draw_flags,
1481  scene->r.alphamode,
1482  viewname,
1483  context->gpu_offscreen,
1484  err_out);
1485  if (ibuf == NULL) {
1486  fprintf(stderr, "seq_render_scene_strip failed to get opengl buffer: %s\n", err_out);
1487  }
1488  }
1489  else {
1491  const int totviews = BKE_scene_multiview_num_views_get(&scene->r);
1492  ImBuf **ibufs_arr;
1493 
1494  ibufs_arr = MEM_callocN(sizeof(ImBuf *) * totviews, "Sequence Image Views Imbufs");
1495 
1496  /* XXX: this if can be removed when sequence preview rendering uses the job system
1497  *
1498  * disable rendered preview for sequencer while rendering -- it's very much possible
1499  * that preview render will went into conflict with final render
1500  *
1501  * When rendering from command line renderer is called from main thread, in this
1502  * case it's always safe to render scene here
1503  */
1504  if (!is_thread_main || is_rendering == false || is_background || context->for_render) {
1505  if (re == NULL) {
1506  re = RE_NewSceneRender(scene);
1507  }
1508 
1509  const float subframe = frame - floorf(frame);
1510 
1511  RE_RenderFrame(re,
1512  context->bmain,
1513  scene,
1514  have_comp ? NULL : view_layer,
1515  camera,
1516  floorf(frame),
1517  subframe,
1518  false);
1519 
1520  /* restore previous state after it was toggled on & off by RE_RenderFrame */
1521  G.is_rendering = is_rendering;
1522  }
1523 
1524  for (int view_id = 0; view_id < totviews; view_id++) {
1525  SeqRenderData localcontext = *context;
1526  RenderResult rres;
1527 
1528  localcontext.view_id = view_id;
1529 
1530  RE_AcquireResultImage(re, &rres, view_id);
1531 
1532  if (rres.rectf) {
1533  ibufs_arr[view_id] = IMB_allocImBuf(rres.rectx, rres.recty, 32, IB_rectfloat);
1534  memcpy(ibufs_arr[view_id]->rect_float,
1535  rres.rectf,
1536  sizeof(float[4]) * rres.rectx * rres.recty);
1537 
1538  if (rres.rectz) {
1539  addzbuffloatImBuf(ibufs_arr[view_id]);
1540  memcpy(
1541  ibufs_arr[view_id]->zbuf_float, rres.rectz, sizeof(float) * rres.rectx * rres.recty);
1542  }
1543 
1544  /* float buffers in the sequencer are not linear */
1545  seq_imbuf_to_sequencer_space(context->scene, ibufs_arr[view_id], false);
1546  }
1547  else if (rres.rect32) {
1548  ibufs_arr[view_id] = IMB_allocImBuf(rres.rectx, rres.recty, 32, IB_rect);
1549  memcpy(ibufs_arr[view_id]->rect, rres.rect32, 4 * rres.rectx * rres.recty);
1550  }
1551 
1552  if (view_id != context->view_id) {
1553  seq_cache_put(&localcontext, seq, timeline_frame, SEQ_CACHE_STORE_RAW, ibufs_arr[view_id]);
1554  }
1555 
1557  }
1558 
1559  /* return the original requested ImBuf */
1560  ibuf = ibufs_arr[context->view_id];
1561 
1562  /* "remove" the others (decrease their refcount) */
1563  for (int view_id = 0; view_id < totviews; view_id++) {
1564  if (ibufs_arr[view_id] != ibuf) {
1565  IMB_freeImBuf(ibufs_arr[view_id]);
1566  }
1567  }
1568  MEM_freeN(ibufs_arr);
1569  }
1570 
1571 finally:
1572  /* restore */
1573  scene->r.scemode = orig_data.scemode;
1574  scene->r.cfra = orig_data.timeline_frame;
1575  scene->r.subframe = orig_data.subframe;
1576 
1577  if (is_frame_update && (depsgraph != NULL)) {
1579  }
1580 
1581 #ifdef DURIAN_CAMERA_SWITCH
1582  /* stooping to new low's in hackyness :( */
1583  scene->r.mode &= orig_data.mode | ~R_NO_CAMERA_SWITCH;
1584 #endif
1585 
1586  return ibuf;
1587 }
1588 
1594  Sequence *seq,
1595  float frame_index)
1596 {
1597  ImBuf *ibuf = NULL;
1598  ListBase *seqbase = NULL;
1599  ListBase *channels = NULL;
1600  int offset;
1601 
1602  seqbase = SEQ_get_seqbase_from_sequence(seq, &channels, &offset);
1603 
1604  if (seqbase && !BLI_listbase_is_empty(seqbase)) {
1605 
1606  if (seq->flag & SEQ_SCENE_STRIPS && seq->scene) {
1607  BKE_animsys_evaluate_all_animation(context->bmain, context->depsgraph, frame_index + offset);
1608  }
1609 
1611  state,
1612  channels,
1613  seqbase,
1614  /* scene strips don't have their start taken into account */
1615  frame_index + offset,
1616  0);
1617  }
1618 
1619  return ibuf;
1620 }
1621 
1624 /* -------------------------------------------------------------------- */
1630  Sequence *seq,
1631  float timeline_frame,
1632  bool *r_is_proxy_image)
1633 {
1634  ImBuf *ibuf = NULL;
1635  float frame_index = seq_give_frame_index(context->scene, seq, timeline_frame);
1636  int type = (seq->type & SEQ_TYPE_EFFECT) ? SEQ_TYPE_EFFECT : seq->type;
1637  switch (type) {
1638  case SEQ_TYPE_META: {
1639  ibuf = do_render_strip_seqbase(context, state, seq, frame_index);
1640  break;
1641  }
1642 
1643  case SEQ_TYPE_SCENE: {
1644  if (seq->flag & SEQ_SCENE_STRIPS) {
1645  if (seq->scene && (context->scene != seq->scene)) {
1646  /* recursive check */
1647  if (BLI_linklist_index(state->scene_parents, seq->scene) != -1) {
1648  break;
1649  }
1650  LinkNode scene_parent = {
1651  .next = state->scene_parents,
1652  .link = seq->scene,
1653  };
1654  state->scene_parents = &scene_parent;
1655  /* end check */
1656 
1657  /* Use the Scene sequence-strip's scene for the context when rendering the
1658  * scene's sequences (necessary for multi-cam selector among others). */
1659  SeqRenderData local_context = *context;
1660  local_context.scene = seq->scene;
1661  local_context.skip_cache = true;
1662 
1663  ibuf = do_render_strip_seqbase(&local_context, state, seq, frame_index);
1664 
1665  /* step back in the list */
1666  state->scene_parents = state->scene_parents->next;
1667  }
1668  }
1669  else {
1670  /* scene can be NULL after deletions */
1671  ibuf = seq_render_scene_strip(context, seq, frame_index, timeline_frame);
1672  }
1673 
1674  break;
1675  }
1676 
1677  case SEQ_TYPE_EFFECT: {
1678  ibuf = seq_render_effect_strip_impl(context, state, seq, timeline_frame);
1679  break;
1680  }
1681 
1682  case SEQ_TYPE_IMAGE: {
1683  ibuf = seq_render_image_strip(context, seq, frame_index, timeline_frame, r_is_proxy_image);
1684  break;
1685  }
1686 
1687  case SEQ_TYPE_MOVIE: {
1688  ibuf = seq_render_movie_strip(context, seq, frame_index, timeline_frame, r_is_proxy_image);
1689  break;
1690  }
1691 
1692  case SEQ_TYPE_MOVIECLIP: {
1693  ibuf = seq_render_movieclip_strip(context, seq, frame_index, r_is_proxy_image);
1694 
1695  if (ibuf) {
1696  /* duplicate frame so movie cache wouldn't be confused by sequencer's stuff */
1697  ImBuf *i = IMB_dupImBuf(ibuf);
1698  IMB_freeImBuf(ibuf);
1699  ibuf = i;
1700 
1701  if (ibuf->rect_float) {
1702  seq_imbuf_to_sequencer_space(context->scene, ibuf, false);
1703  }
1704  }
1705 
1706  break;
1707  }
1708 
1709  case SEQ_TYPE_MASK: {
1710  /* ibuf is always new */
1711  ibuf = seq_render_mask_strip(context, seq, frame_index);
1712  break;
1713  }
1714  }
1715 
1716  if (ibuf) {
1717  seq_imbuf_assign_spaces(context->scene, ibuf);
1718  }
1719 
1720  return ibuf;
1721 }
1722 
1725  Sequence *seq,
1726  float timeline_frame)
1727 {
1728  ImBuf *ibuf = NULL;
1729  bool use_preprocess = false;
1730  bool is_proxy_image = false;
1731 
1732  ibuf = seq_cache_get(context, seq, timeline_frame, SEQ_CACHE_STORE_PREPROCESSED);
1733  if (ibuf != NULL) {
1734  return ibuf;
1735  }
1736 
1737  /* Proxies are not stored in cache. */
1738  if (!SEQ_can_use_proxy(
1739  context, seq, SEQ_rendersize_to_proxysize(context->preview_render_size))) {
1740  ibuf = seq_cache_get(context, seq, timeline_frame, SEQ_CACHE_STORE_RAW);
1741  }
1742 
1743  if (ibuf == NULL) {
1744  ibuf = do_render_strip_uncached(context, state, seq, timeline_frame, &is_proxy_image);
1745  }
1746 
1747  if (ibuf) {
1748  use_preprocess = seq_input_have_to_preprocess(context, seq, timeline_frame);
1750  context, seq, ibuf, timeline_frame, use_preprocess, is_proxy_image);
1751  }
1752 
1753  if (ibuf == NULL) {
1754  ibuf = IMB_allocImBuf(context->rectx, context->recty, 32, IB_rect);
1755  seq_imbuf_assign_spaces(context->scene, ibuf);
1756  }
1757 
1758  return ibuf;
1759 }
1760 
1762 {
1763  bool swap_input = false;
1764 
1765  /* bad hack, to fix crazy input ordering of
1766  * those two effects */
1767 
1769  swap_input = true;
1770  }
1771 
1772  return swap_input;
1773 }
1774 
1776 {
1778  float fac = seq->blend_opacity / 100.0f;
1779  int early_out = sh.early_out(seq, fac);
1780 
1782  return early_out;
1783  }
1784 
1786  if (early_out == EARLY_USE_INPUT_2) {
1787  return EARLY_USE_INPUT_1;
1788  }
1789  if (early_out == EARLY_USE_INPUT_1) {
1790  return EARLY_USE_INPUT_2;
1791  }
1792  }
1793  return early_out;
1794 }
1795 
1797  const SeqRenderData *context, Sequence *seq, float timeline_frame, ImBuf *ibuf1, ImBuf *ibuf2)
1798 {
1799  ImBuf *out;
1801  float fac = seq->blend_opacity / 100.0f;
1802  int swap_input = seq_must_swap_input_in_blend_mode(seq);
1803 
1804  if (swap_input) {
1805  if (sh.multithreaded) {
1807  &sh, context, seq, timeline_frame, fac, ibuf2, ibuf1, NULL);
1808  }
1809  else {
1810  out = sh.execute(context, seq, timeline_frame, fac, ibuf2, ibuf1, NULL);
1811  }
1812  }
1813  else {
1814  if (sh.multithreaded) {
1816  &sh, context, seq, timeline_frame, fac, ibuf1, ibuf2, NULL);
1817  }
1818  else {
1819  out = sh.execute(context, seq, timeline_frame, fac, ibuf1, ibuf2, NULL);
1820  }
1821  }
1822 
1823  return out;
1824 }
1825 
1828  ListBase *channels,
1829  ListBase *seqbasep,
1830  float timeline_frame,
1831  int chanshown)
1832 {
1833  Sequence *seq_arr[MAXSEQ + 1];
1834  int count;
1835  int i;
1836  ImBuf *out = NULL;
1837 
1839  context->scene, channels, seqbasep, timeline_frame, chanshown, (Sequence **)&seq_arr);
1840 
1841  if (count == 0) {
1842  return NULL;
1843  }
1844 
1845  for (i = count - 1; i >= 0; i--) {
1846  int early_out;
1847  Sequence *seq = seq_arr[i];
1848 
1849  out = seq_cache_get(context, seq, timeline_frame, SEQ_CACHE_STORE_COMPOSITE);
1850 
1851  if (out) {
1852  break;
1853  }
1854  if (seq->blend_mode == SEQ_BLEND_REPLACE) {
1855  out = seq_render_strip(context, state, seq, timeline_frame);
1856  break;
1857  }
1858 
1860 
1861  /* Early out for alpha over. It requires image to be rendered, so it can't use
1862  * `seq_get_early_out_for_blend_mode`. */
1863  if (out == NULL && seq->blend_mode == SEQ_TYPE_ALPHAOVER && seq->blend_opacity == 100.0f) {
1864  ImBuf *test = seq_render_strip(context, state, seq, timeline_frame);
1867  }
1868  else {
1870  }
1871  /* Free the image. It is stored in cache, so this doesn't affect performance. */
1872  IMB_freeImBuf(test);
1873  }
1874 
1875  switch (early_out) {
1876  case EARLY_NO_INPUT:
1877  case EARLY_USE_INPUT_2:
1878  out = seq_render_strip(context, state, seq, timeline_frame);
1879  break;
1880  case EARLY_USE_INPUT_1:
1881  if (i == 0) {
1882  out = IMB_allocImBuf(context->rectx, context->recty, 32, IB_rect);
1883  }
1884  break;
1885  case EARLY_DO_EFFECT:
1886  if (i == 0) {
1887  ImBuf *ibuf1 = IMB_allocImBuf(context->rectx, context->recty, 32, IB_rect);
1888  ImBuf *ibuf2 = seq_render_strip(context, state, seq, timeline_frame);
1889 
1890  out = seq_render_strip_stack_apply_effect(context, seq, timeline_frame, ibuf1, ibuf2);
1891 
1892  seq_cache_put(context, seq_arr[i], timeline_frame, SEQ_CACHE_STORE_COMPOSITE, out);
1893 
1894  IMB_freeImBuf(ibuf1);
1895  IMB_freeImBuf(ibuf2);
1896  }
1897  break;
1898  }
1899 
1900  if (out) {
1901  break;
1902  }
1903  }
1904 
1905  i++;
1906  for (; i < count; i++) {
1907  Sequence *seq = seq_arr[i];
1908 
1910  ImBuf *ibuf1 = out;
1911  ImBuf *ibuf2 = seq_render_strip(context, state, seq, timeline_frame);
1912 
1913  out = seq_render_strip_stack_apply_effect(context, seq, timeline_frame, ibuf1, ibuf2);
1914 
1915  IMB_freeImBuf(ibuf1);
1916  IMB_freeImBuf(ibuf2);
1917  }
1918 
1919  seq_cache_put(context, seq_arr[i], timeline_frame, SEQ_CACHE_STORE_COMPOSITE, out);
1920  }
1921 
1922  return out;
1923 }
1924 
1925 ImBuf *SEQ_render_give_ibuf(const SeqRenderData *context, float timeline_frame, int chanshown)
1926 {
1927  Scene *scene = context->scene;
1928  Editing *ed = SEQ_editing_get(scene);
1929  ListBase *seqbasep;
1930  ListBase *channels;
1931 
1932  if (ed == NULL) {
1933  return NULL;
1934  }
1935 
1936  if ((chanshown < 0) && !BLI_listbase_is_empty(&ed->metastack)) {
1937  int count = BLI_listbase_count(&ed->metastack);
1938  count = max_ii(count + chanshown, 0);
1939  seqbasep = ((MetaStack *)BLI_findlink(&ed->metastack, count))->oldbasep;
1940  channels = ((MetaStack *)BLI_findlink(&ed->metastack, count))->old_channels;
1941  }
1942  else {
1943  seqbasep = ed->seqbasep;
1945  }
1946 
1949  ImBuf *out = NULL;
1950  Sequence *seq_arr[MAXSEQ + 1];
1951  int count;
1952 
1953  count = seq_get_shown_sequences(scene, channels, seqbasep, timeline_frame, chanshown, seq_arr);
1954 
1955  if (count) {
1956  out = seq_cache_get(context, seq_arr[count - 1], timeline_frame, SEQ_CACHE_STORE_FINAL_OUT);
1957  }
1958 
1959  seq_cache_free_temp_cache(context->scene, context->task_id, timeline_frame);
1960  /* Make sure we only keep the `anim` data for strips that are in view. */
1961  SEQ_relations_free_all_anim_ibufs(context->scene, timeline_frame);
1962 
1963  if (count && !out) {
1965  out = seq_render_strip_stack(context, &state, channels, seqbasep, timeline_frame, chanshown);
1966 
1967  if (context->is_prefetch_render) {
1968  seq_cache_put(context, seq_arr[count - 1], timeline_frame, SEQ_CACHE_STORE_FINAL_OUT, out);
1969  }
1970  else {
1972  context, seq_arr[count - 1], timeline_frame, SEQ_CACHE_STORE_FINAL_OUT, out);
1973  }
1975  }
1976 
1977  seq_prefetch_start(context, timeline_frame);
1978 
1979  return out;
1980 }
1981 
1983  float timeline_frame,
1984  int chan_shown,
1985  ListBase *channels,
1986  ListBase *seqbasep)
1987 {
1990 
1991  return seq_render_strip_stack(context, &state, channels, seqbasep, timeline_frame, chan_shown);
1992 }
1993 
1995  float timeline_frame,
1996  Sequence *seq)
1997 {
2000 
2001  ImBuf *ibuf = seq_render_strip(context, &state, seq, timeline_frame);
2002  return ibuf;
2003 }
2004 
2006  Sequence *seq,
2007  float frame_step,
2008  rctf *view_area)
2009 {
2010  int first_drawable_frame = max_iii(
2011  SEQ_time_left_handle_frame_get(scene, seq), seq->start, view_area->xmin);
2012 
2013  /* First frame should correspond to handle position. */
2014  if (first_drawable_frame == SEQ_time_left_handle_frame_get(scene, seq)) {
2016  }
2017 
2018  float aligned_frame_offset = (int)((first_drawable_frame - seq->start) / frame_step) *
2019  frame_step;
2020  return seq->start + aligned_frame_offset;
2021 }
2022 
2024  Sequence *seq,
2025  float last_frame,
2026  float frame_step)
2027 {
2028  float next_frame = last_frame + frame_step;
2029 
2030  /* If handle position was displayed, align next frame with `seq->start`. */
2031  if (last_frame == SEQ_time_left_handle_frame_get(scene, seq)) {
2032  next_frame = seq->start + ((int)((last_frame - seq->start) / frame_step) + 1) * frame_step;
2033  }
2034 
2035  return next_frame;
2036 }
2037 
2038 /* Gets the direct image from source and scales to thumbnail size. */
2041  Sequence *seq,
2042  float timeline_frame)
2043 {
2044  bool is_proxy_image = false;
2045  ImBuf *ibuf = do_render_strip_uncached(context, state, seq, timeline_frame, &is_proxy_image);
2046 
2047  if (ibuf == NULL) {
2048  return NULL;
2049  }
2050 
2051  float aspect_ratio = (float)ibuf->x / ibuf->y;
2052  int rectx, recty;
2053  /* Calculate new dimensions - THUMB_SIZE (256) for x or y. */
2054  if (ibuf->x > ibuf->y) {
2055  rectx = SEQ_RENDER_THUMB_SIZE;
2056  recty = round_fl_to_int(rectx / aspect_ratio);
2057  }
2058  else {
2059  recty = SEQ_RENDER_THUMB_SIZE;
2060  rectx = round_fl_to_int(recty * aspect_ratio);
2061  }
2062 
2063  /* Scale ibuf to thumbnail size. */
2064  ImBuf *scaled_ibuf = IMB_allocImBuf(rectx, recty, 32, ibuf->rect_float ? IB_rectfloat : IB_rect);
2065  sequencer_thumbnail_transform(ibuf, scaled_ibuf);
2066  seq_imbuf_assign_spaces(context->scene, scaled_ibuf);
2067  IMB_freeImBuf(ibuf);
2068 
2069  return scaled_ibuf;
2070 }
2071 
2073  const SeqRenderData *context, Sequence *seq, float timeline_frame, rcti *crop, bool clipped)
2074 {
2075  ImBuf *ibuf = seq_cache_get(context, seq, roundf(timeline_frame), SEQ_CACHE_STORE_THUMBNAIL);
2076 
2077  if (!clipped || ibuf == NULL) {
2078  return ibuf;
2079  }
2080 
2081  /* Do clipping. */
2082  ImBuf *ibuf_cropped = IMB_dupImBuf(ibuf);
2083  if (crop->xmin < 0 || crop->ymin < 0) {
2084  crop->xmin = 0;
2085  crop->ymin = 0;
2086  }
2087  if (crop->xmax >= ibuf->x || crop->ymax >= ibuf->y) {
2088  crop->xmax = ibuf->x - 1;
2089  crop->ymax = ibuf->y - 1;
2090  }
2091  IMB_rect_crop(ibuf_cropped, crop);
2092  IMB_freeImBuf(ibuf);
2093  return ibuf_cropped;
2094 }
2095 
2097  Sequence *seq,
2098  Sequence *seq_orig,
2099  float frame_step,
2100  rctf *view_area,
2101  const short *stop)
2102 {
2105  const Scene *scene = context->scene;
2106 
2107  /* Adding the hold offset value (seq->anim_startofs) to the start frame. Position of image not
2108  * affected, but frame loaded affected. */
2109  float upper_thumb_bound = SEQ_time_has_right_still_frames(scene, seq) ?
2110  (seq->start + seq->len) :
2112  upper_thumb_bound = (upper_thumb_bound > view_area->xmax) ? view_area->xmax + frame_step :
2113  upper_thumb_bound;
2114 
2115  float timeline_frame = SEQ_render_thumbnail_first_frame_get(scene, seq, frame_step, view_area);
2116  while ((timeline_frame < upper_thumb_bound) & !*stop) {
2117  ImBuf *ibuf = seq_cache_get(
2118  context, seq_orig, round_fl_to_int(timeline_frame), SEQ_CACHE_STORE_THUMBNAIL);
2119  if (ibuf) {
2120  IMB_freeImBuf(ibuf);
2121  timeline_frame = SEQ_render_thumbnail_next_frame_get(scene, seq, timeline_frame, frame_step);
2122  continue;
2123  }
2124 
2125  ibuf = seq_get_uncached_thumbnail(context, &state, seq, round_fl_to_int(timeline_frame));
2126 
2127  if (ibuf) {
2128  seq_cache_thumbnail_put(context, seq_orig, round_fl_to_int(timeline_frame), ibuf, view_area);
2129  IMB_freeImBuf(ibuf);
2130  seq_orig->flag &= ~SEQ_FLAG_SKIP_THUMBNAILS;
2131  }
2132  else {
2133  /* Can not open source file. */
2134  seq_orig->flag |= SEQ_FLAG_SKIP_THUMBNAILS;
2135  return;
2136  }
2137 
2138  timeline_frame = SEQ_render_thumbnail_next_frame_get(scene, seq, timeline_frame, frame_step);
2139  }
2140 }
2141 
2143 {
2144  const int content_start = max_ii(SEQ_time_left_handle_frame_get(scene, seq), seq->start);
2145  const int content_end = min_ii(SEQ_time_right_handle_frame_get(scene, seq),
2146  seq->start + seq->len);
2147  const int content_len = content_end - content_start;
2148 
2149  /* Arbitrary, but due to performance reasons should be as low as possible. */
2150  const int thumbnails_base_set_count = min_ii(content_len / 100, 30);
2151  if (thumbnails_base_set_count <= 0) {
2152  return content_len;
2153  }
2154  return content_len / thumbnails_base_set_count;
2155 }
2156 
2158  Sequence *seq,
2159  Sequence *seq_orig,
2160  rctf *view_area,
2161  const short *stop)
2162 {
2165  const Scene *scene = context->scene;
2166 
2167  int timeline_frame = SEQ_time_left_handle_frame_get(scene, seq);
2168  const int frame_step = SEQ_render_thumbnails_guaranteed_set_frame_step_get(scene, seq);
2169 
2170  while (timeline_frame < SEQ_time_right_handle_frame_get(scene, seq) && !*stop) {
2171  ImBuf *ibuf = seq_cache_get(
2172  context, seq_orig, roundf(timeline_frame), SEQ_CACHE_STORE_THUMBNAIL);
2173  if (ibuf) {
2174  IMB_freeImBuf(ibuf);
2175 
2176  if (frame_step == 0) {
2177  return;
2178  }
2179 
2180  timeline_frame += frame_step;
2181  continue;
2182  }
2183 
2184  ibuf = seq_get_uncached_thumbnail(context, &state, seq, timeline_frame);
2185 
2186  if (ibuf) {
2187  seq_cache_thumbnail_put(context, seq_orig, timeline_frame, ibuf, view_area);
2188  IMB_freeImBuf(ibuf);
2189  }
2190 
2191  if (frame_step == 0) {
2192  return;
2193  }
2194 
2195  timeline_frame += frame_step;
2196  }
2197 }
2198 
2200 {
2201 
2203  return seq->flag & SEQ_MUTE || SEQ_channel_is_muted(channel);
2204 }
2205 
typedef float(TangentPoint)[2]
struct AnimData * BKE_animdata_from_id(const struct ID *id)
void BKE_animsys_evaluate_all_animation(struct Main *main, struct Depsgraph *depsgraph, float ctime)
Definition: anim_sys.c:3985
AnimationEvalContext BKE_animsys_eval_context_construct(struct Depsgraph *depsgraph, float eval_time)
Definition: anim_sys.c:761
@ ADT_RECALC_ANIM
Definition: BKE_animsys.h:290
void BKE_animsys_evaluate_animdata(struct ID *id, struct AnimData *adt, const struct AnimationEvalContext *anim_eval_context, eAnimData_Recalc recalc, bool flush_to_original)
float evaluate_fcurve(struct FCurve *fcu, float evaltime)
Definition: fcurve.c:2135
struct FCurve * id_data_find_fcurve(ID *id, void *data, struct StructRNA *type, const char *prop_name, int index, bool *r_driven)
Definition: fcurve.c:201
struct anim * openanim(const char *name, int flags, int streamindex, char colorspace[IMA_MAX_SPACE])
struct ViewLayer * BKE_view_layer_default_render(const struct Scene *scene)
@ LIB_ID_COPY_LOCALIZE
Definition: BKE_lib_id.h:187
@ LIB_ID_COPY_NO_ANIMDATA
Definition: BKE_lib_id.h:154
struct ID * BKE_id_copy_ex(struct Main *bmain, const struct ID *id, struct ID **r_newid, int flag)
void BKE_id_free(struct Main *bmain, void *idv)
const char * BKE_main_blendfile_path_from_global(void)
Definition: main.c:562
void BKE_maskrasterize_handle_free(MaskRasterHandle *mr_handle)
void BKE_mask_evaluate(struct Mask *mask, float ctime, bool do_newframe)
Definition: mask.c:1568
void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle, struct Mask *mask, int width, int height, bool do_aspect_correct, bool do_mask_aa, bool do_feather)
MaskRasterHandle * BKE_maskrasterize_handle_new(void)
void BKE_maskrasterize_buffer(MaskRasterHandle *mr_handle, unsigned int width, unsigned int height, float *buffer)
Rasterize a buffer from a single mask (threaded execution).
bool BKE_movieclip_proxy_enabled(struct MovieClip *clip)
Definition: movieclip.c:1894
#define MOVIECLIP_CACHE_SKIP
struct ImBuf * BKE_movieclip_get_ibuf_flag(struct MovieClip *clip, struct MovieClipUser *user, int flag, int cache_flag)
Definition: movieclip.c:1334
void BKE_movieclip_user_set_frame(struct MovieClipUser *user, int framenr)
Definition: movieclip.c:1614
struct ImBuf * BKE_movieclip_get_stable_ibuf(struct MovieClip *clip, struct MovieClipUser *user, float loc[2], float *scale, float *angle, int postprocess_flag)
Definition: movieclip.c:1447
const char * BKE_scene_multiview_render_view_name_get(const struct RenderData *rd, int view_id)
void BKE_render_resolution(const struct RenderData *r, const bool use_crop, int *r_width, int *r_height)
Definition: scene.cc:2960
void BKE_scene_multiview_view_prefix_get(struct Scene *scene, const char *name, char *r_prefix, const char **r_ext)
Definition: scene.cc:3233
bool BKE_scene_camera_switch_update(struct Scene *scene)
Definition: scene.cc:2295
void BKE_scene_graph_update_for_newframe(struct Depsgraph *depsgraph)
Definition: scene.cc:2728
int BKE_scene_multiview_num_views_get(const struct RenderData *rd)
struct Depsgraph * BKE_scene_ensure_depsgraph(struct Main *bmain, struct Scene *scene, struct ViewLayer *view_layer)
Definition: scene.cc:3456
void BKE_scene_frame_set(struct Scene *scene, float frame)
Definition: scene.cc:2420
struct ImBuf *(* SequencerDrawView)(struct Depsgraph *depsgraph, struct Scene *scene, struct View3DShading *shading_override, enum eDrawType drawtype, struct Object *camera, int width, int height, enum eImBufFlags flag, eV3DOffscreenDrawFlag draw_flags, int alpha_mode, const char *viewname, struct GPUOffScreen *ofs, char err_out[256])
#define BLI_assert_msg(a, msg)
Definition: BLI_assert.h:53
unsigned int BLI_gset_len(const GSet *gs) ATTR_WARN_UNUSED_RESULT
Definition: BLI_ghash.c:957
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
Definition: BLI_listbase.h:269
int BLI_listbase_count_at_most(const struct ListBase *listbase, int count_max) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void * BLI_findlink(const struct ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
int BLI_listbase_count(const struct ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
MINLINE int round_fl_to_int(float a)
MINLINE int min_ii(int a, int b)
MINLINE int max_ii(int a, int b)
MINLINE int max_iii(int a, int b, int c)
MINLINE void srgb_to_linearrgb_v4(float linear[4], const float srgb[4])
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])
Definition: math_geom.c:1536
bool invert_m4(float R[4][4])
Definition: math_matrix.c:1206
void unit_m3(float m[3][3])
Definition: math_matrix.c:40
void loc_rot_size_to_mat4(float R[4][4], const float loc[3], const float rot[3][3], const float size[3])
Definition: math_matrix.c:2537
void transform_pivot_set_m4(float mat[4][4], const float pivot[3])
Definition: math_matrix.c:2369
void axis_angle_to_mat3_single(float R[3][3], char axis, float angle)
MINLINE void add_v2_v2(float r[2], const float a[2])
#define FILE_MAX
bool BLI_path_abs(char *path, const char *basepath) ATTR_NONNULL()
Definition: path_util.c:897
void BLI_join_dirfile(char *__restrict dst, size_t maxlen, const char *__restrict dir, const char *__restrict file) ATTR_NONNULL()
Definition: path_util.c:1531
void BLI_rctf_init(struct rctf *rect, float xmin, float xmax, float ymin, float ymax)
Definition: rct.c:407
#define BLI_MUTEX_INITIALIZER
Definition: BLI_threads.h:83
int BLI_thread_is_main(void)
Definition: threads.cc:207
void BLI_mutex_lock(ThreadMutex *mutex)
Definition: threads.cc:373
void BLI_mutex_unlock(ThreadMutex *mutex)
Definition: threads.cc:378
pthread_mutex_t ThreadMutex
Definition: BLI_threads.h:82
#define UNUSED(x)
#define ELEM(...)
#define STREQ(a, b)
typedef double(DMatrix)[4][4]
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:35
struct Object * DEG_get_evaluated_object(const struct Depsgraph *depsgraph, struct Object *object)
#define DNA_struct_default_get(struct_name)
Definition: DNA_defaults.h:29
@ MCLIP_PROXY_RENDER_USE_FALLBACK_RENDER
@ MCLIP_PROXY_RENDER_UNDISTORT
@ MCLIP_PROXY_RENDER_SIZE_75
@ MCLIP_PROXY_RENDER_SIZE_100
@ MCLIP_PROXY_RENDER_SIZE_50
@ MCLIP_PROXY_RENDER_SIZE_FULL
@ MCLIP_PROXY_RENDER_SIZE_25
@ OB_RENDER
#define R_MULTIVIEW
#define R_NO_CAMERA_SWITCH
#define R_IMF_PLANES_BW
#define R_DOCOMP
#define R_DOSEQ
@ R_SEQ_OVERRIDE_SCENE_SETTINGS
#define R_IMF_PLANES_RGBA
@ R_IMF_VIEWS_STEREO_3D
#define R_IMF_PLANES_RGB
#define SEQ_BLEND_REPLACE
@ SEQ_TYPE_META
@ SEQ_TYPE_OVERDROP
@ SEQ_TYPE_ALPHAUNDER
@ SEQ_TYPE_SCENE
@ SEQ_TYPE_MOVIECLIP
@ SEQ_TYPE_ALPHAOVER
@ SEQ_TYPE_IMAGE
@ SEQ_TYPE_SPEED
@ SEQ_TYPE_EFFECT
@ SEQ_TYPE_MOVIE
@ SEQ_TYPE_MASK
@ SEQ_ALPHA_PREMUL
#define SEQ_MOVIECLIP_RENDER_STABILIZED
#define SEQ_MOVIECLIP_RENDER_UNDISTORTED
@ SEQ_STORAGE_PROXY_CUSTOM_FILE
@ SEQ_CACHE_STORE_PREPROCESSED
@ SEQ_CACHE_STORE_RAW
@ SEQ_CACHE_STORE_THUMBNAIL
@ SEQ_CACHE_STORE_FINAL_OUT
@ SEQ_CACHE_STORE_COMPOSITE
@ SEQ_MUTE
@ SEQ_FILTERY
@ SEQ_FLIPX
@ SEQ_MAKE_FLOAT
@ SEQ_FLAG_SKIP_THUMBNAILS
@ SEQ_SCENE_STRIPS
@ SEQ_USE_EFFECT_DEFAULT_FADE
@ SEQ_FLIPY
@ SEQ_USE_VIEWS
@ SEQ_SCENE_NO_ANNOTATION
#define MAXSEQ
@ SEQ_TRANSFORM_FILTER_NEAREST
#define SEQ_EDIT_PROXY_DIR_STORAGE
@ SEQ_RENDER_SIZE_SCENE
@ V3D_OFSDRAW_NONE
@ V3D_OFSDRAW_OVERRIDE_SCENE_SETTINGS
@ V3D_OFSDRAW_SHOW_ANNOTATION
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble right
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble top
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble bottom
const char * IMB_colormanagement_get_rect_colorspace(struct ImBuf *ibuf)
@ COLOR_ROLE_SCENE_LINEAR
void IMB_colormanagement_transform_from_byte_threaded(float *float_buffer, unsigned char *byte_buffer, int width, int height, int channels, const char *from_colorspace, const char *to_colorspace)
void IMB_colormanagement_assign_float_colorspace(struct ImBuf *ibuf, const char *name)
void IMB_colormanagement_transform_threaded(float *buffer, int width, int height, int channels, const char *from_colorspace, const char *to_colorspace, bool predivide)
void IMB_colormanagement_transform_byte_threaded(unsigned char *buffer, int width, int height, int channels, const char *from_colorspace, const char *to_colorspace)
void IMB_colormanagement_assign_rect_colorspace(struct ImBuf *ibuf, const char *name)
const char * IMB_colormanagement_role_colorspace_name_get(int role)
void IMB_colormanagement_transform_v4(float pixel[4], const char *from_colorspace, const char *to_colorspace)
const char * IMB_colormanagement_get_float_colorspace(struct ImBuf *ibuf)
struct ImBuf * IMB_makeSingleUser(struct ImBuf *ibuf)
Definition: allocimbuf.c:227
bool IMB_anim_get_fps(struct anim *anim, short *frs_sec, float *frs_sec_base, bool no_av_base)
Definition: anim_movie.c:1678
struct ImBuf * IMB_allocImBuf(unsigned int x, unsigned int y, unsigned char planes, unsigned int flags)
Definition: allocimbuf.c:500
bool imb_addrectfloatImBuf(struct ImBuf *ibuf, const unsigned int channels)
Definition: allocimbuf.c:367
struct ImBuf * IMB_dupImBuf(const struct ImBuf *ibuf1)
void IMB_rect_crop(struct ImBuf *ibuf, const struct rcti *crop)
IMB_Proxy_Size
Definition: IMB_imbuf.h:340
@ IMB_PROXY_100
Definition: IMB_imbuf.h:345
@ IMB_PROXY_75
Definition: IMB_imbuf.h:344
@ IMB_PROXY_50
Definition: IMB_imbuf.h:343
@ IMB_PROXY_25
Definition: IMB_imbuf.h:342
@ IMB_PROXY_NONE
Definition: IMB_imbuf.h:341
void IMB_filtery(struct ImBuf *ibuf)
Definition: filter.c:102
void imb_freerectImBuf(struct ImBuf *ibuf)
Definition: allocimbuf.c:97
void IMB_processor_apply_threaded(int buffer_lines, int handle_size, void *init_customdata, void(init_handle)(void *handle, int start_line, int tot_line, void *customdata), void *(do_thread)(void *))
Definition: imageprocess.c:355
@ IMB_TRANSFORM_MODE_REGULAR
Do not crop or repeat.
Definition: IMB_imbuf.h:894
@ IMB_TRANSFORM_MODE_CROP_SRC
Crop the source buffer.
Definition: IMB_imbuf.h:896
bool addzbuffloatImBuf(struct ImBuf *ibuf)
Definition: allocimbuf.c:270
void IMB_saturation(struct ImBuf *ibuf, float sat)
Definition: divers.c:889
void IMB_ImBufFromStereo3d(const struct Stereo3dFormat *s3d, struct ImBuf *ibuf_stereo, struct ImBuf **r_ibuf_left, struct ImBuf **r_ibuf_right)
struct ImBuf * IMB_loadiffname(const char *filepath, int flags, char colorspace[IM_MAX_SPACE])
Definition: readimage.c:209
void IMB_transform(const struct ImBuf *src, struct ImBuf *dst, eIMBTransformMode mode, eIMBInterpolationFilterMode filter, const float transform_matrix[4][4], const struct rctf *src_crop)
Transform source image buffer onto destination image buffer using a transform matrix.
Definition: transform.cc:569
void IMB_flipx(struct ImBuf *ibuf)
Definition: rotate.c:75
struct ImBuf * IMB_anim_absolute(struct anim *anim, int position, IMB_Timecode_Type tc, IMB_Proxy_Size preview_size)
Definition: anim_movie.c:1571
eIMBInterpolationFilterMode
Definition: IMB_imbuf.h:349
@ IMB_FILTER_NEAREST
Definition: IMB_imbuf.h:350
@ IMB_FILTER_BILINEAR
Definition: IMB_imbuf.h:351
void IMB_flipy(struct ImBuf *ibuf)
Definition: rotate.c:16
@ IMB_TC_NONE
Definition: IMB_imbuf.h:318
@ IMB_TC_RECORD_RUN
Definition: IMB_imbuf.h:324
Contains defines and structs used throughout the imbuf module.
@ IB_alphamode_premul
@ IB_rectfloat
@ IB_metadata
@ IB_rect
void IMB_metadata_copy(struct ImBuf *dimb, struct ImBuf *simb)
Definition: metadata.c:64
Read Guarded memory(de)allocation.
static void init_data(ModifierData *md)
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Sky Generate a procedural sky texture Noise Generate fractal Perlin noise Wave Generate procedural bands or rings with noise Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a or normal between camera
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert a producing a negative Combine Generate a color from its and blue channels(Deprecated)") DefNode(ShaderNode
#define SEQ_ITERATOR_FOREACH(var, collection)
Definition: SEQ_iterator.h:35
@ SEQ_TASK_MAIN_RENDER
Definition: SEQ_render.h:23
#define SEQ_RENDER_THUMB_SIZE
Definition: SEQ_render.h:14
SIMD_FORCE_INLINE btVector3 transform(const btVector3 &point) const
static void mul(btAlignedObjectArray< T > &items, const Q &value)
SeqTimelineChannel * SEQ_channel_get_by_index(const ListBase *channels, const int channel_index)
Definition: channels.c:59
bool SEQ_channel_is_muted(const SeqTimelineChannel *channel)
Definition: channels.c:80
Scene scene
const Depsgraph * depsgraph
struct SeqEffectHandle SEQ_effect_handle_get(Sequence *seq)
Definition: effects.c:3704
float seq_speed_effect_target_frame_get(Scene *scene, Sequence *seq_speed, float timeline_frame, int input)
Definition: effects.c:2632
int SEQ_effect_get_num_inputs(int seq_type)
Definition: effects.c:3741
struct SeqEffectHandle seq_effect_get_sequence_blend(Sequence *seq)
Definition: effects.c:3719
#define str(s)
void IMB_freeImBuf(ImBuf *UNUSED(ibuf))
void seq_cache_thumbnail_put(const SeqRenderData *context, Sequence *seq, float timeline_frame, ImBuf *i, rctf *view_area)
Definition: image_cache.c:815
bool seq_cache_put_if_possible(const SeqRenderData *context, Sequence *seq, float timeline_frame, int type, ImBuf *ibuf)
Definition: image_cache.c:790
void seq_cache_put(const SeqRenderData *context, Sequence *seq, float timeline_frame, int type, ImBuf *i)
Definition: image_cache.c:846
void seq_cache_free_temp_cache(Scene *scene, short id, int timeline_frame)
Definition: image_cache.c:547
struct ImBuf * seq_cache_get(const SeqRenderData *context, Sequence *seq, float timeline_frame, int type)
Definition: image_cache.c:726
DO_INLINE void filter(lfVector *V, fmatrix3x3 *S)
int count
SeqCollection * SEQ_query_rendered_strips(const Scene *scene, ListBase *channels, ListBase *seqbase, const int timeline_frame, const int displayed_channel)
Definition: iterator.c:309
void SEQ_collection_free(SeqCollection *collection)
Definition: iterator.c:81
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
ccl_global KernelShaderEvalInput * input
const int state
ccl_gpu_kernel_postfix ccl_global float int int int int sh
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:27
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:31
void *(* MEM_mallocN)(size_t len, const char *str)
Definition: mallocn.c:33
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)
Definition: math_float4.h:513
static int left
#define G(x, y, z)
#define floorf(x)
Definition: metal/compat.h:224
int seq_num_files(Scene *scene, char views_format, const bool is_multiview)
Definition: multiview.c:26
void seq_multiview_name(Scene *scene, const int view_id, const char *prefix, const char *ext, char *r_path, size_t r_size)
Definition: multiview.c:39
static unsigned c
Definition: RandGen.cpp:83
static unsigned a[3]
Definition: RandGen.cpp:78
static const pxr::TfToken out("out", pxr::TfToken::Immortal)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
void RE_ReleaseResultImage(Render *re)
Definition: pipeline.c:474
Render * RE_GetSceneRender(const Scene *scene)
Definition: pipeline.c:551
void RE_AcquireResultImage(Render *re, RenderResult *rr, const int view_id)
Definition: pipeline.c:428
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)
Definition: pipeline.c:1813
Render * RE_NewSceneRender(const Scene *scene)
Definition: pipeline.c:558
void seq_prefetch_start(const SeqRenderData *context, float timeline_frame)
Definition: prefetch.c:561
int SEQ_rendersize_to_proxysize(int render_size)
Definition: proxy.c:71
ImBuf * seq_proxy_fetch(const SeqRenderData *context, Sequence *seq, int timeline_frame)
Definition: proxy.c:201
bool SEQ_can_use_proxy(const struct SeqRenderData *context, Sequence *seq, int psize)
Definition: proxy.c:191
double SEQ_rendersize_to_scale_factor(int render_size)
Definition: proxy.c:86
bool seq_proxy_get_custom_file_fname(Sequence *seq, char *name, const int view_id)
Definition: proxy.c:99
#define PROXY_MAXFILE
Definition: proxy.h:19
static ImBuf * seq_render_mask_strip(const SeqRenderData *context, Sequence *seq, float frame_index)
Definition: render.c:1322
static ImBuf * seq_render_preprocess_ibuf(const SeqRenderData *context, Sequence *seq, ImBuf *ibuf, float timeline_frame, bool use_preprocess, const bool is_proxy_image)
Definition: render.c:654
static ImBuf * seq_render_strip_stack_apply_effect(const SeqRenderData *context, Sequence *seq, float timeline_frame, ImBuf *ibuf1, ImBuf *ibuf2)
Definition: render.c:1796
ImBuf * SEQ_render_give_ibuf(const SeqRenderData *context, float timeline_frame, int chanshown)
Definition: render.c:1925
static ImBuf * seq_render_image_strip(const SeqRenderData *context, Sequence *seq, float UNUSED(frame_index), float timeline_frame, bool *r_is_proxy_image)
Definition: render.c:929
static void * render_effect_execute_do_thread(void *thread_data_v)
Definition: render.c:722
static ImBuf * input_preprocess(const SeqRenderData *context, Sequence *seq, float timeline_frame, ImBuf *ibuf, const bool is_proxy_image)
Definition: render.c:574
static bool seq_input_have_to_preprocess(const SeqRenderData *context, Sequence *seq, float UNUSED(timeline_frame))
Definition: render.c:337
static ImBuf * seq_render_scene_strip(const SeqRenderData *context, Sequence *seq, float frame_index, float timeline_frame)
Definition: render.c:1329
SequencerDrawView sequencer_view3d_fn
Definition: render.c:82
static ThreadMutex seq_render_mutex
Definition: render.c:81
static int seq_get_early_out_for_blend_mode(Sequence *seq)
Definition: render.c:1775
ImBuf * seq_render_mask(const SeqRenderData *context, Mask *mask, float frame_index, bool make_float)
Definition: render.c:1238
int SEQ_render_thumbnails_guaranteed_set_frame_step_get(const Scene *scene, const Sequence *seq)
Definition: render.c:2142
struct RenderEffectInitData RenderEffectInitData
static ImBuf * do_render_strip_seqbase(const SeqRenderData *context, SeqRenderState *state, Sequence *seq, float frame_index)
Definition: render.c:1592
static ImBuf * do_render_strip_uncached(const SeqRenderData *context, SeqRenderState *state, Sequence *seq, float timeline_frame, bool *r_is_proxy_image)
Definition: render.c:1628
ImBuf * SEQ_get_thumbnail(const SeqRenderData *context, Sequence *seq, float timeline_frame, rcti *crop, bool clipped)
Definition: render.c:2072
static int seq_channel_cmp_fn(const void *a, const void *b)
Definition: render.c:256
static void sequencer_thumbnail_transform(ImBuf *in, ImBuf *out)
Definition: render.c:432
static void sequencer_image_crop_init(const Sequence *seq, const ImBuf *in, float crop_scale_factor, rctf *r_crop)
Definition: render.c:418
static ImBuf * seq_render_effect_strip_impl(const SeqRenderData *context, SeqRenderState *state, Sequence *seq, float timeline_frame)
Definition: render.c:771
static void sequencer_preprocess_transform_crop(ImBuf *in, ImBuf *out, const SeqRenderData *context, Sequence *seq, const bool is_proxy_image)
Definition: render.c:495
ImBuf * SEQ_render_give_ibuf_direct(const SeqRenderData *context, float timeline_frame, Sequence *seq)
Definition: render.c:1994
static ImBuf * seq_render_movie_strip_view(const SeqRenderData *context, Sequence *seq, float frame_index, float timeline_frame, StripAnim *sanim, bool *r_is_proxy_image)
Definition: render.c:1036
void SEQ_render_new_render_data(Main *bmain, struct Depsgraph *depsgraph, Scene *scene, int rectx, int recty, int preview_render_size, int for_render, SeqRenderData *r_context)
Definition: render.c:205
ImBuf * seq_render_strip(const SeqRenderData *context, SeqRenderState *state, Sequence *seq, float timeline_frame)
Definition: render.c:1723
void SEQ_render_thumbnails_base_set(const SeqRenderData *context, Sequence *seq, Sequence *seq_orig, rctf *view_area, const short *stop)
Definition: render.c:2157
static ImBuf * seq_render_strip_stack(const SeqRenderData *context, SeqRenderState *state, ListBase *channels, ListBase *seqbasep, float timeline_frame, int chanshown)
Definition: render.c:1826
bool SEQ_render_is_muted(const ListBase *channels, const Sequence *seq)
Definition: render.c:2199
void seq_imbuf_assign_spaces(Scene *scene, ImBuf *ibuf)
Definition: render.c:88
static void multibuf(ImBuf *ibuf, const float fmul)
Definition: render.c:535
struct RenderEffectThread RenderEffectThread
static bool seq_need_scale_to_render_size(const Sequence *seq, bool is_proxy_image)
Definition: render.c:379
static bool seq_must_swap_input_in_blend_mode(Sequence *seq)
Definition: render.c:1761
StripElem * SEQ_render_give_stripelem(const Scene *scene, Sequence *seq, int timeline_frame)
Definition: render.c:236
static ImBuf * seq_render_movieclip_strip(const SeqRenderData *context, Sequence *seq, float frame_index, bool *r_is_proxy_image)
Definition: render.c:1183
static bool seq_image_transform_transparency_gained(const SeqRenderData *context, Sequence *seq)
Definition: render.c:461
float SEQ_render_thumbnail_first_frame_get(const Scene *scene, Sequence *seq, float frame_step, rctf *view_area)
Definition: render.c:2005
void seq_render_state_init(SeqRenderState *state)
Definition: render.c:231
static void sequencer_image_crop_transform_matrix(const Sequence *seq, const ImBuf *in, const ImBuf *out, const float image_scale_factor, const float preview_scale_factor, float r_transform_matrix[4][4])
Definition: render.c:392
static bool sequencer_use_crop(const Sequence *seq)
Definition: render.c:327
ImBuf * seq_render_give_ibuf_seqbase(const SeqRenderData *context, float timeline_frame, int chan_shown, ListBase *channels, ListBase *seqbasep)
Definition: render.c:1982
static bool seq_image_strip_is_multiview_render(Scene *scene, Sequence *seq, int totfiles, char *name, char *r_prefix, const char *r_ext)
Definition: render.c:913
static ImBuf * seq_render_movie_strip(const SeqRenderData *context, Sequence *seq, float frame_index, float timeline_frame, bool *r_is_proxy_image)
Definition: render.c:1086
void SEQ_render_thumbnails(const SeqRenderData *context, Sequence *seq, Sequence *seq_orig, float frame_step, rctf *view_area, const short *stop)
Definition: render.c:2096
static bool sequencer_use_transform(const Sequence *seq)
Definition: render.c:315
static ImBuf * seq_get_uncached_thumbnail(const SeqRenderData *context, SeqRenderState *state, Sequence *seq, float timeline_frame)
Definition: render.c:2039
static ImBuf * seq_render_movie_strip_custom_file_proxy(const SeqRenderData *context, Sequence *seq, int timeline_frame)
Definition: render.c:1012
int seq_get_shown_sequences(const Scene *scene, ListBase *channels, ListBase *seqbase, const int timeline_frame, const int chanshown, Sequence **r_seq_arr)
Definition: render.c:261
void seq_imbuf_to_sequencer_space(Scene *scene, ImBuf *ibuf, bool make_float)
Definition: render.c:101
void SEQ_render_imbuf_from_sequencer_space(Scene *scene, ImBuf *ibuf)
Definition: render.c:167
static ImBuf * seq_get_movieclip_ibuf(Sequence *seq, MovieClipUser user)
Definition: render.c:1170
ImBuf * seq_render_effect_execute_threaded(struct SeqEffectHandle *sh, const SeqRenderData *context, Sequence *seq, float timeline_frame, float fac, ImBuf *ibuf1, ImBuf *ibuf2, ImBuf *ibuf3)
Definition: render.c:740
static ImBuf * seq_render_image_strip_view(const SeqRenderData *context, Sequence *seq, char *name, char *prefix, const char *ext, int view_id)
Definition: render.c:873
float SEQ_render_thumbnail_next_frame_get(const Scene *scene, Sequence *seq, float last_frame, float frame_step)
Definition: render.c:2023
static void render_effect_execute_init_handle(void *handle_v, int start_line, int tot_line, void *init_data_v)
Definition: render.c:700
void SEQ_render_pixel_from_sequencer_space_v4(struct Scene *scene, float pixel[4])
Definition: render.c:184
#define EARLY_USE_INPUT_2
Definition: render.h:24
#define EARLY_DO_EFFECT
Definition: render.h:22
#define EARLY_USE_INPUT_1
Definition: render.h:23
#define EARLY_NO_INPUT
Definition: render.h:21
ImBuf * SEQ_modifier_apply_stack(const SeqRenderData *context, Sequence *seq, ImBuf *ibuf, int timeline_frame)
Editing * SEQ_editing_get(const Scene *scene)
Definition: sequencer.c:241
void SEQ_relations_free_all_anim_ibufs(Scene *scene, int timeline_frame)
bool SEQ_time_has_right_still_frames(const Scene *scene, const Sequence *seq)
Definition: strip_time.c:471
int SEQ_time_left_handle_frame_get(const Scene *UNUSED(scene), const Sequence *seq)
Definition: strip_time.c:506
float seq_give_frame_index(const Scene *scene, Sequence *seq, float timeline_frame)
Definition: strip_time.c:52
int SEQ_time_right_handle_frame_get(const Scene *scene, const Sequence *seq)
Definition: strip_time.c:515
void SEQ_image_transform_final_quad_get(const Scene *scene, const Sequence *seq, float r_quad[4][2])
ListBase seqbase
ListBase * seqbasep
ListBase * displayed_channels
ListBase metastack
int channels
unsigned char planes
unsigned int * rect
float * rect_float
struct LinkNode * next
Definition: BLI_linklist.h:23
void * first
Definition: DNA_listBase.h:31
Definition: BKE_main.h:121
const SeqRenderData * context
Definition: render.c:681
struct SeqEffectHandle * sh
Definition: render.c:680
Sequence * seq
Definition: render.c:682
float timeline_frame
Definition: render.c:683
float timeline_frame
Definition: render.c:693
const SeqRenderData * context
Definition: render.c:691
ImBuf * ibuf1
Definition: render.c:694
struct SeqEffectHandle * sh
Definition: render.c:690
ImBuf * ibuf3
Definition: render.c:694
ImBuf * ibuf2
Definition: render.c:694
Sequence * seq
Definition: render.c:692
float * rectz
Definition: RE_pipeline.h:114
float * rectf
Definition: RE_pipeline.h:112
struct bNodeTree * nodetree
struct Editing * ed
struct RenderData r
struct Object * camera
char use_nodes
ColorManagedColorspaceSettings sequencer_colorspace_settings
struct GSet * set
Definition: SEQ_iterator.h:41
void(* execute_slice)(const struct SeqRenderData *context, struct Sequence *seq, float timeline_frame, float fac, struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3, int start_line, int total_lines, struct ImBuf *out)
Definition: SEQ_effects.h:81
int(* early_out)(struct Sequence *seq, float fac)
Definition: SEQ_effects.h:55
int preview_render_size
Definition: SEQ_render.h:33
struct Main * bmain
Definition: SEQ_render.h:28
bool is_proxy_render
Definition: SEQ_render.h:39
struct Scene * scene
Definition: SEQ_render.h:30
struct GPUOffScreen * gpu_offscreen
Definition: SEQ_render.h:46
bool skip_cache
Definition: SEQ_render.h:38
float motion_blur_shutter
Definition: SEQ_render.h:37
int motion_blur_samples
Definition: SEQ_render.h:36
bool is_prefetch_render
Definition: SEQ_render.h:40
struct Depsgraph * depsgraph
Definition: SEQ_render.h:29
eSeqTaskId task_id
Definition: SEQ_render.h:43
struct MovieClip * clip
struct Scene * scene
ListBase anims
struct Object * scene_camera
struct Sequence * seq3
struct Mask * mask
ListBase modifiers
struct Sequence * seq1
struct Sequence * seq2
struct Stereo3dFormat * stereo3d_format
struct anim * anim
struct StripAnim * next
char name[256]
struct anim * anim
ColorManagedColorspaceSettings colorspace_settings
StripProxy * proxy
StripTransform * transform
StripElem * stripdata
char dir[768]
StripCrop * crop
float xmax
Definition: DNA_vec_types.h:69
float xmin
Definition: DNA_vec_types.h:69
int ymin
Definition: DNA_vec_types.h:64
int ymax
Definition: DNA_vec_types.h:64
int xmin
Definition: DNA_vec_types.h:63
int xmax
Definition: DNA_vec_types.h:63
ListBase * SEQ_get_seqbase_from_sequence(Sequence *seq, ListBase **r_channels, int *r_offset)
Definition: utils.c:182
void seq_open_anim_file(Scene *scene, Sequence *seq, bool openfile)
Definition: utils.c:209