aboutsummaryrefslogtreecommitdiff
path: root/helpers.c
blob: dc7e754ff0a662dc4dd24c9c260ed75b1043aef1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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);
}
}