Blender  V2.93
strip_add.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
17  * All rights reserved.
18  *
19  * - Blender Foundation, 2003-2009
20  * - Peter Schlaile <peter [at] schlaile [dot] de> 2005/2006
21  */
22 
27 #include <math.h>
28 #include <string.h>
29 
30 #include "MEM_guardedalloc.h"
31 
32 #include "DNA_mask_types.h"
33 #include "DNA_scene_types.h"
34 #include "DNA_sequence_types.h"
35 #include "DNA_sound_types.h"
36 
37 #include "BLI_listbase.h"
38 #include "BLI_path_util.h"
39 #include "BLI_string.h"
40 #include "BLI_string_utf8.h"
41 
42 #include "BKE_context.h"
43 #include "BKE_image.h"
44 #include "BKE_lib_id.h"
45 #include "BKE_main.h"
46 #include "BKE_mask.h"
47 #include "BKE_movieclip.h"
48 #include "BKE_scene.h"
49 #include "BKE_sound.h"
50 
51 #include "DEG_depsgraph_query.h"
52 
53 #include "IMB_colormanagement.h"
54 #include "IMB_imbuf.h"
55 #include "IMB_imbuf_types.h"
56 #include "IMB_metadata.h"
57 
58 #include "SEQ_add.h"
59 #include "SEQ_effects.h"
60 #include "SEQ_relations.h"
61 #include "SEQ_render.h"
62 #include "SEQ_select.h"
63 #include "SEQ_sequencer.h"
64 #include "SEQ_time.h"
65 #include "SEQ_transform.h"
66 #include "SEQ_utils.h"
67 
68 #include "multiview.h"
69 #include "proxy.h"
70 #include "utils.h"
71 
83  const char *name,
84  const char *path,
85  const int start_frame,
86  const int channel)
87 {
88  memset(load_data, 0, sizeof(SeqLoadData));
89  if (name != NULL) {
90  BLI_strncpy(load_data->name, name, sizeof(load_data->name));
91  }
92  if (path != NULL) {
93  BLI_strncpy(load_data->path, path, sizeof(load_data->path));
94  }
95  load_data->start_frame = start_frame;
96  load_data->channel = channel;
97 }
98 
99 static void seq_add_generic_update(Scene *scene, ListBase *UNUSED(seqbase), Sequence *seq)
100 {
103  SEQ_sort(scene);
105 }
106 
107 static void seq_add_set_name(Sequence *seq, SeqLoadData *load_data)
108 {
109  if (load_data->name[0] != '\0') {
110  BLI_strncpy(seq->name + 2, load_data->name, sizeof(seq->name) - 2);
111  }
112  else {
113  if (seq->type == SEQ_TYPE_SCENE) {
114  BLI_strncpy(seq->name + 2, load_data->scene->id.name + 2, sizeof(seq->name) - 2);
115  }
116  else if (seq->type == SEQ_TYPE_MOVIECLIP) {
117  BLI_strncpy(seq->name + 2, load_data->clip->id.name + 2, sizeof(seq->name) - 2);
118  }
119  else if (seq->type == SEQ_TYPE_MASK) {
120  BLI_strncpy(seq->name + 2, load_data->mask->id.name + 2, sizeof(seq->name) - 2);
121  }
122  else if ((seq->type & SEQ_TYPE_EFFECT) != 0) {
123  BLI_strncpy(seq->name + 2, SEQ_sequence_give_name(seq), sizeof(seq->name) - 2);
124  }
125  else { /* Image, sound and movie. */
126  BLI_strncpy_utf8(seq->name + 2, load_data->name, sizeof(seq->name) - 2);
127  BLI_utf8_invalid_strip(seq->name + 2, strlen(seq->name + 2));
128  }
129  }
130 }
131 
133 {
134  const char *strip_colorspace = seq->strip->colorspace_settings.name;
135 
136  if (load_data->flags & SEQ_LOAD_SET_VIEW_TRANSFORM) {
137  const char *role_colorspace_byte;
139 
140  if (STREQ(strip_colorspace, role_colorspace_byte)) {
143  const char *default_view_transform =
145  STRNCPY(scene->view_settings.view_transform, default_view_transform);
146  }
147  }
148 }
149 
159 {
161  seqbase, load_data->start_frame, load_data->channel, SEQ_TYPE_SCENE);
162  seq->blend_mode = SEQ_TYPE_CROSS;
163  seq->scene = load_data->scene;
164  seq->len = load_data->scene->r.efra - load_data->scene->r.sfra + 1;
165  id_us_ensure_real((ID *)load_data->scene);
166  seq_add_set_name(seq, load_data);
167  seq_add_generic_update(scene, seqbase, seq);
168  return seq;
169 }
170 
180 {
182  seqbase, load_data->start_frame, load_data->channel, SEQ_TYPE_MOVIECLIP);
183  seq->blend_mode = SEQ_TYPE_CROSS;
184  seq->clip = load_data->clip;
185  seq->len = BKE_movieclip_get_duration(load_data->clip);
186  id_us_ensure_real((ID *)load_data->clip);
187  seq_add_set_name(seq, load_data);
188  seq_add_generic_update(scene, seqbase, seq);
189  return seq;
190 }
191 
201 {
203  seqbase, load_data->start_frame, load_data->channel, SEQ_TYPE_MASK);
204  seq->blend_mode = SEQ_TYPE_CROSS;
205  seq->mask = load_data->mask;
206  seq->len = BKE_mask_get_duration(load_data->mask);
207  id_us_ensure_real((ID *)load_data->mask);
208  seq_add_set_name(seq, load_data);
209  seq_add_generic_update(scene, seqbase, seq);
210  return seq;
211 }
212 
222 {
224  seqbase, load_data->start_frame, load_data->channel, load_data->effect.type);
225 
227  struct SeqEffectHandle sh = SEQ_effect_handle_get(seq);
228  sh.init(seq);
229  seq->seq1 = load_data->effect.seq1;
230  seq->seq2 = load_data->effect.seq2;
231  seq->seq3 = load_data->effect.seq3;
232 
233  if (seq->type == SEQ_TYPE_COLOR) {
234  seq->blend_mode = SEQ_TYPE_CROSS;
235  }
236  else if (seq->type == SEQ_TYPE_ADJUSTMENT) {
237  seq->blend_mode = SEQ_TYPE_CROSS;
238  }
239  else if (seq->type == SEQ_TYPE_TEXT) {
241  }
242  else if (SEQ_effect_get_num_inputs(seq->type) == 1) {
243  seq->blend_mode = seq->seq1->blend_mode;
244  }
245 
246  if (!load_data->effect.seq1) {
247  seq->len = 1; /* Effect is generator, set non zero length. */
249  }
250 
251  SEQ_relations_update_changed_seq_and_deps(scene, seq, 1, 1); /* Runs SEQ_time_update_sequence. */
252  seq_add_set_name(seq, load_data);
253  seq_add_generic_update(scene, seqbase, seq);
254 
255  return seq;
256 }
257 
264 void SEQ_add_image_set_directory(Sequence *seq, char *path)
265 {
266  BLI_strncpy(seq->strip->dir, path, sizeof(seq->strip->dir));
267 }
268 
276 void SEQ_add_image_load_file(Sequence *seq, size_t strip_frame, char *filename)
277 {
278  StripElem *se = SEQ_render_give_stripelem(seq, seq->start + strip_frame);
279  BLI_strncpy(se->name, filename, sizeof(se->name));
280 }
281 
288 {
289  if (seq->strip && seq->strip->stripdata) {
290  char name[FILE_MAX];
291  ImBuf *ibuf;
292 
293  BLI_join_dirfile(name, sizeof(name), seq->strip->dir, seq->strip->stripdata->name);
295 
296  /* Initialize input color space. */
297  if (seq->type == SEQ_TYPE_IMAGE) {
298  ibuf = IMB_loadiffname(
300 
301  /* Byte images are default to straight alpha, however sequencer
302  * works in premul space, so mark strip to be premultiplied first.
303  */
305  if (ibuf) {
306  if (ibuf->flags & IB_alphamode_premul) {
308  }
309 
310  IMB_freeImBuf(ibuf);
311  }
312  }
313  }
314 }
315 
327 {
329  seqbase, load_data->start_frame, load_data->channel, SEQ_TYPE_IMAGE);
330  seq->blend_mode = SEQ_TYPE_CROSS; /* so alpha adjustment fade to the strip below */
331  seq->len = load_data->image.len;
332  Strip *strip = seq->strip;
333  strip->stripdata = MEM_callocN(load_data->image.len * sizeof(StripElem), "stripelem");
334 
335  /* Multiview settings. */
336  if (load_data->use_multiview) {
337  seq->flag |= SEQ_USE_VIEWS;
338  seq->views_format = load_data->views_format;
339  }
340  if (load_data->stereo3d_format) {
341  seq->stereo3d_format = load_data->stereo3d_format;
342  }
343 
344  /* Set initial scale based on load_data->fit_method. */
345  char file_path[FILE_MAX];
346  BLI_strncpy(file_path, load_data->path, sizeof(file_path));
347  BLI_path_abs(file_path, BKE_main_blendfile_path(bmain));
348  ImBuf *ibuf = IMB_loadiffname(file_path, IB_rect, seq->strip->colorspace_settings.name);
349  if (ibuf != NULL) {
350  /* Set image resolution. Assume that all images in sequence are same size. This fields are only
351  * informative. */
352  StripElem *strip_elem = strip->stripdata;
353  for (int i = 0; i < load_data->image.len; i++) {
354  strip_elem->orig_width = ibuf->x;
355  strip_elem->orig_height = ibuf->y;
356  strip_elem++;
357  }
358 
360  seq, ibuf->x, ibuf->y, scene->r.xsch, scene->r.ysch, load_data->fit_method);
361  IMB_freeImBuf(ibuf);
362  }
363 
364  /* Set Last active directory. */
366  seq_add_set_view_transform(scene, seq, load_data);
367  seq_add_set_name(seq, load_data);
368  seq_add_generic_update(scene, seqbase, seq);
369 
370  return seq;
371 }
372 
373 #ifdef WITH_AUDASPACE
386  Scene *scene,
387  ListBase *seqbase,
388  SeqLoadData *load_data,
389  const double audio_offset)
390 {
391  bSound *sound = BKE_sound_new_file(bmain, load_data->path); /* Handles relative paths. */
392  sound->offset_time = audio_offset;
393  SoundInfo info;
394  bool sound_loaded = BKE_sound_info_get(bmain, sound, &info);
395 
396  if (!sound_loaded && !load_data->allow_invalid_file) {
397  BKE_id_free(bmain, sound);
398  return NULL;
399  }
400 
401  if (info.specs.channels == SOUND_CHANNELS_INVALID && !load_data->allow_invalid_file) {
402  BKE_id_free(bmain, sound);
403  return NULL;
404  }
405 
406  /* If this sound it part of a video, then the sound might start after the video.
407  * In this case we need to then offset the start frame of the audio so it syncs up
408  * properly with the video.
409  */
410  int start_frame_offset = info.start_offset * FPS;
411  double start_frame_offset_remainer = (info.start_offset * FPS - start_frame_offset) / FPS;
412 
413  if (start_frame_offset_remainer > FLT_EPSILON) {
414  /* We can't represent a fraction of a frame, so skip the first frame fraction of sound so we
415  * start on a "whole" frame.
416  */
417  start_frame_offset++;
418  }
419 
420  sound->offset_time += start_frame_offset_remainer;
421 
422  Sequence *seq = SEQ_sequence_alloc(seqbase,
423  load_data->start_frame + start_frame_offset,
424  load_data->channel,
426  seq->sound = sound;
427  seq->scene_sound = NULL;
428 
429  /* We round the frame duration as the audio sample lenghts usually does not
430  * line up with the video frames. Therefore we round this number to the
431  * nearsest frame as the audio track usually overshoots or undershoots the
432  * end frame ofthe video by a little bit.
433  * See T47135 for under shoot example.
434  */
435  seq->len = MAX2(1, round((info.length - sound->offset_time) * FPS));
436 
437  Strip *strip = seq->strip;
438  /* We only need 1 element to store the filename. */
439  StripElem *se = strip->stripdata = se = MEM_callocN(sizeof(StripElem), "stripelem");
440  BLI_split_dirfile(load_data->path, strip->dir, se->name, sizeof(strip->dir), sizeof(se->name));
441 
442  if (seq != NULL && seq->sound != NULL) {
443  if (load_data->flags & SEQ_LOAD_SOUND_MONO) {
444  seq->sound->flags |= SOUND_FLAGS_MONO;
445  }
446 
447  if (load_data->flags & SEQ_LOAD_SOUND_CACHE) {
448  if (seq->sound) {
450  }
451  }
452  }
453 
454  /* Set Last active directory. */
456  seq_add_set_name(seq, load_data);
457  seq_add_generic_update(scene, seqbase, seq);
458 
459  return seq;
460 }
461 
462 #else // WITH_AUDASPACE
464  Scene *UNUSED(scene),
465  ListBase *UNUSED(seqbase),
466  SeqLoadData *UNUSED(load_data),
467  const double UNUSED(audio_offset))
468 {
469  return NULL;
470 }
471 #endif // WITH_AUDASPACE
472 
483 {
484  /* Allocate sequence. */
486  seqbase, load_data->start_frame, load_data->channel, SEQ_TYPE_META);
487 
488  /* Set name. */
489  seq_add_set_name(seqm, load_data);
490 
491  /* Set frames start and length. */
492  seqm->start = load_data->start_frame;
493  seqm->len = 1;
495 
496  return seqm;
497 }
498 
509  Scene *scene,
510  ListBase *seqbase,
511  SeqLoadData *load_data,
512  double *r_video_start_offset)
513 {
514  char path[sizeof(load_data->path)];
515  BLI_strncpy(path, load_data->path, sizeof(path));
517 
518  char colorspace[64] = "\0"; /* MAX_COLORSPACE_NAME */
519  bool is_multiview_loaded = false;
520  const int totfiles = seq_num_files(scene, load_data->views_format, load_data->use_multiview);
521  struct anim **anim_arr = MEM_callocN(sizeof(struct anim *) * totfiles, "Video files");
522  int i;
523  int orig_width = 0;
524  int orig_height = 0;
525 
526  if (load_data->use_multiview && (load_data->views_format == R_IMF_VIEWS_INDIVIDUAL)) {
527  char prefix[FILE_MAX];
528  const char *ext = NULL;
529  size_t j = 0;
530 
531  BKE_scene_multiview_view_prefix_get(scene, path, prefix, &ext);
532 
533  if (prefix[0] != '\0') {
534  for (i = 0; i < totfiles; i++) {
535  char str[FILE_MAX];
536 
537  seq_multiview_name(scene, i, prefix, ext, str, FILE_MAX);
538  anim_arr[j] = openanim(str, IB_rect, 0, colorspace);
539 
540  if (anim_arr[j]) {
541  seq_anim_add_suffix(scene, anim_arr[j], i);
542  j++;
543  }
544  }
545  is_multiview_loaded = true;
546  }
547  }
548 
549  if (is_multiview_loaded == false) {
550  anim_arr[0] = openanim(path, IB_rect, 0, colorspace);
551  }
552 
553  if (anim_arr[0] == NULL && !load_data->allow_invalid_file) {
554  MEM_freeN(anim_arr);
555  return NULL;
556  }
557 
559  seqbase, load_data->start_frame, load_data->channel, SEQ_TYPE_MOVIE);
560 
561  /* Multiview settings. */
562  if (load_data->use_multiview) {
563  seq->flag |= SEQ_USE_VIEWS;
564  seq->views_format = load_data->views_format;
565  }
566  if (load_data->stereo3d_format) {
567  seq->stereo3d_format = load_data->stereo3d_format;
568  }
569 
570  for (i = 0; i < totfiles; i++) {
571  if (anim_arr[i]) {
572  StripAnim *sanim = MEM_mallocN(sizeof(StripAnim), "Strip Anim");
573  BLI_addtail(&seq->anims, sanim);
574  sanim->anim = anim_arr[i];
575  }
576  else {
577  break;
578  }
579  }
580 
581  seq->blend_mode = SEQ_TYPE_CROSS; /* so alpha adjustment fade to the strip below */
582 
583  if (anim_arr[0] != NULL) {
584  seq->len = IMB_anim_get_duration(anim_arr[0], IMB_TC_RECORD_RUN);
585  *r_video_start_offset = IMD_anim_get_offset(anim_arr[0]);
586 
587  IMB_anim_load_metadata(anim_arr[0]);
588 
589  /* Adjust scene's frame rate settings to match. */
590  if (load_data->flags & SEQ_LOAD_MOVIE_SYNC_FPS) {
591  IMB_anim_get_fps(anim_arr[0], &scene->r.frs_sec, &scene->r.frs_sec_base, true);
592  }
593 
594  /* Set initial scale based on load_data->fit_method. */
595  orig_width = IMB_anim_get_image_width(anim_arr[0]);
596  orig_height = IMB_anim_get_image_height(anim_arr[0]);
598  seq, orig_width, orig_height, scene->r.xsch, scene->r.ysch, load_data->fit_method);
599  }
600 
601  seq->len = MAX2(1, seq->len);
603  colorspace,
604  sizeof(seq->strip->colorspace_settings.name));
605 
606  Strip *strip = seq->strip;
607  /* We only need 1 element for MOVIE strips. */
608  StripElem *se;
609  strip->stripdata = se = MEM_callocN(sizeof(StripElem), "stripelem");
610  strip->stripdata->orig_width = orig_width;
611  strip->stripdata->orig_height = orig_height;
612  BLI_split_dirfile(load_data->path, strip->dir, se->name, sizeof(strip->dir), sizeof(se->name));
613 
614  seq_add_set_view_transform(scene, seq, load_data);
615  seq_add_set_name(seq, load_data);
616  seq_add_generic_update(scene, seqbase, seq);
617 
618  MEM_freeN(anim_arr);
619  return seq;
620 }
621 
622 /* note: caller should run SEQ_time_update_sequence(scene, seq) after */
623 void SEQ_add_reload_new_file(Main *bmain, Scene *scene, Sequence *seq, const bool lock_range)
624 {
625  char path[FILE_MAX];
626  int prev_startdisp = 0, prev_enddisp = 0;
627  /* note: don't rename the strip, will break animation curves */
628 
629  if (ELEM(seq->type,
636  SEQ_TYPE_MASK) == 0) {
637  return;
638  }
639 
640  if (lock_range) {
641  /* keep so we don't have to move the actual start and end points (only the data) */
643  prev_startdisp = seq->startdisp;
644  prev_enddisp = seq->enddisp;
645  }
646 
647  switch (seq->type) {
648  case SEQ_TYPE_IMAGE: {
649  /* Hack? */
650  size_t olen = MEM_allocN_len(seq->strip->stripdata) / sizeof(StripElem);
651 
652  seq->len = olen;
653  seq->len -= seq->anim_startofs;
654  seq->len -= seq->anim_endofs;
655  if (seq->len < 0) {
656  seq->len = 0;
657  }
658  break;
659  }
660  case SEQ_TYPE_MOVIE: {
661  StripAnim *sanim;
662  bool is_multiview_loaded = false;
663  const bool is_multiview = (seq->flag & SEQ_USE_VIEWS) != 0 &&
664  (scene->r.scemode & R_MULTIVIEW) != 0;
665 
666  BLI_join_dirfile(path, sizeof(path), seq->strip->dir, seq->strip->stripdata->name);
668 
670 
671  if (is_multiview && (seq->views_format == R_IMF_VIEWS_INDIVIDUAL)) {
672  char prefix[FILE_MAX];
673  const char *ext = NULL;
674  const int totfiles = seq_num_files(scene, seq->views_format, true);
675  int i = 0;
676 
677  BKE_scene_multiview_view_prefix_get(scene, path, prefix, &ext);
678 
679  if (prefix[0] != '\0') {
680  for (i = 0; i < totfiles; i++) {
681  struct anim *anim;
682  char str[FILE_MAX];
683 
684  seq_multiview_name(scene, i, prefix, ext, str, FILE_MAX);
685  anim = openanim(str,
686  IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0),
687  seq->streamindex,
689 
690  if (anim) {
692  sanim = MEM_mallocN(sizeof(StripAnim), "Strip Anim");
693  BLI_addtail(&seq->anims, sanim);
694  sanim->anim = anim;
695  }
696  }
697  is_multiview_loaded = true;
698  }
699  }
700 
701  if (is_multiview_loaded == false) {
702  struct anim *anim;
703  anim = openanim(path,
704  IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0),
705  seq->streamindex,
707  if (anim) {
708  sanim = MEM_mallocN(sizeof(StripAnim), "Strip Anim");
709  BLI_addtail(&seq->anims, sanim);
710  sanim->anim = anim;
711  }
712  }
713 
714  /* use the first video as reference for everything */
715  sanim = seq->anims.first;
716 
717  if ((!sanim) || (!sanim->anim)) {
718  return;
719  }
720 
722 
723  seq->len = IMB_anim_get_duration(
724  sanim->anim, seq->strip->proxy ? seq->strip->proxy->tc : IMB_TC_RECORD_RUN);
725 
726  seq->len -= seq->anim_startofs;
727  seq->len -= seq->anim_endofs;
728  if (seq->len < 0) {
729  seq->len = 0;
730  }
731  break;
732  }
733  case SEQ_TYPE_MOVIECLIP:
734  if (seq->clip == NULL) {
735  return;
736  }
737 
738  seq->len = BKE_movieclip_get_duration(seq->clip);
739 
740  seq->len -= seq->anim_startofs;
741  seq->len -= seq->anim_endofs;
742  if (seq->len < 0) {
743  seq->len = 0;
744  }
745  break;
746  case SEQ_TYPE_MASK:
747  if (seq->mask == NULL) {
748  return;
749  }
750  seq->len = BKE_mask_get_duration(seq->mask);
751  seq->len -= seq->anim_startofs;
752  seq->len -= seq->anim_endofs;
753  if (seq->len < 0) {
754  seq->len = 0;
755  }
756  break;
757  case SEQ_TYPE_SOUND_RAM:
758 #ifdef WITH_AUDASPACE
759  if (!seq->sound) {
760  return;
761  }
762  seq->len = ceil((double)BKE_sound_get_length(bmain, seq->sound) * FPS);
763  seq->len -= seq->anim_startofs;
764  seq->len -= seq->anim_endofs;
765  if (seq->len < 0) {
766  seq->len = 0;
767  }
768 #else
769  UNUSED_VARS(bmain);
770  return;
771 #endif
772  break;
773  case SEQ_TYPE_SCENE: {
774  seq->len = (seq->scene) ? seq->scene->r.efra - seq->scene->r.sfra + 1 : 0;
775  seq->len -= seq->anim_startofs;
776  seq->len -= seq->anim_endofs;
777  if (seq->len < 0) {
778  seq->len = 0;
779  }
780  break;
781  }
782  }
783 
784  free_proxy_seq(seq);
785 
786  if (lock_range) {
787  SEQ_transform_set_left_handle_frame(seq, prev_startdisp);
788  SEQ_transform_set_right_handle_frame(seq, prev_enddisp);
790  }
791 
793 }
794 
796  struct Scene *scene,
797  struct Sequence *seq,
798  bool *r_was_reloaded,
799  bool *r_can_produce_frames)
800 {
801  BLI_assert(seq->type == SEQ_TYPE_MOVIE ||
802  !"This function is only implemented for movie strips.");
803 
804  bool must_reload = false;
805 
806  /* The Sequence struct allows for multiple anim structs to be associated with one strip.
807  * This function will return true only if there is at least one 'anim' AND all anims can
808  * produce frames. */
809 
810  if (BLI_listbase_is_empty(&seq->anims)) {
811  /* No anim present, so reloading is always necessary. */
812  must_reload = true;
813  }
814  else {
815  LISTBASE_FOREACH (StripAnim *, sanim, &seq->anims) {
816  if (!IMB_anim_can_produce_frames(sanim->anim)) {
817  /* Anim cannot produce frames, try reloading. */
818  must_reload = true;
819  break;
820  }
821  };
822  }
823 
824  if (!must_reload) {
825  /* There are one or more anims, and all can produce frames. */
826  *r_was_reloaded = false;
827  *r_can_produce_frames = true;
828  return;
829  }
830 
831  SEQ_add_reload_new_file(bmain, scene, seq, true);
832  *r_was_reloaded = true;
833 
834  if (BLI_listbase_is_empty(&seq->anims)) {
835  /* No anims present after reloading => no frames can be produced. */
836  *r_can_produce_frames = false;
837  return;
838  }
839 
840  /* Check if there are still anims that cannot produce frames. */
841  LISTBASE_FOREACH (StripAnim *, sanim, &seq->anims) {
842  if (!IMB_anim_can_produce_frames(sanim->anim)) {
843  /* There still is an anim that cannot produce frames. */
844  *r_can_produce_frames = false;
845  return;
846  }
847  };
848 
849  /* There are one or more anims, and all can produce frames. */
850  *r_can_produce_frames = true;
851 }
struct anim * openanim(const char *name, int flags, int streamindex, char colorspace[IMA_MAX_SPACE])
Definition: image.c:3115
void BKE_id_free(struct Main *bmain, void *idv)
void id_us_ensure_real(struct ID *id)
Definition: lib_id.c:238
const char * BKE_main_blendfile_path(const struct Main *bmain) ATTR_NONNULL()
const char * BKE_main_blendfile_path_from_global(void)
Definition: main.c:439
int BKE_mask_get_duration(struct Mask *mask)
Definition: mask.c:2062
int BKE_movieclip_get_duration(struct MovieClip *clip)
Definition: movieclip.c:1582
void BKE_scene_multiview_view_prefix_get(struct Scene *scene, const char *name, char *r_prefix, const char **r_ext)
Definition: scene.c:3301
float BKE_sound_get_length(struct Main *bmain, struct bSound *sound)
struct bSound * BKE_sound_new_file(struct Main *main, const char *filepath)
bool BKE_sound_info_get(struct Main *main, struct bSound *sound, SoundInfo *sound_info)
@ SOUND_CHANNELS_INVALID
Definition: BKE_sound.h:84
#define BLI_assert(a)
Definition: BLI_assert.h:58
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
Definition: BLI_listbase.h:124
#define LISTBASE_FOREACH(type, var, list)
Definition: BLI_listbase.h:172
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:110
#define FILE_MAX
void BLI_join_dirfile(char *__restrict dst, const size_t maxlen, const char *__restrict dir, const char *__restrict file) ATTR_NONNULL()
Definition: path_util.c:1737
void BLI_split_dirfile(const char *string, char *dir, char *file, const size_t dirlen, const size_t filelen)
Definition: path_util.c:1654
#define FILE_MAXDIR
bool BLI_path_abs(char *path, const char *basepath) ATTR_NONNULL()
Definition: path_util.c:1016
#define STRNCPY(dst, src)
Definition: BLI_string.h:163
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, const size_t maxncpy) ATTR_NONNULL()
Definition: string.c:108
char * BLI_strncpy_utf8(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL()
Definition: string_utf8.c:258
int BLI_utf8_invalid_strip(char *str, size_t length) ATTR_NONNULL()
Definition: string_utf8.c:203
#define UNUSED_VARS(...)
#define UNUSED(x)
#define MAX2(a, b)
#define ELEM(...)
#define STREQ(a, b)
@ IMA_ALPHA_PREMUL
#define R_MULTIVIEW
@ R_IMF_VIEWS_INDIVIDUAL
#define FPS
@ SEQ_FILTERY
@ SEQ_USE_EFFECT_DEFAULT_FADE
@ SEQ_USE_VIEWS
@ SEQ_ALPHA_STRAIGHT
struct StripElem StripElem
@ SEQ_TYPE_SOUND_RAM
@ SEQ_TYPE_CROSS
@ SEQ_TYPE_META
@ SEQ_TYPE_SCENE
@ SEQ_TYPE_MOVIECLIP
@ SEQ_TYPE_ALPHAOVER
@ SEQ_TYPE_TEXT
@ SEQ_TYPE_IMAGE
@ SEQ_TYPE_COLOR
@ SEQ_TYPE_EFFECT
@ SEQ_TYPE_MOVIE
@ SEQ_TYPE_MASK
@ SEQ_TYPE_ADJUSTMENT
@ SOUND_FLAGS_MONO
@ SOUND_FLAGS_CACHING
const char * IMB_colormanagement_role_colorspace_name_get(int role)
@ COLOR_ROLE_DEFAULT_BYTE
struct ColorManagedDisplay * IMB_colormanagement_display_get_named(const char *name)
const char * IMB_colormanagement_display_get_default_view_transform_name(struct ColorManagedDisplay *display)
bool IMB_anim_get_fps(struct anim *anim, short *frs_sec, float *frs_sec_base, bool no_av_base)
Definition: anim_movie.c:1691
void IMB_freeImBuf(struct ImBuf *ibuf)
Definition: allocimbuf.c:211
int IMB_anim_get_image_height(struct anim *anim)
Definition: anim_movie.c:1729
struct ImBuf * IMB_loadiffname(const char *filepath, int flags, char colorspace[IM_MAX_SPACE])
Definition: readimage.c:224
double IMD_anim_get_offset(struct anim *anim)
Definition: anim_movie.c:1686
int IMB_anim_get_image_width(struct anim *anim)
Definition: anim_movie.c:1724
bool IMB_anim_can_produce_frames(const struct anim *anim)
Definition: anim_movie.c:309
int IMB_anim_get_duration(struct anim *anim, IMB_Timecode_Type tc)
Definition: anim_movie.c:1671
@ IMB_TC_RECORD_RUN
Definition: IMB_imbuf.h:304
Contains defines and structs used throughout the imbuf module.
@ IB_animdeinterlace
@ IB_alphamode_premul
@ IB_alphamode_detect
@ IB_test
@ IB_rect
struct IDProperty * IMB_anim_load_metadata(struct anim *anim)
Definition: anim_movie.c:247
Read Guarded memory(de)allocation.
@ SEQ_LOAD_SOUND_MONO
Definition: SEQ_add.h:37
@ SEQ_LOAD_SOUND_CACHE
Definition: SEQ_add.h:36
@ SEQ_LOAD_SET_VIEW_TRANSFORM
Definition: SEQ_add.h:39
@ SEQ_LOAD_MOVIE_SYNC_FPS
Definition: SEQ_add.h:38
Scene scene
struct SeqEffectHandle SEQ_effect_handle_get(Sequence *seq)
Definition: effects.c:4291
int SEQ_effect_get_num_inputs(int seq_type)
Definition: effects.c:4328
#define str(s)
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:41
size_t(* MEM_allocN_len)(const void *vmemh)
Definition: mallocn.c:40
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:45
void *(* MEM_mallocN)(size_t len, const char *str)
Definition: mallocn.c:47
int seq_num_files(Scene *scene, char views_format, const bool is_multiview)
Definition: multiview.c:44
void seq_anim_add_suffix(Scene *scene, struct anim *anim, const int view_id)
Definition: multiview.c:37
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:57
void free_proxy_seq(Sequence *seq)
Definition: proxy.c:611
StripElem * SEQ_render_give_stripelem(Sequence *seq, int timeline_frame)
Definition: render.c:242
Sequence * SEQ_sequence_alloc(ListBase *lb, int timeline_frame, int machine, int type)
Definition: sequencer.c:113
void SEQ_add_image_load_file(Sequence *seq, size_t strip_frame, char *filename)
Definition: strip_add.c:276
Sequence * SEQ_add_movie_strip(Main *bmain, Scene *scene, ListBase *seqbase, SeqLoadData *load_data, double *r_video_start_offset)
Definition: strip_add.c:508
Sequence * SEQ_add_meta_strip(Scene *scene, ListBase *seqbase, SeqLoadData *load_data)
Definition: strip_add.c:482
Sequence * SEQ_add_mask_strip(Scene *scene, ListBase *seqbase, struct SeqLoadData *load_data)
Definition: strip_add.c:200
void SEQ_add_movie_reload_if_needed(struct Main *bmain, struct Scene *scene, struct Sequence *seq, bool *r_was_reloaded, bool *r_can_produce_frames)
Definition: strip_add.c:795
Sequence * SEQ_add_image_strip(Main *bmain, Scene *scene, ListBase *seqbase, SeqLoadData *load_data)
Definition: strip_add.c:326
Sequence * SEQ_add_effect_strip(Scene *scene, ListBase *seqbase, struct SeqLoadData *load_data)
Definition: strip_add.c:221
static void seq_add_set_name(Sequence *seq, SeqLoadData *load_data)
Definition: strip_add.c:107
Sequence * SEQ_add_movieclip_strip(Scene *scene, ListBase *seqbase, struct SeqLoadData *load_data)
Definition: strip_add.c:179
void SEQ_add_reload_new_file(Main *bmain, Scene *scene, Sequence *seq, const bool lock_range)
Definition: strip_add.c:623
void SEQ_add_image_set_directory(Sequence *seq, char *path)
Definition: strip_add.c:264
void SEQ_add_image_init_alpha_mode(Sequence *seq)
Definition: strip_add.c:287
static void seq_add_set_view_transform(Scene *scene, Sequence *seq, SeqLoadData *load_data)
Definition: strip_add.c:132
Sequence * SEQ_add_sound_strip(Main *UNUSED(bmain), Scene *UNUSED(scene), ListBase *UNUSED(seqbase), SeqLoadData *UNUSED(load_data), const double UNUSED(audio_offset))
Definition: strip_add.c:463
Sequence * SEQ_add_scene_strip(Scene *scene, ListBase *seqbase, struct SeqLoadData *load_data)
Definition: strip_add.c:158
void SEQ_add_load_data_init(SeqLoadData *load_data, const char *name, const char *path, const int start_frame, const int channel)
Definition: strip_add.c:82
static void seq_add_generic_update(Scene *scene, ListBase *UNUSED(seqbase), Sequence *seq)
Definition: strip_add.c:99
void SEQ_relations_update_changed_seq_and_deps(Scene *scene, Sequence *changed_seq, int len_change, int ibuf_change)
void SEQ_relations_sequence_free_anim(Sequence *seq)
void SEQ_relations_invalidate_cache_composite(Scene *scene, Sequence *seq)
void SEQ_time_update_sequence_bounds(Scene *scene, Sequence *seq)
Definition: strip_time.c:150
void SEQ_time_update_sequence(Scene *scene, Sequence *seq)
Definition: strip_time.c:197
void SEQ_transform_fix_single_image_seq_offsets(Sequence *seq)
void SEQ_transform_set_right_handle_frame(Sequence *seq, int val)
void SEQ_transform_set_left_handle_frame(Sequence *seq, int val)
ListBase seqbase
char act_sounddir[1024]
char act_imagedir[1024]
Definition: DNA_ID.h:273
char name[66]
Definition: DNA_ID.h:283
void * first
Definition: DNA_listBase.h:47
Definition: BKE_main.h:116
float frs_sec_base
ColorManagedViewSettings view_settings
struct Editing * ed
struct RenderData r
ColorManagedDisplaySettings display_settings
void(* init)(struct Sequence *seq)
Definition: SEQ_effects.h:51
struct Sequence * seq2
Definition: SEQ_add.h:59
int len
Definition: SEQ_add.h:49
char views_format
Definition: SEQ_add.h:65
bool use_multiview
Definition: SEQ_add.h:64
struct MovieClip * clip
Definition: SEQ_add.h:53
struct SeqLoadData::@1139 image
eSeqImageFitMethod fit_method
Definition: SEQ_add.h:63
struct Scene * scene
Definition: SEQ_add.h:52
int channel
Definition: SEQ_add.h:45
struct Sequence * seq3
Definition: SEQ_add.h:60
struct Stereo3dFormat * stereo3d_format
Definition: SEQ_add.h:66
char path[1024]
Definition: SEQ_add.h:47
bool allow_invalid_file
Definition: SEQ_add.h:67
int end_frame
Definition: SEQ_add.h:50
int start_frame
Definition: SEQ_add.h:44
char name[64]
Definition: SEQ_add.h:46
struct Mask * mask
Definition: SEQ_add.h:54
struct SeqLoadData::@1140 effect
eSeqLoadFlags flags
Definition: SEQ_add.h:62
int type
Definition: SEQ_add.h:56
struct Sequence * seq1
Definition: SEQ_add.h:58
struct MovieClip * clip
struct Scene * scene
ListBase anims
struct Sequence * seq3
void * scene_sound
struct Mask * mask
struct bSound * sound
struct Sequence * seq1
struct Sequence * seq2
struct Stereo3dFormat * stereo3d_format
struct SoundInfo::@62 specs
eSoundChannels channels
Definition: BKE_sound.h:97
float length
Definition: BKE_sound.h:99
double start_offset
Definition: BKE_sound.h:100
struct anim * anim
char name[256]
ColorManagedColorspaceSettings colorspace_settings
StripProxy * proxy
StripElem * stripdata
char dir[768]
Definition: IMB_anim.h:87
char colorspace[64]
Definition: IMB_anim.h:149
short flags
double offset_time
ccl_device_inline float3 ceil(const float3 &a)
const char * SEQ_sequence_give_name(Sequence *seq)
Definition: utils.c:227
void SEQ_sequence_base_unique_name_recursive(ListBase *seqbasep, Sequence *seq)
Definition: utils.c:139
void SEQ_sort(Scene *scene)
Definition: utils.c:58
void SEQ_set_scale_to_fit(const Sequence *seq, const int image_width, const int image_height, const int preview_width, const int preview_height, const eSeqImageFitMethod fit_method)
Definition: utils.c:557