comparison uptools/libcoding/gsm7_unpack.c @ 330:d29b45c4c8db

uptools/libcoding: 7-bit decoding implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 03 Feb 2018 22:21:15 +0000
parents
children
comparison
equal deleted inserted replaced
329:18c692984549 330:d29b45c4c8db
1 /*
2 * This library module implements unpacking of GSM 7-bit data
3 * from packed octets.
4 */
5
6 #include <sys/types.h>
7
8 static u_char shift[8] = {0, 7, 6, 5, 4, 3, 2, 1};
9
10 gsm7_unpack(inbuf, outbuf, nseptets)
11 u_char *inbuf, *outbuf;
12 unsigned nseptets;
13 {
14 u_char *inp = inbuf, *outp = outbuf;
15 unsigned n;
16
17 for (n = 0; n < nseptets; n++) {
18 *outp++ = (((inp[1] << 8) | inp[0]) >> shift[n&7]) & 0x7F;
19 if (n & 7)
20 inp++;
21 }
22 }