Changeset View
Changeset View
Standalone View
Standalone View
source/blender/sequencer/intern/strip_add.c
| Show First 20 Lines • Show All 137 Lines • ▼ Show 20 Lines | |||||
| */ | */ | ||||
| Sequence *SEQ_add_scene_strip(Scene *scene, ListBase *seqbase, struct SeqLoadData *load_data) | Sequence *SEQ_add_scene_strip(Scene *scene, ListBase *seqbase, struct SeqLoadData *load_data) | ||||
| { | { | ||||
| Sequence *seq = SEQ_sequence_alloc( | Sequence *seq = SEQ_sequence_alloc( | ||||
| seqbase, load_data->start_frame, load_data->channel, SEQ_TYPE_SCENE); | seqbase, load_data->start_frame, load_data->channel, SEQ_TYPE_SCENE); | ||||
| seq->blend_mode = SEQ_TYPE_CROSS; | seq->blend_mode = SEQ_TYPE_CROSS; | ||||
| seq->scene = load_data->scene; | seq->scene = load_data->scene; | ||||
| seq->len = load_data->scene->r.efra - load_data->scene->r.sfra + 1; | seq->len = load_data->scene->r.efra - load_data->scene->r.sfra + 1; | ||||
| seq->playback_rate = 1.0f; | |||||
| id_us_ensure_real((ID *)load_data->scene); | id_us_ensure_real((ID *)load_data->scene); | ||||
| seq_add_set_name(seq, load_data); | seq_add_set_name(seq, load_data); | ||||
| seq_add_generic_update(scene, seqbase, seq); | seq_add_generic_update(scene, seqbase, seq); | ||||
| return seq; | return seq; | ||||
| } | } | ||||
| /** | /** | ||||
| * Add movieclip strip. | * Add movieclip strip. | ||||
| * | * | ||||
| * \param scene: Scene where strips will be added | * \param scene: Scene where strips will be added | ||||
| * \param seqbase: ListBase where strips will be added | * \param seqbase: ListBase where strips will be added | ||||
| * \param load_data: SeqLoadData with information necessary to create strip | * \param load_data: SeqLoadData with information necessary to create strip | ||||
| * \return created strip | * \return created strip | ||||
| */ | */ | ||||
| Sequence *SEQ_add_movieclip_strip(Scene *scene, ListBase *seqbase, struct SeqLoadData *load_data) | Sequence *SEQ_add_movieclip_strip(Scene *scene, ListBase *seqbase, struct SeqLoadData *load_data) | ||||
| { | { | ||||
| Sequence *seq = SEQ_sequence_alloc( | Sequence *seq = SEQ_sequence_alloc( | ||||
| seqbase, load_data->start_frame, load_data->channel, SEQ_TYPE_MOVIECLIP); | seqbase, load_data->start_frame, load_data->channel, SEQ_TYPE_MOVIECLIP); | ||||
| seq->blend_mode = SEQ_TYPE_CROSS; | seq->blend_mode = SEQ_TYPE_CROSS; | ||||
| seq->clip = load_data->clip; | seq->clip = load_data->clip; | ||||
| seq->len = BKE_movieclip_get_duration(load_data->clip); | seq->len = BKE_movieclip_get_duration(load_data->clip); | ||||
| seq->playback_rate = 1.0f; | |||||
| id_us_ensure_real((ID *)load_data->clip); | id_us_ensure_real((ID *)load_data->clip); | ||||
| seq_add_set_name(seq, load_data); | seq_add_set_name(seq, load_data); | ||||
| seq_add_generic_update(scene, seqbase, seq); | seq_add_generic_update(scene, seqbase, seq); | ||||
| return seq; | return seq; | ||||
| } | } | ||||
| /** | /** | ||||
| * Add mask strip. | * Add mask strip. | ||||
| * | * | ||||
| * \param scene: Scene where strips will be added | * \param scene: Scene where strips will be added | ||||
| * \param seqbase: ListBase where strips will be added | * \param seqbase: ListBase where strips will be added | ||||
| * \param load_data: SeqLoadData with information necessary to create strip | * \param load_data: SeqLoadData with information necessary to create strip | ||||
| * \return created strip | * \return created strip | ||||
| */ | */ | ||||
| Sequence *SEQ_add_mask_strip(Scene *scene, ListBase *seqbase, struct SeqLoadData *load_data) | Sequence *SEQ_add_mask_strip(Scene *scene, ListBase *seqbase, struct SeqLoadData *load_data) | ||||
| { | { | ||||
| Sequence *seq = SEQ_sequence_alloc( | Sequence *seq = SEQ_sequence_alloc( | ||||
| seqbase, load_data->start_frame, load_data->channel, SEQ_TYPE_MASK); | seqbase, load_data->start_frame, load_data->channel, SEQ_TYPE_MASK); | ||||
| seq->blend_mode = SEQ_TYPE_CROSS; | seq->blend_mode = SEQ_TYPE_CROSS; | ||||
| seq->mask = load_data->mask; | seq->mask = load_data->mask; | ||||
| seq->len = BKE_mask_get_duration(load_data->mask); | seq->len = BKE_mask_get_duration(load_data->mask); | ||||
| seq->playback_rate = 1.0f; | |||||
| id_us_ensure_real((ID *)load_data->mask); | id_us_ensure_real((ID *)load_data->mask); | ||||
| seq_add_set_name(seq, load_data); | seq_add_set_name(seq, load_data); | ||||
| seq_add_generic_update(scene, seqbase, seq); | seq_add_generic_update(scene, seqbase, seq); | ||||
| return seq; | return seq; | ||||
| } | } | ||||
| /** | /** | ||||
| * Add effect strip. | * Add effect strip. | ||||
| Show All 9 Lines | Sequence *seq = SEQ_sequence_alloc( | ||||
| seqbase, load_data->start_frame, load_data->channel, load_data->effect.type); | seqbase, load_data->start_frame, load_data->channel, load_data->effect.type); | ||||
| seq->flag |= SEQ_USE_EFFECT_DEFAULT_FADE; | seq->flag |= SEQ_USE_EFFECT_DEFAULT_FADE; | ||||
| struct SeqEffectHandle sh = SEQ_effect_handle_get(seq); | struct SeqEffectHandle sh = SEQ_effect_handle_get(seq); | ||||
| sh.init(seq); | sh.init(seq); | ||||
| seq->seq1 = load_data->effect.seq1; | seq->seq1 = load_data->effect.seq1; | ||||
| seq->seq2 = load_data->effect.seq2; | seq->seq2 = load_data->effect.seq2; | ||||
| seq->seq3 = load_data->effect.seq3; | seq->seq3 = load_data->effect.seq3; | ||||
| seq->playback_rate = 1.0f; | |||||
| if (seq->type == SEQ_TYPE_COLOR) { | if (seq->type == SEQ_TYPE_COLOR) { | ||||
| seq->blend_mode = SEQ_TYPE_CROSS; | seq->blend_mode = SEQ_TYPE_CROSS; | ||||
| } | } | ||||
| else if (seq->type == SEQ_TYPE_ADJUSTMENT) { | else if (seq->type == SEQ_TYPE_ADJUSTMENT) { | ||||
| seq->blend_mode = SEQ_TYPE_CROSS; | seq->blend_mode = SEQ_TYPE_CROSS; | ||||
| } | } | ||||
| else if (seq->type == SEQ_TYPE_TEXT) { | else if (seq->type == SEQ_TYPE_TEXT) { | ||||
| seq->blend_mode = SEQ_TYPE_ALPHAOVER; | seq->blend_mode = SEQ_TYPE_ALPHAOVER; | ||||
| } | } | ||||
| else if (SEQ_effect_get_num_inputs(seq->type) == 1) { | else if (SEQ_effect_get_num_inputs(seq->type) == 1) { | ||||
| seq->blend_mode = seq->seq1->blend_mode; | seq->blend_mode = seq->seq1->blend_mode; | ||||
| } | } | ||||
| if (!load_data->effect.seq1) { | if (!load_data->effect.seq1) { | ||||
| seq->len = 1; /* Effect is generator, set non zero length. */ | seq->len = 1; /* Effect is generator, set non zero length. */ | ||||
| SEQ_transform_set_right_handle_frame(seq, load_data->effect.end_frame); | SEQ_transform_set_right_handle_frame(scene, seq, load_data->effect.end_frame); | ||||
| } | } | ||||
| SEQ_relations_update_changed_seq_and_deps(scene, seq, 1, 1); /* Runs SEQ_time_update_sequence. */ | SEQ_relations_update_changed_seq_and_deps(scene, seq, 1, 1); /* Runs SEQ_time_update_sequence. */ | ||||
| seq_add_set_name(seq, load_data); | seq_add_set_name(seq, load_data); | ||||
| seq_add_generic_update(scene, seqbase, seq); | seq_add_generic_update(scene, seqbase, seq); | ||||
| return seq; | return seq; | ||||
| } | } | ||||
| Show All 11 Lines | |||||
| /** | /** | ||||
| * Set directory used by image strip. | * Set directory used by image strip. | ||||
| * | * | ||||
| * \param seq: image strip to be changed | * \param seq: image strip to be changed | ||||
| * \param strip_frame: frame index of strip to be changed | * \param strip_frame: frame index of strip to be changed | ||||
| * \param filename: image filename (only filename, not complete path) | * \param filename: image filename (only filename, not complete path) | ||||
| */ | */ | ||||
| void SEQ_add_image_load_file(Sequence *seq, size_t strip_frame, char *filename) | void SEQ_add_image_load_file(Scene *scene, Sequence *seq, size_t strip_frame, char *filename) | ||||
| { | { | ||||
| StripElem *se = SEQ_render_give_stripelem(seq, seq->start + strip_frame); | StripElem *se = SEQ_render_give_stripelem(scene, seq, seq->start + strip_frame); | ||||
| BLI_strncpy(se->name, filename, sizeof(se->name)); | BLI_strncpy(se->name, filename, sizeof(se->name)); | ||||
| } | } | ||||
| /** | /** | ||||
| * Set image strip alpha mode | * Set image strip alpha mode | ||||
| * | * | ||||
| * \param seq: image strip to be changed | * \param seq: image strip to be changed | ||||
| */ | */ | ||||
| Show All 37 Lines | |||||
| * \return created strip | * \return created strip | ||||
| */ | */ | ||||
| Sequence *SEQ_add_image_strip(Main *bmain, Scene *scene, ListBase *seqbase, SeqLoadData *load_data) | Sequence *SEQ_add_image_strip(Main *bmain, Scene *scene, ListBase *seqbase, SeqLoadData *load_data) | ||||
| { | { | ||||
| Sequence *seq = SEQ_sequence_alloc( | Sequence *seq = SEQ_sequence_alloc( | ||||
| seqbase, load_data->start_frame, load_data->channel, SEQ_TYPE_IMAGE); | seqbase, load_data->start_frame, load_data->channel, SEQ_TYPE_IMAGE); | ||||
| seq->blend_mode = SEQ_TYPE_CROSS; /* so alpha adjustment fade to the strip below */ | seq->blend_mode = SEQ_TYPE_CROSS; /* so alpha adjustment fade to the strip below */ | ||||
| seq->len = load_data->image.len; | seq->len = load_data->image.len; | ||||
| seq->playback_rate = 1.0f; | |||||
| Strip *strip = seq->strip; | Strip *strip = seq->strip; | ||||
| strip->stripdata = MEM_callocN(load_data->image.len * sizeof(StripElem), "stripelem"); | strip->stripdata = MEM_callocN(load_data->image.len * sizeof(StripElem), "stripelem"); | ||||
| /* Multiview settings. */ | /* Multiview settings. */ | ||||
| if (load_data->use_multiview) { | if (load_data->use_multiview) { | ||||
| seq->flag |= SEQ_USE_VIEWS; | seq->flag |= SEQ_USE_VIEWS; | ||||
| seq->views_format = load_data->views_format; | seq->views_format = load_data->views_format; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 218 Lines • ▼ Show 20 Lines | if (load_data->flags & SEQ_LOAD_MOVIE_SYNC_FPS) { | ||||
| IMB_anim_get_fps(anim_arr[0], &scene->r.frs_sec, &scene->r.frs_sec_base, true); | IMB_anim_get_fps(anim_arr[0], &scene->r.frs_sec, &scene->r.frs_sec_base, true); | ||||
| } | } | ||||
| /* Set initial scale based on load_data->fit_method. */ | /* Set initial scale based on load_data->fit_method. */ | ||||
| orig_width = IMB_anim_get_image_width(anim_arr[0]); | orig_width = IMB_anim_get_image_width(anim_arr[0]); | ||||
| orig_height = IMB_anim_get_image_height(anim_arr[0]); | orig_height = IMB_anim_get_image_height(anim_arr[0]); | ||||
| SEQ_set_scale_to_fit( | SEQ_set_scale_to_fit( | ||||
| seq, orig_width, orig_height, scene->r.xsch, scene->r.ysch, load_data->fit_method); | seq, orig_width, orig_height, scene->r.xsch, scene->r.ysch, load_data->fit_method); | ||||
| short frs_sec; | |||||
| float frs_sec_base; | |||||
| if (IMB_anim_get_fps(anim_arr[0], &frs_sec, &frs_sec_base, true)) { | |||||
| seq->playback_rate = (float)frs_sec / frs_sec_base; | |||||
| } | |||||
| } | } | ||||
| seq->len = MAX2(1, seq->len); | seq->len = MAX2(1, seq->len); | ||||
| BLI_strncpy(seq->strip->colorspace_settings.name, | BLI_strncpy(seq->strip->colorspace_settings.name, | ||||
| colorspace, | colorspace, | ||||
| sizeof(seq->strip->colorspace_settings.name)); | sizeof(seq->strip->colorspace_settings.name)); | ||||
| Strip *strip = seq->strip; | Strip *strip = seq->strip; | ||||
| ▲ Show 20 Lines • Show All 173 Lines • ▼ Show 20 Lines | case SEQ_TYPE_SCENE: { | ||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| free_proxy_seq(seq); | free_proxy_seq(seq); | ||||
| if (lock_range) { | if (lock_range) { | ||||
| SEQ_transform_set_left_handle_frame(seq, prev_startdisp); | SEQ_transform_set_left_handle_frame(scene, seq, prev_startdisp); | ||||
| SEQ_transform_set_right_handle_frame(seq, prev_enddisp); | SEQ_transform_set_right_handle_frame(scene, seq, prev_enddisp); | ||||
| SEQ_transform_fix_single_image_seq_offsets(seq); | SEQ_transform_fix_single_image_seq_offsets(scene, seq); | ||||
| } | } | ||||
| SEQ_time_update_sequence(scene, seq); | SEQ_time_update_sequence(scene, seq); | ||||
| } | } | ||||
| void SEQ_add_movie_reload_if_needed(struct Main *bmain, | void SEQ_add_movie_reload_if_needed(struct Main *bmain, | ||||
| struct Scene *scene, | struct Scene *scene, | ||||
| struct Sequence *seq, | struct Sequence *seq, | ||||
| ▲ Show 20 Lines • Show All 54 Lines • Show Last 20 Lines | |||||