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];
77 itmp >>= (8 - ibit - tbit);
79 bitcnt = bitcnt - tbit;
84 itmp = itmp << 8 | (int)*(in + index);
92 itmp = (itmp << bitcnt) |
93 (((
int)*(in + index) >> (8 - bitcnt)) & ones[bitcnt - 1]);
148 if (!(g2iout = malloc(n *
sizeof(
g2int))))
151 gbits(in, g2iout, iskip, nbits, nskip, n);
154 for (i = 0; i < n; i++)
155 iout[i] = (
int)g2iout[i];
181 g2int i, bitcnt, tbit, ibit, itmp, imask, itmp2, itmp3;
183 static g2int ones[] = {1, 3, 7, 15, 31, 63, 127, 255};
187 nbit = iskip + nbits - 1;
188 for (i = 0; i < n; i++)
194 nbit = nbit + nbits + nskip;
199 tbit = (bitcnt < (ibit + 1)) ? bitcnt : ibit + 1;
200 imask = ones[tbit - 1] << (7 - ibit);
201 itmp2 = (itmp << (7 - ibit)) & imask;
202 itmp3 = (int)*(out + index) & (255 - imask);
203 out[index] = (
unsigned char)(itmp2 | itmp3);
204 bitcnt = bitcnt - tbit;
213 out[index] = (
unsigned char)(itmp & 255);
222 itmp2 = itmp & ones[bitcnt - 1];
223 itmp3 = (int)*(out + index) & (255 - ones[bitcnt - 1]);
224 out[index] = (
unsigned char)(itmp2 | itmp3);
void gbit(unsigned char *in, g2int *iout, g2int iskip, g2int nbits)
Get arbitrary size values from a packed bit string, right justifying each value in the unpacked iout ...
void gbits(unsigned char *in, g2int *iout, g2int iskip, g2int nbits, g2int nskip, g2int n)
Unpack arbitrary size values from a packed bit string, right justifying each value in the unpacked io...
void sbits(unsigned char *out, g2int *in, g2int iskip, g2int nbits, g2int nskip, g2int n)
Store arbitrary size values into a packed bit string, taking the low order bits from each value in th...
int g2c_gbits_int(unsigned char *in, int *iout, int iskip, int nbits, int nskip, int n)
Extract arbitrary size values from a packed bit string, right justifying each value in the unpacked i...
void g2c_gbit_int(unsigned char *in, int *iout, int iskip, int nbits)
Extract arbitrary size values from a packed bit string, right justifying each value in the unpacked i...
void sbit(unsigned char *out, g2int *in, g2int iskip, g2int nbits)
Store arbitrary size values into a packed bit string, taking the low order bits from each value in th...
#define G2C_ENOMEM
Out of memory.
#define G2C_EINVAL
Invalid input.
int64_t g2int
Long integer type.
#define G2C_NOERROR
No error.
Header file with internal function prototypes NCEPLIBS-g2c library.