# HG changeset patch # User vitor # Date 1211620761 0 # Node ID 521e1b55fc126145795d22b1d2b1dede3aaed94f # Parent 3feec67125d8a772208cb17d4be7a8229a5f26f7 Simplify rms() diff -r 3feec67125d8 -r 521e1b55fc12 ra144.c --- a/ra144.c Sat May 24 09:17:30 2008 +0000 +++ b/ra144.c Sat May 24 09:19:21 2008 +0000 @@ -181,30 +181,24 @@ static unsigned int rms(const int *data, int f) { - const int *c; int x; - unsigned int res; - int b; + unsigned int res = 0x10000; + int b = 0; - c = data; - b = 0; - res = 0x10000; for (x=0; x<10; x++) { - res = (((0x1000000 - (*c) * (*c)) >> 12) * res) >> 12; + res = (((0x1000000 - (*data) * (*data)) >> 12) * res) >> 12; if (res == 0) return 0; - if (res <= 0x3fff) { - while (res <= 0x3fff) { - b++; - res <<= 2; - } - } else { if (res > 0x10000) return 0; /* We're screwed, might as well go out with a bang. :P */ + + while (res <= 0x3fff) { + b++; + res <<= 2; } - c++; + data++; } if (res > 0)