Blender V4.3
rna_sequencer_api.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#include <cstdio>
10#include <cstdlib>
11#include <cstring>
12
13#include "DNA_scene_types.h"
14#include "DNA_sequence_types.h"
15
16#include "BLI_utildefines.h"
17
18#include "RNA_access.hh"
19#include "RNA_define.hh"
20
21#include "SEQ_edit.hh"
22#include "SEQ_sequencer.hh"
23
24#include "rna_internal.hh"
25
26#ifdef RNA_RUNTIME
27
28// #include "DNA_anim_types.h"
29# include "DNA_image_types.h"
30# include "DNA_mask_types.h"
31# include "DNA_sound_types.h"
32
33# include "BLI_path_utils.hh" /* #BLI_path_split_dir_file */
34
35# include "BKE_image.hh"
36# include "BKE_mask.h"
37# include "BKE_movieclip.h"
38
39# include "BKE_report.hh"
40# include "BKE_sound.h"
41
42# include "IMB_imbuf.hh"
43# include "IMB_imbuf_types.hh"
44
45# include "SEQ_add.hh"
46# include "SEQ_edit.hh"
47# include "SEQ_effects.hh"
48# include "SEQ_relations.hh"
49# include "SEQ_render.hh"
50# include "SEQ_retiming.hh"
51# include "SEQ_time.hh"
52
53# include "WM_api.hh"
54
55static StripElem *rna_Sequence_strip_elem_from_frame(ID *id, Sequence *self, int timeline_frame)
56{
57 Scene *scene = (Scene *)id;
58 return SEQ_render_give_stripelem(scene, self, timeline_frame);
59}
60
61static void rna_Sequence_swap_internal(ID *id,
62 Sequence *seq_self,
63 ReportList *reports,
64 Sequence *seq_other)
65{
66 const char *error_msg;
67 Scene *scene = (Scene *)id;
68
69 if (SEQ_edit_sequence_swap(scene, seq_self, seq_other, &error_msg) == false) {
70 BKE_report(reports, RPT_ERROR, error_msg);
71 }
72}
73
74static void rna_Sequences_move_strip_to_meta(
75 ID *id, Sequence *seq_self, Main *bmain, ReportList *reports, Sequence *meta_dst)
76{
77 Scene *scene = (Scene *)id;
78 const char *error_msg;
79
80 /* Move strip to meta. */
81 if (!SEQ_edit_move_strip_to_meta(scene, seq_self, meta_dst, &error_msg)) {
82 BKE_report(reports, RPT_ERROR, error_msg);
83 }
84
85 /* Update depsgraph. */
88
90
92}
93
94static Sequence *rna_Sequence_split(
95 ID *id, Sequence *seq, Main *bmain, ReportList *reports, int frame, int split_method)
96{
97 Scene *scene = (Scene *)id;
98 ListBase *seqbase = SEQ_get_seqbase_by_seq(scene, seq);
99
100 const char *error_msg = nullptr;
102 bmain, scene, seqbase, seq, frame, eSeqSplitMethod(split_method), &error_msg);
103 if (error_msg != nullptr) {
104 BKE_report(reports, RPT_ERROR, error_msg);
105 }
106
107 /* Update depsgraph. */
110
112
113 return r_seq;
114}
115
116static Sequence *rna_Sequence_parent_meta(ID *id, Sequence *seq_self)
117{
118 Scene *scene = (Scene *)id;
119 Editing *ed = SEQ_editing_get(scene);
120
121 return SEQ_find_metastrip_by_sequence(&ed->seqbase, nullptr, seq_self);
122}
123
124static Sequence *rna_Sequences_new_clip(ID *id,
125 ListBase *seqbase,
126 Main *bmain,
127 const char *name,
128 MovieClip *clip,
129 int channel,
130 int frame_start)
131{
132 Scene *scene = (Scene *)id;
133 SeqLoadData load_data;
134 SEQ_add_load_data_init(&load_data, name, nullptr, frame_start, channel);
135 load_data.clip = clip;
136 Sequence *seq = SEQ_add_movieclip_strip(scene, seqbase, &load_data);
137
141
142 return seq;
143}
144
145static Sequence *rna_Sequences_editing_new_clip(ID *id,
146 Editing *ed,
147 Main *bmain,
148 const char *name,
149 MovieClip *clip,
150 int channel,
151 int frame_start)
152{
153 return rna_Sequences_new_clip(id, &ed->seqbase, bmain, name, clip, channel, frame_start);
154}
155
156static Sequence *rna_Sequences_meta_new_clip(ID *id,
157 Sequence *seq,
158 Main *bmain,
159 const char *name,
160 MovieClip *clip,
161 int channel,
162 int frame_start)
163{
164 return rna_Sequences_new_clip(id, &seq->seqbase, bmain, name, clip, channel, frame_start);
165}
166
167static Sequence *rna_Sequences_new_mask(ID *id,
168 ListBase *seqbase,
169 Main *bmain,
170 const char *name,
171 Mask *mask,
172 int channel,
173 int frame_start)
174{
175 Scene *scene = (Scene *)id;
176 SeqLoadData load_data;
177 SEQ_add_load_data_init(&load_data, name, nullptr, frame_start, channel);
178 load_data.mask = mask;
179 Sequence *seq = SEQ_add_mask_strip(scene, seqbase, &load_data);
180
184
185 return seq;
186}
187static Sequence *rna_Sequences_editing_new_mask(
188 ID *id, Editing *ed, Main *bmain, const char *name, Mask *mask, int channel, int frame_start)
189{
190 return rna_Sequences_new_mask(id, &ed->seqbase, bmain, name, mask, channel, frame_start);
191}
192
193static Sequence *rna_Sequences_meta_new_mask(
194 ID *id, Sequence *seq, Main *bmain, const char *name, Mask *mask, int channel, int frame_start)
195{
196 return rna_Sequences_new_mask(id, &seq->seqbase, bmain, name, mask, channel, frame_start);
197}
198
199static Sequence *rna_Sequences_new_scene(ID *id,
200 ListBase *seqbase,
201 Main *bmain,
202 const char *name,
203 Scene *sce_seq,
204 int channel,
205 int frame_start)
206{
207 Scene *scene = (Scene *)id;
208 SeqLoadData load_data;
209 SEQ_add_load_data_init(&load_data, name, nullptr, frame_start, channel);
210 load_data.scene = sce_seq;
211 Sequence *seq = SEQ_add_scene_strip(scene, seqbase, &load_data);
212
216
217 return seq;
218}
219
220static Sequence *rna_Sequences_editing_new_scene(ID *id,
221 Editing *ed,
222 Main *bmain,
223 const char *name,
224 Scene *sce_seq,
225 int channel,
226 int frame_start)
227{
228 return rna_Sequences_new_scene(id, &ed->seqbase, bmain, name, sce_seq, channel, frame_start);
229}
230
231static Sequence *rna_Sequences_meta_new_scene(ID *id,
232 Sequence *seq,
233 Main *bmain,
234 const char *name,
235 Scene *sce_seq,
236 int channel,
237 int frame_start)
238{
239 return rna_Sequences_new_scene(id, &seq->seqbase, bmain, name, sce_seq, channel, frame_start);
240}
241
242static Sequence *rna_Sequences_new_image(ID *id,
243 ListBase *seqbase,
244 Main *bmain,
245 ReportList * /*reports*/,
246 const char *name,
247 const char *file,
248 int channel,
249 int frame_start,
250 int fit_method)
251{
252 Scene *scene = (Scene *)id;
253
254 SeqLoadData load_data;
255 SEQ_add_load_data_init(&load_data, name, file, frame_start, channel);
256 load_data.image.len = 1;
257 load_data.fit_method = eSeqImageFitMethod(fit_method);
258 Sequence *seq = SEQ_add_image_strip(bmain, scene, seqbase, &load_data);
259
260 char dirpath[FILE_MAX], filename[FILE_MAXFILE];
261 BLI_path_split_dir_file(file, dirpath, sizeof(dirpath), filename, sizeof(filename));
262 SEQ_add_image_set_directory(seq, dirpath);
263 SEQ_add_image_load_file(scene, seq, 0, filename);
265
269
270 return seq;
271}
272
273static Sequence *rna_Sequences_editing_new_image(ID *id,
274 Editing *ed,
275 Main *bmain,
276 ReportList *reports,
277 const char *name,
278 const char *file,
279 int channel,
280 int frame_start,
281 int fit_method)
282{
283 return rna_Sequences_new_image(
284 id, &ed->seqbase, bmain, reports, name, file, channel, frame_start, fit_method);
285}
286
287static Sequence *rna_Sequences_meta_new_image(ID *id,
288 Sequence *seq,
289 Main *bmain,
290 ReportList *reports,
291 const char *name,
292 const char *file,
293 int channel,
294 int frame_start,
295 int fit_method)
296{
297 return rna_Sequences_new_image(
298 id, &seq->seqbase, bmain, reports, name, file, channel, frame_start, fit_method);
299}
300
301static Sequence *rna_Sequences_new_movie(ID *id,
302 ListBase *seqbase,
303 Main *bmain,
304 const char *name,
305 const char *file,
306 int channel,
307 int frame_start,
308 int fit_method)
309{
310 Scene *scene = (Scene *)id;
311 SeqLoadData load_data;
312 SEQ_add_load_data_init(&load_data, name, file, frame_start, channel);
313 load_data.fit_method = eSeqImageFitMethod(fit_method);
314 load_data.allow_invalid_file = true;
315 Sequence *seq = SEQ_add_movie_strip(bmain, scene, seqbase, &load_data);
316
320
321 return seq;
322}
323
324static Sequence *rna_Sequences_editing_new_movie(ID *id,
325 Editing *ed,
326 Main *bmain,
327 const char *name,
328 const char *file,
329 int channel,
330 int frame_start,
331 int fit_method)
332{
333 return rna_Sequences_new_movie(
334 id, &ed->seqbase, bmain, name, file, channel, frame_start, fit_method);
335}
336
337static Sequence *rna_Sequences_meta_new_movie(ID *id,
338 Sequence *seq,
339 Main *bmain,
340 const char *name,
341 const char *file,
342 int channel,
343 int frame_start,
344 int fit_method)
345{
346 return rna_Sequences_new_movie(
347 id, &seq->seqbase, bmain, name, file, channel, frame_start, fit_method);
348}
349
350# ifdef WITH_AUDASPACE
351static Sequence *rna_Sequences_new_sound(ID *id,
352 ListBase *seqbase,
353 Main *bmain,
354 ReportList *reports,
355 const char *name,
356 const char *file,
357 int channel,
358 int frame_start)
359{
360 Scene *scene = (Scene *)id;
361 SeqLoadData load_data;
362 SEQ_add_load_data_init(&load_data, name, file, frame_start, channel);
363 load_data.allow_invalid_file = true;
364 Sequence *seq = SEQ_add_sound_strip(bmain, scene, seqbase, &load_data);
365
366 if (seq == nullptr) {
367 BKE_report(reports, RPT_ERROR, "Sequences.new_sound: unable to open sound file");
368 return nullptr;
369 }
370
374
375 return seq;
376}
377# else /* WITH_AUDASPACE */
378static Sequence *rna_Sequences_new_sound(ID * /*id*/,
379 ListBase * /*seqbase*/,
380 Main * /*bmain*/,
381 ReportList *reports,
382 const char * /*name*/,
383 const char * /*file*/,
384 int /*channel*/,
385 int /*frame_start*/)
386{
387 BKE_report(reports, RPT_ERROR, "Blender compiled without Audaspace support");
388 return nullptr;
389}
390# endif /* WITH_AUDASPACE */
391
392static Sequence *rna_Sequences_editing_new_sound(ID *id,
393 Editing *ed,
394 Main *bmain,
395 ReportList *reports,
396 const char *name,
397 const char *file,
398 int channel,
399 int frame_start)
400{
401 return rna_Sequences_new_sound(
402 id, &ed->seqbase, bmain, reports, name, file, channel, frame_start);
403}
404
405static Sequence *rna_Sequences_meta_new_sound(ID *id,
406 Sequence *seq,
407 Main *bmain,
408 ReportList *reports,
409 const char *name,
410 const char *file,
411 int channel,
412 int frame_start)
413{
414 return rna_Sequences_new_sound(
415 id, &seq->seqbase, bmain, reports, name, file, channel, frame_start);
416}
417
418/* Meta sequence
419 * Possibility to create an empty meta to avoid plenty of meta toggling
420 * Created meta have a length equal to 1, must be set through the API. */
421static Sequence *rna_Sequences_new_meta(
422 ID *id, ListBase *seqbase, const char *name, int channel, int frame_start)
423{
424 Scene *scene = (Scene *)id;
425 SeqLoadData load_data;
426 SEQ_add_load_data_init(&load_data, name, nullptr, frame_start, channel);
427 Sequence *seqm = SEQ_add_meta_strip(scene, seqbase, &load_data);
428
429 return seqm;
430}
431
432static Sequence *rna_Sequences_editing_new_meta(
433 ID *id, Editing *ed, const char *name, int channel, int frame_start)
434{
435 return rna_Sequences_new_meta(id, &ed->seqbase, name, channel, frame_start);
436}
437
438static Sequence *rna_Sequences_meta_new_meta(
439 ID *id, Sequence *seq, const char *name, int channel, int frame_start)
440{
441 return rna_Sequences_new_meta(id, &seq->seqbase, name, channel, frame_start);
442}
443
444static Sequence *rna_Sequences_new_effect(ID *id,
445 ListBase *seqbase,
446 ReportList *reports,
447 const char *name,
448 int type,
449 int channel,
450 int frame_start,
451 int frame_end,
452 Sequence *seq1,
453 Sequence *seq2)
454{
455 Scene *scene = (Scene *)id;
456 Sequence *seq;
457 const int num_inputs = SEQ_effect_get_num_inputs(type);
458
459 switch (num_inputs) {
460 case 0:
461 if (frame_end <= frame_start) {
462 BKE_report(reports, RPT_ERROR, "Sequences.new_effect: end frame not set");
463 return nullptr;
464 }
465 break;
466 case 1:
467 if (seq1 == nullptr) {
468 BKE_report(reports, RPT_ERROR, "Sequences.new_effect: effect takes 1 input sequence");
469 return nullptr;
470 }
471 break;
472 case 2:
473 if (seq1 == nullptr || seq2 == nullptr) {
474 BKE_report(reports, RPT_ERROR, "Sequences.new_effect: effect takes 2 input sequences");
475 return nullptr;
476 }
477 break;
478 default:
480 reports,
481 RPT_ERROR,
482 "Sequences.new_effect: effect expects more than 2 inputs (%d, should never happen!)",
483 num_inputs);
484 return nullptr;
485 }
486
487 SeqLoadData load_data;
488 SEQ_add_load_data_init(&load_data, name, nullptr, frame_start, channel);
489 load_data.effect.end_frame = frame_end;
490 load_data.effect.type = type;
491 load_data.effect.seq1 = seq1;
492 load_data.effect.seq2 = seq2;
493 seq = SEQ_add_effect_strip(scene, seqbase, &load_data);
494
497
498 return seq;
499}
500
501static Sequence *rna_Sequences_editing_new_effect(ID *id,
502 Editing *ed,
503 ReportList *reports,
504 const char *name,
505 int type,
506 int channel,
507 int frame_start,
508 int frame_end,
509 Sequence *seq1,
510 Sequence *seq2)
511{
512 return rna_Sequences_new_effect(
513 id, &ed->seqbase, reports, name, type, channel, frame_start, frame_end, seq1, seq2);
514}
515
516static Sequence *rna_Sequences_meta_new_effect(ID *id,
517 Sequence *seq,
518 ReportList *reports,
519 const char *name,
520 int type,
521 int channel,
522 int frame_start,
523 int frame_end,
524 Sequence *seq1,
525 Sequence *seq2)
526{
527 return rna_Sequences_new_effect(
528 id, &seq->seqbase, reports, name, type, channel, frame_start, frame_end, seq1, seq2);
529}
530
531static void rna_Sequences_remove(
532 ID *id, ListBase *seqbase, Main *bmain, ReportList *reports, PointerRNA *seq_ptr)
533{
534 Sequence *seq = static_cast<Sequence *>(seq_ptr->data);
535 Scene *scene = (Scene *)id;
536
537 if (BLI_findindex(seqbase, seq) == -1) {
539 reports, RPT_ERROR, "Sequence '%s' not in scene '%s'", seq->name + 2, scene->id.name + 2);
540 return;
541 }
542
543 SEQ_edit_flag_for_removal(scene, seqbase, seq);
544 SEQ_edit_remove_flagged_sequences(scene, seqbase);
545 RNA_POINTER_INVALIDATE(seq_ptr);
546
550}
551
552static void rna_Sequences_editing_remove(
553 ID *id, Editing *ed, Main *bmain, ReportList *reports, PointerRNA *seq_ptr)
554{
555 rna_Sequences_remove(id, &ed->seqbase, bmain, reports, seq_ptr);
556}
557
558static void rna_Sequences_meta_remove(
559 ID *id, Sequence *seq, Main *bmain, ReportList *reports, PointerRNA *seq_ptr)
560{
561 rna_Sequences_remove(id, &seq->seqbase, bmain, reports, seq_ptr);
562}
563
564static StripElem *rna_SequenceElements_append(ID *id, Sequence *seq, const char *filename)
565{
566 Scene *scene = (Scene *)id;
567 StripElem *se;
568
569 seq->strip->stripdata = se = static_cast<StripElem *>(
570 MEM_reallocN(seq->strip->stripdata, sizeof(StripElem) * (seq->len + 1)));
571 se += seq->len;
572 STRNCPY(se->filename, filename);
573 seq->len++;
574
575 seq->flag &= ~SEQ_SINGLE_FRAME_CONTENT;
576
578
579 return se;
580}
581
582static void rna_SequenceElements_pop(ID *id, Sequence *seq, ReportList *reports, int index)
583{
584 Scene *scene = (Scene *)id;
585 StripElem *new_seq, *se;
586
587 if (seq->len == 1) {
588 BKE_report(reports, RPT_ERROR, "SequenceElements.pop: cannot pop the last element");
589 return;
590 }
591
592 /* python style negative indexing */
593 if (index < 0) {
594 index += seq->len;
595 }
596
597 if (seq->len <= index || index < 0) {
598 BKE_report(reports, RPT_ERROR, "SequenceElements.pop: index out of range");
599 return;
600 }
601
602 new_seq = static_cast<StripElem *>(
603 MEM_callocN(sizeof(StripElem) * (seq->len - 1), "SequenceElements_pop"));
604 seq->len--;
605
606 if (seq->len == 1) {
608 }
609
610 se = seq->strip->stripdata;
611 if (index > 0) {
612 memcpy(new_seq, se, sizeof(StripElem) * index);
613 }
614
615 if (index < seq->len) {
616 memcpy(&new_seq[index], &se[index + 1], sizeof(StripElem) * (seq->len - index));
617 }
618
620 seq->strip->stripdata = new_seq;
621
623}
624
625static void rna_Sequence_invalidate_cache_rnafunc(ID *id, Sequence *self, int type)
626{
627 switch (type) {
630 break;
633 break;
636 break;
637 }
638}
639
640static SeqRetimingKey *rna_Sequence_retiming_keys_add(ID *id, Sequence *seq, int timeline_frame)
641{
642 Scene *scene = (Scene *)id;
643
644 SeqRetimingKey *key = SEQ_retiming_add_key(scene, seq, timeline_frame);
645
648 return key;
649}
650
651static void rna_Sequence_retiming_keys_reset(ID *id, Sequence *seq)
652{
653 Scene *scene = (Scene *)id;
654
656
659}
660
661#else
662
664{
665 FunctionRNA *func;
666 PropertyRNA *parm;
667
668 static const EnumPropertyItem seq_cahce_type_items[] = {
669 {SEQ_CACHE_STORE_RAW, "RAW", 0, "Raw", ""},
670 {SEQ_CACHE_STORE_PREPROCESSED, "PREPROCESSED", 0, "Preprocessed", ""},
671 {SEQ_CACHE_STORE_COMPOSITE, "COMPOSITE", 0, "Composite", ""},
672 {0, nullptr, 0, nullptr, nullptr},
673 };
674
675 static const EnumPropertyItem seq_split_method_items[] = {
676 {SEQ_SPLIT_SOFT, "SOFT", 0, "Soft", ""},
677 {SEQ_SPLIT_HARD, "HARD", 0, "Hard", ""},
678 {0, nullptr, 0, nullptr, nullptr},
679 };
680
681 func = RNA_def_function(srna, "strip_elem_from_frame", "rna_Sequence_strip_elem_from_frame");
683 RNA_def_function_ui_description(func, "Return the strip element from a given frame or None");
684 parm = RNA_def_int(func,
685 "frame",
686 0,
687 -MAXFRAME,
688 MAXFRAME,
689 "Frame",
690 "The frame to get the strip element from",
691 -MAXFRAME,
692 MAXFRAME);
695 func,
696 RNA_def_pointer(func, "elem", "SequenceElement", "", "strip element of the current frame"));
697
698 func = RNA_def_function(srna, "swap", "rna_Sequence_swap_internal");
701 parm = RNA_def_pointer(func, "other", "Sequence", "Other", "");
703
704 func = RNA_def_function(srna, "move_to_meta", "rna_Sequences_move_strip_to_meta");
706 parm = RNA_def_pointer(func,
707 "meta_sequence",
708 "Sequence",
709 "Destination Meta Sequence",
710 "Meta to move the strip into");
712
713 func = RNA_def_function(srna, "parent_meta", "rna_Sequence_parent_meta");
715 RNA_def_function_ui_description(func, "Parent meta");
716 /* return type */
717 parm = RNA_def_pointer(func, "sequence", "Sequence", "", "Parent Meta");
718 RNA_def_function_return(func, parm);
719
720 func = RNA_def_function(srna, "invalidate_cache", "rna_Sequence_invalidate_cache_rnafunc");
723 "Invalidate cached images for strip and all dependent strips");
724 parm = RNA_def_enum(func, "type", seq_cahce_type_items, 0, "Type", "Cache Type");
726
727 func = RNA_def_function(srna, "split", "rna_Sequence_split");
729 RNA_def_function_ui_description(func, "Split Sequence");
730 parm = RNA_def_int(
731 func, "frame", 0, INT_MIN, INT_MAX, "", "Frame where to split the strip", INT_MIN, INT_MAX);
733 parm = RNA_def_enum(func, "split_method", seq_split_method_items, 0, "", "");
735 /* Return type. */
736 parm = RNA_def_pointer(func, "sequence", "Sequence", "", "Right side Sequence");
737 RNA_def_function_return(func, parm);
738}
739
741{
742 StructRNA *srna;
743 PropertyRNA *parm;
744 FunctionRNA *func;
745
746 RNA_def_property_srna(cprop, "SequenceElements");
747 srna = RNA_def_struct(brna, "SequenceElements", nullptr);
748 RNA_def_struct_sdna(srna, "Sequence");
749 RNA_def_struct_ui_text(srna, "SequenceElements", "Collection of SequenceElement");
750
751 func = RNA_def_function(srna, "append", "rna_SequenceElements_append");
753 RNA_def_function_ui_description(func, "Push an image from ImageSequence.directory");
754 parm = RNA_def_string(func, "filename", "File", 0, "", "Filepath to image");
756 /* return type */
757 parm = RNA_def_pointer(func, "elem", "SequenceElement", "", "New SequenceElement");
758 RNA_def_function_return(func, parm);
759
760 func = RNA_def_function(srna, "pop", "rna_SequenceElements_pop");
762 RNA_def_function_ui_description(func, "Pop an image off the collection");
763 parm = RNA_def_int(
764 func, "index", -1, INT_MIN, INT_MAX, "", "Index of image to remove", INT_MIN, INT_MAX);
766}
767
769{
770 StructRNA *srna;
771
772 RNA_def_property_srna(cprop, "RetimingKeys");
773 srna = RNA_def_struct(brna, "RetimingKeys", nullptr);
774 RNA_def_struct_sdna(srna, "Sequence");
775 RNA_def_struct_ui_text(srna, "RetimingKeys", "Collection of RetimingKey");
776
777 FunctionRNA *func = RNA_def_function(srna, "add", "rna_Sequence_retiming_keys_add");
780 func, "timeline_frame", 0, -MAXFRAME, MAXFRAME, "Timeline Frame", "", -MAXFRAME, MAXFRAME);
781 RNA_def_function_ui_description(func, "Add retiming key");
782 /* return type */
783 PropertyRNA *parm = RNA_def_pointer(func, "retiming_key", "RetimingKey", "", "New RetimingKey");
784 RNA_def_function_return(func, parm);
785
786 func = RNA_def_function(srna, "reset", "rna_Sequence_retiming_keys_reset");
788 RNA_def_function_ui_description(func, "Remove all retiming keys");
789}
790
791void RNA_api_sequences(BlenderRNA *brna, PropertyRNA *cprop, const bool metastrip)
792{
793 StructRNA *srna;
794 PropertyRNA *parm;
795 FunctionRNA *func;
796
797 static const EnumPropertyItem seq_effect_items[] = {
798 {SEQ_TYPE_CROSS, "CROSS", 0, "Cross", ""},
799 {SEQ_TYPE_ADD, "ADD", 0, "Add", ""},
800 {SEQ_TYPE_SUB, "SUBTRACT", 0, "Subtract", ""},
801 {SEQ_TYPE_ALPHAOVER, "ALPHA_OVER", 0, "Alpha Over", ""},
802 {SEQ_TYPE_ALPHAUNDER, "ALPHA_UNDER", 0, "Alpha Under", ""},
803 {SEQ_TYPE_GAMCROSS, "GAMMA_CROSS", 0, "Gamma Cross", ""},
804 {SEQ_TYPE_MUL, "MULTIPLY", 0, "Multiply", ""},
805 {SEQ_TYPE_OVERDROP, "OVER_DROP", 0, "Over Drop", ""},
806 {SEQ_TYPE_WIPE, "WIPE", 0, "Wipe", ""},
807 {SEQ_TYPE_GLOW, "GLOW", 0, "Glow", ""},
808 {SEQ_TYPE_TRANSFORM, "TRANSFORM", 0, "Transform", ""},
809 {SEQ_TYPE_COLOR, "COLOR", 0, "Color", ""},
810 {SEQ_TYPE_SPEED, "SPEED", 0, "Speed", ""},
811 {SEQ_TYPE_MULTICAM, "MULTICAM", 0, "Multicam Selector", ""},
812 {SEQ_TYPE_ADJUSTMENT, "ADJUSTMENT", 0, "Adjustment Layer", ""},
813 {SEQ_TYPE_GAUSSIAN_BLUR, "GAUSSIAN_BLUR", 0, "Gaussian Blur", ""},
814 {SEQ_TYPE_TEXT, "TEXT", 0, "Text", ""},
815 {SEQ_TYPE_COLORMIX, "COLORMIX", 0, "Color Mix", ""},
816 {0, nullptr, 0, nullptr, nullptr},
817 };
818
819 static const EnumPropertyItem scale_fit_methods[] = {
820 {SEQ_SCALE_TO_FIT, "FIT", 0, "Scale to Fit", "Scale image so fits in preview"},
822 "FILL",
823 0,
824 "Scale to Fill",
825 "Scale image so it fills preview completely"},
826 {SEQ_STRETCH_TO_FILL, "STRETCH", 0, "Stretch to Fill", "Stretch image so it fills preview"},
827 {SEQ_USE_ORIGINAL_SIZE, "ORIGINAL", 0, "Use Original Size", "Don't scale the image"},
828 {0, nullptr, 0, nullptr, nullptr},
829 };
830
831 const char *new_clip_func_name = "rna_Sequences_editing_new_clip";
832 const char *new_mask_func_name = "rna_Sequences_editing_new_mask";
833 const char *new_scene_func_name = "rna_Sequences_editing_new_scene";
834 const char *new_image_func_name = "rna_Sequences_editing_new_image";
835 const char *new_movie_func_name = "rna_Sequences_editing_new_movie";
836 const char *new_sound_func_name = "rna_Sequences_editing_new_sound";
837 const char *new_meta_func_name = "rna_Sequences_editing_new_meta";
838 const char *new_effect_func_name = "rna_Sequences_editing_new_effect";
839 const char *remove_func_name = "rna_Sequences_editing_remove";
840
841 if (metastrip) {
842 RNA_def_property_srna(cprop, "SequencesMeta");
843 srna = RNA_def_struct(brna, "SequencesMeta", nullptr);
844 RNA_def_struct_sdna(srna, "Sequence");
845
846 new_clip_func_name = "rna_Sequences_meta_new_clip";
847 new_mask_func_name = "rna_Sequences_meta_new_mask";
848 new_scene_func_name = "rna_Sequences_meta_new_scene";
849 new_image_func_name = "rna_Sequences_meta_new_image";
850 new_movie_func_name = "rna_Sequences_meta_new_movie";
851 new_sound_func_name = "rna_Sequences_meta_new_sound";
852 new_meta_func_name = "rna_Sequences_meta_new_meta";
853 new_effect_func_name = "rna_Sequences_meta_new_effect";
854 remove_func_name = "rna_Sequences_meta_remove";
855 }
856 else {
857 RNA_def_property_srna(cprop, "SequencesTopLevel");
858 srna = RNA_def_struct(brna, "SequencesTopLevel", nullptr);
859 RNA_def_struct_sdna(srna, "Editing");
860 }
861
862 RNA_def_struct_ui_text(srna, "Sequences", "Collection of Sequences");
863
864 func = RNA_def_function(srna, "new_clip", new_clip_func_name);
866 RNA_def_function_ui_description(func, "Add a new movie clip sequence");
867 parm = RNA_def_string(func, "name", "Name", 0, "", "Name for the new sequence");
869 parm = RNA_def_pointer(func, "clip", "MovieClip", "", "Movie clip to add");
871 parm = RNA_def_int(func,
872 "channel",
873 0,
874 1,
876 "Channel",
877 "The channel for the new sequence",
878 1,
881 parm = RNA_def_int(func,
882 "frame_start",
883 0,
884 -MAXFRAME,
885 MAXFRAME,
886 "",
887 "The start frame for the new sequence",
888 -MAXFRAME,
889 MAXFRAME);
891 /* return type */
892 parm = RNA_def_pointer(func, "sequence", "Sequence", "", "New Sequence");
893 RNA_def_function_return(func, parm);
894
895 func = RNA_def_function(srna, "new_mask", new_mask_func_name);
897 RNA_def_function_ui_description(func, "Add a new mask sequence");
898 parm = RNA_def_string(func, "name", "Name", 0, "", "Name for the new sequence");
900 parm = RNA_def_pointer(func, "mask", "Mask", "", "Mask to add");
902 parm = RNA_def_int(func,
903 "channel",
904 0,
905 1,
907 "Channel",
908 "The channel for the new sequence",
909 1,
912 parm = RNA_def_int(func,
913 "frame_start",
914 0,
915 -MAXFRAME,
916 MAXFRAME,
917 "",
918 "The start frame for the new sequence",
919 -MAXFRAME,
920 MAXFRAME);
922 /* return type */
923 parm = RNA_def_pointer(func, "sequence", "Sequence", "", "New Sequence");
924 RNA_def_function_return(func, parm);
925
926 func = RNA_def_function(srna, "new_scene", new_scene_func_name);
928 RNA_def_function_ui_description(func, "Add a new scene sequence");
929 parm = RNA_def_string(func, "name", "Name", 0, "", "Name for the new sequence");
931 parm = RNA_def_pointer(func, "scene", "Scene", "", "Scene to add");
933 parm = RNA_def_int(func,
934 "channel",
935 0,
936 1,
938 "Channel",
939 "The channel for the new sequence",
940 1,
943 parm = RNA_def_int(func,
944 "frame_start",
945 0,
946 -MAXFRAME,
947 MAXFRAME,
948 "",
949 "The start frame for the new sequence",
950 -MAXFRAME,
951 MAXFRAME);
953 /* return type */
954 parm = RNA_def_pointer(func, "sequence", "Sequence", "", "New Sequence");
955 RNA_def_function_return(func, parm);
956
957 func = RNA_def_function(srna, "new_image", new_image_func_name);
959 RNA_def_function_ui_description(func, "Add a new image sequence");
960 parm = RNA_def_string(func, "name", "Name", 0, "", "Name for the new sequence");
962 parm = RNA_def_string(func, "filepath", "File", 0, "", "Filepath to image");
964 parm = RNA_def_int(func,
965 "channel",
966 0,
967 1,
969 "Channel",
970 "The channel for the new sequence",
971 1,
974 parm = RNA_def_int(func,
975 "frame_start",
976 0,
977 -MAXFRAME,
978 MAXFRAME,
979 "",
980 "The start frame for the new sequence",
981 -MAXFRAME,
982 MAXFRAME);
984 parm = RNA_def_enum(
985 func, "fit_method", scale_fit_methods, SEQ_USE_ORIGINAL_SIZE, "Image Fit Method", nullptr);
987 /* return type */
988 parm = RNA_def_pointer(func, "sequence", "Sequence", "", "New Sequence");
989 RNA_def_function_return(func, parm);
990
991 func = RNA_def_function(srna, "new_movie", new_movie_func_name);
993 RNA_def_function_ui_description(func, "Add a new movie sequence");
994 parm = RNA_def_string(func, "name", "Name", 0, "", "Name for the new sequence");
996 parm = RNA_def_string(func, "filepath", "File", 0, "", "Filepath to movie");
998 parm = RNA_def_int(func,
999 "channel",
1000 0,
1001 1,
1003 "Channel",
1004 "The channel for the new sequence",
1005 1,
1008 parm = RNA_def_int(func,
1009 "frame_start",
1010 0,
1011 -MAXFRAME,
1012 MAXFRAME,
1013 "",
1014 "The start frame for the new sequence",
1015 -MAXFRAME,
1016 MAXFRAME);
1018 parm = RNA_def_enum(
1019 func, "fit_method", scale_fit_methods, SEQ_USE_ORIGINAL_SIZE, "Image Fit Method", nullptr);
1021 /* return type */
1022 parm = RNA_def_pointer(func, "sequence", "Sequence", "", "New Sequence");
1023 RNA_def_function_return(func, parm);
1024
1025 func = RNA_def_function(srna, "new_sound", new_sound_func_name);
1027 RNA_def_function_ui_description(func, "Add a new sound sequence");
1028 parm = RNA_def_string(func, "name", "Name", 0, "", "Name for the new sequence");
1030 parm = RNA_def_string(func, "filepath", "File", 0, "", "Filepath to movie");
1032 parm = RNA_def_int(func,
1033 "channel",
1034 0,
1035 1,
1037 "Channel",
1038 "The channel for the new sequence",
1039 1,
1042 parm = RNA_def_int(func,
1043 "frame_start",
1044 0,
1045 -MAXFRAME,
1046 MAXFRAME,
1047 "",
1048 "The start frame for the new sequence",
1049 -MAXFRAME,
1050 MAXFRAME);
1052 /* return type */
1053 parm = RNA_def_pointer(func, "sequence", "Sequence", "", "New Sequence");
1054 RNA_def_function_return(func, parm);
1055
1056 func = RNA_def_function(srna, "new_meta", new_meta_func_name);
1058 RNA_def_function_ui_description(func, "Add a new meta sequence");
1059 parm = RNA_def_string(func, "name", "Name", 0, "", "Name for the new sequence");
1061 parm = RNA_def_int(func,
1062 "channel",
1063 0,
1064 1,
1066 "Channel",
1067 "The channel for the new sequence",
1068 1,
1071 parm = RNA_def_int(func,
1072 "frame_start",
1073 0,
1074 -MAXFRAME,
1075 MAXFRAME,
1076 "",
1077 "The start frame for the new sequence",
1078 -MAXFRAME,
1079 MAXFRAME);
1081 /* return type */
1082 parm = RNA_def_pointer(func, "sequence", "Sequence", "", "New Sequence");
1083 RNA_def_function_return(func, parm);
1084
1085 func = RNA_def_function(srna, "new_effect", new_effect_func_name);
1087 RNA_def_function_ui_description(func, "Add a new effect sequence");
1088 parm = RNA_def_string(func, "name", "Name", 0, "", "Name for the new sequence");
1090 parm = RNA_def_enum(func, "type", seq_effect_items, 0, "Type", "type for the new sequence");
1092 parm = RNA_def_int(func,
1093 "channel",
1094 0,
1095 1,
1097 "Channel",
1098 "The channel for the new sequence",
1099 1,
1101 /* don't use MAXFRAME since it makes importer scripts fail */
1103 parm = RNA_def_int(func,
1104 "frame_start",
1105 0,
1106 INT_MIN,
1107 INT_MAX,
1108 "",
1109 "The start frame for the new sequence",
1110 INT_MIN,
1111 INT_MAX);
1113 RNA_def_int(func,
1114 "frame_end",
1115 0,
1116 INT_MIN,
1117 INT_MAX,
1118 "",
1119 "The end frame for the new sequence",
1120 INT_MIN,
1121 INT_MAX);
1122 RNA_def_pointer(func, "seq1", "Sequence", "", "Sequence 1 for effect");
1123 RNA_def_pointer(func, "seq2", "Sequence", "", "Sequence 2 for effect");
1124 /* return type */
1125 parm = RNA_def_pointer(func, "sequence", "Sequence", "", "New Sequence");
1126 RNA_def_function_return(func, parm);
1127
1128 func = RNA_def_function(srna, "remove", remove_func_name);
1130 RNA_def_function_ui_description(func, "Remove a Sequence");
1131 parm = RNA_def_pointer(func, "sequence", "Sequence", "", "Sequence to remove");
1134}
1135
1136#endif
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:125
int BLI_findindex(const struct ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
#define FILE_MAXFILE
#define FILE_MAX
void BLI_path_split_dir_file(const char *filepath, char *dir, size_t dir_maxncpy, char *file, size_t file_maxncpy) ATTR_NONNULL(1
#define STRNCPY(dst, src)
Definition BLI_string.h:593
void DEG_id_tag_update(ID *id, unsigned int flags)
void DEG_relations_tag_update(Main *bmain)
@ ID_RECALC_SEQUENCER_STRIPS
Definition DNA_ID.h:1089
eSeqImageFitMethod
@ SEQ_SCALE_TO_FILL
@ SEQ_STRETCH_TO_FILL
@ SEQ_USE_ORIGINAL_SIZE
@ SEQ_SCALE_TO_FIT
#define MAXFRAME
@ SEQ_CACHE_STORE_PREPROCESSED
@ SEQ_CACHE_STORE_RAW
@ SEQ_CACHE_STORE_COMPOSITE
@ SEQ_TYPE_TRANSFORM
@ SEQ_TYPE_CROSS
@ SEQ_TYPE_GLOW
@ SEQ_TYPE_COLORMIX
@ SEQ_TYPE_WIPE
@ SEQ_TYPE_OVERDROP
@ SEQ_TYPE_ALPHAUNDER
@ SEQ_TYPE_GAMCROSS
@ SEQ_TYPE_MULTICAM
@ SEQ_TYPE_MUL
@ SEQ_TYPE_GAUSSIAN_BLUR
@ SEQ_TYPE_ADD
@ SEQ_TYPE_ALPHAOVER
@ SEQ_TYPE_TEXT
@ SEQ_TYPE_SUB
@ SEQ_TYPE_SPEED
@ SEQ_TYPE_COLOR
@ SEQ_TYPE_ADJUSTMENT
@ SEQ_SINGLE_FRAME_CONTENT
Contains defines and structs used throughout the imbuf module.
#define MEM_reallocN(vmemh, len)
#define RNA_POINTER_INVALIDATE(ptr)
ParameterFlag
Definition RNA_types.hh:396
@ PARM_RNAPTR
Definition RNA_types.hh:399
@ PARM_PYFUNC_OPTIONAL
Definition RNA_types.hh:407
@ PARM_REQUIRED
Definition RNA_types.hh:397
@ FUNC_USE_REPORTS
Definition RNA_types.hh:680
@ FUNC_USE_MAIN
Definition RNA_types.hh:678
@ FUNC_USE_SELF_ID
Definition RNA_types.hh:667
PropertyFlag
Definition RNA_types.hh:201
@ PROP_THICK_WRAP
Definition RNA_types.hh:312
@ PROP_NEVER_NULL
Definition RNA_types.hh:266
eSeqSplitMethod
Definition SEQ_edit.hh:54
@ SEQ_SPLIT_SOFT
Definition SEQ_edit.hh:55
@ SEQ_SPLIT_HARD
Definition SEQ_edit.hh:56
constexpr int SEQ_MAX_CHANNELS
#define ND_SEQUENCER
Definition WM_types.hh:404
#define NC_SCENE
Definition WM_types.hh:345
PyObject * self
int len
int SEQ_effect_get_num_inputs(int seq_type)
Definition effects.cc:3467
void MEM_freeN(void *vmemh)
Definition mallocn.cc:105
void *(* MEM_callocN)(size_t len, const char *str)
Definition mallocn.cc:42
ccl_device_inline float4 mask(const int4 mask, const float4 a)
StripElem * SEQ_render_give_stripelem(const Scene *scene, const Sequence *seq, int timeline_frame)
Definition render.cc:248
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
void RNA_def_parameter_clear_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
void RNA_def_property_srna(PropertyRNA *prop, const char *type)
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier, const char *call)
PropertyRNA * RNA_def_pointer(StructOrFunctionRNA *cont_, const char *identifier, const char *type, const char *ui_name, const char *ui_description)
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
void RNA_def_function_flag(FunctionRNA *func, int flag)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
void RNA_api_sequence_retiming_keys(BlenderRNA *brna, PropertyRNA *cprop)
void RNA_api_sequences(BlenderRNA *brna, PropertyRNA *cprop, const bool metastrip)
void RNA_api_sequence_strip(StructRNA *srna)
void RNA_api_sequence_elements(BlenderRNA *brna, PropertyRNA *cprop)
void SEQ_sequence_lookup_invalidate(const Scene *scene)
ListBase * SEQ_get_seqbase_by_seq(const Scene *scene, Sequence *seq)
Editing * SEQ_editing_get(const Scene *scene)
Definition sequencer.cc:262
static const EnumPropertyItem scale_fit_methods[]
Sequence * SEQ_add_scene_strip(Scene *scene, ListBase *seqbase, SeqLoadData *load_data)
Definition strip_add.cc:124
Sequence * SEQ_add_movieclip_strip(Scene *scene, ListBase *seqbase, SeqLoadData *load_data)
Definition strip_add.cc:136
Sequence * SEQ_add_effect_strip(Scene *scene, ListBase *seqbase, SeqLoadData *load_data)
Definition strip_add.cc:160
Sequence * SEQ_add_mask_strip(Scene *scene, ListBase *seqbase, SeqLoadData *load_data)
Definition strip_add.cc:148
Sequence * SEQ_add_movie_strip(Main *bmain, Scene *scene, ListBase *seqbase, SeqLoadData *load_data)
Definition strip_add.cc:391
void SEQ_add_image_set_directory(Sequence *seq, const char *dirpath)
Definition strip_add.cc:188
Sequence * SEQ_add_meta_strip(Scene *scene, ListBase *seqbase, SeqLoadData *load_data)
Definition strip_add.cc:373
void SEQ_add_image_init_alpha_mode(Sequence *seq)
Definition strip_add.cc:200
void SEQ_add_image_load_file(Scene *scene, Sequence *seq, size_t strip_frame, const char *filename)
Definition strip_add.cc:193
Sequence * SEQ_add_sound_strip(Main *, Scene *, ListBase *, SeqLoadData *)
Definition strip_add.cc:364
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.cc:56
Sequence * SEQ_add_image_strip(Main *bmain, Scene *scene, ListBase *seqbase, SeqLoadData *load_data)
Definition strip_add.cc:230
void SEQ_edit_flag_for_removal(Scene *scene, ListBase *seqbase, Sequence *seq)
Sequence * SEQ_edit_strip_split(Main *bmain, Scene *scene, ListBase *seqbase, Sequence *seq, const int timeline_frame, const eSeqSplitMethod method, const char **r_error)
bool SEQ_edit_sequence_swap(Scene *scene, Sequence *seq_a, Sequence *seq_b, const char **r_error_str)
Definition strip_edit.cc:42
void SEQ_edit_remove_flagged_sequences(Scene *scene, ListBase *seqbase)
bool SEQ_edit_move_strip_to_meta(Scene *scene, Sequence *src_seq, Sequence *dst_seqm, const char **r_error_str)
void SEQ_relations_invalidate_cache_raw(Scene *scene, Sequence *seq)
Sequence * SEQ_find_metastrip_by_sequence(ListBase *seqbase, Sequence *meta, Sequence *seq)
void SEQ_relations_invalidate_cache_preprocessed(Scene *scene, Sequence *seq)
void SEQ_relations_invalidate_cache_composite(Scene *scene, Sequence *seq)
void SEQ_retiming_data_clear(Sequence *seq)
SeqRetimingKey * SEQ_retiming_add_key(const Scene *scene, Sequence *seq, const int timeline_frame)
ListBase seqbase
Definition DNA_ID.h:413
void * data
Definition RNA_types.hh:42
Scene * scene
Definition SEQ_add.hh:43
struct SeqLoadData::@1364 effect
eSeqImageFitMethod fit_method
Definition SEQ_add.hh:53
Sequence * seq1
Definition SEQ_add.hh:49
bool allow_invalid_file
Definition SEQ_add.hh:57
Sequence * seq2
Definition SEQ_add.hh:50
int end_frame
Definition SEQ_add.hh:41
MovieClip * clip
Definition SEQ_add.hh:44
Mask * mask
Definition SEQ_add.hh:45
struct SeqLoadData::@1363 image
char filename[256]
StripElem * stripdata
void WM_main_add_notifier(uint type, void *reference)