OpenJPH
Open-source implementation of JPEG2000 Part-15
Loading...
Searching...
No Matches
ojph_codestream_local.h
Go to the documentation of this file.
1//***************************************************************************/
2// This software is released under the 2-Clause BSD license, included
3// below.
4//
5// Copyright (c) 2019, Aous Naman
6// Copyright (c) 2019, Kakadu Software Pty Ltd, Australia
7// Copyright (c) 2019, The University of New South Wales, Australia
8//
9// Redistribution and use in source and binary forms, with or without
10// modification, are permitted provided that the following conditions are
11// met:
12//
13// 1. Redistributions of source code must retain the above copyright
14// notice, this list of conditions and the following disclaimer.
15//
16// 2. Redistributions in binary form must reproduce the above copyright
17// notice, this list of conditions and the following disclaimer in the
18// documentation and/or other materials provided with the distribution.
19//
20// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
21// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
26// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31//***************************************************************************/
32// This file is part of the OpenJPH software implementation.
33// File: ojph_codestream_local.h
34// Author: Aous Naman
35// Date: 28 August 2019
36//***************************************************************************/
37
38
39#ifndef OJPH_CODESTREAM_LOCAL_H
40#define OJPH_CODESTREAM_LOCAL_H
41
42#include "ojph_defs.h"
43#include "ojph_params_local.h"
44
45namespace ojph {
46
48 //defined elsewhere
49 class line_buf;
50 class mem_fixed_allocator;
51 class mem_elastic_allocator;
52 class codestream;
53
54 namespace local {
55
57 static inline
59 {
60 return (ui16)((t << 8) | (t >> 8));
61 }
62
64 //defined elsewhere
65 class tile;
66
69 {
70 friend ::ojph::codestream;
71
72 public:
73 codestream();
75
76 void pre_alloc();
77 void finalize_alloc();
78
79 ojph::param_siz access_siz() //return externally wrapped siz
80 { return ojph::param_siz(&siz); }
81 const param_siz* get_siz() //return internal siz
82 { return &siz; }
83 ojph::param_cod access_cod() //return externally wrapped cod
84 { return ojph::param_cod(&cod); }
85 const param_cod* get_cod() //return internal cod
86 { return &cod; }
87 const param_cod* get_cod(ui32 comp_num) //return internal cod
88 { return cod.get_cod(comp_num); }
90 {
91 if (used_qcc_fields > 0)
92 for (int v = 0; v < used_qcc_fields; ++v)
93 if (qcc[v].get_comp_num() == comp_num)
94 return qcc + v;
95 return &qcd;
96 }
98 { if (dfs.exists()) return &dfs; else return NULL; }
100 { return &nlt; }
104
105 line_buf* exchange(line_buf* line, ui32& next_component);
106 void write_headers(outfile_base *file, const comment_exchange* comments,
107 ui32 num_comments);
108 void enable_resilience();
109 bool is_resilient() { return resilient; }
110 void read_headers(infile_base *file);
111 void restrict_input_resolution(ui32 skipped_res_for_data,
113 void read();
114 void set_planar(int planar);
115 void set_profile(const char *s);
116 void set_tilepart_divisions(ui32 value);
117 void request_tlm_marker(bool needed);
118 line_buf* pull(ui32 &comp_num);
119 void flush();
120 void close();
121
122 bool is_planar() const { return planar != 0; }
123 si32 get_profile() const { return profile; };
124 ui32 get_tilepart_div() const { return tilepart_div; };
125 bool is_tlm_needed() const { return need_tlm; };
126
127 void check_imf_validity();
129
135
136 private:
139
140 private:
146
147 private:
152 size *comp_size; //stores full resolution no. of lines and width
153 size *recon_comp_size; //stores number of lines and width of each comp
157 ui32 tilepart_div; // tilepart division value
158 bool need_tlm; // true if tlm markers are needed
159
160 private:
161 param_siz siz; // image and tile size
162 param_cod cod; // coding style default
163 param_cap cap; // extended capabilities
164 param_qcd qcd; // quantization default
165 param_tlm tlm; // tile-part lengths
166 param_nlt nlt; // non-linearity point transformation
167
168 private: // this is to handle qcc and coc
170 param_qcc *qcc; // quantization component
171 param_qcc qcc_store[4]; // we allocate 4, we allocate more if needed
173 param_cod *coc; // coding style component
174 param_cod coc_store[4]; // we allocate 4, we allocate more if needed
175
176 private: // these are from Part 2 of the standard
177 param_dfs dfs; // downsmapling factor styles
178 param_atk* atk; // a pointer to atk
179 param_atk atk_store[3];// 0 and 1 are for DWT from Part 1, 2 onward are
180 // for arbitrary transformation kernels
181
182
183 private:
188 };
189
190 }
191}
192
193#endif // !OJPH_CODESTREAM_LOCAL_H
param_qcd * access_qcd(ui32 comp_num)
mem_elastic_allocator * get_elastic_alloc()
line_buf * exchange(line_buf *line, ui32 &next_component)
mem_fixed_allocator * get_allocator()
void restrict_input_resolution(ui32 skipped_res_for_data, ui32 skipped_res_for_recon)
mem_elastic_allocator * elastic_alloc
const param_dfs * access_dfs()
mem_fixed_allocator * allocator
void write_headers(outfile_base *file, const comment_exchange *comments, ui32 num_comments)
void read_headers(infile_base *file)
const param_cod * get_cod(ui32 comp_num)
line_buf * pull(ui32 &comp_num)
static ui16 swap_byte(ui16 t)
uint16_t ui16
Definition ojph_defs.h:52
int32_t si32
Definition ojph_defs.h:55
uint32_t ui32
Definition ojph_defs.h:54
uint8_t ui8
Definition ojph_defs.h:50
const param_cod * get_cod(ui32 comp_num) const