39#ifndef OJPH_BITBUFFER_READ_H
40#define OJPH_BITBUFFER_READ_H
85 throw "error reading from file";
116 assert(num_bits <= 32);
127 bits |= (bbp->
tmp >> bbp->
avail_bits) & ((1 << tx_bits) - 1);
144 if (num_bytes > bytes_read)
147 0, num_bytes - bytes_read);
149 return bytes_read == bytes;
159 if (bbp->
file->
read(marker, 2) != 2)
160 throw "error reading from file";
162 if ((
int)marker[0] != (
EPH >> 8) || (
int)marker[1] != (
EPH & 0xFF))
163 throw "should find EPH, but found something else";
189 if (bbp->
file->
read(marker, 2) != 2)
190 throw "error reading from file";
191 if ((
int)marker[0] == (
SOP >> 8) && (
int)marker[1] == (
SOP & 0xFF))
197 if (bbp->
file->
read(&com_len, 2) != 2)
198 throw "error reading from file";
201 throw "something is wrong with SOP length";
205 throw "error seeking file";
209 throw "precinct truncated early";
216 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 void bb_init(bit_read_buf *bbp, ui32 bytes_left, infile_base *file)
static void bb_skip_eph(bit_read_buf *bbp)
static ui16 swap_bytes_if_le(ui16 t)