[Bf-blender-cvs] [9b1f109] terrible_consequencer: Hack to make undo/redo faster in sequencer when using strips with waveform display.

Antony Riakiotakis noreply at git.blender.org
Fri Sep 19 19:51:14 CEST 2014


Commit: 9b1f109c8964613d937e7490c6da3d3c8766cd4b
Author: Antony Riakiotakis
Date:   Fri Sep 19 19:51:01 2014 +0200
Branches: terrible_consequencer
https://developer.blender.org/rB9b1f109c8964613d937e7490c6da3d3c8766cd4b

Hack to make undo/redo faster in sequencer when using strips with
waveform display.

Basically, we store the waveform. This is not really recommended but
until we have nice threaded creation for the strips that doesn't block
the interface it's a nice solution for gooseverry.

May be wise to limit the undo memory for people who use that because
basically each operation will store a copy of the waveform in the file.

===================================================================

M	source/blender/blenkernel/BKE_sound.h
M	source/blender/blenkernel/intern/packedFile.c
M	source/blender/blenkernel/intern/sound.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/blenloader/intern/writefile.c
M	source/blender/editors/sound/sound_ops.c
M	source/blender/makesdna/DNA_sound_types.h
M	source/blender/makesrna/intern/rna_sequencer.c
M	source/blender/makesrna/intern/rna_sound.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_sound.h b/source/blender/blenkernel/BKE_sound.h
index 50ca5fc..7ea234d 100644
--- a/source/blender/blenkernel/BKE_sound.h
+++ b/source/blender/blenkernel/BKE_sound.h
@@ -75,7 +75,7 @@ void sound_cache_notifying(struct Main *main, struct bSound *sound);
 
 void sound_delete_cache(struct bSound *sound);
 
-void sound_load(struct Main *main, struct bSound *sound);
+void sound_load(struct Main *main, struct bSound *sound, bool waveform);
 
 void BKE_sound_free(struct bSound *sound);
 
diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c
index d186b42..290ed71 100644
--- a/source/blender/blenkernel/intern/packedFile.c
+++ b/source/blender/blenkernel/intern/packedFile.c
@@ -520,7 +520,7 @@ int unpackSound(Main *bmain, ReportList *reports, bSound *sound, int how)
 			freePackedFile(sound->packedfile);
 			sound->packedfile = NULL;
 
-			sound_load(bmain, sound);
+			sound_load(bmain, sound, true);
 
 			ret_value = RET_OK;
 		}
diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c
index da6ead0..25c92e5 100644
--- a/source/blender/blenkernel/intern/sound.c
+++ b/source/blender/blenkernel/intern/sound.c
@@ -86,7 +86,7 @@ bSound *sound_new_file(struct Main *bmain, const char *filename)
 	BLI_strncpy(sound->name, filename, FILE_MAX);
 	/* sound->type = SOUND_TYPE_FILE; */ /* XXX unused currently */
 
