Inserts 1 to 8 bits into the output buffer. */
| 55 | |
| 56 | /* Inserts 1 to 8 bits into the output buffer. */ |
| 57 | static void __inline |
| 58 | putbits8(uint8_t *buf, uint32_t val, const uint32_t n, uint32_t *i, uint32_t *l) |
| 59 | { |
| 60 | buf += *i; |
| 61 | if (*l >= n) { |
| 62 | *l = (*l) - n; |
| 63 | val <<= *l; |
| 64 | *buf = *buf | (val & 0xff); |
| 65 | if (*l == 0) { |
| 66 | *l = 8; |
| 67 | (*i)++; |
| 68 | *(++buf) = 0; |
| 69 | } |
| 70 | } else { |
| 71 | (*i)++; |
| 72 | *l = 8 - n + (*l); |
| 73 | val <<= *l; |
| 74 | *buf = *buf | ((val >> 8) & 0xff); |
| 75 | *(++buf) = val & 0xff; |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | /* Inserts 9 to 16 bits into the output buffer. */ |
| 80 | static void __inline |