#ifndef _BITIO_H #define _BITIO_H #include #include "h261vlc.h" #include "except.h" struct huffman_elem { int symbol; int prob; huffman_elem() {symbol = 0; prob = 0;} }; struct tree_node { tree_node *left, *right; /* Left branch, right branch */ tree_node *top; /* Root */ huffman_elem huf; tree_node() { left = right = top = 0;} }; /* Bidirectional class for bit input/output operations: Either for read or write but not both */ class bit_io { private: int valid_rbits; int valid_wbits; int buf_rbytes; int buf_wbytes; int total_rbytes; int total_wbytes; u_char curr_rbyte; u_char curr_wbyte; u_short dummy; u_char *read_buf; u_char *write_buf; int max_rbits; int max_wbytes; public: bit_io(); void attach_rbuf(u_char *buf, int max_bits); void attach_wbuf(u_char *buf, int max_bytes); int read_bit(void) throw (PicException_t); int read_bits(int len); /* Upto 32 bits */ int write_bit(int bitvalue); int write_bits(u_char *bitstream, int numbits, int terminate=0); int write_bits(struct symbol_code& s, int terminate=0); int bit_io::write_flush(void) throw (PicException_t); void print(void); /* Debugging */ int GetBufWbytes(void); int wflush_bits(void); int GetRbufBits(void); }; int add_to_tree(tree_node *root, struct symbol_string& s); /* 0 on success, -1 on error */ int tree_read(bit_io *input, tree_node *root, int& symbol); #endif