summaryrefslogtreecommitdiffstats
path: root/tools/resampler_tools
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2012-11-04 02:03:49 -0800
committerMathias Agopian <mathias@google.com>2012-11-05 01:03:43 -0800
commite8299af5665bf9c396466c33b9b16a84fe78c7f6 (patch)
treef3356a4917a4ec9827d70bc9acf80feac7c1360c /tools/resampler_tools
parent50ebdf2086b645b9b703a6d489238767a9afb34f (diff)
downloadframeworks_av-e8299af5665bf9c396466c33b9b16a84fe78c7f6.zip
frameworks_av-e8299af5665bf9c396466c33b9b16a84fe78c7f6.tar.gz
frameworks_av-e8299af5665bf9c396466c33b9b16a84fe78c7f6.tar.bz2
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
Diffstat (limited to 'tools/resampler_tools')
-rw-r--r--tools/resampler_tools/fir.cpp39
1 files changed, 19 insertions, 20 deletions
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<N ; i++) {
- double x = (2.0 * M_PI * i * Fcr) / (1 << nz);
- double y = kaiser(i+N, 2*N, beta) * sinc(x) * 2.0 * Fcr;
- y *= atten;
+ for (int i=0 ; i<=M ; i++) { // an extra set of coefs for interpolation
+ for (int j=0 ; j<nzc ; j++) {
+ int ix = j*M + i;
+ double x = (2.0 * M_PI * ix * Fcr) / (1 << nz);
+ double y = kaiser(ix+N, 2*N, beta) * sinc(x) * 2.0 * Fcr;
+ y *= atten;
- if (!debug) {
- if ((i % (1<<nz)) == 0)
- printf("\n ");
- }
+ if (!debug) {
+ if (j == 0)
+ printf("\n ");
+ }
- 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,");
+ 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");