diff options
author | Max Kellermann <max@duempel.org> | 2012-03-21 08:44:43 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2012-03-21 08:44:43 +0100 |
commit | c1d0a8b5ce93c4b70b00b14f2015fb6a57681dbe (patch) | |
tree | acae564b851d4c799dd3bd635e25a18531770b94 /src/dsd2pcm/dsd2pcm.c | |
parent | 08ce24ec3fb094f653b3f3421388edec02f1dced (diff) | |
download | mpd-c1d0a8b5ce93c4b70b00b14f2015fb6a57681dbe.tar.gz mpd-c1d0a8b5ce93c4b70b00b14f2015fb6a57681dbe.tar.xz mpd-c1d0a8b5ce93c4b70b00b14f2015fb6a57681dbe.zip |
dsd2pcm: move the bit reversing code to a generic library
Instead of doing run-time initialisation, use a constant lookup table.
Diffstat (limited to 'src/dsd2pcm/dsd2pcm.c')
-rw-r--r-- | src/dsd2pcm/dsd2pcm.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/dsd2pcm/dsd2pcm.c b/src/dsd2pcm/dsd2pcm.c index 315820f60..4c7640853 100644 --- a/src/dsd2pcm/dsd2pcm.c +++ b/src/dsd2pcm/dsd2pcm.c @@ -1,3 +1,5 @@ +#include "util/bit_reverse.h" + #include <stdlib.h> #include <string.h> @@ -84,7 +86,6 @@ static const double htaps[HTAPS] = { }; static float ctables[CTABLES][256]; -static unsigned char bitreverse[256]; static int precalculated = 0; static void precalc(void) @@ -92,11 +93,6 @@ static void precalc(void) int t, e, m, k; double acc; if (precalculated) return; - for (t=0, e=0; t<256; ++t) { - bitreverse[t] = e; - for (m=128; m && !((e^=m)&m); m>>=1) - ; - } for (t=0; t<CTABLES; ++t) { k = HTAPS - t*8; if (k>8) k=8; @@ -170,10 +166,10 @@ extern void dsd2pcm_translate( lsbf = lsbf ? 1 : 0; while (samples-- > 0) { bite1 = *src & 0xFFu; - if (lsbf) bite1 = bitreverse[bite1]; + if (lsbf) bite1 = bit_reverse(bite1); ptr->fifo[ffp] = bite1; src += src_stride; p = ptr->fifo + ((ffp-CTABLES) & FIFOMASK); - *p = bitreverse[*p & 0xFF]; + *p = bit_reverse(*p); acc = 0; for (i=0; i<CTABLES; ++i) { bite1 = ptr->fifo[(ffp -i) & FIFOMASK] & 0xFF; |