MCPcopy Create free account
hub / github.com/F-Stack/f-stack / putbits16

Function putbits16

freebsd/net/mppcc.c:80–103  ·  view source on GitHub ↗

Inserts 9 to 16 bits into the output buffer. */

Source from the content-addressed store, hash-verified

78
79/* Inserts 9 to 16 bits into the output buffer. */
80static void __inline
81putbits16(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. */
106static void __inline

Callers 1

MPPC_CompressFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected