Mercurial > libavcodec.hg
changeset 7201:4d441356fa23 libavcodec
Create a function for float dot product instead of duplicating all over the file
author | vitor |
---|---|
date | Sat, 05 Jul 2008 18:42:08 +0000 |
parents | 64f7b6e3998b |
children | 2a4ac127112c |
files | ra288.c |
diffstat | 1 files changed, 14 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/ra288.c Sat Jul 05 10:16:54 2008 +0000 +++ b/ra288.c Sat Jul 05 18:42:08 2008 +0000 @@ -37,6 +37,16 @@ float lhist[10]; } Real288_internal; +static inline float scalar_product_float(float * v1, float * v2, int size) +{ + float res = 0.; + + while (size--) + res += *v1++ * *v2++; + + return res; +} + /* Decode and produce output */ static void decode(Real288_internal *glob, float gain, int cb_coef) { @@ -48,19 +58,11 @@ glob->sb[x+5] = glob->sb[x]; for (x=4; x >= 0; x--) { - float *p1 = glob->sb+x; - float *p2 = glob->pr1; - sum = 0; - for (y=0; y < 36; y++) - sum -= (*(++p1))*(*(p2++)); - - glob->sb[x] = sum; + glob->sb[x] = -scalar_product_float(glob->sb + x + 1, glob->pr1, 36); } /* convert log and do rms */ - sum = 32; - for (x=0; x < 10; x++) - sum -= glob->pr2[x] * glob->lhist[x]; + sum = 32. - scalar_product_float(glob->pr2, glob->lhist, 10); if (sum < 0) sum = 0; @@ -148,17 +150,9 @@ /* product sum (lsf) */ static void prodsum(float *tgt, float *src, int len, int n) { - unsigned int x; - double sum; + for (; n >= 0; n--) + tgt[n] = scalar_product_float(src, src - n, len); - while (n >= 0) { - float *p2 = src; - float *p1 = p2 - n; - sum = 0; - for (x=0; x < len; x++) - sum += (*p1++) * (*p2++); - tgt[n--] = sum; - } } static void co(int n, int i, int j, float *in, float *out, float *st1,