Inserts 9 to 16 bits into the output buffer. */
| 78 | |
| 79 | /* Inserts 9 to 16 bits into the output buffer. */ |
| 80 | static void __inline |
| 81 | putbits16(uint8_t *buf, uint32_t val, const uint32_t n, uint32_t *i, uint32_t *l) |
| 82 | { |
| 83 | buf += *i; |
| 84 | if (*l >= n - 8) { |
| 85 | (*i)++; |
| 86 | *l = 8 - n + (*l); |
| 87 | val <<= *l; |
| 88 | *buf = *buf | ((val >> 8) & 0xff); |
| 89 | *(++buf) = val & 0xff; |
| 90 | if (*l == 0) { |
| 91 | *l = 8; |
| 92 | (*i)++; |
| 93 | *(++buf) = 0; |
| 94 | } |
| 95 | } else { |
| 96 | (*i)++; (*i)++; |
| 97 | *l = 16 - n + (*l); |
| 98 | val <<= *l; |
| 99 | *buf = *buf | ((val >> 16) & 0xff); |
| 100 | *(++buf) = (val >> 8) & 0xff; |
| 101 | *(++buf) = val & 0xff; |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | /* Inserts 17 to 24 bits into the output buffer. */ |
| 106 | static void __inline |