[Bf-blender-cvs] [649a2bc] master: Politically correct terrible consequencer changes

Antony Riakiotakis noreply at git.blender.org
Mon Nov 24 18:27:25 CET 2014


Commit: 649a2bcc3d51cfc6f9fc237695015c87bcca7deb
Author: Antony Riakiotakis
Date:   Mon Nov 24 18:18:35 2014 +0100
Branches: master
https://developer.blender.org/rB649a2bcc3d51cfc6f9fc237695015c87bcca7deb

Politically correct terrible consequencer changes

This patch includes the work done in the terrible consequencer branch
that hasn't been merged to master minus a few controversial and WIP
stuff, like strip parenting, new sequence data structs and cuddly
widgets.

What is included:

* Strip extensions only when slipping. It can very easily be made an
option but with a few strips with overlapping durations it makes view
too crowded and difficult to make out.
* Threaded waveform loading + code that restores waveforms on undo (not
used though, since sound_load recreates everything. There's a patch for
review D876)
* Toggle to enable backdrop in the strip sequence editor
* Toggle to easily turn on/off waveform display
* Snapping during transform on sequence boundaries. Snapping to start or
end of selection depends on position of mouse when invoking the operator
* Snapping of timeline indicator in sequencer to strip boundaries. To
use just press and hold ctrl while dragging.

Reviewers: campbellbarton

Differential Revision: https://developer.blender.org/D904

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

M	intern/audaspace/intern/AUD_C-API.cpp
M	intern/audaspace/intern/AUD_C-API.h
M	release/scripts/startup/bl_ui/space_sequencer.py
M	source/blender/blenkernel/BKE_sequencer.h
M	source/blender/blenkernel/BKE_sound.h
M	source/blender/blenkernel/intern/sequencer.c
M	source/blender/blenkernel/intern/sound.c
M	source/blender/blenloader/intern/readblenentry.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/blenloader/intern/readfile.h
M	source/blender/blenloader/intern/writefile.c
M	source/blender/editors/animation/anim_ops.c
M	source/blender/editors/space_sequencer/CMakeLists.txt
M	source/blender/editors/space_sequencer/sequencer_draw.c
M	source/blender/editors/space_sequencer/sequencer_edit.c
M	source/blender/editors/space_sequencer/sequencer_intern.h
M	source/blender/editors/space_sequencer/sequencer_ops.c
A	source/blender/editors/space_sequencer/sequencer_preview.c
M	source/blender/editors/space_sequencer/space_sequencer.c
M	source/blender/editors/transform/transform.c
M	source/blender/editors/transform/transform.h
M	source/blender/editors/transform/transform_conversions.c
M	source/blender/editors/transform/transform_snap.c
M	source/blender/makesdna/DNA_sequence_types.h
M	source/blender/makesdna/DNA_sound_types.h
M	source/blender/makesdna/DNA_space_types.h
M	source/blender/makesrna/intern/rna_sound.c
M	source/blender/makesrna/intern/rna_space.c
M	source/blender/windowmanager/WM_api.h

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

diff --git a/intern/audaspace/intern/AUD_C-API.cpp b/intern/audaspace/intern/AUD_C-API.cpp
index d2a9347..45d72cc 100644
--- a/intern/audaspace/intern/AUD_C-API.cpp
+++ b/intern/audaspace/intern/AUD_C-API.cpp
@@ -46,6 +46,7 @@
 #include <cstring>
 #include <cmath>
 #include <sstream>
+#include <iostream>
 
 #include "AUD_NULLDevice.h"
 #include "AUD_I3DDevice.h"
@@ -317,8 +318,9 @@ AUD_SoundInfo AUD_getInfo(AUD_Sound *sound)
 			info.length = reader->getLength() / (float) info.specs.rate;
 		}
 	}
-	catch(AUD_Exception&)
+	catch(AUD_Exception &ae)
 	{
+		std::cout << ae.str << std::endl;
 	}
 
 	return info;
