shithub: libsamplerate

Download patch

ref: f59ea54307f17b0a9b7706409170cec4712ce530
parent: 44797743ae7d84f8571ffbe447c3027fa707b978
author: Erik de Castro Lopo <erikd@mega-nerd.com>
date: Thu May 24 19:34:08 EDT 2007

src/*.c : Use fmod_one where appropriate.

--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,12 @@
     * src/src_sinc.c
     Change macros into inline functions for better error checking.
 
+    * src/common.h
+    Add static inline function fmod_one.
+
+    * src/*.c
+    Use fmod_one where appropriate.
+
 2007-05-12  Erik de Castro Lopo  <erikd AT mega-nerd DOT com>
 
     * tests.Makefile.am
--- a/src/samplerate.c
+++ b/src/samplerate.c
@@ -29,8 +29,8 @@
 #include	"config.h"
 
 #include	"samplerate.h"
-#include	"common.h"
 #include	"float_cast.h"
+#include	"common.h"
 
 static int psrc_set_converter (SRC_PRIVATE	*psrc, int converter_type) ;
 
--- a/src/src_linear.c
+++ b/src/src_linear.c
@@ -1,5 +1,5 @@
 /*
-** Copyright (C) 2002-2006 Erik de Castro Lopo <erikd@mega-nerd.com>
+** Copyright (C) 2002-2007 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
@@ -96,9 +96,9 @@
 		input_index += 1.0 / src_ratio ;
 		} ;
 
-	rem = fmod (input_index, 1.0) ;
+	rem = fmod_one (input_index) ;
 	linear->in_used += linear->channels * lrint (input_index - rem) ;
-	input_index = fmod (input_index, 1.0) ;
+	input_index = rem ;
 
 	/* Main processing loop. */
 	while (linear->out_gen < linear->out_count && linear->in_used + linear->channels * input_index <= linear->in_count)
@@ -119,7 +119,7 @@
 
 		/* Figure out the next index. */
 		input_index += 1.0 / src_ratio ;
-		rem = fmod (input_index, 1.0) ;
+		rem = fmod_one (input_index) ;
 
 		linear->in_used += linear->channels * lrint (input_index - rem) ;
 		input_index = rem ;
--- a/src/src_sinc.c
+++ b/src/src_sinc.c
@@ -122,6 +122,7 @@
 {	return fp_fraction_part (x) * INV_FP_ONE ;
 } /* fp_to_double */
 
+
 /*----------------------------------------------------------------------------------------
 */
 
@@ -220,7 +221,7 @@
 	*/
 
 	temp_filter.b_len = 1000 + 2 * lrint (0.5 + temp_filter.coeff_len / (temp_filter.index_inc * 1.0) * SRC_MAX_RATIO) ;
-	temp_filter.b_len = MIN (temp_filter.b_len, 2048) ;
+	temp_filter.b_len = MIN (temp_filter.b_len, 4096) ;
 	temp_filter.b_len *= temp_filter.channels ;
 
 	if ((filter = calloc (1, sizeof (SINC_FILTER) + sizeof (filter->buffer [0]) * (temp_filter.b_len + temp_filter.channels))) == NULL)
@@ -299,7 +300,7 @@
 	input_index = psrc->last_position ;
 	float_increment = filter->index_inc ;
 
-	rem = fmod (input_index, 1.0) ;
+	rem = fmod_one (input_index) ;
 	filter->b_current = (filter->b_current + filter->channels * lrint (input_index - rem)) % filter->b_len ;
 	input_index = rem ;
 
@@ -344,7 +345,7 @@
 
 		/* Figure out the next index. */
 		input_index += 1.0 / src_ratio ;
-		rem = fmod (input_index, 1.0) ;
+		rem = fmod_one (input_index) ;
 
 		filter->b_current = (filter->b_current + filter->channels * lrint (input_index - rem)) % filter->b_len ;
 		input_index = rem ;
--- a/src/src_zoh.c
+++ b/src/src_zoh.c
@@ -93,7 +93,7 @@
 		input_index += 1.0 / src_ratio ;
 		} ;
 
-	rem = fmod (input_index, 1.0) ;
+	rem = fmod_one (input_index) ;
 	zoh->in_used += zoh->channels * lrint (input_index - rem) ;
 	input_index = rem ;
 
@@ -110,7 +110,7 @@
 
 		/* Figure out the next index. */
 		input_index += 1.0 / src_ratio ;
-		rem = fmod (input_index, 1.0) ;
+		rem = fmod_one (input_index) ;
 
 		zoh->in_used += zoh->channels * lrint (input_index - rem) ;
 		input_index = rem ;