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

Unified · Split

3 files
  1. ChangeLog +11 −1
  2. src/src_linear.c +11 −0
  3. src/src_zoh.c +9 −0
ChangeLog+11−1
@@ -1,3 +1,13 @@
1+2005-08-11 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
2+
3+ * tests/termination_test.c
4+ Rename term_test() to init_term_test() and add extra test functionality
5+ to sanity test the first sample output after reset.
6+
7+ * src/src_zoh.c src/src_linear.c
8+ Fix bug found by new test. Thanks Stas Sergeev for bringint this to my
9+ attention.
10+
111 2005-08-02 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
212
313 * doc/Makefile.am
@@ -53,7 +63,7 @@ · 49 unmodified lines
5363 * configure.ac Win32/Makefile.mingw.in
5464 Add preliminary support for compiling on Win32 using MinGW.
5565
56− * configure.ac
66+ * configure.ac
5767 Bump version to 0.1.2.
5868 Add --enable-gcc-werror configure option.
5969
src/src_linear.c+11−0
@@ -43,6 +43,7 @@ static void linear_reset (SRC_PRIVATE *psrc) ; · 42 unmodified lines
4343 typedef struct
4444 { int linear_magic_marker ;
4545 int channels ;
46+ int reset ;
4647 long in_count, in_used ;
4748 long out_count, out_gen ;
4849 float last_value [1] ;
@@ -62,6 +63,13 @@ linear_process (SRC_PRIVATE *psrc, SRC_DATA *data) · 13 unmodified lines
6263
6364 linear = (LINEAR_DATA*) psrc->private_data ;
6465
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+
6573 linear->in_count = data->input_frames * linear->channels ;
6674 linear->out_count = data->output_frames * linear->channels ;
6775 linear->in_used = linear->out_gen = 0 ;
@@ -201,6 +209,9 @@ linear_reset (SRC_PRIVATE *psrc) · 133 unmodified lines
201209 if (linear == NULL)
202210 return ;
203211
212+ linear->channels = psrc->channels ;
213+ linear->reset = 1 ;
214+
204215 memset (linear->last_value, 0, sizeof (linear->last_value [0]) * linear->channels) ;
205216 } /* linear_reset */
206217 /*
src/src_zoh.c+9−0
@@ -41,6 +41,7 @@ static void zoh_reset (SRC_PRIVATE *psrc) ; · 40 unmodified lines
4141 typedef struct
4242 { int zoh_magic_marker ;
4343 int channels ;
44+ int reset ;
4445 long in_count, in_used ;
4546 long out_count, out_gen ;
4647 float last_value [1] ;
@@ -60,6 +61,13 @@ zoh_process (SRC_PRIVATE *psrc, SRC_DATA *data) · 13 unmodified lines
6061
6162 zoh = (ZOH_DATA*) psrc->private_data ;
6263
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+
6371 zoh->in_count = data->input_frames * zoh->channels ;
6472 zoh->out_count = data->output_frames * zoh->channels ;
6573 zoh->in_used = zoh->out_gen = 0 ;
@@ -194,6 +202,7 @@ zoh_reset (SRC_PRIVATE *psrc) · 128 unmodified lines
194202 return ;
195203
196204 zoh->channels = psrc->channels ;
205+ zoh->reset = 1 ;
197206 memset (zoh->last_value, 0, sizeof (zoh->last_value [0]) * zoh->channels) ;
198207
199208 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