-	sound_load(bmain, sound);
+	sound_load(bmain, sound, true);
 
 	if (!sound->playback_handle) {
 		BKE_libblock_free(bmain, sound);
@@ -236,7 +236,7 @@ bSound *sound_new_buffer(struct Main *bmain, bSound *source)
 	sound->child_sound = source;
 	sound->type = SOUND_TYPE_BUFFER;
 
-	sound_load(bmain, sound);
+	sound_load(bmain, sound, true);
 
 	if (!sound->playback_handle)
 	{
@@ -262,7 +262,7 @@ bSound *sound_new_limiter(struct Main *bmain, bSound *source, float start, float
 	sound->end = end;
 	sound->type = SOUND_TYPE_LIMITER;
 
-	sound_load(bmain, sound);
+	sound_load(bmain, sound, true);
 
 	if (!sound->playback_handle)
 	{
@@ -312,7 +312,7 @@ void sound_delete_cache(bSound *sound)
 	}
 }
 
-void sound_load(struct Main *bmain, bSound *sound)
+void sound_load(struct Main *bmain, bSound *sound, bool waveform)
 {
 	if (sound) {
 		if (sound->cache) {
@@ -326,7 +326,8 @@ void sound_load(struct Main *bmain, bSound *sound)
 			sound->playback_handle = NULL;
 		}
 
-		sound_free_waveform(sound);
+		if (waveform)
+			sound_free_waveform(sound);
 
 /* XXX unused currently */
 #if 0
@@ -809,7 +810,7 @@ void sound_exit(void) {}
 void sound_exit_once(void) {}
 void sound_cache(struct bSound *UNUSED(sound)) {}
 void sound_delete_cache(struct bSound *UNUSED(sound)) {}
-void sound_load(struct Main *UNUSED(bmain), struct bSound *UNUSED(sound)) {}
+void sound_load(struct Main *UNUSED(bmain), struct bSound *UNUSED(sound), true) {}
 void sound_create_scene(struct Scene *UNUSED(scene)) {}
 void sound_destroy_scene(struct Scene *UNUSED(scene)) {}
 void sound_mute_scene(struct Scene *UNUSED(scene), int UNUSED(muted)) {}
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index a786d9f..780857d 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -6702,8 +6702,18 @@ static void direct_link_sound(FileData *fd, bSound *sound)
 {
 	sound->handle = NULL;
 	sound->playback_handle = NULL;
-	sound->waveform = NULL;
 
+	if (!(sound->flags & SOUND_FLAGS_WAVEFORM_SAVED)) {
+		sound->waveform = NULL;
+	}
+	else {
+		if (sound->waveform) {
+			SoundWaveform *waveform = sound->waveform = newdataadr(fd, sound->waveform);
+			waveform->data = newdataadr(fd, waveform->data);
+			/* waveform has been read, restore the flag */
+			sound->flags &= ~SOUND_FLAGS_WAVEFORM_SAVED;
+		}	
+	}
 	// versioning stuff, if there was a cache, then we enable caching:
 	if (sound->cache) {
 		sound->flags |= SOUND_FLAGS_CACHING;
@@ -6723,7 +6733,7 @@ static void lib_link_sound(FileData *fd, Main *main)
 			sound->id.flag -= LIB_NEED_LINK;
 			sound->ipo = newlibadr_us(fd, sound->id.lib, sound->ipo); // XXX deprecated - old animation system
 			
-			sound_load(main, sound);
+			sound_load(main, sound, false);
 		}
 	}
 }
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 59f1265..fa327b0 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -156,6 +156,7 @@
 #include "BKE_node.h"
 #include "BKE_report.h"
 #include "BKE_sequencer.h"
+#include "BKE_sound.h"
 #include "BKE_subsurf.h"
 #include "BKE_modifier.h"
 #include "BKE_fcurve.h"
@@ -2907,9 +2908,18 @@ static void write_sounds(WriteData *wd, ListBase *idbase)
 	while (sound) {
 		if (sound->id.us>0 || wd->current) {
 			/* write LibData */
+			if (sound->waveform)
+				sound->flags |= SOUND_FLAGS_WAVEFORM_SAVED;
+
 			writestruct(wd, ID_SO, "bSound", 1, sound);
 			if (sound->id.properties) IDP_WriteProperty(sound->id.properties, wd);
 
+			if (sound->waveform) {
+				SoundWaveform *waveform = sound->waveform;
+				writedata(wd, DATA, sizeof(SoundWaveform), waveform);
+				writedata(wd, DATA, sizeof(float) * 3 * waveform->length, waveform->data);
+			}
+			
 			if (sound->packedfile) {
 				pf = sound->packedfile;
 				writestruct(wd, DATA, "PackedFile", 1, pf);
diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c
index 619fbd7..fcb2a52 100644
--- a/source/blender/editors/sound/sound_ops.c
+++ b/source/blender/editors/sound/sound_ops.c
@@ -123,7 +123,7 @@ static int sound_open_exec(bContext *C, wmOperator *op)
 
 	if (RNA_boolean_get(op->ptr, "mono")) {
 		sound->flags |= SOUND_FLAGS_MONO;
-		sound_load(bmain, sound);
+		sound_load(bmain, sound, true);
 	}
 
 	if (RNA_boolean_get(op->ptr, "cache")) {
@@ -691,7 +691,7 @@ static int sound_pack_exec(bContext *C, wmOperator *op)
 		return OPERATOR_CANCELLED;
 
 	sound->packedfile = newPackedFile(op->reports, sound->name, ID_BLEND_PATH(bmain, &sound->id));
-	sound_load(bmain, sound);
+	sound_load(bmain, sound, true);
 
 	return OPERATOR_FINISHED;
 }
diff --git a/source/blender/makesdna/DNA_sound_types.h b/source/blender/makesdna/DNA_sound_types.h
index d7a5135..ff4c69e 100644
--- a/source/blender/makesdna/DNA_sound_types.h
+++ b/source/blender/makesdna/DNA_sound_types.h
@@ -119,6 +119,7 @@ enum {
 	SOUND_FLAGS_3D          = (1 << 3),  /* deprecated! used for sound actuator loading */
 	SOUND_FLAGS_CACHING     = (1 << 4),
 	SOUND_FLAGS_MONO        = (1 << 5),
+	SOUND_FLAGS_WAVEFORM_SAVED = (1 << 6)
 };
 
 #if (DNA_DEPRECATED_GCC_POISON == 1)
diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c
index 00f0a6f..24e3887 100644
--- a/source/blender/makesrna/intern/rna_sequencer.c
+++ b/source/blender/makesrna/intern/rna_sequencer.c
@@ -585,7 +585,7 @@ static void rna_Sequence_filepath_set(PointerRNA *ptr, const char *value)
 		PointerRNA id_ptr;
 		RNA_id_pointer_create((ID *)seq->sound, &id_ptr);
 		RNA_string_set(&id_ptr, "filepath", value);
-		sound_load(G.main, seq->sound);
+		sound_load(G.main, seq->sound, true);
 		sound_update_scene_sound(seq->scene_sound, seq->sound);
 	}
 
diff --git a/source/blender/makesrna/intern/rna_sound.c b/source/blender/makesrna/intern/rna_sound.c
index 206a72a..8b2aaa2 100644
--- a/source/blender/makesrna/intern/rna_sound.c
+++ b/source/blender/makesrna/intern/rna_sound.c
@@ -41,7 +41,7 @@
 
 static void rna_Sound_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
 {
-	sound_load(bmain, (bSound *)ptr->data);
+	sound_load(bmain, (bSound *)ptr->data, true);
 }
 
 static int rna_Sound_caching_get(PointerRNA *ptr)




More information about the Bf-blender-cvs mailing list