shithub: libsamplerate

Download patch

ref: cf3601b8909b861f1b24b786d91dd8a48570823a
parent: ca2e559c6541a0b290771163ce94e34106845512
author: Erik de Castro Lopo <erikd@mega-nerd.com>
date: Wed Aug 22 17:08:25 EDT 2012

src/src_sinc.c : Cleanup calculation of float_increment.

--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2012-08-22  Erik de Castro Lopo  <erikd AT mega-nerd DOT com>
+
+    * src/src_sinc.c
+    Cleanup calculation of float_increment.
+
 2012-03-11  Erik de Castro Lopo  <erikd AT mega-nerd DOT com>
 
     * src/samplerate.c
--- a/src/src_sinc.c
+++ b/src/src_sinc.c
@@ -1,5 +1,5 @@
 /*
-** Copyright (C) 2002-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
+** Copyright (C) 2002-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
 **
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -388,10 +388,7 @@
 		if (filter->out_count > 0 && fabs (psrc->last_ratio - data->src_ratio) > 1e-10)
 			src_ratio = psrc->last_ratio + filter->out_gen * (data->src_ratio - psrc->last_ratio) / filter->out_count ;
 
-		float_increment = filter->index_inc * 1.0 ;
-		if (src_ratio < 1.0)
-			float_increment = filter->index_inc * src_ratio ;
-
+		float_increment = filter->index_inc * (src_ratio < 1.0 ? src_ratio : 1.0) ;
 		increment = double_to_fp (float_increment) ;
 
 		start_filter_index = double_to_fp (input_index * float_increment) ;
@@ -537,10 +534,7 @@
 		if (filter->out_count > 0 && fabs (psrc->last_ratio - data->src_ratio) > 1e-10)
 			src_ratio = psrc->last_ratio + filter->out_gen * (data->src_ratio - psrc->last_ratio) / filter->out_count ;
 
-		float_increment = filter->index_inc * 1.0 ;
-		if (src_ratio < 1.0)
-			float_increment = filter->index_inc * src_ratio ;
-
+		float_increment = filter->index_inc * (src_ratio < 1.0 ? src_ratio : 1.0) ;
 		increment = double_to_fp (float_increment) ;
 
 		start_filter_index = double_to_fp (input_index * float_increment) ;
@@ -691,10 +685,7 @@
 		if (filter->out_count > 0 && fabs (psrc->last_ratio - data->src_ratio) > 1e-10)
 			src_ratio = psrc->last_ratio + filter->out_gen * (data->src_ratio - psrc->last_ratio) / filter->out_count ;
 
-		float_increment = filter->index_inc * 1.0 ;
-		if (src_ratio < 1.0)
-			float_increment = filter->index_inc * src_ratio ;
-
+		float_increment = filter->index_inc * (src_ratio < 1.0 ? src_ratio : 1.0) ;
 		increment = double_to_fp (float_increment) ;
 
 		start_filter_index = double_to_fp (input_index * float_increment) ;
@@ -851,10 +842,7 @@
 		if (filter->out_count > 0 && fabs (psrc->last_ratio - data->src_ratio) > 1e-10)
 			src_ratio = psrc->last_ratio + filter->out_gen * (data->src_ratio - psrc->last_ratio) / filter->out_count ;
 
-		float_increment = filter->index_inc * 1.0 ;
-		if (src_ratio < 1.0)
-			float_increment = filter->index_inc * src_ratio ;
-
+		float_increment = filter->index_inc * (src_ratio < 1.0 ? src_ratio : 1.0) ;
 		increment = double_to_fp (float_increment) ;
 
 		start_filter_index = double_to_fp (input_index * float_increment) ;
@@ -1098,10 +1086,7 @@
 		if (filter->out_count > 0 && fabs (psrc->last_ratio - data->src_ratio) > 1e-10)
 			src_ratio = psrc->last_ratio + filter->out_gen * (data->src_ratio - psrc->last_ratio) / filter->out_count ;
 
-		float_increment = filter->index_inc * 1.0 ;
-		if (src_ratio < 1.0)
-			float_increment = filter->index_inc * src_ratio ;
-
+		float_increment = filter->index_inc * (src_ratio < 1.0 ? src_ratio : 1.0) ;
 		increment = double_to_fp (float_increment) ;
 
 		start_filter_index = double_to_fp (input_index * float_increment) ;