From 46afbec3743f1d799f185273ff897d1f8e0175dd Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Sun, 4 Nov 2012 02:03:49 -0800 Subject: change how we store the FIR coefficients The coefficient table is now transposed and shows much better its polyphase nature: we now have a FIR per line, each line corresponding to a phase. This doesn't change at all the results produced by the filter, but allows us to make slightly better use of the data cache and improves performance a bit (although not as much as I thought it would). The main benefit is that it is the first step before we can make much larger optimizations (like using NEON). Change-Id: Iebf7695825dcbd41f25861efcaefbaa3365ecb43 --- tools/resampler_tools/fir.cpp | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) (limited to 'tools') diff --git a/tools/resampler_tools/fir.cpp b/tools/resampler_tools/fir.cpp index ea3ef50..cc3d509 100644 --- a/tools/resampler_tools/fir.cpp +++ b/tools/resampler_tools/fir.cpp @@ -195,7 +195,8 @@ int main(int argc, char** argv) // total number of coefficients (one side) - const int N = (1 << nz) * nzc; + const int M = (1 << nz); + const int N = M * nzc; // generate the right half of the filter if (!debug) { @@ -220,22 +221,25 @@ int main(int argc, char** argv) } if (!polyphase) { - for (int i=0 ; i= (1LL<<(nc-1))) yi = (1LL<<(nc-1))-1; - printf("0x%08x, ", int32_t(yi)); - } else { - printf("%.9g%s ", y, debug ? "," : "f,"); + if (!format) { + int64_t yi = floor(y * ((1ULL<<(nc-1))) + 0.5); + if (yi >= (1LL<<(nc-1))) yi = (1LL<<(nc-1))-1; + printf("0x%08x, ", int32_t(yi)); + } else { + printf("%.9g%s ", y, debug ? "," : "f,"); + } } } } else { @@ -266,11 +270,6 @@ int main(int argc, char** argv) } if (!debug) { - if (!format) { - printf("\n 0x%08x ", 0); - } else { - printf("\n %.9g ", 0.0f); - } printf("\n};"); } printf("\n"); -- cgit v1.1