ref: 2df44c2d55f305fd1a66ada8fb1d4abababbaa39
parent: f2b2cbce0296d7a76d6bcc5c621a8f86bdd82f31
author: Erik de Castro Lopo <erikd@mega-nerd.com>
date: Wed Jul 9 18:37:50 EDT 2008
src/src_linear.c : Fix a bug where the the converter was reading beyond the end of the input. Thanks to Paul Kelly for the bug report.
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,14 @@
* tests/callback_test.c
Test with 2 channels for improved generality. Simplify setup.
+ * src/src_linear.c src/src_zoh.c
+ Change local variable names to be the same across these two files for easier
+ comparison.
+
+ * src/src_linear.c
+ Fix a bug where the the converter was reading beyond the end of the input.
+ Thanks to Paul Kelly for the bug report.
+
2008-07-02 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* tests/downsample_test.c
--- a/src/src_linear.c
+++ b/src/src_linear.c
@@ -80,7 +80,7 @@
/* Calculate samples before first sample in input array. */
while (input_index < 1.0 && priv->out_gen < priv->out_count)
{
- if (priv->in_used + priv->channels * input_index > priv->in_count)
+ if (priv->in_used + priv->channels * (1.0 + input_index) >= priv->in_count)
break ;
if (priv->out_count > 0 && fabs (psrc->last_ratio - data->src_ratio) > SRC_MIN_RATIO_DIFF)
@@ -101,7 +101,7 @@
input_index = rem ;
/* Main processing loop. */
- while (priv->out_gen < priv->out_count && priv->in_used + priv->channels * input_index <= priv->in_count)
+ while (priv->out_gen < priv->out_count && priv->in_used + priv->channels * input_index < priv->in_count)
{
if (priv->out_count > 0 && fabs (psrc->last_ratio - data->src_ratio) > SRC_MIN_RATIO_DIFF)
src_ratio = psrc->last_ratio + priv->out_gen * (data->src_ratio - psrc->last_ratio) / priv->out_count ;