@@ -1084,7 +1086,7 @@ int AUD_doesPlayback()
 	return -1;
 }
 
-int AUD_readSound(AUD_Sound *sound, sample_t *buffer, int length, int samples_per_second)
+int AUD_readSound(AUD_Sound *sound, sample_t *buffer, int length, int samples_per_second, short *interrupt)
 {
 	AUD_DeviceSpecs specs;
 	sample_t *buf;
@@ -1107,6 +1109,9 @@ int AUD_readSound(AUD_Sound *sound, sample_t *buffer, int length, int samples_pe
 	for (int i = 0; i < length; i++) {
 		len = floor(samplejump * (i+1)) - floor(samplejump * i);
 
+		if (*interrupt) {
+			return 0;
+		}
 		aBuffer.assureSize(len * AUD_SAMPLE_SIZE(specs));
 		buf = aBuffer.getBuffer();
 
diff --git a/intern/audaspace/intern/AUD_C-API.h b/intern/audaspace/intern/AUD_C-API.h
index 64a3d06..657d4e6 100644
--- a/intern/audaspace/intern/AUD_C-API.h
+++ b/intern/audaspace/intern/AUD_C-API.h
@@ -646,7 +646,7 @@ extern int AUD_doesPlayback(void);
  * \param samples_per_second How many samples to read per second of the sound.
  * \return How many samples really have been read. Always <= length.
  */
-extern int AUD_readSound(AUD_Sound *sound, sample_t *buffer, int length, int samples_per_second);
+extern int AUD_readSound(AUD_Sound *sound, sample_t *buffer, int length, int samples_per_second, short *interrupt);
 
 /**
  * Copies a sound.
diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py
index feb90da..650c631 100644
--- a/release/scripts/startup/bl_ui/space_sequencer.py
+++ b/release/scripts/startup/bl_ui/space_sequencer.py
@@ -71,6 +71,7 @@ class SEQUENCER_HT_header(Header):
         row.prop(scene, "lock_frame_selection_to_range", text="", toggle=True)
 
         layout.prop(st, "view_type", expand=True, text="")
+        layout.prop(st, "waveform_draw_type", text="")
 
         if st.view_type in {'PREVIEW', 'SEQUENCER_PREVIEW'}:
             layout.prop(st, "display_mode", expand=True, text="")
@@ -82,6 +83,7 @@ class SEQUENCER_HT_header(Header):
 
             layout.separator()
             layout.operator("sequencer.refresh_all")
+            layout.prop(st, "show_backdrop")
         else:
             if st.view_type == 'SEQUENCER_PREVIEW':
                 layout.separator()
@@ -716,6 +718,7 @@ class SEQUENCER_PT_sound(SequencerButtonsPanel, Panel):
     def draw(self, context):
         layout = self.layout
 
+        st = context.space_data
         strip = act_strip(context)
         sound = strip.sound
 
@@ -734,7 +737,9 @@ class SEQUENCER_PT_sound(SequencerButtonsPanel, Panel):
 
             row.prop(sound, "use_memory_cache")
 
-        layout.prop(strip, "show_waveform")
+        if st.waveform_draw_type == 'DEFAULT_WAVEFORMS':
+            layout.prop(strip, "show_waveform")
+
         layout.prop(strip, "volume")
         layout.prop(strip, "pitch")
         layout.prop(strip, "pan")
diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h
index e460d0d..97cd5bd 100644
--- a/source/blender/blenkernel/BKE_sequencer.h
+++ b/source/blender/blenkernel/BKE_sequencer.h
@@ -377,6 +377,17 @@ struct Sequence *BKE_sequence_alloc(ListBase *lb, int cfra, int machine);
 void BKE_sequence_alpha_mode_from_extension(struct Sequence *seq);
 void BKE_sequence_init_colorspace(struct Sequence *seq);
 
+/* RNA enums, just to be more readable */
+enum {
+	SEQ_SIDE_NONE = 0,
+	SEQ_SIDE_LEFT,
+	SEQ_SIDE_RIGHT,
+	SEQ_SIDE_BOTH
+};
+int BKE_sequencer_find_next_prev_edit(
+        struct Scene *scene, int cfra, const short side,
+        const bool do_skip_mute, const bool do_center, const bool do_unselected);
+
 struct Sequence *BKE_sequencer_add_image_strip(struct bContext *C, ListBase *seqbasep, struct SeqLoadInfo *seq_load);
 struct Sequence *BKE_sequencer_add_sound_strip(struct bContext *C, ListBase *seqbasep, struct SeqLoadInfo *seq_load);
 struct Sequence *BKE_sequencer_add_movie_strip(struct bContext *C, ListBase *seqbasep, struct SeqLoadInfo *seq_load);
diff --git a/source/blender/blenkernel/BKE_sound.h b/source/blender/blenkernel/BKE_sound.h
index 50ca5fc..f318c74 100644
--- a/source/blender/blenkernel/BKE_sound.h
+++ b/source/blender/blenkernel/BKE_sound.h
@@ -71,8 +71,6 @@ void sound_delete(struct Main *bmain, struct bSound *sound);
 
 void sound_cache(struct bSound *sound);
 
-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);
@@ -132,7 +130,7 @@ int sound_scene_playing(struct Scene *scene);
 
 void sound_free_waveform(struct bSound *sound);
 
-void sound_read_waveform(struct bSound *sound);
+void sound_read_waveform(struct bSound *sound, bool locked, short *stop);
 
 void sound_update_scene(struct Main *bmain, struct Scene *scene);
 
diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c
index 9a144ec..20698cc 100644
--- a/source/blender/blenkernel/intern/sequencer.c
+++ b/source/blender/blenkernel/intern/sequencer.c
@@ -892,7 +892,6 @@ void BKE_sequencer_sort(Scene *scene)
 	Editing *ed = BKE_sequencer_editing_get(scene, false);
 	Sequence *seq, *seqt;
 
-	
 	if (ed == NULL)
 		return;
 
@@ -4675,3 +4674,70 @@ bool BKE_sequence_is_valid_check(Sequence *seq)
 	return true;
 }
 
+int BKE_sequencer_find_next_prev_edit(
+        Scene *scene, int cfra, const short side,
+        const bool do_skip_mute, const bool do_center, const bool do_unselected)
+{
+	Editing *ed = BKE_sequencer_editing_get(scene, false);
+	Sequence *seq;
+
+	int dist, best_dist, best_frame = cfra;
+	int seq_frames[2], seq_frames_tot;
+
+	/* in case where both is passed, frame just finds the nearest end while frame_left the nearest start */
+
+	best_dist = MAXFRAME * 2;
+
+	if (ed == NULL) return cfra;
+
+	for (seq = ed->seqbasep->first; seq; seq = seq->next) {
+		int i;
+
+		if (do_skip_mute && (seq->flag & SEQ_MUTE)) {
+			continue;
+		}
+
+		if (do_unselected && (seq->flag & SELECT))
+			continue;
+
+		if (do_center) {
+			seq_frames[0] = (seq->startdisp + seq->enddisp) / 2;
+			seq_frames_tot = 1;
+		}
+		else {
+			seq_frames[0] = seq->startdisp;
+			seq_frames[1] = seq->enddisp;
+
+			seq_frames_tot = 2;
+		}
+
+		for (i = 0; i < seq_frames_tot; i++) {
+			const int seq_frame = seq_frames[i];
+
+			dist = MAXFRAME * 2;
+
+			switch (side) {
+				case SEQ_SIDE_LEFT:
+					if (seq_frame < cfra) {
+						dist = cfra - seq_frame;
+					}
+					break;
+				case SEQ_SIDE_RIGHT:
+					if (seq_frame > cfra) {
+						dist = seq_frame - cfra;
+					}
+					break;
+				case SEQ_SIDE_BOTH:
+					dist = abs(seq_frame - cfra);
+					break;
+			}
+
+			if (dist < best_dist) {
+				best_frame = seq_frame;
+				best_dist = dist;
+			}
+		}
+	}
+
+	return best_frame;
+}
diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c
index da6ead0..3c7b01f 100644
--- a/source/blender/blenkernel/intern/sound.c
+++ b/source/blender/blenkernel/intern/sound.c
@@ -36,6 +36,7 @@
 
 #include "BLI_blenlib.h"
 #include "BLI_math.h"
+#include "BLI_threads.h"
 
 #include "DNA_anim_types.h"
 #include "DNA_object_types.h"
@@ -116,6 +117,12 @@ void BKE_sound_free(bSound *sound)
 	}
 
 	sound_free_waveform(sound);
