Loading...
Searching...
No Matches
ojph_codestream.cpp
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.cpp
// Author: Aous Naman
// Date: 28 August 2019
//***************************************************************************/
#include <climits>
#include <cmath>
#include "ojph_mem.h"
#include "ojph_params.h"
#include "ojph_codestream.h"
#include "ojph_codestream_local.h"
namespace ojph {
//
//
//
//
//
codestream::~codestream()
{
if (state)
delete state;
state = NULL;
}
codestream::codestream()
{
state = new local::codestream;
}
void codestream::restart()
{
assert(state != NULL);
state->restart();
}
param_siz codestream::access_siz()
{
return param_siz(&state->siz);
}
param_cod codestream::access_cod()
{
return param_cod(&state->cod);
}
param_qcd codestream::access_qcd()
{
return param_qcd(&state->qcd);
}
param_nlt codestream::access_nlt()
{
return param_nlt(&state->nlt);
}
void codestream::set_planar(bool planar)
{
state->set_planar(planar ? 1 : 0);
}
void codestream::set_profile(const char *s)
{
state->set_profile(s);
}
void codestream::set_tilepart_divisions(bool at_resolutions,
bool at_components)
{
ui32 value = 0;
if (at_resolutions)
value |= OJPH_TILEPART_RESOLUTIONS;
if (at_components)
value |= OJPH_TILEPART_COMPONENTS;
state->set_tilepart_divisions(value);
}
bool codestream::is_tilepart_division_at_resolutions()
{
ui32 res = state->get_tilepart_div() & OJPH_TILEPART_RESOLUTIONS;
return res ? true : false;
}
bool codestream::is_tilepart_division_at_components()
{
ui32 comp = state->get_tilepart_div() & OJPH_TILEPART_COMPONENTS;
return comp ? true : false;
}
void codestream::request_tlm_marker(bool needed)
{
state->request_tlm_marker(needed);
}
bool codestream::is_tlm_requested()
{
return state->is_tlm_needed();
}
bool codestream::is_planar() const
{
return state->is_planar();
}
void codestream::write_headers(outfile_base *file,
const comment_exchange* comments,
ui32 num_comments)
{
state->write_headers(file, comments, num_comments);
}
void codestream::enable_resilience()
{
state->enable_resilience();
}
void codestream::read_headers(infile_base *file)
{
state->read_headers(file);
}
void codestream::restrict_input_resolution(ui32 skipped_res_for_read,
ui32 skipped_res_for_recon)
{
state->restrict_input_resolution(skipped_res_for_read,
skipped_res_for_recon);
}
void codestream::create()
{
state->read();
}
line_buf* codestream::pull(ui32 &comp_num)
{
return state->pull(comp_num);
}
void codestream::flush()
{
state->flush();
}
void codestream::close()
{
state->close();
}
line_buf* codestream::exchange(line_buf* line, ui32& next_component)
{
return state->exchange(line, next_component);
}
}
ojph::codestream::access_siz
param_siz access_siz()
Returns the underlying SIZ marker segment object.
Definition ojph_codestream.cpp:79
ojph::codestream::access_cod
param_cod access_cod()
Returns the underlying COD marker segment object.
Definition ojph_codestream.cpp:85
ojph::codestream::restrict_input_resolution
void restrict_input_resolution(ui32 skipped_res_for_data, ui32 skipped_res_for_recon)
This function restricts resolution decoding for a codestream. It is for a reading (decoding) codestre...
Definition ojph_codestream.cpp:179
ojph::codestream::is_tilepart_division_at_resolutions
bool is_tilepart_division_at_resolutions()
Query if the tile will be partitioned at resolution boundary.
Definition ojph_codestream.cpp:127
ojph::codestream::state
local::codestream * state
Definition ojph_codestream.h:382
ojph::codestream::close
void close()
Call this function to close the underlying file; works for both encoding and decoding codestreams.
Definition ojph_codestream.cpp:206
ojph::codestream::set_planar
void set_planar(bool planar)
Sets the sequence of pushing or pull rows from the machinery.
Definition ojph_codestream.cpp:103
ojph::codestream::~codestream
~codestream()
default destructor
Definition ojph_codestream.cpp:58
ojph::codestream::enable_resilience
void enable_resilience()
This enables codestream resilience; that is, the library tries its best to decode the codestream,...
Definition ojph_codestream.cpp:167
ojph::codestream::exchange
line_buf * exchange(line_buf *line, ui32 &next_component)
This call is used to send image data rows to the library. We expect to send one row from a single com...
Definition ojph_codestream.cpp:212
ojph::codestream::request_tlm_marker
void request_tlm_marker(bool needed)
Request the addition of the optional TLM marker segment. This request should occur before writing cod...
Definition ojph_codestream.cpp:141
ojph::codestream::codestream
codestream()
default constructor
Definition ojph_codestream.cpp:66
ojph::codestream::set_profile
void set_profile(const char *s)
Sets the codestream profile.
Definition ojph_codestream.cpp:109
ojph::codestream::access_qcd
param_qcd access_qcd()
Returns the underlying QCD marker segment object.
Definition ojph_codestream.cpp:91
ojph::codestream::is_tilepart_division_at_components
bool is_tilepart_division_at_components()
Query if the tile will be partitioned at component boundary.
Definition ojph_codestream.cpp:134
ojph::codestream::read_headers
void read_headers(infile_base *file)
This call reads the headers of a codestream. It is for a reading (or decoding) codestream,...
Definition ojph_codestream.cpp:173
ojph::codestream::set_tilepart_divisions
void set_tilepart_divisions(bool at_resolutions, bool at_components)
Sets the locations where a tile is partitioned into tile parts.
Definition ojph_codestream.cpp:115
ojph::codestream::is_tlm_requested
bool is_tlm_requested()
Query if the optional TLM marker segment is to be added.
Definition ojph_codestream.cpp:147
ojph::codestream::write_headers
void write_headers(outfile_base *file, const comment_exchange *comments=NULL, ui32 num_comments=0)
Writes codestream headers when the codestream is used for writing. This function should be called aft...
Definition ojph_codestream.cpp:159
ojph::codestream::create
void create()
This call is for a decoding (or reading) codestream. Call this function after calling restrict_input_...
Definition ojph_codestream.cpp:187
ojph::codestream::access_nlt
param_nlt access_nlt()
Returns the underlying NLT marker segment object.
Definition ojph_codestream.cpp:97
ojph::codestream::is_planar
bool is_planar() const
Query if the codestream extraction is planar or not. See the documentation for ojph::codestream::set_...
Definition ojph_codestream.cpp:153
ojph::codestream::flush
void flush()
This is the last call to a writing (encoding) codestream. This will write encoded bitstream data to t...
Definition ojph_codestream.cpp:200
ojph::codestream::restart
void restart()
Restarts the codestream.
Definition ojph_codestream.cpp:72
ojph::codestream::pull
line_buf * pull(ui32 &comp_num)
This call is to pull one row from the codestream, being decoded. The returned line_buf object holds o...
Definition ojph_codestream.cpp:193
ojph::comment_exchange
Definition ojph_params.h:291
ojph::infile_base
Definition ojph_file.h:267
ojph::line_buf
Definition ojph_mem.h:161
ojph::local::codestream
Definition ojph_codestream_local.h:69
ojph::outfile_base
Definition ojph_file.h:75
ojph::param_cod
Definition ojph_params.h:104
ojph::param_nlt
non-linearity point transformation object (implements NLT marker segment)
Definition ojph_params.h:245
ojph::param_qcd
Quantization parameters object.
Definition ojph_params.h:163
ojph::param_siz
Definition ojph_params.h:71
ojph
Definition ojph_img_io.h:52
ojph::OJPH_TILEPART_RESOLUTIONS
@ OJPH_TILEPART_RESOLUTIONS
Definition ojph_params_local.h:100
ojph::OJPH_TILEPART_COMPONENTS
@ OJPH_TILEPART_COMPONENTS
Definition ojph_params_local.h:101
ojph::ui32
uint32_t ui32
Definition ojph_defs.h:54
ojph_codestream.h
ojph_codestream_local.h
ojph_mem.h
ojph_params.h