Loading...
Searching...
No Matches
ojph_codestream_local.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_codestream_local.h
// Author: Aous Naman
// Date: 28 August 2019
//***************************************************************************/
#ifndef OJPH_CODESTREAM_LOCAL_H
#define OJPH_CODESTREAM_LOCAL_H
#include "ojph_defs.h"
#include "ojph_params_local.h"
namespace ojph {
//defined elsewhere
class line_buf;
class mem_fixed_allocator;
class mem_elastic_allocator;
class codestream;
namespace local {
static inline
ui16 swap_byte(ui16 t)
{
return (ui16)((t << 8) | (t >> 8));
}
//defined elsewhere
class tile;
class codestream
{
friend ::ojph::codestream;
public:
codestream();
~codestream();
void restart();
void pre_alloc();
void finalize_alloc();
ojph::param_siz access_siz() // returns externally wrapped siz
{ return ojph::param_siz(&siz); }
const param_siz* get_siz() // returns internal siz
{ return &siz; }
ojph::param_cod access_cod() // returns externally wrapped cod
{ return ojph::param_cod(&cod); }
const param_cod* get_cod() // returns internal cod
{ return &cod; }
const param_cod* get_coc(ui32 comp_num) // returns internal cod
{ return cod.get_coc(comp_num); }
const param_qcd* access_qcd()
{ return &qcd; }
const param_dfs* access_dfs()
{ if (dfs.exists()) return &dfs; else return NULL; }
const param_nlt* get_nlt()
{ return &nlt; }
mem_fixed_allocator* get_allocator() { return allocator; }
mem_elastic_allocator* get_elastic_alloc() { return elastic_alloc; }
outfile_base* get_file() { return outfile; }
line_buf* exchange(line_buf* line, ui32& next_component);
void write_headers(outfile_base *file, const comment_exchange* comments,
ui32 num_comments);
void enable_resilience();
bool is_resilient() { return resilient; }
void read_headers(infile_base *file);
void restrict_input_resolution(ui32 skipped_res_for_data,
ui32 skipped_res_for_recon);
void read();
void set_planar(int planar);
void set_profile(const char *s);
void set_tilepart_divisions(ui32 value);
void request_tlm_marker(bool needed);
line_buf* pull(ui32 &comp_num);
void flush();
void close();
bool is_planar() const { return planar != 0; }
si32 get_profile() const { return profile; };
ui32 get_tilepart_div() const { return tilepart_div; };
bool is_tlm_needed() const { return need_tlm; };
void check_imf_validity();
void check_broadcast_validity();
ui8* get_precinct_scratch() { return precinct_scratch; }
ui32 get_skipped_res_for_recon()
{ return skipped_res_for_recon; }
ui32 get_skipped_res_for_read()
{ return skipped_res_for_read; }
private:
ui32 precinct_scratch_needed_bytes;
ui8* precinct_scratch;
private:
ui32 cur_line;
ui32 cur_comp;
ui32 cur_tile_row;
bool resilient;
ui32 skipped_res_for_read, skipped_res_for_recon;
private:
size num_tiles;
tile *tiles;
line_buf* lines;
ui32 num_comps;
size *comp_size; //stores full resolution no. of lines and width
size *recon_comp_size; //stores number of lines and width of each comp
bool employ_color_transform;
int planar;
int profile;
ui32 tilepart_div; // tilepart division value
bool need_tlm; // true if tlm markers are needed
private:
param_siz siz; // image and tile size
param_cod cod; // coding style default
param_cap cap; // extended capabilities
param_qcd qcd; // quantization default
param_tlm tlm; // tile-part lengths
param_nlt nlt; // non-linearity point transformation
private: // these are from Part 2 of the standard
param_dfs dfs; // downsmapling factor styles
param_atk atk; // wavelet structure and coefficients
private:
mem_fixed_allocator *allocator;
mem_elastic_allocator *elastic_alloc;
outfile_base *outfile;
infile_base *infile;
};
}
}
#endif // !OJPH_CODESTREAM_LOCAL_H
ojph::codestream
The object represent a codestream.
Definition ojph_codestream.h:89
ojph::comment_exchange
Definition ojph_params.h:291
ojph::infile_base
Definition ojph_file.h:247
ojph::line_buf
Definition ojph_mem.h:160
ojph::local::codestream::cap
param_cap cap
Definition ojph_codestream_local.h:159
ojph::local::codestream::is_resilient
bool is_resilient()
Definition ojph_codestream_local.h:105
ojph::local::codestream::qcd
param_qcd qcd
Definition ojph_codestream_local.h:160
ojph::local::codestream::outfile
outfile_base * outfile
Definition ojph_codestream_local.h:171
ojph::local::codestream::read
void read()
Definition ojph_codestream_local.cpp:883
ojph::local::codestream::nlt
param_nlt nlt
Definition ojph_codestream_local.h:162
ojph::local::codestream::atk
param_atk atk
Definition ojph_codestream_local.h:166
ojph::local::codestream::infile
infile_base * infile
Definition ojph_codestream_local.h:172
ojph::local::codestream::is_planar
bool is_planar() const
Definition ojph_codestream_local.h:118
ojph::local::codestream::get_profile
si32 get_profile() const
Definition ojph_codestream_local.h:119
ojph::local::codestream::~codestream
~codestream()
Definition ojph_codestream_local.cpp:69
ojph::local::codestream::tiles
tile * tiles
Definition ojph_codestream_local.h:145
ojph::local::codestream::skipped_res_for_recon
ui32 skipped_res_for_recon
Definition ojph_codestream_local.h:141
ojph::local::codestream::pre_alloc
void pre_alloc()
Definition ojph_codestream_local.cpp:113
ojph::local::codestream::get_tilepart_div
ui32 get_tilepart_div() const
Definition ojph_codestream_local.h:120
ojph::local::codestream::resilient
bool resilient
Definition ojph_codestream_local.h:140
ojph::local::codestream::access_siz
ojph::param_siz access_siz()
Definition ojph_codestream_local.h:81
ojph::local::codestream::tilepart_div
ui32 tilepart_div
Definition ojph_codestream_local.h:153
ojph::local::codestream::tlm
param_tlm tlm
Definition ojph_codestream_local.h:161
ojph::local::codestream::profile
int profile
Definition ojph_codestream_local.h:152
ojph::local::codestream::get_coc
const param_cod * get_coc(ui32 comp_num)
Definition ojph_codestream_local.h:89
ojph::local::codestream::get_elastic_alloc
mem_elastic_allocator * get_elastic_alloc()
Definition ojph_codestream_local.h:98
ojph::local::codestream::planar
int planar
Definition ojph_codestream_local.h:151
ojph::local::codestream::close
void close()
Definition ojph_codestream_local.cpp:1132
ojph::local::codestream::get_skipped_res_for_read
ui32 get_skipped_res_for_read()
Definition ojph_codestream_local.h:129
ojph::local::codestream::request_tlm_marker
void request_tlm_marker(bool needed)
Definition ojph_codestream_local.cpp:1107
ojph::local::codestream::exchange
line_buf * exchange(line_buf *line, ui32 &next_component)
Definition ojph_codestream_local.cpp:1141
ojph::local::codestream::set_planar
void set_planar(int planar)
Definition ojph_codestream_local.cpp:1083
ojph::local::codestream::access_qcd
const param_qcd * access_qcd()
Definition ojph_codestream_local.h:91
ojph::local::codestream::get_siz
const param_siz * get_siz()
Definition ojph_codestream_local.h:83
ojph::local::codestream::precinct_scratch
ui8 * precinct_scratch
Definition ojph_codestream_local.h:134
ojph::local::codestream::lines
line_buf * lines
Definition ojph_codestream_local.h:146
ojph::local::codestream::check_imf_validity
void check_imf_validity()
Definition ojph_codestream_local.cpp:281
ojph::local::codestream::get_allocator
mem_fixed_allocator * get_allocator()
Definition ojph_codestream_local.h:97
ojph::local::codestream::get_nlt
const param_nlt * get_nlt()
Definition ojph_codestream_local.h:95
ojph::local::codestream::restart
void restart()
Definition ojph_codestream_local.cpp:78
ojph::local::codestream::restrict_input_resolution
void restrict_input_resolution(ui32 skipped_res_for_data, ui32 skipped_res_for_recon)
Definition ojph_codestream_local.cpp:854
ojph::local::codestream::need_tlm
bool need_tlm
Definition ojph_codestream_local.h:154
ojph::local::codestream::get_precinct_scratch
ui8 * get_precinct_scratch()
Definition ojph_codestream_local.h:126
ojph::local::codestream::get_file
outfile_base * get_file()
Definition ojph_codestream_local.h:99
ojph::local::codestream::elastic_alloc
mem_elastic_allocator * elastic_alloc
Definition ojph_codestream_local.h:170
ojph::local::codestream::access_cod
ojph::param_cod access_cod()
Definition ojph_codestream_local.h:85
ojph::local::codestream::cur_comp
ui32 cur_comp
Definition ojph_codestream_local.h:138
ojph::local::codestream::siz
param_siz siz
Definition ojph_codestream_local.h:157
ojph::local::codestream::cur_tile_row
ui32 cur_tile_row
Definition ojph_codestream_local.h:139
ojph::local::codestream::get_cod
const param_cod * get_cod()
Definition ojph_codestream_local.h:87
ojph::local::codestream::is_tlm_needed
bool is_tlm_needed() const
Definition ojph_codestream_local.h:121
ojph::local::codestream::access_dfs
const param_dfs * access_dfs()
Definition ojph_codestream_local.h:93
ojph::local::codestream::allocator
mem_fixed_allocator * allocator
Definition ojph_codestream_local.h:169
ojph::local::codestream::flush
void flush()
Definition ojph_codestream_local.cpp:1113
ojph::local::codestream::write_headers
void write_headers(outfile_base *file, const comment_exchange *comments, ui32 num_comments)
Definition ojph_codestream_local.cpp:544
ojph::local::codestream::recon_comp_size
size * recon_comp_size
Definition ojph_codestream_local.h:149
ojph::local::codestream::precinct_scratch_needed_bytes
ui32 precinct_scratch_needed_bytes
Definition ojph_codestream_local.h:133
ojph::local::codestream::cod
param_cod cod
Definition ojph_codestream_local.h:158
ojph::local::codestream::check_broadcast_validity
void check_broadcast_validity()
Definition ojph_codestream_local.cpp:444
ojph::local::codestream::read_headers
void read_headers(infile_base *file)
Definition ojph_codestream_local.cpp:740
ojph::local::codestream::codestream
codestream()
Definition ojph_codestream_local.cpp:56
ojph::local::codestream::num_comps
ui32 num_comps
Definition ojph_codestream_local.h:147
ojph::local::codestream::set_profile
void set_profile(const char *s)
Definition ojph_codestream_local.cpp:1089
ojph::local::codestream::employ_color_transform
bool employ_color_transform
Definition ojph_codestream_local.h:150
ojph::local::codestream::set_tilepart_divisions
void set_tilepart_divisions(ui32 value)
Definition ojph_codestream_local.cpp:1101
ojph::local::codestream::finalize_alloc
void finalize_alloc()
Definition ojph_codestream_local.cpp:209
ojph::local::codestream::dfs
param_dfs dfs
Definition ojph_codestream_local.h:165
ojph::local::codestream::num_tiles
size num_tiles
Definition ojph_codestream_local.h:144
ojph::local::codestream::cur_line
ui32 cur_line
Definition ojph_codestream_local.h:137
ojph::local::codestream::get_skipped_res_for_recon
ui32 get_skipped_res_for_recon()
Definition ojph_codestream_local.h:127
ojph::local::codestream::pull
line_buf * pull(ui32 &comp_num)
Definition ojph_codestream_local.cpp:1192
ojph::local::codestream::enable_resilience
void enable_resilience()
Definition ojph_codestream_local.cpp:874
ojph::local::codestream::skipped_res_for_read
ui32 skipped_res_for_read
Definition ojph_codestream_local.h:141
ojph::local::codestream::comp_size
size * comp_size
Definition ojph_codestream_local.h:148
ojph::local::tile
Definition ojph_tile.h:61
ojph::mem_elastic_allocator
Definition ojph_mem.h:217
ojph::mem_fixed_allocator
Definition ojph_mem.h:58
ojph::outfile_base
Definition ojph_file.h:75
ojph::param_cod
Definition ojph_params.h:104
ojph::param_siz
Definition ojph_params.h:71
ojph::local
Definition ojph_bitbuffer_read.h:52
ojph::local::swap_byte
static ui16 swap_byte(ui16 t)
Definition ojph_codestream_local.h:58
ojph
Definition ojph_img_io.h:52
ojph::ui16
uint16_t ui16
Definition ojph_defs.h:52
ojph::si32
int32_t si32
Definition ojph_defs.h:55
ojph::ui32
uint32_t ui32
Definition ojph_defs.h:54
ojph::ui8
uint8_t ui8
Definition ojph_defs.h:50
ojph_defs.h
ojph_params_local.h
ojph::local::param_atk
Definition ojph_params_local.h:1071
ojph::local::param_cap
Definition ojph_params_local.h:866
ojph::local::param_cod
Definition ojph_params_local.h:371
ojph::local::param_dfs
Definition ojph_params_local.h:979
ojph::local::param_nlt
Definition ojph_params_local.h:788
ojph::local::param_qcd
Definition ojph_params_local.h:663
ojph::local::param_siz
Definition ojph_params_local.h:166
ojph::local::param_tlm
Definition ojph_params_local.h:948
ojph::size
Definition ojph_base.h:48