aboutsummaryrefslogtreecommitdiff
path: root/helpers.c
diff options
context:
space:
mode:
authordaniel aschauer <aschix@users.sourceforge.net>2009-01-09 17:23:55 +0000
committerdaniel aschauer <aschix@users.sourceforge.net>2009-01-09 17:23:55 +0000
commit420ada2dde4af8d71bc1d9c6988311961cf47f1b (patch)
tree874d3bda95a9dbc113a1bd24dfdf1d57ba8dcb6a /helpers.c
svn path=/trunk/externals/algocomp/; revision=10494svn2git-root
Diffstat (limited to 'helpers.c')
-rwxr-xr-xhelpers.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/helpers.c b/helpers.c
new file mode 100755
index 0000000..dc7e754
--- /dev/null
+++ b/helpers.c
@@ -0,0 +1,42 @@
+void fast_d2bl(int x, short *c, short length) {
+ int i;
+ for (i=0;i<length;i++)
+ *(c++) = (x >> i) & 0x1;
+}
+
+void fast_d2b(unsigned short x, short *c) {
+ int i;
+ for (i=0;i<8;i++)
+ *(c++) = (x >> i) & 0x1;
+}
+
+
+void fast_b2d(unsigned long int *n, short *c) {
+int i = 32;
+*n = 0;
+while(i--) {
+*n <<=1;
+*n+= *(c+i);
+}
+}
+
+void fast_b2short8(unsigned short *n, short *c) {
+int i = 8;
+*n = 0;
+while(i--) {
+*n <<=1;
+*n+= *(c+i);
+}
+}
+
+void fast_b2short(unsigned int *n, short *c,short length) {
+int i;
+if ((length <= 16) && (length > 0))
+i = length;
+else i = 8;
+*n = 0;
+while(i--) {
+*n <<=1;
+*n+= *(c+i);
+}
+}