+	
+	if (sound->mutex) {
+		BLI_mutex_free(sound->mutex);
+		sound->mutex = NULL;
+	}
+	
 #endif  /* WITH_AUDASPACE */
 }
 
@@ -296,12 +303,6 @@ void sound_cache(bSound *sound)
 		sound->playback_handle = sound->handle;
 }
 
-void sound_cache_notifying(struct Main *main, bSound *sound)
-{
-	sound_cache(sound);
-	sound_update_sequencer(main, sound);
-}
-
 void sound_delete_cache(bSound *sound)
 {
 	sound->flags &= ~SOUND_FLAGS_CACHING;
@@ -680,22 +681,40 @@ void sound_free_waveform(bSound *sound)
 	sound->waveform = NULL;
 }
 
-void sound_read_waveform(bSound *sound)
+void sound_read_waveform(bSound *sound, bool locked, short *stop)
 {
 	AUD_SoundInfo info;
-
+	SoundWaveform *waveform = NULL;
+	
 	info = AUD_getInfo(sound->playback_handle);
-
+	
 	if (info.length > 0) {
-		SoundWaveform *waveform = MEM_mallocN(sizeof(SoundWaveform), "SoundWaveform");
 		int length = info.length * SOUND_WAVE_SAMPLES_PER_SECOND;
-
+		
+		waveform = MEM_mallocN(sizeof(SoundWaveform), "SoundWaveform");
 		waveform->data = MEM_mallocN(length * sizeof(float) * 3, "SoundWaveform.samples");
-		waveform->length = AUD_readSound(sound->playback_handle, waveform->data, length, SOUND_WAVE_SAMPLES_PER_SECOND);
-
+		waveform->length = AUD_readSound(sound->playback_handle, waveform->data, length, SOUND_WAVE_SAMPLES_PER_SECOND, stop);
+		
+		if (*stop) {
+			MEM_freeN(waveform->data);
+			MEM_freeN(waveform);
+			if (locked)
+				BLI_mutex_lock(sound->mutex);
+			sound->flags &= ~SOUND_FLAGS_WAVEFORM_LOADING;
+			if (locked)
+				BLI_mutex_unlock(sound->mutex);
+			return;
+		}
+		
 		sound_free_waveform(sound);
-		sound->waveform = waveform;
 	}
+	
+	if (locked)
+		BLI_mutex_lock(sound->mutex);
+	sound->waveform = waveform;
+	sound->flags &= ~SOUND_FLAGS_WAVEFORM_LOADING;
+	if (locked)
+		BLI_mutex_unlock(sound->mutex);
 }
 
 void sound_update_scene(Main *bmain, struct Scene *scene)
@@ -830,7 +849,7 @@ void sound_stop_scene(struct Scene *UNUSED(scene)) {}
 void sound_seek_scene(struct Main *UNUSED(bmain), struct Scene *UNUSED(scene)) {}
 float sound_sync_scene(struct Scene *UNUSED(scene)) { return NAN_FLT; }
 int sound_scene_playing(struct Scene *UNUSED(scene)) { return -1; }
-void sound_read_waveform(struct bSound *UNUSED(sound)) {}
+void sound_read_waveform(struct bSound *sound, bool locked, short *stop) { UNUSED_VARS(sound, locked, stop); }
 void sound_init_main(struct Main

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list