WIP: VSE: Use seconds for strip length and position #105620
|
@ -19,7 +19,7 @@ extern "C" {
|
|||
/* Blender major and minor version. */
|
||||
#define BLENDER_VERSION 306
|
||||
/* Blender patch version for bugfix releases. */
|
||||
#define BLENDER_VERSION_PATCH 0
|
||||
#define BLENDER_VERSION_PATCH 1
|
||||
/** Blender release cycle stage: alpha/beta/rc/release. */
|
||||
#define BLENDER_VERSION_CYCLE alpha
|
||||
|
||||
|
|
|
@ -777,12 +777,15 @@ void BKE_sound_move_scene_sound_defaults(Scene *scene, Sequence *sequence)
|
|||
{
|
||||
sound_verify_evaluated_id(&scene->id);
|
||||
if (sequence->scene_sound) {
|
||||
BKE_sound_move_scene_sound(scene,
|
||||
sequence->scene_sound,
|
||||
SEQ_time_left_handle_frame_get(scene, sequence),
|
||||
SEQ_time_right_handle_frame_get(scene, sequence),
|
||||
sequence->startofs + sequence->anim_startofs,
|
||||
0.0);
|
||||
BKE_sound_move_scene_sound(
|
||||
scene,
|
||||
sequence->scene_sound,
|
||||
SEQ_time_left_handle_frame_get(scene, sequence),
|
||||
SEQ_time_right_handle_frame_get(scene, sequence),
|
||||
SEQ_time_seconds_to_frames(
|
||||
scene,
|
||||
sequence->startofs + sequence->anim_startofs), // XXX don't use the function here!
|
||||
0.0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1650,6 +1650,10 @@ static bool version_set_seq_single_frame_content(Sequence *seq, void * /*user_da
|
|||
|
||||
static bool version_seq_convert_frames_to_seconds(Sequence *seq, void *user_data)
|
||||
{
|
||||
if (seq->seq1 != nullptr || seq->seq2 != nullptr) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const Scene *scene = static_cast<Scene *>(user_data);
|
||||
double scene_playback_rate = (float)scene->r.frs_sec / scene->r.frs_sec_base;
|
||||
|
||||
|
@ -4027,16 +4031,7 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Versioning code until next subversion bump goes here.
|
||||
*
|
||||
* \note Be sure to check when bumping the version:
|
||||
* - "versioning_userdef.c", #blo_do_versions_userdef
|
||||
* - "versioning_userdef.c", #do_versions_theme
|
||||
*
|
||||
* \note Keep this message at the bottom of the function.
|
||||
*/
|
||||
{
|
||||
if (!MAIN_VERSION_ATLEAST(bmain, 306, 1)) {
|
||||
/* Z bias for retopology overlay. */
|
||||
if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "retopology_offset")) {
|
||||
LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
|
||||
|
@ -4067,6 +4062,18 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain)
|
|||
SEQ_for_each_callback(&ed->seqbase, version_seq_convert_frames_to_seconds, scene);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Versioning code until next subversion bump goes here.
|
||||
*
|
||||
* \note Be sure to check when bumping the version:
|
||||
* - "versioning_userdef.c", #blo_do_versions_userdef
|
||||
* - "versioning_userdef.c", #do_versions_theme
|
||||
*
|
||||
* \note Keep this message at the bottom of the function.
|
||||
*/
|
||||
{
|
||||
/* Keep this block, even when empty. */
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,7 +49,8 @@ static bool sequencer_refresh_sound_length_recursive(Main *bmain, Scene *scene,
|
|||
int old = seq->len;
|
||||
float fac;
|
||||
|
||||
seq->len = MAX2(1, round((info.length - seq->sound->offset_time) * FPS));
|
||||
SEQ_time_strip_length_set(
|
||||
scene, seq, MAX2(1, round((info.length - seq->sound->offset_time) * FPS)));
|
||||
fac = (float)seq->len / (float)old;
|
||||
old = seq->startofs;
|
||||
seq->startofs *= fac;
|
||||
|
@ -97,7 +98,8 @@ void SEQ_sound_update_bounds(Scene *scene, Sequence *seq)
|
|||
if (seq->type == SEQ_TYPE_SCENE) {
|
||||
if (seq->scene && seq->scene_sound) {
|
||||
/* We have to take into account start frame of the sequence's scene! */
|
||||
int startofs = seq->startofs + seq->anim_startofs + seq->scene->r.sfra;
|
||||
int startofs = SEQ_time_seconds_to_frames(scene, seq->startofs + seq->anim_startofs) +
|
||||
seq->scene->r.sfra;
|
||||
|
||||
BKE_sound_move_scene_sound(scene,
|
||||
seq->scene_sound,
|
||||
|
|
|
@ -101,17 +101,6 @@ float seq_give_frame_index(const Scene *scene, Sequence *seq, float timeline_fra
|
|||
|
||||
return frame_index;
|
||||
}
|
||||
|
||||
static int metaseq_start(Sequence *metaseq)
|
||||
{
|
||||
return metaseq->start + metaseq->startofs;
|
||||
}
|
||||
|
||||
static int metaseq_end(Sequence *metaseq)
|
||||
{
|
||||
return metaseq->start + metaseq->len - metaseq->endofs;
|
||||
}
|
||||
|
||||
static void seq_update_sound_bounds_recursive_impl(const Scene *scene,
|
||||
Sequence *metaseq,
|
||||
int start,
|
||||
|
@ -124,18 +113,23 @@ static void seq_update_sound_bounds_recursive_impl(const Scene *scene,
|
|||
for (seq = metaseq->seqbase.first; seq; seq = seq->next) {
|
||||
if (seq->type == SEQ_TYPE_META) {
|
||||
seq_update_sound_bounds_recursive_impl(
|
||||
scene, seq, max_ii(start, metaseq_start(seq)), min_ii(end, metaseq_end(seq)));
|
||||
scene,
|
||||
seq,
|
||||
max_ii(start, SEQ_time_left_handle_frame_get(scene, seq)),
|
||||
min_ii(end, SEQ_time_right_handle_frame_get(scene, seq)));
|
||||
}
|
||||
else if (ELEM(seq->type, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SCENE)) {
|
||||
if (seq->scene_sound) {
|
||||
int startofs = seq->startofs;
|
||||
int endofs = seq->endofs;
|
||||
if (seq->startofs + seq->start < start) {
|
||||
startofs = start - seq->start;
|
||||
int start_frame = SEQ_time_start_frame_get(scene, seq);
|
||||
int length = SEQ_time_strip_length_get(scene, seq);
|
||||
int startofs = SEQ_time_seconds_to_frames(scene, seq->startofs);
|
||||
int endofs = SEQ_time_seconds_to_frames(scene, seq->endofs);
|
||||
if (startofs + start_frame < start) {
|
||||
startofs = start - start_frame;
|
||||
}
|
||||
|
||||
if (seq->start + seq->len - seq->endofs > end) {
|
||||
endofs = seq->start + seq->len - end;
|
||||
if (start_frame + length - endofs > end) {
|
||||
endofs = start_frame + length - end;
|
||||
}
|
||||
|
||||
double offset_time = 0.0f;
|
||||
|
@ -145,8 +139,8 @@ static void seq_update_sound_bounds_recursive_impl(const Scene *scene,
|
|||
|
||||
BKE_sound_move_scene_sound(scene,
|
||||
seq->scene_sound,
|
||||
seq->start + startofs,
|
||||
seq->start + seq->len - endofs,
|
||||
start_frame + startofs,
|
||||
start_frame + length - endofs,
|
||||
startofs + seq->anim_startofs,
|
||||
offset_time);
|
||||
}
|
||||
|
@ -156,8 +150,10 @@ static void seq_update_sound_bounds_recursive_impl(const Scene *scene,
|
|||
|
||||
void seq_update_sound_bounds_recursive(const Scene *scene, Sequence *metaseq)
|
||||
{
|
||||
seq_update_sound_bounds_recursive_impl(
|
||||
scene, metaseq, metaseq_start(metaseq), metaseq_end(metaseq));
|
||||
seq_update_sound_bounds_recursive_impl(scene,
|
||||
metaseq,
|
||||
SEQ_time_left_handle_frame_get(scene, metaseq),
|
||||
SEQ_time_right_handle_frame_get(scene, metaseq));
|
||||
}
|
||||
|
||||
/* Update meta strip content start and end, update sound playback range. */
|
||||
|
|
Loading…
Reference in New Issue