90 return t + (x & (x - 1) ? 1 : 0);
109 ui32 num_levels = 1 +
138 for (
ui32 y = 0; y < height; ++y)
140 for (
ui32 x = 0; x < width; ++x)
158 *
inc_tag.get(0,0,num_levels) = 0;
162 if (*
inc_tag.get(0, 0, num_levels-1) != 0)
187 for (
ui32 y = 0; y < height; ++y)
191 for (
ui32 x = 0; x < width; ++x, ++
cp)
211 if (
cp->num_passes == 0)
230 switch (
cp->num_passes)
250 if (
cp->num_passes > 1)
259 if (
cp->num_passes > 1)
298 for (
ui32 y = 0; y < height; ++y)
302 for (
ui32 x = 0; x < width; ++x, ++
cp)
318 file->
write(&buf, 1);
352 ui32 num_levels = 1 +
358 *
inc_tag.get(0, 0, num_levels) = 0;
364 *
mmsb_tag.get(0, 0, num_levels) = 0;
373 for (
ui32 y = 0; y < height; ++y)
377 for (
ui32 x = 0; x < width; ++x, ++
cp)
392 {
data_left = 0;
throw "error reading from file p1"; }
417 {
data_left = 0;
throw "error reading from file p2"; }
426 throw "error in parsing a tile header; "
427 "missing msbs are larger or equal to Kmax. The most likely "
428 "cause is a corruption in the bitstream.";
434 {
data_left = 0;
throw "error reading from file p3"; }
439 {
data_left = 0;
throw "error reading from file p4"; }
443 {
data_left = 0;
throw "error reading from file p5"; }
444 num_passes = 3 +
bit;
448 {
data_left = 0;
throw "error reading from file p6"; }
449 num_passes = 6 +
bit;
453 {
data_left = 0;
throw "error reading from file p7"; }
454 num_passes = 37 +
bit;
459 cp->num_passes = num_passes;
469 {
data_left = 0;
throw "error reading from file p8"; }
474 {
data_left = 0;
throw "error reading from file p9"; }
476 throw "The cleanup segment of an HT codeblock cannot contain "
480 throw "The cleanup segment of an HT codeblock must contain "
481 "less than 65535 bytes";
483 cp->pass_length[0] =
bit;
487 {
data_left = 0;
throw "error reading from file p10"; }
489 throw "The refinement segment (SigProp and MagRep passes) of "
490 "an HT codeblock must contain less than 2047 bytes";
492 cp->pass_length[1] =
bit;
504 for (
ui32 y = 0; y < height; ++y)
508 for (
ui32 x = 0; x < width; ++x, ++
cp)
510 ui32 num_bytes =
cp->pass_length[0] +
cp->pass_length[1];
521 cp->pass_length[0] =
cp->pass_length[1] = 0;
530 cp->pass_length[0] =
cp->pass_length[1] = 0;
537 cp->pass_length[0] =
cp->pass_length[1] = 0;
coded_cb_header * coded_cbs
virtual size_t write(const void *ptr, size_t size)=0
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 ui32 log2ceil(ui32 x)
static void bb_put_bits(bit_write_buf *bbp, ui32 data, int num_bits, mem_elastic_allocator *elastic, coded_lists *&cur_coded_list, ui32 &ph_bytes)
static void bb_init(bit_read_buf *bbp, ui32 bytes_left, infile_base *file)
static void bb_put_bit(bit_write_buf *bbp, ui32 bit, mem_elastic_allocator *elastic, coded_lists *&cur_coded_list, ui32 &ph_bytes)
static ui32 count_leading_zeros(ui32 val)
void write(outfile_base *file)
ui32 prepare_precinct(int tag_tree_size, ui32 *lev_idx, mem_elastic_allocator *elastic)
void parse(int tag_tree_size, ui32 *lev_idx, mem_elastic_allocator *elastic, ui32 &data_left, infile_base *file, bool skipped)
ui8 * get(ui32 x, ui32 y, ui32 lev)
void init(ui8 *buf, ui32 *lev_idx, ui32 num_levels, size s, int init_val)