marlin r1359 - trunk/marlin



Author: iain
Date: Wed Feb 18 01:01:59 2009
New Revision: 1359
URL: http://svn.gnome.org/viewvc/marlin?rev=1359&view=rev

Log:
Conflicts:
	marlin/marlin-channel.c

Modified:
   trunk/marlin/marlin-channel.c
   trunk/marlin/marlin-sample-view.c

Modified: trunk/marlin/marlin-channel.c
==============================================================================
--- trunk/marlin/marlin-channel.c	(original)
+++ trunk/marlin/marlin-channel.c	Wed Feb 18 01:01:59 2009
@@ -2319,26 +2319,17 @@
 	return vc->ratio;
 }
 
-gboolean
-marlin_channel_normalize (MarlinChannel     *channel,
-			  MarlinRange       *range,
-			  double             db,
-			  MarlinOperation   *operation,
-			  MarlinUndoContext *ctxt,
-			  GError           **error)
+static double
+lockless_get_max_peak (MarlinChannel   *channel,
+		       MarlinRange     *range,
+		       MarlinOperation *operation)
 {
-	struct _normalize_closure *nc;
-	double max_peak = 0.0;
-	double level = 1.0;
 	guint64 peak_range;
+	double max_peak = 0.0;
 	MarlinBlock *block;
 	MarlinPeak *peak_data;
 	guint64 start, end;
 	guint64 i, o;
-	float *buf;
-	gboolean ret = FALSE;
-
-	WRITE_LOCK (channel->lock);
 
 	block = lockless_get_for_frame (channel->first, range->start);
 	READ_LOCK (block->lock);
@@ -2347,10 +2338,12 @@
 
 	start = range->start / MARLIN_FRAMES_PER_PEAK;
 	end = range->finish / MARLIN_FRAMES_PER_PEAK;
-	peak_range = start - end;
+	peak_range = end - start;
 
-	for (i = 0, o = start; i < peak_range; i++, o++) {
+	for (i = 0, o = (range->start - block->start) / MARLIN_FRAMES_PER_PEAK;
+	     i < peak_range; i++, o++) {
 		guint64 peak_in_channel;
+		short mp;
 		MarlinPeak p;
 
 		peak_in_channel = block->start + (o * MARLIN_FRAMES_PER_PEAK);
@@ -2358,7 +2351,7 @@
 			break;
 		}
 
-		if (peak_in_channel > block->end) {
+		if (o >= block->num_peaks) {
 			/* Next block */
 			READ_UNLOCK (block->lock);
 
@@ -2372,11 +2365,31 @@
 
 		p = peak_data[o];
 
-		max_peak = MAX (max_peak, ((double) p.high / 256.0));
+		mp = MAX (p.high, abs (p.low));
+		max_peak = MAX (max_peak, ((double) mp / 256.0));
 	}
 
 	READ_UNLOCK (block->lock);
 
+	return max_peak;
+}
+
+gboolean
+marlin_channel_normalize (MarlinChannel     *channel,
+			  MarlinRange       *range,
+			  double             db,
+			  MarlinOperation   *operation,
+			  MarlinUndoContext *ctxt,
+			  GError           **error)
+{
+	struct _normalize_closure *nc;
+	double max_peak;
+	double level = 1.0;
+	gboolean ret = FALSE;
+
+	WRITE_LOCK (channel->lock);
+
+	max_peak = lockless_get_max_peak (channel, range, operation);
 	if (db == MARLIN_INFINITE_DB) {
 		level = 0.0;
 	} else {

Modified: trunk/marlin/marlin-sample-view.c
==============================================================================
--- trunk/marlin/marlin-sample-view.c	(original)
+++ trunk/marlin/marlin-sample-view.c	Wed Feb 18 01:01:59 2009
@@ -2524,7 +2524,7 @@
 			marlin_undo_manager_context_end (priv->undo, ctxt);
 			priv->made_selection = TRUE;
 			break;
-			
+
 		case GDK_3BUTTON_PRESS:
 			/* Select all the sample */
 			selection = view->priv->selection;
@@ -2532,9 +2532,9 @@
 			priv->expand = TRUE;
 			ctxt = marlin_undo_manager_context_begin (priv->undo,
 								  _("Select All"));
-			marlin_sample_selection_set (selection, 
+			marlin_sample_selection_set (selection,
 						     priv->cursor->coverage,
-						     0, priv->number_of_frames,
+						     0, priv->number_of_frames - 1,
 						     ctxt);
 			marlin_undo_manager_context_end (priv->undo, ctxt);
 			priv->made_selection = TRUE;
@@ -2543,7 +2543,7 @@
 		default:
 			break;
 		}
-		
+
 		break;
 
 	case 2:



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]