Loading...
Searching...
No Matches
ojph_codeblock.h
Go to the documentation of this file.
//***************************************************************************/
// This software is released under the 2-Clause BSD license, included
// below.
//
// Copyright (c) 2019, Aous Naman
// Copyright (c) 2019, Kakadu Software Pty Ltd, Australia
// Copyright (c) 2019, The University of New South Wales, Australia
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//***************************************************************************/
// This file is part of the OpenJPH software implementation.
// File: ojph_codeblock.h
// Author: Aous Naman
// Date: 28 August 2019
//***************************************************************************/
#ifndef OJPH_CODEBLOCK_H
#define OJPH_CODEBLOCK_H
#include "ojph_defs.h"
#include "ojph_file.h"
#include "ojph_codeblock_fun.h"
namespace ojph {
//defined elsewhere
class line_buf;
class mem_elastic_allocator;
class codestream;
struct coded_lists;
namespace local {
//defined here
struct precinct;
class subband;
struct coded_cb_header;
class codeblock
{
friend struct precinct;
enum : ui32 {
BUF32 = 4,
BUF64 = 8,
};
public:
static void pre_alloc(codestream *codestream, const size& nominal,
ui32 precision);
void finalize_alloc(codestream *codestream, subband* parent,
const size& nominal, const size& cb_size,
coded_cb_header* coded_cb, ui32 K_max,
int tbx0, ui32 precision, ui32 comp_idx);
void push(line_buf *line);
void encode(mem_elastic_allocator *elastic);
void recreate(const size& cb_size, coded_cb_header* coded_cb);
void decode();
void pull_line(line_buf *line);
private:
ui32 precision;
union {
ui32* buf32;
ui64* buf64;
};
size nominal_size;
size cb_size;
ui32 stride;
ui32 buf_size;
subband* parent;
int line_offset;
ui32 cur_line;
float delta, delta_inv;
ui32 K_max;
bool reversible;
bool resilient;
bool stripe_causal;
bool zero_block; // true when the decoded block is all zero
union {
ui32 max_val32[8]; // supports up to 256 bits
ui64 max_val64[4]; // supports up to 256 bits
};
coded_cb_header* coded_cb;
codeblock_fun codeblock_functions;
};
struct coded_cb_header
{
ui32 pass_length[2];
ui32 num_passes; // number of passes to be decoded
ui32 Kmax;
ui32 missing_msbs;
coded_lists *next_coded;
static const int prefix_buf_size = 8;
static const int suffix_buf_size = 16;
};
}
}
#endif // !OJPH_CODEBLOCK_H
ojph::codestream
The object represent a codestream.
Definition ojph_codestream.h:89
ojph::line_buf
Definition ojph_mem.h:161
ojph::local::codeblock
Definition ojph_codeblock.h:66
ojph::local::codeblock::nominal_size
size nominal_size
Definition ojph_codeblock.h:93
ojph::local::codeblock::line_offset
int line_offset
Definition ojph_codeblock.h:98
ojph::local::codeblock::max_val64
ui64 max_val64[4]
Definition ojph_codeblock.h:108
ojph::local::codeblock::BUF32
@ BUF32
Definition ojph_codeblock.h:69
ojph::local::codeblock::BUF64
@ BUF64
Definition ojph_codeblock.h:70
ojph::local::codeblock::stripe_causal
bool stripe_causal
Definition ojph_codeblock.h:104
ojph::local::codeblock::resilient
bool resilient
Definition ojph_codeblock.h:103
ojph::local::codeblock::coded_cb
coded_cb_header * coded_cb
Definition ojph_codeblock.h:110
ojph::local::codeblock::decode
void decode()
Definition ojph_codeblock.cpp:188
ojph::local::codeblock::parent
subband * parent
Definition ojph_codeblock.h:97
ojph::local::codeblock::finalize_alloc
void finalize_alloc(codestream *codestream, subband *parent, const size &nominal, const size &cb_size, coded_cb_header *coded_cb, ui32 K_max, int tbx0, ui32 precision, ui32 comp_idx)
Definition ojph_codeblock.cpp:72
ojph::local::codeblock::precision
ui32 precision
Definition ojph_codeblock.h:88
ojph::local::codeblock::push
void push(line_buf *line)
Definition ojph_codeblock.cpp:115
ojph::local::codeblock::precinct
friend struct precinct
Definition ojph_codeblock.h:67
ojph::local::codeblock::buf64
ui64 * buf64
Definition ojph_codeblock.h:91
ojph::local::codeblock::cb_size
size cb_size
Definition ojph_codeblock.h:94
ojph::local::codeblock::buf_size
ui32 buf_size
Definition ojph_codeblock.h:96
ojph::local::codeblock::K_max
ui32 K_max
Definition ojph_codeblock.h:101
ojph::local::codeblock::pre_alloc
static void pre_alloc(codestream *codestream, const size &nominal, ui32 precision)
Definition ojph_codeblock.cpp:56
ojph::local::codeblock::delta_inv
float delta_inv
Definition ojph_codeblock.h:100
ojph::local::codeblock::encode
void encode(mem_elastic_allocator *elastic)
Definition ojph_codeblock.cpp:140
ojph::local::codeblock::recreate
void recreate(const size &cb_size, coded_cb_header *coded_cb)
Definition ojph_codeblock.cpp:176
ojph::local::codeblock::delta
float delta
Definition ojph_codeblock.h:100
ojph::local::codeblock::max_val32
ui32 max_val32[8]
Definition ojph_codeblock.h:107
ojph::local::codeblock::stride
ui32 stride
Definition ojph_codeblock.h:95
ojph::local::codeblock::reversible
bool reversible
Definition ojph_codeblock.h:102
ojph::local::codeblock::cur_line
ui32 cur_line
Definition ojph_codeblock.h:99
ojph::local::codeblock::zero_block
bool zero_block
Definition ojph_codeblock.h:105
ojph::local::codeblock::codeblock_functions
codeblock_fun codeblock_functions
Definition ojph_codeblock.h:111
ojph::local::codeblock::pull_line
void pull_line(line_buf *line)
Definition ojph_codeblock.cpp:228
ojph::local::codeblock::buf32
ui32 * buf32
Definition ojph_codeblock.h:90
ojph::local::codestream
Definition ojph_codestream_local.h:69
ojph::local::subband
Definition ojph_subband.h:63
ojph::mem_elastic_allocator
Definition ojph_mem.h:218
ojph::local
Definition ojph_bitbuffer_read.h:52
ojph
Definition ojph_img_io.h:52
ojph::ui64
uint64_t ui64
Definition ojph_defs.h:56
ojph::ui32
uint32_t ui32
Definition ojph_defs.h:54
ojph_codeblock_fun.h
ojph_defs.h
ojph_file.h
ojph::coded_lists
Definition ojph_mem.h:202
ojph::local::codeblock_fun
Definition ojph_codeblock_fun.h:93
ojph::local::coded_cb_header
Definition ojph_codeblock.h:116
ojph::local::coded_cb_header::next_coded
coded_lists * next_coded
Definition ojph_codeblock.h:121
ojph::local::coded_cb_header::suffix_buf_size
static const int suffix_buf_size
Definition ojph_codeblock.h:124
ojph::local::coded_cb_header::pass_length
ui32 pass_length[2]
Definition ojph_codeblock.h:117
ojph::local::coded_cb_header::missing_msbs
ui32 missing_msbs
Definition ojph_codeblock.h:120
ojph::local::coded_cb_header::prefix_buf_size
static const int prefix_buf_size
Definition ojph_codeblock.h:123
ojph::local::coded_cb_header::Kmax
ui32 Kmax
Definition ojph_codeblock.h:119
ojph::local::coded_cb_header::num_passes
ui32 num_passes
Definition ojph_codeblock.h:118
ojph::local::precinct
Definition ojph_precinct.h:59
ojph::size
Definition ojph_base.h:48