2
* Copyright 1996 by Jutta Degener and Carsten Bormann, Technische
3
* Universitaet Berlin. See the accompanying file "COPYRIGHT" for
4
* details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
9
/* Generate code to pack a bit array from a name:#bits description */
16
/* This module goes back to one Jeff Chilton used for his implementation
17
* of the #49 WAV GSM format. (In his original patch 8, it replaced
20
* In Microsoft's WAV #49 version of the GSM format, two 32 1/2
21
* byte GSM frames are packed together to make one WAV frame, and
22
* the GSM parameters are packed into bytes right-to-left rather
25
* That is, where toast's GSM format writes
27
* aaaaaabb bbbbcccc cdddddee ...
28
* ___1____ ___2____ ___3____
30
* for parameters a (6 bits), b (6 bits), c (5 bits), d (5 bits), e ..
33
* bbaaaaaa ccccbbbb eedddddc ...
34
* ___1____ ___2____ ___3____
36
* (This format looks a lot prettier if one pictures octets coming
37
* in through a fifo queue from the left, rather than waiting in the
38
* right-hand remainder of a C array.)
41
#define WORD_BITS 16 /* sizeof(uword) * CHAR_BIT on the
42
* target architecture---if this isn't 16,
43
* you're in trouble with this library anyway.
46
#define CHAR_BITS 8 /* CHAR_BIT on the target architecture---
47
* if this isn't 8, you're in *deep* trouble.
50
void write_code P2((s_spex, n_spex), struct spex * s_spex, int n_spex)
52
struct spex * sp = s_spex;
55
printf("uword sr = 0;\n");
57
for (; n_spex > 0; n_spex--, sp++) {
60
* new var value unused
63
* [____________xxxxxx**********]
67
printf("sr = sr >> %d | %s << %d;\n",
70
WORD_BITS - sp->varsize);
74
while (n_in >= CHAR_BIT) {
75
printf("*c++ = sr >> %d;\n",
81
while (n_in >= CHAR_BIT) {
82
printf("*c++ = sr >> %d;\n", WORD_BITS - n_in);
87
fprintf(stderr, "warning: %d bits left over\n", n_in);