OpenJPH
Open-source implementation of JPEG2000 Part-15
Loading...
Searching...
No Matches
ojph_params.cpp
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_params.cpp
34// Author: Aous Naman
35// Date: 28 August 2019
36//***************************************************************************/
37
38#define _USE_MATH_DEFINES
39#include <cmath>
40
41#include "ojph_base.h"
42#include "ojph_file.h"
43#include "ojph_params.h"
44
45#include "ojph_params_local.h"
46#include "ojph_message.h"
47
48namespace ojph {
49
51 //
52 //
53 //
54 //
55 //
57
60 {
61 state->Xsiz = dims.x;
62 state->Ysiz = dims.y;
63 }
64
67 {
68 state->XTsiz = s.w;
69 state->YTsiz = s.h;
70 }
71
74 { // WARNING need to check if these are valid
75 state->XOsiz = offset.x;
76 state->YOsiz = offset.y;
77 }
78
81 { // WARNING need to check if these are valid
82 state->XTOsiz = offset.x;
83 state->YTOsiz = offset.y;
84 }
85
88 {
89 state->set_num_components(num_comps);
90 }
91
93 void param_siz::set_component(ui32 comp_num, const point& downsampling,
94 ui32 bit_depth, bool is_signed)
95 {
96 state->set_comp_info(comp_num, downsampling, bit_depth, is_signed);
97 }
98
101 {
102 return point(state->Xsiz, state->Ysiz);
103 }
104
107 {
108 return point(state->XOsiz, state->YOsiz);
109 }
110
113 {
114 return size(state->XTsiz, state->YTsiz);
115 }
116
119 {
120 return point(state->XTOsiz, state->YTOsiz);
121 }
122
125 {
126 return state->Csiz;
127 }
128
131 {
132 return state->get_bit_depth(comp_num);
133 }
134
136 bool param_siz::is_signed(ui32 comp_num) const
137 {
138 return state->is_signed(comp_num);
139 }
140
143 {
144 return state->get_downsampling(comp_num);
145 }
146
149 {
150 return state->get_recon_width(comp_num);
151 }
152
155 {
156 return state->get_recon_height(comp_num);
157 }
158
160 //
161 //
162 //
163 //
164 //
166
168 void param_cod::set_num_decomposition(ui32 num_decompositions)
169 {
170 if (num_decompositions > 32)
171 OJPH_ERROR(0x00050001,
172 "maximum number of decompositions cannot exceed 32");
173 state->SPcod.num_decomp = (ui8)num_decompositions;
174 }
175
178 {
179 ui32 log_width = 31 - count_leading_zeros(width);
180 ui32 log_height = 31 - count_leading_zeros(height);
181 if (width == 0 || width != (1u << log_width)
182 || height == 0 || height != (1u << log_height)
183 || log_width < 2 || log_height < 2
184 || log_width + log_height > 12)
185 OJPH_ERROR(0x00050011, "incorrect code block dimensions");
186 state->SPcod.block_width = (ui8)(log_width - 2);
187 state->SPcod.block_height = (ui8)(log_height - 2);
188 }
189
191 void param_cod::set_precinct_size(int num_levels, size* precinct_size)
192 {
193 if (num_levels == 0 || precinct_size == NULL)
194 state->Scod &= 0xFE;
195 else
196 {
197 state->Scod |= 1;
198 for (int i = 0; i <= state->SPcod.num_decomp; ++i)
199 {
200 size t = precinct_size[i < num_levels ? i : num_levels - 1];
201
202 ui32 PPx = 31 - count_leading_zeros(t.w);
203 ui32 PPy = 31 - count_leading_zeros(t.h);
204 if (t.w == 0 || t.h == 0)
205 OJPH_ERROR(0x00050021, "precinct width or height cannot be 0");
206 if (t.w != (1u<<PPx) || t.h != (1u<<PPy))
207 OJPH_ERROR(0x00050022,
208 "precinct width and height should be a power of 2");
209 if (PPx > 15 || PPy > 15)
210 OJPH_ERROR(0x00050023, "precinct size is too large");
211 if (i > 0 && (PPx == 0 || PPy == 0))
212 OJPH_ERROR(0x00050024, "precinct size is too small");
213 state->SPcod.precinct_size[i] = (ui8)(PPx | (PPy << 4));
214 }
215 }
216 }
217
219 void param_cod::set_progression_order(const char *name)
220 {
221 int prog_order = 0;
222 size_t len = strlen(name);
223 if (len == 4)
224 {
225 if (strncmp(name, OJPH_PO_STRING_LRCP, 4) == 0)
226 prog_order = OJPH_PO_LRCP;
227 else if (strncmp(name, OJPH_PO_STRING_RLCP, 4) == 0)
228 prog_order = OJPH_PO_RLCP;
229 else if (strncmp(name, OJPH_PO_STRING_RPCL, 4) == 0)
230 prog_order = OJPH_PO_RPCL;
231 else if (strncmp(name, OJPH_PO_STRING_PCRL, 4) == 0)
232 prog_order = OJPH_PO_PCRL;
233 else if (strncmp(name, OJPH_PO_STRING_CPRL, 4) == 0)
234 prog_order = OJPH_PO_CPRL;
235 else
236 OJPH_ERROR(0x00050031, "unknown progression order");
237 }
238 else
239 OJPH_ERROR(0x00050032, "improper progression order");
240
241
242 state->SGCod.prog_order = (ui8)prog_order;
243 }
244
246 void param_cod::set_color_transform(bool color_transform)
247 {
248 state->employ_color_transform(color_transform ? 1 : 0);
249 }
250
252 void param_cod::set_reversible(bool reversible)
253 {
254 state->set_reversible(reversible);
255 }
256
262
265 {
266 return state->get_block_dims();
267 }
268
271 {
272 return state->get_log_block_dims();
273 }
274
277 {
278 return state->is_reversible();
279 }
280
283 {
284 return state->get_precinct_size(level_num);
285 }
286
289 {
290 return state->get_log_precinct_size(level_num);
291 }
292
295 {
296 return state->SGCod.prog_order;
297 }
298
301 {
303 return OJPH_PO_STRING_LRCP;
304 else if (state->SGCod.prog_order == OJPH_PO_RLCP)
305 return OJPH_PO_STRING_RLCP;
306 else if (state->SGCod.prog_order == OJPH_PO_RPCL)
307 return OJPH_PO_STRING_RPCL;
308 else if (state->SGCod.prog_order == OJPH_PO_PCRL)
309 return OJPH_PO_STRING_PCRL;
310 else if (state->SGCod.prog_order == OJPH_PO_CPRL)
311 return OJPH_PO_STRING_CPRL;
312 else
313 assert(0);
314 return "";
315 }
316
319 {
320 return state->SGCod.num_layers;
321 }
322
328
331 {
332 return state->packets_may_use_sop();
333 }
334
337 {
338 return state->packets_use_eph();
339 }
340
346
347
349 //
350 //
351 //
352 //
353 //
355
358 {
359 state->set_delta(delta);
360 }
361
363 //
364 //
365 // LOCAL
366 //
367 //
369
370 namespace local {
371
373 static inline
375 {
376 return (ui16)((t << 8) | (t >> 8));
377 }
378
380 static inline
382 {
383 ui32 u = swap_byte((ui16)(t & 0xFFFFu));
384 u <<= 16;
385 u |= swap_byte((ui16)(t >> 16));
386 return u;
387 }
388
390 //
391 //
392 //
393 //
394 //
396
398 //static
400 {
401 public:
402 static float get_gain_l(ui32 num_decomp, bool reversible)
403 { return reversible ? gain_5x3_l[num_decomp] : gain_9x7_l[num_decomp]; }
404 static float get_gain_h(ui32 num_decomp, bool reversible)
405 { return reversible ? gain_5x3_h[num_decomp] : gain_9x7_h[num_decomp]; }
406
407 private:
408 static const float gain_9x7_l[34];
409 static const float gain_9x7_h[34];
410 static const float gain_5x3_l[34];
411 static const float gain_5x3_h[34];
412 };
413
415 const float sqrt_energy_gains::gain_9x7_l[34] = { 1.0000e+00f,
416 1.4021e+00f, 2.0304e+00f, 2.9012e+00f, 4.1153e+00f, 5.8245e+00f,
417 8.2388e+00f, 1.1652e+01f, 1.6479e+01f, 2.3304e+01f, 3.2957e+01f,
418 4.6609e+01f, 6.5915e+01f, 9.3217e+01f, 1.3183e+02f, 1.8643e+02f,
419 2.6366e+02f, 3.7287e+02f, 5.2732e+02f, 7.4574e+02f, 1.0546e+03f,
420 1.4915e+03f, 2.1093e+03f, 2.9830e+03f, 4.2185e+03f, 5.9659e+03f,
421 8.4371e+03f, 1.1932e+04f, 1.6874e+04f, 2.3864e+04f, 3.3748e+04f,
422 4.7727e+04f, 6.7496e+04f, 9.5454e+04f };
423 const float sqrt_energy_gains::gain_9x7_h[34] = { 1.4425e+00f,
424 1.9669e+00f, 2.8839e+00f, 4.1475e+00f, 5.8946e+00f, 8.3472e+00f,
425 1.1809e+01f, 1.6701e+01f, 2.3620e+01f, 3.3403e+01f, 4.7240e+01f,
426 6.6807e+01f, 9.4479e+01f, 1.3361e+02f, 1.8896e+02f, 2.6723e+02f,
427 3.7792e+02f, 5.3446e+02f, 7.5583e+02f, 1.0689e+03f, 1.5117e+03f,
428 2.1378e+03f, 3.0233e+03f, 4.2756e+03f, 6.0467e+03f, 8.5513e+03f,
429 1.2093e+04f, 1.7103e+04f, 2.4187e+04f, 3.4205e+04f, 4.8373e+04f,
430 6.8410e+04f, 9.6747e+04f, 1.3682e+05f };
431 const float sqrt_energy_gains::gain_5x3_l[34] = { 1.0000e+00f,
432 1.2247e+00f, 1.3229e+00f, 1.5411e+00f, 1.7139e+00f, 1.9605e+00f,
433 2.2044e+00f, 2.5047e+00f, 2.8277e+00f, 3.2049e+00f, 3.6238e+00f,
434 4.1033e+00f, 4.6423e+00f, 5.2548e+00f, 5.9462e+00f, 6.7299e+00f,
435 7.6159e+00f, 8.6193e+00f, 9.7544e+00f, 1.1039e+01f, 1.2493e+01f,
436 1.4139e+01f, 1.6001e+01f, 1.8108e+01f, 2.0493e+01f, 2.3192e+01f,
437 2.6246e+01f, 2.9702e+01f, 3.3614e+01f, 3.8041e+01f, 4.3051e+01f,
438 4.8721e+01f, 5.5138e+01f, 6.2399e+01f };
439 const float sqrt_energy_gains::gain_5x3_h[34] = { 1.0458e+00f,
440 1.3975e+00f, 1.4389e+00f, 1.7287e+00f, 1.8880e+00f, 2.1841e+00f,
441 2.4392e+00f, 2.7830e+00f, 3.1341e+00f, 3.5576e+00f, 4.0188e+00f,
442 4.5532e+00f, 5.1494e+00f, 5.8301e+00f, 6.5963e+00f, 7.4663e+00f,
443 8.4489e+00f, 9.5623e+00f, 1.0821e+01f, 1.2247e+01f, 1.3860e+01f,
444 1.5685e+01f, 1.7751e+01f, 2.0089e+01f, 2.2735e+01f, 2.5729e+01f,
445 2.9117e+01f, 3.2952e+01f, 3.7292e+01f, 4.2203e+01f, 4.7761e+01f,
446 5.4051e+01f, 6.1170e+01f, 6.9226e+01f };
447
449 //static
451 {
452 public:
453 static float get_bibo_gain_l(ui32 num_decomp, bool reversible)
454 { return reversible ? gain_5x3_l[num_decomp] : gain_9x7_l[num_decomp]; }
455 static float get_bibo_gain_h(ui32 num_decomp, bool reversible)
456 { return reversible ? gain_5x3_h[num_decomp] : gain_9x7_h[num_decomp]; }
457
458 private:
459 static const float gain_9x7_l[34];
460 static const float gain_9x7_h[34];
461 static const float gain_5x3_l[34];
462 static const float gain_5x3_h[34];
463 };
464
466 const float bibo_gains::gain_9x7_l[34] = { 1.0000e+00f, 1.3803e+00f,
467 1.3328e+00f, 1.3067e+00f, 1.3028e+00f, 1.3001e+00f, 1.2993e+00f,
468 1.2992e+00f, 1.2992e+00f, 1.2992e+00f, 1.2992e+00f, 1.2992e+00f,
469 1.2992e+00f, 1.2992e+00f, 1.2992e+00f, 1.2992e+00f, 1.2992e+00f,
470 1.2992e+00f, 1.2992e+00f, 1.2992e+00f, 1.2992e+00f, 1.2992e+00f,
471 1.2992e+00f, 1.2992e+00f, 1.2992e+00f, 1.2992e+00f, 1.2992e+00f,
472 1.2992e+00f, 1.2992e+00f, 1.2992e+00f, 1.2992e+00f, 1.2992e+00f,
473 1.2992e+00f, 1.2992e+00f };
474 const float bibo_gains::gain_9x7_h[34] = { 1.2976e+00f, 1.3126e+00f,
475 1.2757e+00f, 1.2352e+00f, 1.2312e+00f, 1.2285e+00f, 1.2280e+00f,
476 1.2278e+00f, 1.2278e+00f, 1.2278e+00f, 1.2278e+00f, 1.2278e+00f,
477 1.2278e+00f, 1.2278e+00f, 1.2278e+00f, 1.2278e+00f, 1.2278e+00f,
478 1.2278e+00f, 1.2278e+00f, 1.2278e+00f, 1.2278e+00f, 1.2278e+00f,
479 1.2278e+00f, 1.2278e+00f, 1.2278e+00f, 1.2278e+00f, 1.2278e+00f,
480 1.2278e+00f, 1.2278e+00f, 1.2278e+00f, 1.2278e+00f, 1.2278e+00f,
481 1.2278e+00f, 1.2278e+00f };
482 const float bibo_gains::gain_5x3_l[34] = { 1.0000e+00f, 1.5000e+00f,
483 1.6250e+00f, 1.6875e+00f, 1.6963e+00f, 1.7067e+00f, 1.7116e+00f,
484 1.7129e+00f, 1.7141e+00f, 1.7145e+00f, 1.7151e+00f, 1.7152e+00f,
485 1.7155e+00f, 1.7155e+00f, 1.7156e+00f, 1.7156e+00f, 1.7156e+00f,
486 1.7156e+00f, 1.7156e+00f, 1.7156e+00f, 1.7156e+00f, 1.7156e+00f,
487 1.7156e+00f, 1.7156e+00f, 1.7156e+00f, 1.7156e+00f, 1.7156e+00f,
488 1.7156e+00f, 1.7156e+00f, 1.7156e+00f, 1.7156e+00f, 1.7156e+00f,
489 1.7156e+00f, 1.7156e+00f };
490 const float bibo_gains::gain_5x3_h[34] = { 2.0000e+00f, 2.5000e+00f,
491 2.7500e+00f, 2.8047e+00f, 2.8198e+00f, 2.8410e+00f, 2.8558e+00f,
492 2.8601e+00f, 2.8628e+00f, 2.8656e+00f, 2.8662e+00f, 2.8667e+00f,
493 2.8669e+00f, 2.8670e+00f, 2.8671e+00f, 2.8671e+00f, 2.8671e+00f,
494 2.8671e+00f, 2.8671e+00f, 2.8671e+00f, 2.8671e+00f, 2.8671e+00f,
495 2.8671e+00f, 2.8671e+00f, 2.8671e+00f, 2.8671e+00f, 2.8671e+00f,
496 2.8671e+00f, 2.8671e+00f, 2.8671e+00f, 2.8671e+00f, 2.8671e+00f,
497 2.8671e+00f, 2.8671e+00f };
498
499
501 //
502 //
503 //
504 //
505 //
507
510 {
511 //marker size excluding header
512 Lsiz = (ui16)(38 + 3 * Csiz);
513
514 ui8 buf[4];
515 bool result = true;
516
517 *(ui16*)buf = JP2K_MARKER::SIZ;
518 *(ui16*)buf = swap_byte(*(ui16*)buf);
519 result &= file->write(&buf, 2) == 2;
520 *(ui16*)buf = swap_byte(Lsiz);
521 result &= file->write(&buf, 2) == 2;
522 *(ui16*)buf = swap_byte(Rsiz);
523 result &= file->write(&buf, 2) == 2;
524 *(ui32*)buf = swap_byte(Xsiz);
525 result &= file->write(&buf, 4) == 4;
526 *(ui32*)buf = swap_byte(Ysiz);
527 result &= file->write(&buf, 4) == 4;
528 *(ui32*)buf = swap_byte(XOsiz);
529 result &= file->write(&buf, 4) == 4;
530 *(ui32*)buf = swap_byte(YOsiz);
531 result &= file->write(&buf, 4) == 4;
532 *(ui32*)buf = swap_byte(XTsiz);
533 result &= file->write(&buf, 4) == 4;
534 *(ui32*)buf = swap_byte(YTsiz);
535 result &= file->write(&buf, 4) == 4;
536 *(ui32*)buf = swap_byte(XTOsiz);
537 result &= file->write(&buf, 4) == 4;
538 *(ui32*)buf = swap_byte(YTOsiz);
539 result &= file->write(&buf, 4) == 4;
540 *(ui16*)buf = swap_byte(Csiz);
541 result &= file->write(&buf, 2) == 2;
542 for (int c = 0; c < Csiz; ++c)
543 {
544 buf[0] = cptr[c].SSiz;
545 buf[1] = cptr[c].XRsiz;
546 buf[2] = cptr[c].YRsiz;
547 result &= file->write(&buf, 3) == 3;
548 }
549
550 return result;
551 }
552
555 {
556 if (file->read(&Lsiz, 2) != 2)
557 OJPH_ERROR(0x00050041, "error reading SIZ marker");
559 int num_comps = (Lsiz - 38) / 3;
560 if (Lsiz != 38 + 3 * num_comps)
561 OJPH_ERROR(0x00050042, "error in SIZ marker length");
562 if (file->read(&Rsiz, 2) != 2)
563 OJPH_ERROR(0x00050043, "error reading SIZ marker");
565 if ((Rsiz & 0x4000) == 0)
566 OJPH_ERROR(0x00050044, "Rsiz bit 14 not set (this is not a JPH file)");
567 if (Rsiz & 0xBFFF)
568 OJPH_WARN(0x00050001, "Rsiz in SIZ has unimplemented fields");
569 if (file->read(&Xsiz, 4) != 4)
570 OJPH_ERROR(0x00050045, "error reading SIZ marker");
572 if (file->read(&Ysiz, 4) != 4)
573 OJPH_ERROR(0x00050046, "error reading SIZ marker");
575 if (file->read(&XOsiz, 4) != 4)
576 OJPH_ERROR(0x00050047, "error reading SIZ marker");
578 if (file->read(&YOsiz, 4) != 4)
579 OJPH_ERROR(0x00050048, "error reading SIZ marker");
581 if (file->read(&XTsiz, 4) != 4)
582 OJPH_ERROR(0x00050049, "error reading SIZ marker");
584 if (file->read(&YTsiz, 4) != 4)
585 OJPH_ERROR(0x0005004A, "error reading SIZ marker");
587 if (file->read(&XTOsiz, 4) != 4)
588 OJPH_ERROR(0x0005004B, "error reading SIZ marker");
590 if (file->read(&YTOsiz, 4) != 4)
591 OJPH_ERROR(0x0005004C, "error reading SIZ marker");
593 if (file->read(&Csiz, 2) != 2)
594 OJPH_ERROR(0x0005004D, "error reading SIZ marker");
596 if (Csiz != num_comps)
597 OJPH_ERROR(0x0005004E, "Csiz does not match the SIZ marker size");
598 if (Csiz > old_Csiz)
599 {
600 if (cptr != store)
601 delete[] cptr;
602 cptr = new siz_comp_info[num_comps];
603 old_Csiz = Csiz;
604 }
605 for (int c = 0; c < Csiz; ++c)
606 {
607 if (file->read(&cptr[c].SSiz, 1) != 1)
608 OJPH_ERROR(0x00050051, "error reading SIZ marker");
609 if (file->read(&cptr[c].XRsiz, 1) != 1)
610 OJPH_ERROR(0x00050052, "error reading SIZ marker");
611 if (file->read(&cptr[c].YRsiz, 1) != 1)
612 OJPH_ERROR(0x00050053, "error reading SIZ marker");
613 }
614 }
615
617 //
618 //
619 //
620 //
621 //
623
626 {
627 //marker size excluding header
628 Lcap = 8;
629
630 char buf[4];
631 bool result = true;
632
633 *(ui16*)buf = JP2K_MARKER::CAP;
634 *(ui16*)buf = swap_byte(*(ui16*)buf);
635 result &= file->write(&buf, 2) == 2;
636 *(ui16*)buf = swap_byte(Lcap);
637 result &= file->write(&buf, 2) == 2;
638 *(ui32*)buf = swap_byte(Pcap);
639 result &= file->write(&buf, 4) == 4;
640
641 *(ui16*)buf = swap_byte(Ccap[0]);
642 result &= file->write(&buf, 2) == 2;
643
644 return result;
645 }
646
649 {
650 if (file->read(&Lcap, 2) != 2)
651 OJPH_ERROR(0x00050061, "error reading CAP marker");
653 if (file->read(&Pcap, 4) != 4)
654 OJPH_ERROR(0x00050062, "error reading CAP marker");
656 ui32 count = population_count(Pcap);
657 if (Pcap & 0xFFFDFFFF)
658 OJPH_ERROR(0x00050063,
659 "error Pcap in CAP has options that are not supported");
660 if ((Pcap & 0x00020000) == 0)
661 OJPH_ERROR(0x00050064,
662 "error Pcap should have its 15th MSB set, Pcap^15. "
663 " This is not a JPH file");
664 for (ui32 i = 0; i < count; ++i)
665 if (file->read(Ccap+i, 2) != 2)
666 OJPH_ERROR(0x00050065, "error reading CAP marker");
667 if (Lcap != 6 + 2 * count)
668 OJPH_ERROR(0x00050066, "error in CAP marker length");
669 }
670
672 //
673 //
674 //
675 //
676 //
678
681 {
682 //marker size excluding header
683 Lcod = 12;
684 Lcod = (ui16)(Lcod + (Scod & 1 ? 1 + SPcod.num_decomp : 0));
685
686 ui8 buf[4];
687 bool result = true;
688
689 *(ui16*)buf = JP2K_MARKER::COD;
690 *(ui16*)buf = swap_byte(*(ui16*)buf);
691 result &= file->write(&buf, 2) == 2;
692 *(ui16*)buf = swap_byte(Lcod);
693 result &= file->write(&buf, 2) == 2;
694 *(ui8*)buf = Scod;
695 result &= file->write(&buf, 1) == 1;
696 *(ui8*)buf = SGCod.prog_order;
697 result &= file->write(&buf, 1) == 1;
698 *(ui16*)buf = swap_byte(SGCod.num_layers);
699 result &= file->write(&buf, 2) == 2;
700 *(ui8*)buf = SGCod.mc_trans;
701 result &= file->write(&buf, 1) == 1;
702 buf[0] = SPcod.num_decomp;
703 buf[1] = SPcod.block_width;
704 buf[2] = SPcod.block_height;
705 buf[3] = SPcod.block_style;
706 result &= file->write(&buf, 4) == 4;
707 *(ui8*)buf = SPcod.wavelet_trans;
708 result &= file->write(&buf, 1) == 1;
709 if (Scod & 1)
710 for (int i = 0; i <= SPcod.num_decomp; ++i)
711 {
712 *(ui8*)buf = SPcod.precinct_size[i];
713 result &= file->write(&buf, 1) == 1;
714 }
715
716 return result;
717 }
718
721 {
722 if (file->read(&Lcod, 2) != 2)
723 OJPH_ERROR(0x00050071, "error reading COD marker");
725 if (file->read(&Scod, 1) != 1)
726 OJPH_ERROR(0x00050072, "error reading COD marker");
727 if (file->read(&SGCod.prog_order, 1) != 1)
728 OJPH_ERROR(0x00050073, "error reading COD marker");
729 if (file->read(&SGCod.num_layers, 2) != 2)
730 OJPH_ERROR(0x00050074, "error reading COD marker");
731 if (file->read(&SGCod.mc_trans, 1) != 1)
732 OJPH_ERROR(0x00050075, "error reading COD marker");
733 if (file->read(&SPcod.num_decomp, 1) != 1)
734 OJPH_ERROR(0x00050076, "error reading COD marker");
735 if (file->read(&SPcod.block_width, 1) != 1)
736 OJPH_ERROR(0x00050077, "error reading COD marker");
737 if (file->read(&SPcod.block_height, 1) != 1)
738 OJPH_ERROR(0x00050078, "error reading COD marker");
739 if (file->read(&SPcod.block_style, 1) != 1)
740 OJPH_ERROR(0x00050079, "error reading COD marker");
741 if (file->read(&SPcod.wavelet_trans, 1) != 1)
742 OJPH_ERROR(0x0005007A, "error reading COD marker");
743 if (Scod & 1)
744 for (int i = 0; i <= SPcod.num_decomp; ++i)
745 if (file->read(&SPcod.precinct_size[i], 1) != 1)
746 OJPH_ERROR(0x0005007B, "error reading COD marker");
747 if (Lcod != 12 + ((Scod & 1) ? 1 + SPcod.num_decomp : 0))
748 OJPH_ERROR(0x0005007C, "error in COD marker length");
749 }
750
752 //
753 //
754 //
755 //
756 //
758
761 bool is_employing_color_transform)
762 {
763 int guard_bits = 1;
764 Sqcd = (ui8)(guard_bits << 5); //one guard bit, and no quantization
765 ui32 B = bit_depth;
766 B += is_employing_color_transform ? 1 : 0; //1 bit for RCT
767 int s = 0;
768 float bibo_l = bibo_gains::get_bibo_gain_l(num_decomps, true);
769 //we leave some leeway for numerical error by multiplying by 1.1f
770 ui32 X = (ui32) ceil(log(bibo_l * bibo_l * 1.1f) / M_LN2);
771 u8_SPqcd[s++] = (ui8)((B + X) << 3);
772 for (ui32 d = num_decomps; d > 0; --d)
773 {
774 float bibo_l = bibo_gains::get_bibo_gain_l(d, true);
775 float bibo_h = bibo_gains::get_bibo_gain_h(d - 1, true);
776 X = (ui32) ceil(log(bibo_h * bibo_l * 1.1f) / M_LN2);
777 u8_SPqcd[s++] = (ui8)((B + X) << 3);
778 u8_SPqcd[s++] = (ui8)((B + X) << 3);
779 X = (ui32) ceil(log(bibo_h * bibo_h * 1.1f) / M_LN2);
780 u8_SPqcd[s++] = (ui8)((B + X) << 3);
781 }
782 }
783
786 {
787 int guard_bits = 1;
788 Sqcd = (ui8)((guard_bits<<5)|0x2);//one guard bit, scalar quantization
789 int s = 0;
790 float gain_l = sqrt_energy_gains::get_gain_l(num_decomps, false);
791 float delta_b = base_delta / (gain_l * gain_l);
792 int exp = 0, mantissa;
793 while (delta_b < 1.0f)
794 { exp++; delta_b *= 2.0f; }
795 //with rounding, there is a risk of becoming equal to 1<<12
796 // but that should not happen in reality
797 mantissa = (int)round(delta_b * (float)(1<<11)) - (1<<11);
798 mantissa = mantissa < (1<<11) ? mantissa : 0x7FF;
799 u16_SPqcd[s++] = (ui16)((exp << 11) | mantissa);
800 for (ui32 d = num_decomps; d > 0; --d)
801 {
802 float gain_l = sqrt_energy_gains::get_gain_l(d, false);
803 float gain_h = sqrt_energy_gains::get_gain_h(d - 1, false);
804
805 delta_b = base_delta / (gain_l * gain_h);
806
807 int exp = 0, mantissa;
808 while (delta_b < 1.0f)
809 { exp++; delta_b *= 2.0f; }
810 mantissa = (int)round(delta_b * (float)(1<<11)) - (1<<11);
811 mantissa = mantissa < (1<<11) ? mantissa : 0x7FF;
812 u16_SPqcd[s++] = (ui16)((exp << 11) | mantissa);
813 u16_SPqcd[s++] = (ui16)((exp << 11) | mantissa);
814
815 delta_b = base_delta / (gain_h * gain_h);
816
817 exp = 0;
818 while (delta_b < 1)
819 { exp++; delta_b *= 2.0f; }
820 mantissa = (int)round(delta_b * (float)(1<<11)) - (1<<11);
821 mantissa = mantissa < (1<<11) ? mantissa : 0x7FF;
822 u16_SPqcd[s++] = (ui16)((exp << 11) | mantissa);
823 }
824 }
825
828 { //this can be written better, but it is only executed once
829 ui32 B = 0;
830 int irrev = Sqcd & 0x1F;
831 if (irrev == 0) //reversible
832 for (ui32 i = 0; i < 3 * num_decomps + 1; ++i)
833 B = ojph_max(B, (u8_SPqcd[i] >> 3) + get_num_guard_bits() - 1u);
834 else if (irrev == 2) //scalar expounded
835 for (ui32 i = 0; i < 3 * num_decomps + 1; ++i)
836 {
837 ui32 nb = num_decomps - (i ? (i - 1) / 3 : 0); //decompsition level
838 B = ojph_max(B, (u16_SPqcd[i] >> 11) + get_num_guard_bits() - nb);
839 }
840 else
841 assert(0);
842
843 return B;
844 }
845
848 {
849 assert((resolution == 0 && subband == 0) ||
850 (resolution <= num_decomps && subband > 0 && subband<4));
851 assert((Sqcd & 0x1F) == 2);
852 float arr[] = { 1.0f, 2.0f, 2.0f, 4.0f };
853
854 ui32 idx = resolution == 0 ? 0 : (resolution - 1) * 3 + subband;
855 int eps = u16_SPqcd[idx] >> 11;
856 float mantissa;
857 mantissa = (float)((u16_SPqcd[idx] & 0x7FF) | 0x800) * arr[subband];
858 mantissa /= (float)(1 << 11);
859 mantissa /= (float)(1u << eps);
860 return mantissa;
861 }
862
865 {
866 return (Sqcd >> 5);
867 }
868
871 {
872 assert((resolution == 0 && subband == 0) ||
874 ui32 num_bits = get_num_guard_bits();
875 ui32 idx = resolution == 0 ? 0 : (resolution - 1) * 3 + subband;
876 int irrev = Sqcd & 0x1F;
877 if (irrev == 0) //reversible; this is (10.22) from the J2K book
878 {
879 num_bits += u8_SPqcd[idx] >> 3;
880 num_bits = num_bits == 0 ? 0 : num_bits - 1;
881 }
882 else if (irrev == 1)
883 assert(0);
884 else if (irrev == 2) //scalar expounded
885 num_bits += (u16_SPqcd[idx] >> 11) - 1;
886 else
887 assert(0);
888
889 return num_bits;
890 }
891
894 {
895 int irrev = Sqcd & 0x1F;
896 ui32 num_subbands = 1 + 3 * num_decomps;
897
898 //marker size excluding header
899 Lqcd = 3;
900 if (irrev == 0)
901 Lqcd = (ui16)(Lqcd + num_subbands);
902 else if (irrev == 2)
903 Lqcd = (ui16)(Lqcd + 2 * num_subbands);
904 else
905 assert(0);
906
907 char buf[4];
908 bool result = true;
909
910 *(ui16*)buf = JP2K_MARKER::QCD;
911 *(ui16*)buf = swap_byte(*(ui16*)buf);
912 result &= file->write(&buf, 2) == 2;
913 *(ui16*)buf = swap_byte(Lqcd);
914 result &= file->write(&buf, 2) == 2;
915 *(ui8*)buf = Sqcd;
916 result &= file->write(&buf, 1) == 1;
917
918 if (irrev == 0)
919 for (ui32 i = 0; i < num_subbands; ++i)
920 {
921 *(ui8*)buf = u8_SPqcd[i];
922 result &= file->write(&buf, 1) == 1;
923 }
924 else if (irrev == 2)
925 for (ui32 i = 0; i < num_subbands; ++i)
926 {
927 *(ui16*)buf = swap_byte(u16_SPqcd[i]);
928 result &= file->write(&buf, 2) == 2;
929 }
930 else
931 assert(0);
932
933
934 return result;
935 }
938 {
939 if (file->read(&Lqcd, 2) != 2)
940 OJPH_ERROR(0x00050081, "error reading QCD marker");
942 if (file->read(&Sqcd, 1) != 1)
943 OJPH_ERROR(0x00050082, "error reading QCD marker");
944 if ((Sqcd & 0x1F) == 0)
945 {
946 num_decomps = (Lqcd - 4) / 3;
947 if (Lqcd != 4 + 3 * num_decomps)
948 OJPH_ERROR(0x00050083, "wrong Lqcd value in QCD marker");
949 for (ui32 i = 0; i < 1 + 3 * num_decomps; ++i)
950 if (file->read(&u8_SPqcd[i], 1) != 1)
951 OJPH_ERROR(0x00050084, "error reading QCD marker");
952 }
953 else if ((Sqcd & 0x1F) == 1)
954 {
955 num_decomps = 0;
956 OJPH_ERROR(0x00050089,
957 "Scalar derived quantization is not supported yet in QCD marker");
958 if (Lqcd != 5)
959 OJPH_ERROR(0x00050085, "wrong Lqcd value in QCD marker");
960 }
961 else if ((Sqcd & 0x1F) == 2)
962 {
963 num_decomps = (Lqcd - 5) / 6;
964 if (Lqcd != 5 + 6 * num_decomps)
965 OJPH_ERROR(0x00050086, "wrong Lqcd value in QCD marker");
966 for (ui32 i = 0; i < 1 + 3 * num_decomps; ++i)
967 {
968 if (file->read(&u16_SPqcd[i], 2) != 2)
969 OJPH_ERROR(0x00050087, "error reading QCD marker");
971 }
972 }
973 else
974 OJPH_ERROR(0x00050088, "wrong Sqcd value in QCD marker");
975 }
976
978 //
979 //
980 //
981 //
982 //
984
986 void param_qcc::read(infile_base *file, ui32 num_comps)
987 {
988 if (file->read(&Lqcd, 2) != 2)
989 OJPH_ERROR(0x000500A1, "error reading QCC marker");
991 if (num_comps < 257)
992 {
993 ui8 v;
994 if (file->read(&v, 1) != 1)
995 OJPH_ERROR(0x000500A2, "error reading QCC marker");
996 comp_idx = v;
997 }
998 else
999 {
1000 if (file->read(&comp_idx, 2) != 2)
1001 OJPH_ERROR(0x000500A3, "error reading QCC marker");
1003 }
1004 if (file->read(&Sqcd, 1) != 1)
1005 OJPH_ERROR(0x000500A4, "error reading QCC marker");
1006 if ((Sqcd & 0x1F) == 0)
1007 {
1008 ui32 offset = num_comps < 257 ? 5 : 6;
1009 num_decomps = (Lqcd - offset) / 3;
1010 if (Lqcd != offset + 3 * num_decomps)
1011 OJPH_ERROR(0x000500A5, "wrong Lqcd value in QCC marker");
1012 for (ui32 i = 0; i < 1 + 3 * num_decomps; ++i)
1013 if (file->read(&u8_SPqcd[i], 1) != 1)
1014 OJPH_ERROR(0x000500A6, "error reading QCC marker");
1015 }
1016 else if ((Sqcd & 0x1F) == 1)
1017 {
1018 ui32 offset = num_comps < 257 ? 6 : 7;
1019 num_decomps = 0;
1020 OJPH_ERROR(0x000500AB,
1021 "Scalar derived quantization is not supported yet in QCC marker");
1022 if (Lqcd != offset)
1023 OJPH_ERROR(0x000500A7, "wrong Lqcc value in QCC marker");
1024 }
1025 else if ((Sqcd & 0x1F) == 2)
1026 {
1027 ui32 offset = num_comps < 257 ? 6 : 7;
1028 num_decomps = (Lqcd - offset) / 6;
1029 if (Lqcd != offset + 6 * num_decomps)
1030 OJPH_ERROR(0x000500A8, "wrong Lqcc value in QCC marker");
1031 for (ui32 i = 0; i < 1 + 3 * num_decomps; ++i)
1032 {
1033 if (file->read(&u16_SPqcd[i], 2) != 2)
1034 OJPH_ERROR(0x000500A9, "error reading QCC marker");
1036 }
1037 }
1038 else
1039 OJPH_ERROR(0x000500AA, "wrong Sqcc value in QCC marker");
1040 }
1041
1043 //
1044 //
1045 //
1046 //
1047 //
1049
1052 {
1053 char buf[4];
1054 bool result = true;
1055
1056 this->Psot = payload_len + 14; //inc. SOT marker, field & SOD
1057
1058 *(ui16*)buf = JP2K_MARKER::SOT;
1059 *(ui16*)buf = swap_byte(*(ui16*)buf);
1060 result &= file->write(&buf, 2) == 2;
1061 *(ui16*)buf = swap_byte(Lsot);
1062 result &= file->write(&buf, 2) == 2;
1063 *(ui16*)buf = swap_byte(Isot);
1064 result &= file->write(&buf, 2) == 2;
1065 *(ui32*)buf = swap_byte(Psot);
1066 result &= file->write(&buf, 4) == 4;
1067 *(ui8*)buf = TPsot;
1068 result &= file->write(&buf, 1) == 1;
1069 *(ui8*)buf = TNsot;
1070 result &= file->write(&buf, 1) == 1;
1071
1072 return result;
1073 }
1074
1077 ui8 TPsot, ui8 TNsot)
1078 {
1079 char buf[4];
1080 bool result = true;
1081
1082 *(ui16*)buf = JP2K_MARKER::SOT;
1083 *(ui16*)buf = swap_byte(*(ui16*)buf);
1084 result &= file->write(&buf, 2) == 2;
1085 *(ui16*)buf = swap_byte(Lsot);
1086 result &= file->write(&buf, 2) == 2;
1087 *(ui16*)buf = swap_byte(Isot);
1088 result &= file->write(&buf, 2) == 2;
1089 *(ui32*)buf = swap_byte(payload_len + 14);
1090 result &= file->write(&buf, 4) == 4;
1091 *(ui8*)buf = TPsot;
1092 result &= file->write(&buf, 1) == 1;
1093 *(ui8*)buf = TNsot;
1094 result &= file->write(&buf, 1) == 1;
1095
1096 return result;
1097 }
1098
1100 bool param_sot::read(infile_base *file, bool resilient)
1101 {
1102 if (resilient)
1103 {
1104 if (file->read(&Lsot, 2) != 2)
1105 {
1106 OJPH_INFO(0x00050091, "error reading SOT marker");
1107 Lsot = 0; Isot = 0; Psot = 0; TPsot = 0; TNsot = 0;
1108 return false;
1109 }
1110 Lsot = swap_byte(Lsot);
1111 if (Lsot != 10)
1112 {
1113 OJPH_INFO(0x00050092, "error in SOT length");
1114 Lsot = 0; Isot = 0; Psot = 0; TPsot = 0; TNsot = 0;
1115 return false;
1116 }
1117 if (file->read(&Isot, 2) != 2)
1118 {
1119 OJPH_INFO(0x00050093, "error reading tile index");
1120 Lsot = 0; Isot = 0; Psot = 0; TPsot = 0; TNsot = 0;
1121 return false;
1122 }
1123 Isot = swap_byte(Isot);
1124 if (Isot == 0xFFFF)
1125 {
1126 OJPH_INFO(0x00050094, "tile index in SOT marker cannot be 0xFFFF");
1127 Lsot = 0; Isot = 0; Psot = 0; TPsot = 0; TNsot = 0;
1128 return false;
1129 }
1130 if (file->read(&Psot, 4) != 4)
1131 {
1132 OJPH_INFO(0x00050095, "error reading SOT marker");
1133 Lsot = 0; Isot = 0; Psot = 0; TPsot = 0; TNsot = 0;
1134 return false;
1135 }
1136 Psot = swap_byte(Psot);
1137 if (file->read(&TPsot, 1) != 1)
1138 {
1139 OJPH_INFO(0x00050096, "error reading SOT marker");
1140 Lsot = 0; Isot = 0; Psot = 0; TPsot = 0; TNsot = 0;
1141 return false;
1142 }
1143 if (file->read(&TNsot, 1) != 1)
1144 {
1145 OJPH_INFO(0x00050097, "error reading SOT marker");
1146 Lsot = 0; Isot = 0; Psot = 0; TPsot = 0; TNsot = 0;
1147 return false;
1148 }
1149 }
1150 else
1151 {
1152 if (file->read(&Lsot, 2) != 2)
1153 OJPH_ERROR(0x00050091, "error reading SOT marker");
1154 Lsot = swap_byte(Lsot);
1155 if (Lsot != 10)
1156 OJPH_ERROR(0x00050092, "error in SOT length");
1157 if (file->read(&Isot, 2) != 2)
1158 OJPH_ERROR(0x00050093, "error reading SOT tile index");
1159 Isot = swap_byte(Isot);
1160 if (Isot == 0xFFFF)
1161 OJPH_ERROR(0x00050094, "tile index in SOT marker cannot be 0xFFFF");
1162 if (file->read(&Psot, 4) != 4)
1163 OJPH_ERROR(0x00050095, "error reading SOT marker");
1164 Psot = swap_byte(Psot);
1165 if (file->read(&TPsot, 1) != 1)
1166 OJPH_ERROR(0x00050096, "error reading SOT marker");
1167 if (file->read(&TNsot, 1) != 1)
1168 OJPH_ERROR(0x00050097, "error reading SOT marker");
1169 }
1170 return true;
1171 }
1172
1174 //
1175 //
1176 //
1177 //
1178 //
1180
1182 void param_tlm::init(ui32 num_pairs, Ttlm_Ptlm_pair *store)
1183 {
1184 this->num_pairs = num_pairs;
1185 pairs = (Ttlm_Ptlm_pair*)store;
1186 Ltlm = (ui16)(4 + 6 * num_pairs);
1187 Ztlm = 0;
1188 Stlm = 0x60;
1189 }
1190
1193 {
1195 pairs[next_pair_index].Ttlm = Ttlm;
1196 pairs[next_pair_index].Ptlm = Ptlm + 14;
1198 }
1199
1202 {
1204 char buf[4];
1205 bool result = true;
1206
1207 *(ui16*)buf = JP2K_MARKER::TLM;
1208 *(ui16*)buf = swap_byte(*(ui16*)buf);
1209 result &= file->write(&buf, 2) == 2;
1210 *(ui16*)buf = swap_byte(Ltlm);
1211 result &= file->write(&buf, 2) == 2;
1212 result &= file->write(&Ztlm, 1) == 1;
1213 result &= file->write(&Stlm, 1) == 1;
1214 for (ui32 i = 0; i < num_pairs; ++i)
1215 {
1216 *(ui16*)buf = swap_byte(pairs[i].Ttlm);
1217 result &= file->write(&buf, 2) == 2;
1218 *(ui32*)buf = swap_byte(pairs[i].Ptlm);
1219 result &= file->write(&buf, 4) == 4;
1220 }
1221 return result;
1222 }
1223
1224 }
1225
1226}
virtual size_t read(void *ptr, size_t size)=0
static const float gain_5x3_l[34]
static float get_bibo_gain_l(ui32 num_decomp, bool reversible)
static const float gain_5x3_h[34]
static float get_bibo_gain_h(ui32 num_decomp, bool reversible)
static const float gain_9x7_h[34]
static const float gain_9x7_l[34]
static const float gain_5x3_l[34]
static const float gain_5x3_h[34]
static float get_gain_l(ui32 num_decomp, bool reversible)
static const float gain_9x7_l[34]
static float get_gain_h(ui32 num_decomp, bool reversible)
static const float gain_9x7_h[34]
virtual size_t write(const void *ptr, size_t size)=0
OJPH_EXPORT size get_block_dims() const
OJPH_EXPORT int get_progression_order() const
OJPH_EXPORT bool is_using_color_transform() const
OJPH_EXPORT void set_num_decomposition(ui32 num_decompositions)
OJPH_EXPORT ui32 get_num_decompositions() const
OJPH_EXPORT size get_log_block_dims() const
OJPH_EXPORT bool packets_may_use_sop() const
OJPH_EXPORT size get_precinct_size(ui32 level_num) const
OJPH_EXPORT const char * get_progression_order_as_string() const
OJPH_EXPORT void set_precinct_size(int num_levels, size *precinct_size)
OJPH_EXPORT bool packets_use_eph() const
local::param_cod * state
OJPH_EXPORT bool is_reversible() const
OJPH_EXPORT void set_progression_order(const char *name)
OJPH_EXPORT bool get_block_vertical_causality() const
OJPH_EXPORT void set_block_dims(ui32 width, ui32 height)
OJPH_EXPORT size get_log_precinct_size(ui32 level_num) const
OJPH_EXPORT int get_num_layers() const
OJPH_EXPORT void set_color_transform(bool color_transform)
OJPH_EXPORT void set_reversible(bool reversible)
OJPH_EXPORT void set_irrev_quant(float delta)
local::param_qcd * state
OJPH_EXPORT void set_tile_size(size s)
OJPH_EXPORT point get_image_extent() const
OJPH_EXPORT void set_component(ui32 comp_num, const point &downsampling, ui32 bit_depth, bool is_signed)
OJPH_EXPORT void set_num_components(ui32 num_comps)
OJPH_EXPORT ui32 get_bit_depth(ui32 comp_num) const
OJPH_EXPORT void set_tile_offset(point offset)
OJPH_EXPORT point get_image_offset() const
local::param_siz * state
OJPH_EXPORT void set_image_offset(point offset)
OJPH_EXPORT size get_tile_size() const
OJPH_EXPORT ui32 get_recon_height(ui32 comp_num) const
OJPH_EXPORT point get_downsampling(ui32 comp_num) const
OJPH_EXPORT void set_image_extent(point extent)
OJPH_EXPORT point get_tile_offset() const
OJPH_EXPORT ui32 get_recon_width(ui32 comp_num) const
OJPH_EXPORT bool is_signed(ui32 comp_num) const
OJPH_EXPORT ui32 get_num_components() const
static ui16 swap_byte(ui16 t)
const char OJPH_PO_STRING_PCRL[]
uint16_t ui16
Definition ojph_defs.h:52
static ui32 population_count(ui32 val)
Definition ojph_arch.h:89
const char OJPH_PO_STRING_RLCP[]
const char OJPH_PO_STRING_RPCL[]
const char OJPH_PO_STRING_CPRL[]
static ui32 count_leading_zeros(ui32 val)
Definition ojph_arch.h:109
uint32_t ui32
Definition ojph_defs.h:54
uint8_t ui8
Definition ojph_defs.h:50
const char OJPH_PO_STRING_LRCP[]
#define ojph_max(a, b)
Definition ojph_defs.h:73
#define OJPH_INFO(t,...)
#define OJPH_ERROR(t,...)
#define OJPH_WARN(t,...)
void read(infile_base *file)
bool write(outfile_base *file)
bool write(outfile_base *file)
void set_reversible(bool reversible)
bool is_employing_color_transform() const
void employ_color_transform(ui8 val)
void read(infile_base *file)
size get_log_precinct_size(ui32 res_num) const
size get_precinct_size(ui32 res_num) const
void read(infile_base *file, ui32 num_comps)
ui32 get_Kmax(ui32 resolution, ui32 subband) const
ui32 get_num_guard_bits() const
void set_delta(float delta)
bool write(outfile_base *file)
void read(infile_base *file)
void set_rev_quant(ui32 bit_depth, bool is_employing_color_transform)
float irrev_get_delta(ui32 resolution, ui32 subband) const
ui32 get_bit_depth(ui32 comp_num) const
ui32 get_recon_height(ui32 comp_num) const
bool is_signed(ui32 comp_num) const
bool write(outfile_base *file)
void set_comp_info(ui32 comp_num, const point &downsampling, ui32 bit_depth, bool is_signed)
point get_downsampling(ui32 comp_num) const
void read(infile_base *file)
void set_num_components(ui32 num_comps)
ui32 get_recon_width(ui32 comp_num) const
bool read(infile_base *file, bool resilient)
bool write(outfile_base *file, ui32 payload_len)
void set_next_pair(ui16 Ttlm, ui32 Ptlm)
bool write(outfile_base *file)
void init(ui32 num_pairs, Ttlm_Ptlm_pair *store)