Changeset View
Changeset View
Standalone View
Standalone View
source/blender/sequencer/intern/strip_add.c
| Show First 20 Lines • Show All 281 Lines • ▼ Show 20 Lines | Sequence *SEQ_add_image_strip(Main *bmain, Scene *scene, ListBase *seqbase, SeqLoadData *load_data) | ||||
| seq_add_set_view_transform(scene, seq, load_data); | seq_add_set_view_transform(scene, seq, load_data); | ||||
| seq_add_set_name(scene, seq, load_data); | seq_add_set_name(scene, seq, load_data); | ||||
| seq_add_generic_update(scene, seqbase, seq); | seq_add_generic_update(scene, seqbase, seq); | ||||
| return seq; | return seq; | ||||
| } | } | ||||
| #ifdef WITH_AUDASPACE | #ifdef WITH_AUDASPACE | ||||
| Sequence *SEQ_add_sound_strip(Main *bmain, | |||||
| Scene *scene, | static void seq_add_sound_av_sync(Main *bmain, Scene *scene, Sequence *seq, SeqLoadData *load_data) | ||||
| ListBase *seqbase, | { | ||||
| SeqLoadData *load_data, | SoundStreamInfo sound_stream; | ||||
| const double audio_offset) | if (!BKE_sound_stream_info_get(bmain, load_data->path, 0, &sound_stream)) { | ||||
| return; | |||||
| } | |||||
| const double av_stream_offset = sound_stream.start - load_data->r_video_stream_start; | |||||
| const int frame_offset = av_stream_offset * FPS; | |||||
| /* Set subframe offset. */ | |||||
| seq->sound->offset_time = ((double)frame_offset / FPS) - av_stream_offset; | |||||
| SEQ_transform_translate_sequence(scene, seq, frame_offset); | |||||
| } | |||||
| Sequence *SEQ_add_sound_strip(Main *bmain, Scene *scene, ListBase *seqbase, SeqLoadData *load_data) | |||||
| { | { | ||||
| bSound *sound = BKE_sound_new_file(bmain, load_data->path); /* Handles relative paths. */ | bSound *sound = BKE_sound_new_file(bmain, load_data->path); /* Handles relative paths. */ | ||||
| sound->offset_time = audio_offset; | |||||
| SoundInfo info; | SoundInfo info; | ||||
| bool sound_loaded = BKE_sound_info_get(bmain, sound, &info); | bool sound_loaded = BKE_sound_info_get(bmain, sound, &info); | ||||
| if (!sound_loaded && !load_data->allow_invalid_file) { | if (!sound_loaded && !load_data->allow_invalid_file) { | ||||
| BKE_id_free(bmain, sound); | BKE_id_free(bmain, sound); | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| Show All 26 Lines | if (seq != NULL && seq->sound != NULL) { | ||||
| if (load_data->flags & SEQ_LOAD_SOUND_CACHE) { | if (load_data->flags & SEQ_LOAD_SOUND_CACHE) { | ||||
| if (seq->sound) { | if (seq->sound) { | ||||
| seq->sound->flags |= SOUND_FLAGS_CACHING; | seq->sound->flags |= SOUND_FLAGS_CACHING; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| seq_add_sound_av_sync(bmain, scene, seq, load_data); | |||||
| /* Set Last active directory. */ | /* Set Last active directory. */ | ||||
| BLI_strncpy(scene->ed->act_sounddir, strip->dir, FILE_MAXDIR); | BLI_strncpy(scene->ed->act_sounddir, strip->dir, FILE_MAXDIR); | ||||
| seq_add_set_name(scene, seq, load_data); | seq_add_set_name(scene, seq, load_data); | ||||
| seq_add_generic_update(scene, seqbase, seq); | seq_add_generic_update(scene, seqbase, seq); | ||||
| return seq; | return seq; | ||||
| } | } | ||||
| Show All 20 Lines | Sequence *SEQ_add_meta_strip(Scene *scene, ListBase *seqbase, SeqLoadData *load_data) | ||||
| /* Set frames start and length. */ | /* Set frames start and length. */ | ||||
| seqm->start = load_data->start_frame; | seqm->start = load_data->start_frame; | ||||
| seqm->len = 1; | seqm->len = 1; | ||||
| SEQ_time_update_sequence(scene, seqbase, seqm); | SEQ_time_update_sequence(scene, seqbase, seqm); | ||||
| return seqm; | return seqm; | ||||
| } | } | ||||
| Sequence *SEQ_add_movie_strip( | Sequence *SEQ_add_movie_strip(Main *bmain, Scene *scene, ListBase *seqbase, SeqLoadData *load_data) | ||||
| Main *bmain, Scene *scene, ListBase *seqbase, SeqLoadData *load_data, double *r_start_offset) | |||||
| { | { | ||||
| char path[sizeof(load_data->path)]; | char path[sizeof(load_data->path)]; | ||||
| BLI_strncpy(path, load_data->path, sizeof(path)); | BLI_strncpy(path, load_data->path, sizeof(path)); | ||||
| BLI_path_abs(path, BKE_main_blendfile_path(bmain)); | BLI_path_abs(path, BKE_main_blendfile_path(bmain)); | ||||
| char colorspace[64] = "\0"; /* MAX_COLORSPACE_NAME */ | char colorspace[64] = "\0"; /* MAX_COLORSPACE_NAME */ | ||||
| bool is_multiview_loaded = false; | bool is_multiview_loaded = false; | ||||
| const int totfiles = seq_num_files(scene, load_data->views_format, load_data->use_multiview); | const int totfiles = seq_num_files(scene, load_data->views_format, load_data->use_multiview); | ||||
| Show All 29 Lines | if (is_multiview_loaded == false) { | ||||
| anim_arr[0] = openanim(path, IB_rect, 0, colorspace); | anim_arr[0] = openanim(path, IB_rect, 0, colorspace); | ||||
| } | } | ||||
| if (anim_arr[0] == NULL && !load_data->allow_invalid_file) { | if (anim_arr[0] == NULL && !load_data->allow_invalid_file) { | ||||
| MEM_freeN(anim_arr); | MEM_freeN(anim_arr); | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| int video_frame_offset = 0; | |||||
| float video_fps = 0.0f; | float video_fps = 0.0f; | ||||
| load_data->r_video_stream_start = 0.0; | |||||
| if (anim_arr[0] != NULL) { | if (anim_arr[0] != NULL) { | ||||
| short fps_denom; | short fps_denom; | ||||
| float fps_num; | float fps_num; | ||||
| IMB_anim_get_fps(anim_arr[0], &fps_denom, &fps_num, true); | IMB_anim_get_fps(anim_arr[0], &fps_denom, &fps_num, true); | ||||
| video_fps = fps_denom / fps_num; | video_fps = fps_denom / fps_num; | ||||
| /* Adjust scene's frame rate settings to match. */ | /* Adjust scene's frame rate settings to match. */ | ||||
| if (load_data->flags & SEQ_LOAD_MOVIE_SYNC_FPS) { | if (load_data->flags & SEQ_LOAD_MOVIE_SYNC_FPS) { | ||||
| scene->r.frs_sec = fps_denom; | scene->r.frs_sec = fps_denom; | ||||
| scene->r.frs_sec_base = fps_num; | scene->r.frs_sec_base = fps_num; | ||||
| } | } | ||||
| double video_start_offset = IMD_anim_get_offset(anim_arr[0]); | load_data->r_video_stream_start = IMD_anim_get_offset(anim_arr[0]); | ||||
| int minimum_frame_offset; | |||||
| if (*r_start_offset >= 0) { | |||||
| minimum_frame_offset = MIN2(video_start_offset, *r_start_offset) * FPS; | |||||
| } | |||||
| else { | |||||
| minimum_frame_offset = video_start_offset * FPS; | |||||
| } | |||||
| video_frame_offset = video_start_offset * FPS - minimum_frame_offset; | |||||
| *r_start_offset = video_start_offset; | |||||
| } | } | ||||
| Sequence *seq = SEQ_sequence_alloc( | Sequence *seq = SEQ_sequence_alloc( | ||||
| seqbase, load_data->start_frame + video_frame_offset, load_data->channel, SEQ_TYPE_MOVIE); | seqbase, load_data->start_frame, load_data->channel, SEQ_TYPE_MOVIE); | ||||
| /* 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; | ||||
| } | } | ||||
| if (load_data->stereo3d_format) { | if (load_data->stereo3d_format) { | ||||
| seq->stereo3d_format = load_data->stereo3d_format; | seq->stereo3d_format = load_data->stereo3d_format; | ||||
| ▲ Show 20 Lines • Show All 280 Lines • Show Last 20 Lines | |||||