diff options
author | Jens Arnold <amiconn@rockbox.org> | 2008-11-12 18:16:27 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2008-11-12 18:16:27 +0000 |
commit | 60e16e8e7a3060790df3eeacbcdae14f240f689e (patch) | |
tree | 815778e6402e1a49e263e54bb1f4fc16e1f0ab3c | |
parent | c8d0a6522ed8af11e4de0d9278ba170d546067d6 (diff) | |
download | rockbox-60e16e8e7a3060790df3eeacbcdae14f240f689e.tar.gz rockbox-60e16e8e7a3060790df3eeacbcdae14f240f689e.zip |
Tiny speedup by simplifying the filter wrap check.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19101 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/codecs/demac/libdemac/filter.c | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/apps/codecs/demac/libdemac/filter.c b/apps/codecs/demac/libdemac/filter.c index 55378e62c8..a73215f6d0 100644 --- a/apps/codecs/demac/libdemac/filter.c +++ b/apps/codecs/demac/libdemac/filter.c | |||
@@ -45,7 +45,7 @@ struct filter_t { | |||
45 | int16_t* coeffs; /* ORDER entries */ | 45 | int16_t* coeffs; /* ORDER entries */ |
46 | 46 | ||
47 | /* We store all the filter delays in a single buffer */ | 47 | /* We store all the filter delays in a single buffer */ |
48 | int16_t* historybuffer; /* ORDER*2 + HISTORY_SIZE entries */ | 48 | int16_t* history_end; |
49 | 49 | ||
50 | int16_t* delay; | 50 | int16_t* delay; |
51 | int16_t* adaptcoeffs; | 51 | int16_t* adaptcoeffs; |
@@ -143,11 +143,11 @@ static void ICODE_ATTR_DEMAC do_apply_filter_3980(struct filter_t* f, | |||
143 | f->adaptcoeffs++; | 143 | f->adaptcoeffs++; |
144 | 144 | ||
145 | /* Have we filled the history buffer? */ | 145 | /* Have we filled the history buffer? */ |
146 | if (f->delay == f->historybuffer + HISTORY_SIZE + (ORDER*2)) { | 146 | if (f->delay == f->history_end) { |
147 | memmove(f->historybuffer, f->delay - (ORDER*2), | 147 | memmove(f->coeffs + ORDER, f->delay - (ORDER*2), |
148 | (ORDER*2) * sizeof(int16_t)); | 148 | (ORDER*2) * sizeof(int16_t)); |
149 | f->delay = f->historybuffer + ORDER*2; | 149 | f->adaptcoeffs = f->coeffs + ORDER*2; |
150 | f->adaptcoeffs = f->historybuffer + ORDER; | 150 | f->delay = f->coeffs + ORDER*3; |
151 | } | 151 | } |
152 | } | 152 | } |
153 | } | 153 | } |
@@ -188,11 +188,11 @@ static void ICODE_ATTR_DEMAC do_apply_filter_3970(struct filter_t* f, | |||
188 | f->adaptcoeffs++; | 188 | f->adaptcoeffs++; |
189 | 189 | ||
190 | /* Have we filled the history buffer? */ | 190 | /* Have we filled the history buffer? */ |
191 | if (f->delay == f->historybuffer + HISTORY_SIZE + (ORDER*2)) { | 191 | if (f->delay == f->history_end) { |
192 | memmove(f->historybuffer, f->delay - (ORDER*2), | 192 | memmove(f->coeffs + ORDER, f->delay - (ORDER*2), |
193 | (ORDER*2) * sizeof(int16_t)); | 193 | (ORDER*2) * sizeof(int16_t)); |
194 | f->delay = f->historybuffer + ORDER*2; | 194 | f->adaptcoeffs = f->coeffs + ORDER*2; |
195 | f->adaptcoeffs = f->historybuffer + ORDER; | 195 | f->delay = f->coeffs + ORDER*3; |
196 | } | 196 | } |
197 | } | 197 | } |
198 | } | 198 | } |
@@ -203,15 +203,14 @@ static struct filter_t filter1 IBSS_ATTR; | |||
203 | static void do_init_filter(struct filter_t* f, int16_t* buf) | 203 | static void do_init_filter(struct filter_t* f, int16_t* buf) |
204 | { | 204 | { |
205 | f->coeffs = buf; | 205 | f->coeffs = buf; |
206 | f->historybuffer = buf + ORDER; | 206 | f->history_end = buf + ORDER*3 + HISTORY_SIZE; |
207 | 207 | ||
208 | /* Zero the output history buffer */ | 208 | /* Init pointers */ |
209 | memset(f->historybuffer, 0 , (ORDER*2) * sizeof(int16_t)); | 209 | f->adaptcoeffs = f->coeffs + ORDER*2; |
210 | f->delay = f->historybuffer + ORDER*2; | 210 | f->delay = f->coeffs + ORDER*3; |
211 | f->adaptcoeffs = f->historybuffer + ORDER; | ||
212 | 211 | ||
213 | /* Zero the co-efficients */ | 212 | /* Zero coefficients and history buffer */ |
214 | memset(f->coeffs, 0, ORDER * sizeof(int16_t)); | 213 | memset(f->coeffs, 0, ORDER*3 * sizeof(int16_t)); |
215 | 214 | ||
216 | /* Zero the running average */ | 215 | /* Zero the running average */ |
217 | f->avg = 0; | 216 | f->avg = 0; |