History

Fix a bug in ZOH and LINEAR converters found after new test was added.

Erik de Castro Lopo committed 21 years ago

Commit 3a6cc4f1 parent b2cc20f3 files · +31 −1Browse files

Showing the changes to src (2 of 3 files). Show all

Unified · Split

2 files
  1. src/src_linear.c +11 −0
  2. src/src_zoh.c +9 −0
src/src_linear.c+11−0
@@ -43,6 +43,7 @@ static void linear_reset (SRC_PRIVATE *psrc) ; · 42 unmodified lines
43typedef struct43typedef struct
44{ int linear_magic_marker ;44{ int linear_magic_marker ;
45 int channels ;45 int channels ;
46 int reset ;
46 long in_count, in_used ;47 long in_count, in_used ;
47 long out_count, out_gen ;48 long out_count, out_gen ;
48 float last_value [1] ;49 float last_value [1] ;
@@ -62,6 +63,13 @@ linear_process (SRC_PRIVATE *psrc, SRC_DATA *data) · 13 unmodified lines
62 63
63 linear = (LINEAR_DATA*) psrc->private_data ;64 linear = (LINEAR_DATA*) psrc->private_data ;
64 65
66 if (linear->reset)
67 { /* If we have just been reset, set the last_value data. */
68 for (ch = 0 ; ch < linear->channels ; ch++)
69 linear->last_value [ch] = data->data_in [ch] ;
70 linear->reset = 0 ;
71 } ;
72
65 linear->in_count = data->input_frames * linear->channels ;73 linear->in_count = data->input_frames * linear->channels ;
66 linear->out_count = data->output_frames * linear->channels ;74 linear->out_count = data->output_frames * linear->channels ;
67 linear->in_used = linear->out_gen = 0 ;75 linear->in_used = linear->out_gen = 0 ;
@@ -201,6 +209,9 @@ linear_reset (SRC_PRIVATE *psrc) · 133 unmodified lines
201 if (linear == NULL)209 if (linear == NULL)
202 return ;210 return ;
203 211
212 linear->channels = psrc->channels ;
213 linear->reset = 1 ;
214
204 memset (linear->last_value, 0, sizeof (linear->last_value [0]) * linear->channels) ;215 memset (linear->last_value, 0, sizeof (linear->last_value [0]) * linear->channels) ;
205} /* linear_reset */216} /* linear_reset */
206/*217/*
src/src_zoh.c+9−0
@@ -41,6 +41,7 @@ static void zoh_reset (SRC_PRIVATE *psrc) ; · 40 unmodified lines
41typedef struct41typedef struct
42{ int zoh_magic_marker ;42{ int zoh_magic_marker ;
43 int channels ;43 int channels ;
44 int reset ;
44 long in_count, in_used ;45 long in_count, in_used ;
45 long out_count, out_gen ;46 long out_count, out_gen ;
46 float last_value [1] ;47 float last_value [1] ;
@@ -60,6 +61,13 @@ zoh_process (SRC_PRIVATE *psrc, SRC_DATA *data) · 13 unmodified lines
60 61
61 zoh = (ZOH_DATA*) psrc->private_data ;62 zoh = (ZOH_DATA*) psrc->private_data ;
62 63
64 if (zoh->reset)
65 { /* If we have just been reset, set the last_value data. */
66 for (ch = 0 ; ch < zoh->channels ; ch++)
67 zoh->last_value [ch] = data->data_in [ch] ;
68 zoh->reset = 0 ;
69 } ;
70
63 zoh->in_count = data->input_frames * zoh->channels ;71 zoh->in_count = data->input_frames * zoh->channels ;
64 zoh->out_count = data->output_frames * zoh->channels ;72 zoh->out_count = data->output_frames * zoh->channels ;
65 zoh->in_used = zoh->out_gen = 0 ;73 zoh->in_used = zoh->out_gen = 0 ;
@@ -194,6 +202,7 @@ zoh_reset (SRC_PRIVATE *psrc) · 128 unmodified lines
194 return ;202 return ;
195 203
196 zoh->channels = psrc->channels ;204 zoh->channels = psrc->channels ;
205 zoh->reset = 1 ;
197 memset (zoh->last_value, 0, sizeof (zoh->last_value [0]) * zoh->channels) ;206 memset (zoh->last_value, 0, sizeof (zoh->last_value [0]) * zoh->channels) ;
198 207
199 return ;208 return ;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t