39#ifndef OJPH_BITBUFFER_READ_H
40#define OJPH_BITBUFFER_READ_H
49 class mem_elastic_allocator;
84 throw "error reading from file";
115 assert(num_bits <= 32);
126 bits |= (bbp->
tmp >> bbp->
avail_bits) & ((1 << tx_bits) - 1);
143 if (num_bytes > bytes_read)
146 0, num_bytes - bytes_read);
148 return bytes_read == bytes;
158 if (bbp->
file->
read(marker, 2) != 2)
159 throw "error reading from file";
161 if ((
int)marker[0] != (
EPH >> 8) || (
int)marker[1] != (
EPH & 0xFF))
162 throw "should find EPH, but found something else";
188 if (bbp->
file->
read(marker, 2) != 2)
189 throw "error reading from file";
190 if ((
int)marker[0] == (
SOP >> 8) && (
int)marker[1] == (
SOP & 0xFF))
196 if (bbp->
file->
read(&com_len, 2) != 2)
197 throw "error reading from file";
200 throw "something is wrong with SOP length";
204 throw "error seeking file";
208 throw "precinct truncated early";
215 throw "error seeking file";
virtual size_t read(void *ptr, size_t size)=0
void get_buffer(ui32 needed_bytes, coded_lists *&p)
static bool bb_read_chunk(bit_read_buf *bbp, ui32 num_bytes, coded_lists *&cur_coded_list, mem_elastic_allocator *elastic)
static bool bb_read_bit(bit_read_buf *bbp, ui32 &bit)
static bool bb_read_bits(bit_read_buf *bbp, int num_bits, ui32 &bits)
static bool bb_skip_sop(bit_read_buf *bbp)
static bool bb_terminate(bit_read_buf *bbp, bool uses_eph)
static bool bb_read(bit_read_buf *bbp)
static ui16 swap_byte(ui16 t)
static void bb_init(bit_read_buf *bbp, ui32 bytes_left, infile_base *file)
static void bb_skip_eph(bit_read_buf *bbp)