ref: 5003d89bbaedb986ce0d86cd8be975cea9f9609c
parent: be0cfba3d64b3c73e008495aa8923b63da836f8d
author: Erik de Castro Lopo <erikd@mega-nerd.com>
date: Fri Jun 15 17:55:28 EDT 2007
src/src_sinc.c : Adapt to change of coefficient storage.
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2007-06-15 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/*_coeffs.h
+ Change the way the coefficients are defined for improved safety.
+
+ * src/src_sinc.c
+ Adapt to the above.
+
2007-05-24 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/src_sinc.c
--- a/src/src_sinc.c
+++ b/src/src_sinc.c
@@ -47,6 +47,10 @@
typedef int32_t increment_t ;
typedef float coeff_t ;
+#include "high_qual_coeffs.h"
+#include "mid_qual_coeffs.h"
+#include "fastest_coeffs.h"
+
typedef struct
{ int sinc_magic_marker ;
@@ -55,11 +59,9 @@
long out_count, out_gen ;
int coeff_half_len, index_inc ;
- int has_diffs ;
double src_ratio, input_index ;
- int coeff_len ;
coeff_t const *coeffs ;
int b_current, b_end, b_real_end, b_len ;
@@ -74,22 +76,6 @@
static void sinc_reset (SRC_PRIVATE *psrc) ;
-static coeff_t const high_qual_coeffs [] =
-{
-#include "../Octave/test.h"
-} ; /* high_qual_coeffs */
-
-static coeff_t const mid_qual_coeffs [] =
-{
-#include "mid_qual_coeffs.h"
-} ; /* mid_qual_coeffs */
-
-static coeff_t const fastest_coeffs [] =
-{
-#include "fastest_coeffs.h"
-} ; /* fastest_coeffs */
-
-
static inline increment_t
double_to_fp (double x)
{ if (sizeof (increment_t) == 8)
@@ -184,27 +170,21 @@
switch (src_enum)
{ case SRC_SINC_BEST_QUALITY :
- temp_filter.coeffs = high_qual_coeffs ;
- temp_filter.coeff_half_len = ARRAY_LEN (high_qual_coeffs) - 1 ;
- temp_filter.index_inc = 512 ;
- temp_filter.has_diffs = SRC_FALSE ;
- temp_filter.coeff_len = ARRAY_LEN (high_qual_coeffs) ;
+ temp_filter.coeffs = high_qual_coeffs.coeffs ;
+ temp_filter.coeff_half_len = ARRAY_LEN (high_qual_coeffs.coeffs) - 1 ;
+ temp_filter.index_inc = high_qual_coeffs.increment ;
break ;
case SRC_SINC_MEDIUM_QUALITY :
- temp_filter.coeffs = mid_qual_coeffs ;
- temp_filter.coeff_half_len = ARRAY_LEN (mid_qual_coeffs) - 1 ;
- temp_filter.index_inc = 128 ;
- temp_filter.has_diffs = SRC_FALSE ;
- temp_filter.coeff_len = ARRAY_LEN (mid_qual_coeffs) ;
+ temp_filter.coeffs = mid_qual_coeffs.coeffs ;
+ temp_filter.coeff_half_len = ARRAY_LEN (mid_qual_coeffs.coeffs) - 1 ;
+ temp_filter.index_inc = mid_qual_coeffs.increment ;
break ;
case SRC_SINC_FASTEST :
- temp_filter.coeffs = fastest_coeffs ;
- temp_filter.coeff_half_len = ARRAY_LEN (fastest_coeffs) - 1 ;
- temp_filter.index_inc = 128 ;
- temp_filter.has_diffs = SRC_FALSE ;
- temp_filter.coeff_len = ARRAY_LEN (fastest_coeffs) ;
+ temp_filter.coeffs = fastest_coeffs.coeffs ;
+ temp_filter.coeff_half_len = ARRAY_LEN (fastest_coeffs.coeffs) - 1 ;
+ temp_filter.index_inc = fastest_coeffs.increment ;
break ;
default :
@@ -216,7 +196,7 @@
** a better way. Need to look at prepare_data () at the same time.
*/
- 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 = 1000 + 2 * lrint (0.5 + 2 * temp_filter.coeff_half_len / (temp_filter.index_inc * 1.0) * SRC_MAX_RATIO) ;
temp_filter.b_len = MIN (temp_filter.b_len, 4096) ;
temp_filter.b_len *= temp_filter.channels ;