60 g2int i, tbit, bitcnt, ibit, itmp;
62 static g2int ones[]={1, 3, 7, 15, 31, 63, 127, 255};
66 for (i = 0; i < n; i++)
71 nbit = nbit + nbits + nskip;
74 tbit = (bitcnt < (8 - ibit)) ? bitcnt : 8 - ibit;
75 itmp = (int)*(in + index) & ones[7 - ibit];
76 if (tbit != 8 - ibit) itmp >>= (8 - ibit - tbit);
78 bitcnt = bitcnt - tbit;
83 itmp = itmp << 8 | (int)*(in + index);
91 itmp = ( itmp << bitcnt ) |
92 (((
int)*(in + index) >> (8 - bitcnt)) & ones[bitcnt - 1]);
117 g2int i, bitcnt, tbit, ibit, itmp, imask, itmp2, itmp3;
119 static g2int ones[]={1, 3, 7, 15, 31, 63, 127, 255};
123 nbit = iskip + nbits - 1;
124 for (i = 0; i < n; i++)
130 nbit = nbit + nbits + nskip;
135 tbit = (bitcnt < (ibit+1)) ? bitcnt : ibit + 1;
136 imask = ones[tbit - 1] << (7 - ibit);
137 itmp2 = (itmp << (7 - ibit)) & imask;
138 itmp3 = (int)*(out + index) & (255 - imask);
139 out[index] = (
unsigned char)(itmp2 | itmp3);
140 bitcnt = bitcnt - tbit;
149 out[index] = (
unsigned char)(itmp & 255);
158 itmp2 = itmp & ones[bitcnt - 1];
159 itmp3 = (int)*(out + index) & (255 - ones[bitcnt - 1]);
160 out[index] = (
unsigned char)(itmp2 | itmp3);