From 60e16e8e7a3060790df3eeacbcdae14f240f689e Mon Sep 17 00:00:00 2001 From: Jens Arnold Date: Wed, 12 Nov 2008 18:16:27 +0000 Subject: Tiny speedup by simplifying the filter wrap check. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19101 a1c6a512-1295-4272-9138-f99709370657 --- apps/codecs/demac/libdemac/filter.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to 'apps') 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 { int16_t* coeffs; /* ORDER entries */ /* We store all the filter delays in a single buffer */ - int16_t* historybuffer; /* ORDER*2 + HISTORY_SIZE entries */ + int16_t* history_end; int16_t* delay; int16_t* adaptcoeffs; @@ -143,11 +143,11 @@ static void ICODE_ATTR_DEMAC do_apply_filter_3980(struct filter_t* f, f->adaptcoeffs++; /* Have we filled the history buffer? */ - if (f->delay == f->historybuffer + HISTORY_SIZE + (ORDER*2)) { - memmove(f->historybuffer, f->delay - (ORDER*2), + if (f->delay == f->history_end) { + memmove(f->coeffs + ORDER, f->delay - (ORDER*2), (ORDER*2) * sizeof(int16_t)); - f->delay = f->historybuffer + ORDER*2; - f->adaptcoeffs = f->historybuffer + ORDER; + f->adaptcoeffs = f->coeffs + ORDER*2; + f->delay = f->coeffs + ORDER*3; } } } @@ -188,11 +188,11 @@ static void ICODE_ATTR_DEMAC do_apply_filter_3970(struct filter_t* f, f->adaptcoeffs++; /* Have we filled the history buffer? */ - if (f->delay == f->historybuffer + HISTORY_SIZE + (ORDER*2)) { - memmove(f->historybuffer, f->delay - (ORDER*2), + if (f->delay == f->history_end) { + memmove(f->coeffs + ORDER, f->delay - (ORDER*2), (ORDER*2) * sizeof(int16_t)); - f->delay = f->historybuffer + ORDER*2; - f->adaptcoeffs = f->historybuffer + ORDER; + f->adaptcoeffs = f->coeffs + ORDER*2; + f->delay = f->coeffs + ORDER*3; } } } @@ -203,15 +203,14 @@ static struct filter_t filter1 IBSS_ATTR; static void do_init_filter(struct filter_t* f, int16_t* buf) { f->coeffs = buf; - f->historybuffer = buf + ORDER; + f->history_end = buf + ORDER*3 + HISTORY_SIZE; - /* Zero the output history buffer */ - memset(f->historybuffer, 0 , (ORDER*2) * sizeof(int16_t)); - f->delay = f->historybuffer + ORDER*2; - f->adaptcoeffs = f->historybuffer + ORDER; + /* Init pointers */ + f->adaptcoeffs = f->coeffs + ORDER*2; + f->delay = f->coeffs + ORDER*3; - /* Zero the co-efficients */ - memset(f->coeffs, 0, ORDER * sizeof(int16_t)); + /* Zero coefficients and history buffer */ + memset(f->coeffs, 0, ORDER*3 * sizeof(int16_t)); /* Zero the running average */ f->avg = 0; -- cgit v1.2.3