shithub: libsamplerate

Download patch

ref: c13383a36ee666803c3759e96f68fc885cba3728
parent: 3300aaffb85b15d7d54a742216d468de1aee08e2
parent: 46a0e2673f497009f0e05cdb4778a5bf7dd5a28b
author: Erik de Castro Lopo <[email protected]>
date: Tue Jun 12 13:24:02 EDT 2007

src_sinc.c : Make it safe for 64 bit increment_t.

--- a/src/src_sinc.c
+++ b/src/src_sinc.c
@@ -103,20 +103,15 @@
 } /* int_to_fp */
 
 static inline int
-fp_fraction_part (increment_t x)
-{	return ((x) & ((((increment_t) 1) << SHIFT_BITS) - 1)) ;
-} /* fp_fraction_part */
-
-static inline int
-fp_integer_part (increment_t x)
-{	return ((x) & (((increment_t) -1) << SHIFT_BITS)) ;
-} /* fp_integer_part */
-
-static inline int
 fp_to_int (increment_t x)
 {	return (((x) >> SHIFT_BITS)) ;
 } /* fp_to_int */
 
+static inline increment_t
+fp_fraction_part (increment_t x)
+{	return ((x) & ((((increment_t) 1) << SHIFT_BITS) - 1)) ;
+} /* fp_fraction_part */
+
 static inline double
 fp_to_double (increment_t x)
 {	return fp_fraction_part (x) * INV_FP_ONE ;
@@ -163,7 +158,8 @@
 int
 sinc_set_converter (SRC_PRIVATE *psrc, int src_enum)
 {	SINC_FILTER *filter, temp_filter ;
-	int count, bits ;
+	increment_t count ;
+	int bits ;
 
 	/* Quick sanity check. */
 	if (SHIFT_BITS >= sizeof (increment_t) * 8 - 1)
@@ -235,8 +231,8 @@
 	sinc_reset (psrc) ;
 
 	count = filter->coeff_half_len ;
-	for (bits = 0 ; (1 << bits) < count ; bits++)
-		count |= (1 << bits) ;
+	for (bits = 0 ; (MAKE_INCREMENT_T (1) << bits) < count ; bits++)
+		count |= (MAKE_INCREMENT_T (1) << bits) ;
 
 	if (bits + SHIFT_BITS - 1 >= (int) (sizeof (increment_t) * 8))
 		return SRC_ERR_FILTER_LEN ;