Cleanup/Fix VSE readfile code, fully deprecate SEQ_TYPE_SOUND_HD.
This fixes a few related issues in VSE code: * 'lib_link' code was doing 'read_data' tasks (like cleaning up internal runtime data). * Handling of `SEQ_TYPE_SOUND_HD` deprecated type of strips was extremely confusing (versioning done partly in 'lib_link' code, partly in some 2.50 do_version code). * Still using deprecated `SEQ_TYPE_SOUND_HD` strip type outside of versioning code. * Missing proper usage of deprecated `SEQ_TYPE_SOUND_HD` type inside of versioning code (!). Note that the actual conversion from `SEQ_TYPE_SOUND_HD` to `SEQ_TYPE_SOUND_RAM` is now done in the 'after setup' versioning process, where it is somewhat safer to add IDs. This implies that `SEQ_TYPE_SOUND_HD` must be taken into account throughout the whole regular versioning process (before and after liblink). Conversion logic itself has been moved to the VSE code. Pull Request: https://projects.blender.org/blender/blender/pulls/111135
This commit is contained in:
@@ -629,16 +629,8 @@ static void do_versions_socket_default_value_259(bNodeSocket *sock)
|
||||
}
|
||||
}
|
||||
|
||||
static bool seq_sound_proxy_update_cb(Sequence *seq, void *user_data)
|
||||
static bool seq_sound_proxy_update_cb(Sequence *seq, void * /*user_data*/)
|
||||
{
|
||||
Main *bmain = (Main *)user_data;
|
||||
if (seq->type == SEQ_TYPE_SOUND_HD) {
|
||||
char filepath_abs[FILE_MAX];
|
||||
BLI_path_join(
|
||||
filepath_abs, sizeof(filepath_abs), seq->strip->dirpath, seq->strip->stripdata->filename);
|
||||
BLI_path_abs(filepath_abs, BKE_main_blendfile_path(bmain));
|
||||
seq->sound = BKE_sound_new_file(bmain, filepath_abs);
|
||||
}
|
||||
#define SEQ_USE_PROXY_CUSTOM_DIR (1 << 19)
|
||||
#define SEQ_USE_PROXY_CUSTOM_FILE (1 << 21)
|
||||
/* don't know, if anybody used that this way, but just in case, upgrade to new way... */
|
||||
@@ -688,7 +680,7 @@ void blo_do_versions_250(FileData *fd, Library * /*lib*/, Main *bmain)
|
||||
}
|
||||
|
||||
LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
|
||||
if (scene->ed && scene->ed->seqbasep) {
|
||||
if (scene->ed) {
|
||||
SEQ_for_each_callback(&scene->ed->seqbase, seq_sound_proxy_update_cb, bmain);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -255,7 +255,7 @@ static void seq_convert_transform_crop_lb(const Scene *scene,
|
||||
{
|
||||
|
||||
LISTBASE_FOREACH (Sequence *, seq, lb) {
|
||||
if (seq->type != SEQ_TYPE_SOUND_RAM) {
|
||||
if (!ELEM(seq->type, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SOUND_HD)) {
|
||||
seq_convert_transform_crop(scene, seq, render_size);
|
||||
}
|
||||
if (seq->type == SEQ_TYPE_META) {
|
||||
@@ -341,7 +341,7 @@ static void seq_convert_transform_crop_lb_2(const Scene *scene,
|
||||
{
|
||||
|
||||
LISTBASE_FOREACH (Sequence *, seq, lb) {
|
||||
if (seq->type != SEQ_TYPE_SOUND_RAM) {
|
||||
if (!ELEM(seq->type, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SOUND_HD)) {
|
||||
seq_convert_transform_crop_2(scene, seq, render_size);
|
||||
}
|
||||
if (seq->type == SEQ_TYPE_META) {
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
#include "BKE_node.hh"
|
||||
#include "BKE_node_runtime.hh"
|
||||
|
||||
#include "SEQ_sequencer.h"
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "BLO_readfile.h"
|
||||
@@ -504,6 +506,14 @@ void do_versions_after_setup(Main *new_bmain, BlendFileReadReport *reports)
|
||||
do_versions_ipos_to_animato(new_bmain);
|
||||
}
|
||||
|
||||
if (!blendfile_or_libraries_versions_atleast(new_bmain, 250, 0)) {
|
||||
LISTBASE_FOREACH (Scene *, scene, &new_bmain->scenes) {
|
||||
if (scene->ed) {
|
||||
SEQ_doversion_250_sound_proxy_update(new_bmain, scene->ed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!blendfile_or_libraries_versions_atleast(new_bmain, 302, 1)) {
|
||||
BKE_lib_override_library_main_proxy_convert(new_bmain, reports);
|
||||
/* Currently liboverride code can generate invalid namemap. This is a known issue, requires
|
||||
|
||||
@@ -2968,7 +2968,7 @@ static int sequencer_change_path_exec(bContext *C, wmOperator *op)
|
||||
* Important not to set seq->len = len; allow the function to handle it. */
|
||||
SEQ_add_reload_new_file(bmain, scene, seq, true);
|
||||
}
|
||||
else if (ELEM(seq->type, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SOUND_HD)) {
|
||||
else if (seq->type == SEQ_TYPE_SOUND_RAM) {
|
||||
bSound *sound = seq->sound;
|
||||
if (sound == nullptr) {
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
@@ -685,7 +685,7 @@ typedef enum SequenceType {
|
||||
SEQ_TYPE_SCENE = 2,
|
||||
SEQ_TYPE_MOVIE = 3,
|
||||
SEQ_TYPE_SOUND_RAM = 4,
|
||||
SEQ_TYPE_SOUND_HD = 5,
|
||||
SEQ_TYPE_SOUND_HD = 5, /* DEPRECATED */
|
||||
SEQ_TYPE_MOVIECLIP = 6,
|
||||
SEQ_TYPE_MASK = 7,
|
||||
|
||||
|
||||
@@ -498,7 +498,7 @@ static void rna_Sequence_frame_offset_start_range(
|
||||
PointerRNA *ptr, float *min, float *max, float * /*softmin*/, float * /*softmax*/)
|
||||
{
|
||||
Sequence *seq = (Sequence *)ptr->data;
|
||||
*min = ELEM(seq->type, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SOUND_HD) ? 0 : INT_MIN;
|
||||
*min = (seq->type == SEQ_TYPE_SOUND_RAM) ? 0 : INT_MIN;
|
||||
*max = seq->len - seq->endofs - 1;
|
||||
}
|
||||
|
||||
@@ -506,7 +506,7 @@ static void rna_Sequence_frame_offset_end_range(
|
||||
PointerRNA *ptr, float *min, float *max, float * /*softmin*/, float * /*softmax*/)
|
||||
{
|
||||
Sequence *seq = (Sequence *)ptr->data;
|
||||
*min = ELEM(seq->type, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SOUND_HD) ? 0 : INT_MIN;
|
||||
*min = (seq->type == SEQ_TYPE_SOUND_RAM) ? 0 : INT_MIN;
|
||||
*max = seq->len - seq->startofs - 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -113,6 +113,8 @@ void SEQ_blend_read_lib(struct BlendLibReader *reader,
|
||||
|
||||
void SEQ_blend_read_expand(struct BlendExpander *expander, struct ListBase *seqbase);
|
||||
|
||||
void SEQ_doversion_250_sound_proxy_update(struct Main *bmain, struct Editing *ed);
|
||||
|
||||
/* Depsgraph update function. */
|
||||
|
||||
/**
|
||||
|
||||
@@ -1558,7 +1558,7 @@ void SEQ_modifier_list_copy(Sequence *seqn, Sequence *seq)
|
||||
|
||||
int SEQ_sequence_supports_modifiers(Sequence *seq)
|
||||
{
|
||||
return !ELEM(seq->type, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SOUND_HD);
|
||||
return (seq->type != SEQ_TYPE_SOUND_RAM);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
@@ -18,10 +18,12 @@
|
||||
#include "DNA_sound_types.h"
|
||||
|
||||
#include "BLI_listbase.h"
|
||||
#include "BLI_path_util.h"
|
||||
|
||||
#include "BKE_fcurve.h"
|
||||
#include "BKE_idprop.h"
|
||||
#include "BKE_lib_id.h"
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_sound.h"
|
||||
|
||||
#include "DEG_depsgraph.h"
|
||||
@@ -68,7 +70,7 @@ static Strip *seq_strip_alloc(int type)
|
||||
{
|
||||
Strip *strip = static_cast<Strip *>(MEM_callocN(sizeof(Strip), "strip"));
|
||||
|
||||
if (ELEM(type, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SOUND_HD) == 0) {
|
||||
if (type != SEQ_TYPE_SOUND_RAM) {
|
||||
strip->transform = static_cast<StripTransform *>(
|
||||
MEM_callocN(sizeof(StripTransform), "StripTransform"));
|
||||
strip->transform->scale_x = 1;
|
||||
@@ -745,7 +747,7 @@ static bool seq_write_data_cb(Sequence *seq, void *userdata)
|
||||
MEM_allocN_len(strip->stripdata) / sizeof(StripElem),
|
||||
strip->stripdata);
|
||||
}
|
||||
else if (ELEM(seq->type, SEQ_TYPE_MOVIE, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SOUND_HD)) {
|
||||
else if (ELEM(seq->type, SEQ_TYPE_MOVIE, SEQ_TYPE_SOUND_RAM)) {
|
||||
BLO_write_struct(writer, StripElem, strip->stripdata);
|
||||
}
|
||||
|
||||
@@ -782,6 +784,11 @@ static bool seq_read_data_cb(Sequence *seq, void *user_data)
|
||||
{
|
||||
BlendDataReader *reader = (BlendDataReader *)user_data;
|
||||
|
||||
/* Runtime data cleanup. */
|
||||
seq->scene_sound = nullptr;
|
||||
BLI_listbase_clear(&seq->anims);
|
||||
seq->flag &= ~SEQ_FLAG_SKIP_THUMBNAILS;
|
||||
|
||||
/* Do as early as possible, so that other parts of reading can rely on valid session UUID. */
|
||||
SEQ_relations_session_uuid_generate(seq);
|
||||
|
||||
@@ -813,6 +820,7 @@ static bool seq_read_data_cb(Sequence *seq, void *user_data)
|
||||
if (seq->strip && seq->strip->done == 0) {
|
||||
seq->strip->done = true;
|
||||
|
||||
/* `SEQ_TYPE_SOUND_HD` case needs to be kept here, for backward compatibility. */
|
||||
if (ELEM(seq->type, SEQ_TYPE_IMAGE, SEQ_TYPE_MOVIE, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SOUND_HD)) {
|
||||
BLO_read_data_address(reader, &seq->strip->stripdata);
|
||||
}
|
||||
@@ -865,10 +873,8 @@ static bool seq_read_lib_cb(Sequence *seq, void *user_data)
|
||||
/* XXX: deprecated - old animation system. */
|
||||
BLO_read_id_address(reader, &sce->id, &seq->ipo);
|
||||
}
|
||||
seq->scene_sound = nullptr;
|
||||
if (seq->scene) {
|
||||
BLO_read_id_address(reader, &sce->id, &seq->scene);
|
||||
seq->scene_sound = nullptr;
|
||||
}
|
||||
if (seq->clip) {
|
||||
BLO_read_id_address(reader, &sce->id, &seq->clip);
|
||||
@@ -880,27 +886,15 @@ static bool seq_read_lib_cb(Sequence *seq, void *user_data)
|
||||
BLO_read_id_address(reader, &sce->id, &seq->scene_camera);
|
||||
}
|
||||
if (seq->sound) {
|
||||
seq->scene_sound = nullptr;
|
||||
if (seq->type == SEQ_TYPE_SOUND_HD) {
|
||||
seq->type = SEQ_TYPE_SOUND_RAM;
|
||||
}
|
||||
else {
|
||||
BLO_read_id_address(reader, &sce->id, &seq->sound);
|
||||
}
|
||||
if (seq->sound) {
|
||||
id_us_plus_no_lib((ID *)seq->sound);
|
||||
seq->scene_sound = nullptr;
|
||||
}
|
||||
BLO_read_id_address(reader, &sce->id, &seq->sound);
|
||||
}
|
||||
if (seq->type == SEQ_TYPE_TEXT) {
|
||||
TextVars *t = static_cast<TextVars *>(seq->effectdata);
|
||||
BLO_read_id_address(reader, &sce->id, &t->text_font);
|
||||
}
|
||||
BLI_listbase_clear(&seq->anims);
|
||||
|
||||
SEQ_modifier_blend_read_lib(reader, sce, &seq->modifiers);
|
||||
|
||||
seq->flag &= ~SEQ_FLAG_SKIP_THUMBNAILS;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -944,6 +938,25 @@ void SEQ_blend_read_expand(BlendExpander *expander, ListBase *seqbase)
|
||||
SEQ_for_each_callback(seqbase, seq_blend_read_expand, expander);
|
||||
}
|
||||
|
||||
static bool seq_doversion_250_sound_proxy_update_cb(Sequence *seq, void *user_data)
|
||||
{
|
||||
Main *bmain = static_cast<Main *>(user_data);
|
||||
if (seq->type == SEQ_TYPE_SOUND_HD) {
|
||||
char filepath_abs[FILE_MAX];
|
||||
BLI_path_join(
|
||||
filepath_abs, sizeof(filepath_abs), seq->strip->dirpath, seq->strip->stripdata->filename);
|
||||
BLI_path_abs(filepath_abs, BKE_main_blendfile_path(bmain));
|
||||
seq->sound = BKE_sound_new_file(bmain, filepath_abs);
|
||||
seq->type = SEQ_TYPE_SOUND_RAM;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void SEQ_doversion_250_sound_proxy_update(Main *bmain, Editing *ed)
|
||||
{
|
||||
SEQ_for_each_callback(&ed->seqbase, seq_doversion_250_sound_proxy_update_cb, bmain);
|
||||
}
|
||||
|
||||
/* Depsgraph update functions. */
|
||||
|
||||
static bool seq_disable_sound_strips_cb(Sequence *seq, void *user_data)
|
||||
|
||||
@@ -175,7 +175,7 @@ void SEQ_relations_invalidate_cache_preprocessed(Scene *scene, Sequence *seq)
|
||||
|
||||
void SEQ_relations_invalidate_cache_composite(Scene *scene, Sequence *seq)
|
||||
{
|
||||
if (ELEM(seq->type, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SOUND_HD)) {
|
||||
if (seq->type == SEQ_TYPE_SOUND_RAM) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ void SEQ_relations_invalidate_cache_composite(Scene *scene, Sequence *seq)
|
||||
|
||||
void SEQ_relations_invalidate_dependent(Scene *scene, Sequence *seq)
|
||||
{
|
||||
if (ELEM(seq->type, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SOUND_HD)) {
|
||||
if (seq->type == SEQ_TYPE_SOUND_RAM) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user