NCEPLIBS-g2c 1.9.0
Loading...
Searching...
No Matches
gbits.c File Reference

Functions to pack and unpack bits to/from a packed bit string. More...

#include "grib2_int.h"

Go to the source code of this file.

Functions

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 iout array.
 
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 iout array.
 
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 array.
 
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 iout array.
 
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 the unpacked array.
 
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 the unpacked array.
 

Detailed Description

Functions to pack and unpack bits to/from a packed bit string.

Author
NOAA Programmer

Definition in file gbits.c.

Function Documentation

◆ g2c_gbit_int()

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 iout array.

This is similar to gbit(), but with int types instead of g2int.

Parameters
inpointer to character array input.
ioutpointer that gets the unpacked array output.
iskipinitial number of bits to skip.
nbitsnumber of bits to take.
Author
NOAA Programmer

Definition at line 113 of file gbits.c.

References g2c_gbits_int().

◆ g2c_gbits_int()

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 iout array.

This is similar to gbits(), but with int types instead of g2int.

Parameters
inPointer to character array input.
ioutPointer that gets the unpacked array output.
iskipInitial number of bits to skip.
nbitsNumber of bits to take.
nskipAdditional number of bits to skip on each iteration.
nNumber of iterations.
Returns
Author
Ed Hartnett
Date
8/31/22

Definition at line 137 of file gbits.c.

References G2C_EINVAL, G2C_ENOMEM, G2C_NOERROR, and gbits().

Referenced by g2c_gbit_int().

◆ gbit()

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 array.

Parameters
inpointer to character array input.
ioutpointer that gets the unpacked array output.
iskipinitial number of bits to skip.
nbitsnumber of bits to take.
Author
NOAA Programmer

Definition at line 20 of file gbits.c.

References gbits().

Referenced by comunpack(), g2_addfield(), g2_addgrid(), g2_addlocal(), g2_getfld(), g2_gribend(), g2_info(), g2_unpack1(), g2_unpack2(), g2_unpack3(), g2_unpack4(), g2_unpack5(), g2_unpack6(), g2c_check_msg(), g2c_unpack7_int(), and seekgb().

◆ gbits()

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 iout array.

Parameters
inPointer to character array input.
ioutPointer that gets the unpacked array output.
iskipInitial number of bits to skip.
nbitsNumber of bits to take.
nskipAdditional number of bits to skip on each iteration.
nNumber of iterations.
Author
NOAA Programmer

Definition at line 57 of file gbits.c.

Referenced by aecunpack_int(), comunpack(), g2_unpack3(), g2_unpack4(), g2_unpack6(), g2c_gbits_int(), gbit(), pngunpack_int(), simunpack(), and specunpack().

◆ sbit()

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 the unpacked array.

Parameters
outPointer to packed array output. Must be allocated large enough to hold output.
inPointer that gets the unpacked array input.
iskipInitial number of bits to skip.
nbitsNumber of bits to pack.
Author
NOAA Programmer

Definition at line 38 of file gbits.c.

References sbits().

Referenced by compack(), g2_addfield(), g2_addgrid(), g2_addlocal(), g2_create(), g2_gribend(), misspack(), and simpack().

◆ sbits()

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 the unpacked array.

Parameters
outPointer to packed array output. Must be allocated large enough to hold output.
inPointer that gets the unpacked array input.
iskipInitial number of bits to skip.
nbitsNumber of bits to pack.
nskipAdditional number of bits to skip on each iteration.
nNumber of iterations.
Author
NOAA Programmer

Definition at line 178 of file gbits.c.

Referenced by aecpack_int(), compack(), g2_addfield(), g2_addgrid(), jpcpack_int(), misspack(), pngpack_int(), sbit(), and simpack().