# BByteStream

## Functions

| `BByteStream`
| `BByteStream`
void | `put`
void | `get`

## Detailed Description

class BByteStream

  Handles transfer of certain unaligned bit lengths via unsigned char arrays.

  We determined that visual artifacts introduced in sending 8-bit normals were too noticeable, and that higher accuracy was required. At the same time, however, we wanted better compression than 16-bit. Thus, the BByteStream class was born.

  For efficiency, this class makes certain assumptions about the number of bits per pixel: 1) that samples are at least 1 byte (see logic controlling byteplace incrementing); 2) that samples never span 3 bytes in the character array (ruling out lengths of 11, 13, 14, 15, and 17+. Additionally, the bit shifting operations here are needless overhead for any length divisible by 8, meaning that this class is not the best way to do it. These assumptions and observations restrict us (at least for the moment) to 9, 10, and 12 as allowable sample lengths.

  This class is a state machine that is intended to match the semantics of a FILE* (with the obvious exception that it goes into a uchar* rather than to a real file. With that in mind, it does not support random access through the data. Only a linear walk from front to back is allowed.

  Public Functions

  inline BByteStream(int size, unsigned char *cptr, int bpv)
  inline BByteStream()
  inline void put(unsigned short value)
  inline void get(unsigned short &value)

    read a sample