From 694e29dfd072e829d147c44d86ce4ce283cf47a1 Mon Sep 17 00:00:00 2001 From: Richard Antalik Date: Tue, 9 May 2023 21:15:19 +0200 Subject: [PATCH 1/3] Fix #107289: Sound strips are invisible and overlap In some cases strips may end up with speed factor of 0 which causes offsets and position to be invalid. The exact cause is unknown, but most likely caused by `do_versions_sequencer_init_retiming_tool_data()`. This could possibly happen if 3.6 file is saved with 3.5 version and then opened again with 3.6 version. To fix strips, sound length is reloaded, offsets stripped and speed factor is set to 1. Previous versioning code is fixed, so speed factor is never set to 0. --- .../blenloader/intern/versioning_300.cc | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/source/blender/blenloader/intern/versioning_300.cc b/source/blender/blenloader/intern/versioning_300.cc index c846f2f871a..41f347c3da0 100644 --- a/source/blender/blenloader/intern/versioning_300.cc +++ b/source/blender/blenloader/intern/versioning_300.cc @@ -38,6 +38,7 @@ #include "DNA_modifier_types.h" #include "DNA_movieclip_types.h" #include "DNA_screen_types.h" +#include "DNA_sound_types.h" #include "DNA_space_types.h" #include "DNA_text_types.h" #include "DNA_tracking_types.h" @@ -67,6 +68,7 @@ #include "BKE_modifier.h" #include "BKE_node.h" #include "BKE_screen.h" +#include "BKE_sound.h" #include "BKE_workspace.h" #include "RNA_access.h" @@ -1373,6 +1375,35 @@ void do_versions_after_linking_300(FileData * /*fd*/, Main *bmain) */ { /* Keep this block, even when empty. */ + + /* Fix sound strips with speed factor set to 0. Cause is unknown, see #107289. */ + LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) { + Editing *ed = SEQ_editing_get(scene); + if (ed == nullptr) { + continue; + } + + LISTBASE_FOREACH (Sequence *, seq, &ed->seqbase) { + if (seq->type != SEQ_TYPE_SOUND_RAM && seq->speed_factor != 0.0f) { + continue; + } + + bSound *sound = seq->sound; + SoundInfo info; + bool sound_loaded = BKE_sound_info_get(bmain, sound, &info); + + if (!sound_loaded) { + continue; + } + if (info.specs.channels == SOUND_CHANNELS_INVALID) { + continue; + } + + seq->len = MAX2(1, round((info.length - sound->offset_time) * FPS)); + seq->speed_factor = 1.0f; + seq->startofs = 0.0f; + } + } } } @@ -4311,7 +4342,6 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain) /* Rename Grease Pencil weight draw brush. */ do_versions_rename_id(bmain, ID_BR, "Draw Weight", "Weight Draw"); } - /** * Versioning code until next subversion bump goes here. * -- 2.30.2 From 393817421d2e5aaccbc4e4da6752cd024964750f Mon Sep 17 00:00:00 2001 From: Richard Antalik Date: Tue, 9 May 2023 21:43:01 +0200 Subject: [PATCH 2/3] I have localized the issue with greater certainty, so now this fix should be applicable --- .../blenloader/intern/versioning_300.cc | 51 ++++++++----------- 1 file changed, 21 insertions(+), 30 deletions(-) diff --git a/source/blender/blenloader/intern/versioning_300.cc b/source/blender/blenloader/intern/versioning_300.cc index 41f347c3da0..c203ba48b2e 100644 --- a/source/blender/blenloader/intern/versioning_300.cc +++ b/source/blender/blenloader/intern/versioning_300.cc @@ -705,7 +705,7 @@ static bool do_versions_sequencer_init_retiming_tool_data(Sequence *seq, void *u SeqRetimingHandle *handle = &seq->retiming_handles[seq->retiming_handle_num - 1]; handle->strip_frame_index = round_fl_to_int(content_length / seq->speed_factor); - seq->speed_factor = 0.0f; + seq->speed_factor = 1.0f; return true; } @@ -1375,35 +1375,6 @@ void do_versions_after_linking_300(FileData * /*fd*/, Main *bmain) */ { /* Keep this block, even when empty. */ - - /* Fix sound strips with speed factor set to 0. Cause is unknown, see #107289. */ - LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) { - Editing *ed = SEQ_editing_get(scene); - if (ed == nullptr) { - continue; - } - - LISTBASE_FOREACH (Sequence *, seq, &ed->seqbase) { - if (seq->type != SEQ_TYPE_SOUND_RAM && seq->speed_factor != 0.0f) { - continue; - } - - bSound *sound = seq->sound; - SoundInfo info; - bool sound_loaded = BKE_sound_info_get(bmain, sound, &info); - - if (!sound_loaded) { - continue; - } - if (info.specs.channels == SOUND_CHANNELS_INVALID) { - continue; - } - - seq->len = MAX2(1, round((info.length - sound->offset_time) * FPS)); - seq->speed_factor = 1.0f; - seq->startofs = 0.0f; - } - } } } @@ -1816,6 +1787,18 @@ static bool version_set_seq_single_frame_content(Sequence *seq, void * /*user_da return true; } +static bool version_seq_fix_broken_sound_strips(Sequence *seq, void * /*user_data*/) +{ + if (seq->type != SEQ_TYPE_SOUND_RAM || seq->speed_factor != 0.0f) { + return true; + } + + seq->speed_factor = 1.0f; + SEQ_retiming_data_clear(seq); + seq->startofs = 0.0f; + return true; +} + /* Those `version_liboverride_rnacollections_*` functions mimic the old, pre-3.0 code to find * anchor and source items in the given list of modifiers, constraints etc., using only the * `subitem_local` data of the override property operation. @@ -4353,5 +4336,13 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain) */ { /* Keep this block, even when empty. */ + + /* Fix sound strips with speed factor set to 0. See #107289. */ + LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) { + Editing *ed = SEQ_editing_get(scene); + if (ed != nullptr) { + SEQ_for_each_callback(&ed->seqbase, version_seq_fix_broken_sound_strips, nullptr); + } + } } } -- 2.30.2 From 6a282bbd73010fd0a9dd8cc9376fd21384aaca4d Mon Sep 17 00:00:00 2001 From: Richard Antalik Date: Tue, 9 May 2023 22:00:15 +0200 Subject: [PATCH 3/3] Failed to ammend changes --- source/blender/blenloader/intern/versioning_300.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/source/blender/blenloader/intern/versioning_300.cc b/source/blender/blenloader/intern/versioning_300.cc index c203ba48b2e..1537548b5d5 100644 --- a/source/blender/blenloader/intern/versioning_300.cc +++ b/source/blender/blenloader/intern/versioning_300.cc @@ -38,7 +38,6 @@ #include "DNA_modifier_types.h" #include "DNA_movieclip_types.h" #include "DNA_screen_types.h" -#include "DNA_sound_types.h" #include "DNA_space_types.h" #include "DNA_text_types.h" #include "DNA_tracking_types.h" @@ -68,7 +67,6 @@ #include "BKE_modifier.h" #include "BKE_node.h" #include "BKE_screen.h" -#include "BKE_sound.h" #include "BKE_workspace.h" #include "RNA_access.h" @@ -4325,6 +4323,7 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain) /* Rename Grease Pencil weight draw brush. */ do_versions_rename_id(bmain, ID_BR, "Draw Weight", "Weight Draw"); } + /** * Versioning code until next subversion bump goes here. * -- 2.30.2