Streams (or sections of streams) can be treated as a string of bits, packed either most significant or least significant bits first.
To read from an msb packed stream, use fz_read_bits:
Conversely, to read from a lsb packed stream, use fz_read_rbits:
;
Whichever of these is used, reading n bits will return the results in the lowest n bits of the returned value.
After reading bits using these functions, if a return to reading bytewise (or objectwise) is required, then fz_sync_bits must be called.
This function skips as many bits as as required to align with a byte boundary.