[go: up one dir, main page]

Menu

[dad864]: / bitstream.h  Maximize  Restore  History

Download this file

32 lines (26 with data), 975 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#ifndef _ACM_LAB_BIT_STREAM_H
#define _ACM_LAB_BIT_STREAM_H
#include <stdio.h>
class CBitStream {
private:
FILE* file;
unsigned long accumulator; // not yet stored bits
int shift; // next bit position
unsigned long bits_written, bytes_written; // for statistics
long seq_zeros; // count of sequential zeros
void internal_flush(); // drops all the fully filled bytes
void drop_zeros(); // flushes all the sequentially coming zero bytes
public:
CBitStream (FILE* a_file)
: file (a_file),
accumulator (0), shift (0),
bits_written (0), bytes_written (0),
seq_zeros (0) {};
~CBitStream() { flush(); };
int init_bit_stream() { return 1; }; // no initialization in current version
void flush(); // flushes the last, unfinished byte. MUST be called at the and of processing
void write_bits (unsigned long value, int count);
unsigned long get_bits_written() { return bits_written; };
unsigned long get_bytes_written() { return bytes_written; };
};
#endif