OpenJPH
Open-source implementation of JPEG2000 Part-15
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
259 {
261 }
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
325 {
327 }
328
331 {
332 return state->packets_may_use_sop();
333 }
334
337 {
338 return state->packets_use_eph();
339 }
340
343 {
345 }
346
347
349 //
350 //
351 //
352 //
353 //
355
358 {
359 state->set_delta(delta);
360 }
361
363 //
364 //
365 //
366 //
367 //
369
372 {
373 size_t t = strlen(str);
374 if (len > 65531)
375 OJPH_ERROR(0x000500C1,
376 "COM marker string length cannot be larger than 65531");
377 this->data = str;
378 this->len = (ui16)t;
379 this->Rcom = 1;
380 }
381
383 void comment_exchange::set_data(char* data, ui16 len)
384 {
385 if (len > 65531)
386 OJPH_ERROR(0x000500C2,
387 "COM marker string length cannot be larger than 65531");
388 this->data = data;
389 this->len = len;
390 this->Rcom = 0;
391 }
392
394 //
395 //
396 // LOCAL
397 //
398 //
400
401 namespace local {
402
404 static inline
406 {
407 return (ui16)((t << 8) | (t >> 8));
408 }
409
411 static inline
413 {
414 ui32 u = swap_byte((ui16)(t & 0xFFFFu));
415 u <<= 16;
416 u |= swap_byte((ui16)(t >> 16));
417 return u;
418 }
419
421 //
422 //
423 //
424 //
425 //
427
429 //static
431 {
432 public:
433 static float get_gain_l(ui32 num_decomp, bool reversible)
434 { return reversible ? gain_5x3_l[num_decomp] : gain_9x7_l[num_decomp]; }
435 static float get_gain_h(ui32 num_decomp, bool reversible)
436 { return reversible ? gain_5x3_h[num_decomp] : gain_9x7_h[num_decomp]; }
437
438 private:
439 static const float gain_9x7_l[34];
440 static const float gain_9x7_h[34];
441 static const float gain_5x3_l[34];
442 static const float gain_5x3_h[34];
443 };
444
446 const float sqrt_energy_gains::gain_9x7_l[34] = { 1.0000e+00f,
447 1.4021e+00f, 2.0304e+00f, 2.9012e+00f, 4.1153e+00f, 5.8245e+00f,
448 8.2388e+00f, 1.1652e+01f, 1.6479e+01f, 2.3304e+01f, 3.2957e+01f,
449 4.6609e+01f, 6.5915e+01f, 9.3217e+01f, 1.3183e+02f, 1.8643e+02f,
450 2.6366e+02f, 3.7287e+02f, 5.2732e+02f, 7.4574e+02f, 1.0546e+03f,
451 1.4915e+03f, 2.1093e+03f, 2.9830e+03f, 4.2185e+03f, 5.9659e+03f,
452 8.4371e+03f, 1.1932e+04f, 1.6874e+04f, 2.3864e+04f, 3.3748e+04f,
453 4.7727e+04f, 6.7496e+04f, 9.5454e+04f };
454 const float sqrt_energy_gains::gain_9x7_h[34] = { 1.4425e+00f,
455 1.9669e+00f, 2.8839e+00f, 4.1475e+00f, 5.8946e+00f, 8.3472e+00f,
456 1.1809e+01f, 1.6701e+01f, 2.3620e+01f, 3.3403e+01f, 4.7240e+01f,
457 6.6807e+01f, 9.4479e+01f, 1.3361e+02f, 1.8896e+02f, 2.6723e+02f,
458 3.7792e+02f, 5.3446e+02f, 7.5583e+02f, 1.0689e+03f, 1.5117e+03f,
459 2.1378e+03f, 3.0233e+03f, 4.2756e+03f, 6.0467e+03f, 8.5513e+03f,
460 1.2093e+04f, 1.7103e+04f, 2.4187e+04f, 3.4205e+04f, 4.8373e+04f,
461 6.8410e+04f, 9.6747e+04f, 1.3682e+05f };
462 const float sqrt_energy_gains::gain_5x3_l[34] = { 1.0000e+00f,
463 1.2247e+00f, 1.3229e+00f, 1.5411e+00f, 1.7139e+00f, 1.9605e+00f,
464 2.2044e+00f, 2.5047e+00f, 2.8277e+00f, 3.2049e+00f, 3.6238e+00f,
465 4.1033e+00f, 4.6423e+00f, 5.2548e+00f, 5.9462e+00f, 6.7299e+00f,
466 7.6159e+00f, 8.6193e+00f, 9.7544e+00f, 1.1039e+01f, 1.2493e+01f,
467 1.4139e+01f, 1.6001e+01f, 1.8108e+01f, 2.0493e+01f, 2.3192e+01f,
468 2.6246e+01f, 2.9702e+01f, 3.3614e+01f, 3.8041e+01f, 4.3051e+01f,
469 4.8721e+01f, 5.5138e+01f, 6.2399e+01f };
470 const float sqrt_energy_gains::gain_5x3_h[34] = { 1.0458e+00f,
471 1.3975e+00f, 1.4389e+00f, 1.7287e+00f, 1.8880e+00f, 2.1841e+00f,
472 2.4392e+00f, 2.7830e+00f, 3.1341e+00f, 3.5576e+00f, 4.0188e+00f,
473 4.5532e+00f, 5.1494e+00f, 5.8301e+00f, 6.5963e+00f, 7.4663e+00f,
474 8.4489e+00f, 9.5623e+00f, 1.0821e+01f, 1.2247e+01f, 1.3860e+01f,
475 1.5685e+01f, 1.7751e+01f, 2.0089e+01f, 2.2735e+01f, 2.5729e+01f,
476 2.9117e+01f, 3.2952e+01f, 3.7292e+01f, 4.2203e+01f, 4.7761e+01f,
477 5.4051e+01f, 6.1170e+01f, 6.9226e+01f };
478
480 //static
482 {
483 public:
484 static float get_bibo_gain_l(ui32 num_decomp, bool reversible)
485 { return reversible ? gain_5x3_l[num_decomp] : gain_9x7_l[num_decomp]; }
486 static float get_bibo_gain_h(ui32 num_decomp, bool reversible)
487 { return reversible ? gain_5x3_h[num_decomp] : gain_9x7_h[num_decomp]; }
488
489 private:
490 static const float gain_9x7_l[34];
491 static const float gain_9x7_h[34];
492 static const float gain_5x3_l[34];
493 static const float gain_5x3_h[34];
494 };
495
497 const float bibo_gains::gain_9x7_l[34] = { 1.0000e+00f, 1.3803e+00f,
498 1.3328e+00f, 1.3067e+00f, 1.3028e+00f, 1.3001e+00f, 1.2993e+00f,
499 1.2992e+00f, 1.2992e+00f, 1.2992e+00f, 1.2992e+00f, 1.2992e+00f,
500 1.2992e+00f, 1.2992e+00f, 1.2992e+00f, 1.2992e+00f, 1.2992e+00f,
501 1.2992e+00f, 1.2992e+00f, 1.2992e+00f, 1.2992e+00f, 1.2992e+00f,
502 1.2992e+00f, 1.2992e+00f, 1.2992e+00f, 1.2992e+00f, 1.2992e+00f,
503 1.2992e+00f, 1.2992e+00f, 1.2992e+00f, 1.2992e+00f, 1.2992e+00f,
504 1.2992e+00f, 1.2992e+00f };
505 const float bibo_gains::gain_9x7_h[34] = { 1.2976e+00f, 1.3126e+00f,
506 1.2757e+00f, 1.2352e+00f, 1.2312e+00f, 1.2285e+00f, 1.2280e+00f,
507 1.2278e+00f, 1.2278e+00f, 1.2278e+00f, 1.2278e+00f, 1.2278e+00f,
508 1.2278e+00f, 1.2278e+00f, 1.2278e+00f, 1.2278e+00f, 1.2278e+00f,
509 1.2278e+00f, 1.2278e+00f, 1.2278e+00f, 1.2278e+00f, 1.2278e+00f,
510 1.2278e+00f, 1.2278e+00f, 1.2278e+00f, 1.2278e+00f, 1.2278e+00f,
511 1.2278e+00f, 1.2278e+00f, 1.2278e+00f, 1.2278e+00f, 1.2278e+00f,
512 1.2278e+00f, 1.2278e+00f };
513 const float bibo_gains::gain_5x3_l[34] = { 1.0000e+00f, 1.5000e+00f,
514 1.6250e+00f, 1.6875e+00f, 1.6963e+00f, 1.7067e+00f, 1.7116e+00f,
515 1.7129e+00f, 1.7141e+00f, 1.7145e+00f, 1.7151e+00f, 1.7152e+00f,
516 1.7155e+00f, 1.7155e+00f, 1.7156e+00f, 1.7156e+00f, 1.7156e+00f,
517 1.7156e+00f, 1.7156e+00f, 1.7156e+00f, 1.7156e+00f, 1.7156e+00f,
518 1.7156e+00f, 1.7156e+00f, 1.7156e+00f, 1.7156e+00f, 1.7156e+00f,
519 1.7156e+00f, 1.7156e+00f, 1.7156e+00f, 1.7156e+00f, 1.7156e+00f,
520 1.7156e+00f, 1.7156e+00f };
521 const float bibo_gains::gain_5x3_h[34] = { 2.0000e+00f, 2.5000e+00f,
522 2.7500e+00f, 2.8047e+00f, 2.8198e+00f, 2.8410e+00f, 2.8558e+00f,
523 2.8601e+00f, 2.8628e+00f, 2.8656e+00f, 2.8662e+00f, 2.8667e+00f,
524 2.8669e+00f, 2.8670e+00f, 2.8671e+00f, 2.8671e+00f, 2.8671e+00f,
525 2.8671e+00f, 2.8671e+00f, 2.8671e+00f, 2.8671e+00f, 2.8671e+00f,
526 2.8671e+00f, 2.8671e+00f, 2.8671e+00f, 2.8671e+00f, 2.8671e+00f,
527 2.8671e+00f, 2.8671e+00f, 2.8671e+00f, 2.8671e+00f, 2.8671e+00f,
528 2.8671e+00f, 2.8671e+00f };
529
530
532 //
533 //
534 //
535 //
536 //
538
541 {
542 //marker size excluding header
543 Lsiz = (ui16)(38 + 3 * Csiz);
544
545 ui8 buf[4];
546 bool result = true;
547
548 *(ui16*)buf = JP2K_MARKER::SIZ;
549 *(ui16*)buf = swap_byte(*(ui16*)buf);
550 result &= file->write(&buf, 2) == 2;
551 *(ui16*)buf = swap_byte(Lsiz);
552 result &= file->write(&buf, 2) == 2;
553 *(ui16*)buf = swap_byte(Rsiz);
554 result &= file->write(&buf, 2) == 2;
555 *(ui32*)buf = swap_byte(Xsiz);
556 result &= file->write(&buf, 4) == 4;
557 *(ui32*)buf = swap_byte(Ysiz);
558 result &= file->write(&buf, 4) == 4;
559 *(ui32*)buf = swap_byte(XOsiz);
560 result &= file->write(&buf, 4) == 4;
561 *(ui32*)buf = swap_byte(YOsiz);
562 result &= file->write(&buf, 4) == 4;
563 *(ui32*)buf = swap_byte(XTsiz);
564 result &= file->write(&buf, 4) == 4;
565 *(ui32*)buf = swap_byte(YTsiz);
566 result &= file->write(&buf, 4) == 4;
567 *(ui32*)buf = swap_byte(XTOsiz);
568 result &= file->write(&buf, 4) == 4;
569 *(ui32*)buf = swap_byte(YTOsiz);
570 result &= file->write(&buf, 4) == 4;
571 *(ui16*)buf = swap_byte(Csiz);
572 result &= file->write(&buf, 2) == 2;
573 for (int c = 0; c < Csiz; ++c)
574 {
575 buf[0] = cptr[c].SSiz;
576 buf[1] = cptr[c].XRsiz;
577 buf[2] = cptr[c].YRsiz;
578 result &= file->write(&buf, 3) == 3;
579 }
580
581 return result;
582 }
583
586 {
587 if (file->read(&Lsiz, 2) != 2)
588 OJPH_ERROR(0x00050041, "error reading SIZ marker");
590 int num_comps = (Lsiz - 38) / 3;
591 if (Lsiz != 38 + 3 * num_comps)
592 OJPH_ERROR(0x00050042, "error in SIZ marker length");
593 if (file->read(&Rsiz, 2) != 2)
594 OJPH_ERROR(0x00050043, "error reading SIZ marker");
596 if ((Rsiz & 0x4000) == 0)
597 OJPH_ERROR(0x00050044, "Rsiz bit 14 not set (this is not a JPH file)");
598 if (Rsiz & 0xBFFF)
599 OJPH_WARN(0x00050001, "Rsiz in SIZ has unimplemented fields");
600 if (file->read(&Xsiz, 4) != 4)
601 OJPH_ERROR(0x00050045, "error reading SIZ marker");
603 if (file->read(&Ysiz, 4) != 4)
604 OJPH_ERROR(0x00050046, "error reading SIZ marker");
606 if (file->read(&XOsiz, 4) != 4)
607 OJPH_ERROR(0x00050047, "error reading SIZ marker");
609 if (file->read(&YOsiz, 4) != 4)
610 OJPH_ERROR(0x00050048, "error reading SIZ marker");
612 if (file->read(&XTsiz, 4) != 4)
613 OJPH_ERROR(0x00050049, "error reading SIZ marker");
615 if (file->read(&YTsiz, 4) != 4)
616 OJPH_ERROR(0x0005004A, "error reading SIZ marker");
618 if (file->read(&XTOsiz, 4) != 4)
619 OJPH_ERROR(0x0005004B, "error reading SIZ marker");
621 if (file->read(&YTOsiz, 4) != 4)
622 OJPH_ERROR(0x0005004C, "error reading SIZ marker");
624 if (file->read(&Csiz, 2) != 2)
625 OJPH_ERROR(0x0005004D, "error reading SIZ marker");
627 if (Csiz != num_comps)
628 OJPH_ERROR(0x0005004E, "Csiz does not match the SIZ marker size");
629 if (Csiz > old_Csiz)
630 {
631 if (cptr != store)
632 delete[] cptr;
633 cptr = new siz_comp_info[(ui32)num_comps];
634 old_Csiz = Csiz;
635 }
636 for (int c = 0; c < Csiz; ++c)
637 {
638 if (file->read(&cptr[c].SSiz, 1) != 1)
639 OJPH_ERROR(0x00050051, "error reading SIZ marker");
640 if (file->read(&cptr[c].XRsiz, 1) != 1)
641 OJPH_ERROR(0x00050052, "error reading SIZ marker");
642 if (file->read(&cptr[c].YRsiz, 1) != 1)
643 OJPH_ERROR(0x00050053, "error reading SIZ marker");
644 }
645 }
646
648 //
649 //
650 //
651 //
652 //
654
657 {
658 //marker size excluding header
659 Lcap = 8;
660
661 char buf[4];
662 bool result = true;
663
664 *(ui16*)buf = JP2K_MARKER::CAP;
665 *(ui16*)buf = swap_byte(*(ui16*)buf);
666 result &= file->write(&buf, 2) == 2;
667 *(ui16*)buf = swap_byte(Lcap);
668 result &= file->write(&buf, 2) == 2;
669 *(ui32*)buf = swap_byte(Pcap);
670 result &= file->write(&buf, 4) == 4;
671
672 *(ui16*)buf = swap_byte(Ccap[0]);
673 result &= file->write(&buf, 2) == 2;
674
675 return result;
676 }
677
680 {
681 if (file->read(&Lcap, 2) != 2)
682 OJPH_ERROR(0x00050061, "error reading CAP marker");
684 if (file->read(&Pcap, 4) != 4)
685 OJPH_ERROR(0x00050062, "error reading CAP marker");
687 ui32 count = population_count(Pcap);
688 if (Pcap & 0xFFFDFFFF)
689 OJPH_ERROR(0x00050063,
690 "error Pcap in CAP has options that are not supported");
691 if ((Pcap & 0x00020000) == 0)
692 OJPH_ERROR(0x00050064,
693 "error Pcap should have its 15th MSB set, Pcap^15. "
694 " This is not a JPH file");
695 for (ui32 i = 0; i < count; ++i)
696 if (file->read(Ccap+i, 2) != 2)
697 OJPH_ERROR(0x00050065, "error reading CAP marker");
698 if (Lcap != 6 + 2 * count)
699 OJPH_ERROR(0x00050066, "error in CAP marker length");
700 }
701
703 //
704 //
705 //
706 //
707 //
709
712 {
713 //marker size excluding header
714 Lcod = 12;
715 Lcod = (ui16)(Lcod + (Scod & 1 ? 1 + SPcod.num_decomp : 0));
716
717 ui8 buf[4];
718 bool result = true;
719
720 *(ui16*)buf = JP2K_MARKER::COD;
721 *(ui16*)buf = swap_byte(*(ui16*)buf);
722 result &= file->write(&buf, 2) == 2;
723 *(ui16*)buf = swap_byte(Lcod);
724 result &= file->write(&buf, 2) == 2;
725 *(ui8*)buf = Scod;
726 result &= file->write(&buf, 1) == 1;
727 *(ui8*)buf = SGCod.prog_order;
728 result &= file->write(&buf, 1) == 1;
729 *(ui16*)buf = swap_byte(SGCod.num_layers);
730 result &= file->write(&buf, 2) == 2;
731 *(ui8*)buf = SGCod.mc_trans;
732 result &= file->write(&buf, 1) == 1;
733 buf[0] = SPcod.num_decomp;
734 buf[1] = SPcod.block_width;
735 buf[2] = SPcod.block_height;
736 buf[3] = SPcod.block_style;
737 result &= file->write(&buf, 4) == 4;
738 *(ui8*)buf = SPcod.wavelet_trans;
739 result &= file->write(&buf, 1) == 1;
740 if (Scod & 1)
741 for (int i = 0; i <= SPcod.num_decomp; ++i)
742 {
743 *(ui8*)buf = SPcod.precinct_size[i];
744 result &= file->write(&buf, 1) == 1;
745 }
746
747 return result;
748 }
749
752 {
753 if (file->read(&Lcod, 2) != 2)
754 OJPH_ERROR(0x00050071, "error reading COD marker");
756 if (file->read(&Scod, 1) != 1)
757 OJPH_ERROR(0x00050072, "error reading COD marker");
758 if (file->read(&SGCod.prog_order, 1) != 1)
759 OJPH_ERROR(0x00050073, "error reading COD marker");
760 if (file->read(&SGCod.num_layers, 2) != 2)
761 { OJPH_ERROR(0x00050074, "error reading COD marker"); }
762 else
764 if (file->read(&SGCod.mc_trans, 1) != 1)
765 OJPH_ERROR(0x00050075, "error reading COD marker");
766 if (file->read(&SPcod.num_decomp, 1) != 1)
767 OJPH_ERROR(0x00050076, "error reading COD marker");
768 if (file->read(&SPcod.block_width, 1) != 1)
769 OJPH_ERROR(0x00050077, "error reading COD marker");
770 if (file->read(&SPcod.block_height, 1) != 1)
771 OJPH_ERROR(0x00050078, "error reading COD marker");
772 if (file->read(&SPcod.block_style, 1) != 1)
773 OJPH_ERROR(0x00050079, "error reading COD marker");
774 if (file->read(&SPcod.wavelet_trans, 1) != 1)
775 OJPH_ERROR(0x0005007A, "error reading COD marker");
776 if (Scod & 1)
777 for (int i = 0; i <= SPcod.num_decomp; ++i)
778 if (file->read(&SPcod.precinct_size[i], 1) != 1)
779 OJPH_ERROR(0x0005007B, "error reading COD marker");
780 if (Lcod != 12 + ((Scod & 1) ? 1 + SPcod.num_decomp : 0))
781 OJPH_ERROR(0x0005007C, "error in COD marker length");
782 }
783
785 //
786 //
787 //
788 //
789 //
791
794 bool is_employing_color_transform)
795 {
796 int guard_bits = 1;
797 Sqcd = (ui8)(guard_bits << 5); //one guard bit, and no quantization
798 ui32 B = bit_depth;
799 B += is_employing_color_transform ? 1 : 0; //1 bit for RCT
800 int s = 0;
801 float bibo_l = bibo_gains::get_bibo_gain_l(num_decomps, true);
802 //we leave some leeway for numerical error by multiplying by 1.1f
803 ui32 X = (ui32) ceil(log(bibo_l * bibo_l * 1.1f) / M_LN2);
804 u8_SPqcd[s++] = (ui8)((B + X) << 3);
805 for (ui32 d = num_decomps; d > 0; --d)
806 {
807 float bibo_l = bibo_gains::get_bibo_gain_l(d, true);
808 float bibo_h = bibo_gains::get_bibo_gain_h(d - 1, true);
809 X = (ui32) ceil(log(bibo_h * bibo_l * 1.1f) / M_LN2);
810 u8_SPqcd[s++] = (ui8)((B + X) << 3);
811 u8_SPqcd[s++] = (ui8)((B + X) << 3);
812 X = (ui32) ceil(log(bibo_h * bibo_h * 1.1f) / M_LN2);
813 u8_SPqcd[s++] = (ui8)((B + X) << 3);
814 }
815 }
816
819 {
820 int guard_bits = 1;
821 Sqcd = (ui8)((guard_bits<<5)|0x2);//one guard bit, scalar quantization
822 int s = 0;
823 float gain_l = sqrt_energy_gains::get_gain_l(num_decomps, false);
824 float delta_b = base_delta / (gain_l * gain_l);
825 int exp = 0, mantissa;
826 while (delta_b < 1.0f)
827 { exp++; delta_b *= 2.0f; }
828 //with rounding, there is a risk of becoming equal to 1<<12
829 // but that should not happen in reality
830 mantissa = (int)round(delta_b * (float)(1<<11)) - (1<<11);
831 mantissa = mantissa < (1<<11) ? mantissa : 0x7FF;
832 u16_SPqcd[s++] = (ui16)((exp << 11) | mantissa);
833 for (ui32 d = num_decomps; d > 0; --d)
834 {
835 float gain_l = sqrt_energy_gains::get_gain_l(d, false);
836 float gain_h = sqrt_energy_gains::get_gain_h(d - 1, false);
837
838 delta_b = base_delta / (gain_l * gain_h);
839
840 int exp = 0, mantissa;
841 while (delta_b < 1.0f)
842 { exp++; delta_b *= 2.0f; }
843 mantissa = (int)round(delta_b * (float)(1<<11)) - (1<<11);
844 mantissa = mantissa < (1<<11) ? mantissa : 0x7FF;
845 u16_SPqcd[s++] = (ui16)((exp << 11) | mantissa);
846 u16_SPqcd[s++] = (ui16)((exp << 11) | mantissa);
847
848 delta_b = base_delta / (gain_h * gain_h);
849
850 exp = 0;
851 while (delta_b < 1)
852 { exp++; delta_b *= 2.0f; }
853 mantissa = (int)round(delta_b * (float)(1<<11)) - (1<<11);
854 mantissa = mantissa < (1<<11) ? mantissa : 0x7FF;
855 u16_SPqcd[s++] = (ui16)((exp << 11) | mantissa);
856 }
857 }
858
861 { //this can be written better, but it is only executed once
862 ui32 B = 0;
863 int irrev = Sqcd & 0x1F;
864 if (irrev == 0) //reversible
865 for (ui32 i = 0; i < 3 * num_decomps + 1; ++i)
866 B = ojph_max(B, (u8_SPqcd[i] >> 3) + get_num_guard_bits() - 1u);
867 else if (irrev == 2) //scalar expounded
868 for (ui32 i = 0; i < 3 * num_decomps + 1; ++i)
869 {
870 ui32 nb = num_decomps - (i ? (i - 1) / 3 : 0); //decompsition level
871 B = ojph_max(B, (u16_SPqcd[i] >> 11) + get_num_guard_bits() - nb);
872 }
873 else
874 assert(0);
875
876 return B;
877 }
878
881 {
882 assert((resolution == 0 && subband == 0) ||
884 assert((Sqcd & 0x1F) == 2);
885 float arr[] = { 1.0f, 2.0f, 2.0f, 4.0f };
886
887 ui32 idx = resolution == 0 ? 0 : (resolution - 1) * 3 + subband;
888 int eps = u16_SPqcd[idx] >> 11;
889 float mantissa;
890 mantissa = (float)((u16_SPqcd[idx] & 0x7FF) | 0x800) * arr[subband];
891 mantissa /= (float)(1 << 11);
892 mantissa /= (float)(1u << eps);
893 return mantissa;
894 }
895
898 {
899 return (Sqcd >> 5);
900 }
901
904 {
905 assert((resolution == 0 && subband == 0) ||
907 ui32 num_bits = get_num_guard_bits();
908 ui32 idx = resolution == 0 ? 0 : (resolution - 1) * 3 + subband;
909 int irrev = Sqcd & 0x1F;
910 if (irrev == 0) //reversible; this is (10.22) from the J2K book
911 {
912 num_bits += u8_SPqcd[idx] >> 3;
913 num_bits = num_bits == 0 ? 0 : num_bits - 1;
914 }
915 else if (irrev == 1)
916 assert(0);
917 else if (irrev == 2) //scalar expounded
918 num_bits += (u16_SPqcd[idx] >> 11) - 1;
919 else
920 assert(0);
921
922 return num_bits;
923 }
924
927 {
928 int irrev = Sqcd & 0x1F;
929 ui32 num_subbands = 1 + 3 * num_decomps;
930
931 //marker size excluding header
932 Lqcd = 3;
933 if (irrev == 0)
934 Lqcd = (ui16)(Lqcd + num_subbands);
935 else if (irrev == 2)
936 Lqcd = (ui16)(Lqcd + 2 * num_subbands);
937 else
938 assert(0);
939
940 char buf[4];
941 bool result = true;
942
943 *(ui16*)buf = JP2K_MARKER::QCD;
944 *(ui16*)buf = swap_byte(*(ui16*)buf);
945 result &= file->write(&buf, 2) == 2;
946 *(ui16*)buf = swap_byte(Lqcd);
947 result &= file->write(&buf, 2) == 2;
948 *(ui8*)buf = Sqcd;
949 result &= file->write(&buf, 1) == 1;
950
951 if (irrev == 0)
952 for (ui32 i = 0; i < num_subbands; ++i)
953 {
954 *(ui8*)buf = u8_SPqcd[i];
955 result &= file->write(&buf, 1) == 1;
956 }
957 else if (irrev == 2)
958 for (ui32 i = 0; i < num_subbands; ++i)
959 {
960 *(ui16*)buf = swap_byte(u16_SPqcd[i]);
961 result &= file->write(&buf, 2) == 2;
962 }
963 else
964 assert(0);
965
966
967 return result;
968 }
971 {
972 if (file->read(&Lqcd, 2) != 2)
973 OJPH_ERROR(0x00050081, "error reading QCD marker");
975 if (file->read(&Sqcd, 1) != 1)
976 OJPH_ERROR(0x00050082, "error reading QCD marker");
977 if ((Sqcd & 0x1F) == 0)
978 {
979 num_decomps = (Lqcd - 4) / 3;
980 if (Lqcd != 4 + 3 * num_decomps)
981 OJPH_ERROR(0x00050083, "wrong Lqcd value in QCD marker");
982 for (ui32 i = 0; i < 1 + 3 * num_decomps; ++i)
983 if (file->read(&u8_SPqcd[i], 1) != 1)
984 OJPH_ERROR(0x00050084, "error reading QCD marker");
985 }
986 else if ((Sqcd & 0x1F) == 1)
987 {
988 num_decomps = 0;
989 OJPH_ERROR(0x00050089,
990 "Scalar derived quantization is not supported yet in QCD marker");
991 if (Lqcd != 5)
992 OJPH_ERROR(0x00050085, "wrong Lqcd value in QCD marker");
993 }
994 else if ((Sqcd & 0x1F) == 2)
995 {
996 num_decomps = (Lqcd - 5) / 6;
997 if (Lqcd != 5 + 6 * num_decomps)
998 OJPH_ERROR(0x00050086, "wrong Lqcd value in QCD marker");
999 for (ui32 i = 0; i < 1 + 3 * num_decomps; ++i)
1000 {
1001 if (file->read(&u16_SPqcd[i], 2) != 2)
1002 OJPH_ERROR(0x00050087, "error reading QCD marker");
1003 u16_SPqcd[i] = swap_byte(u16_SPqcd[i]);
1004 }
1005 }
1006 else
1007 OJPH_ERROR(0x00050088, "wrong Sqcd value in QCD marker");
1008 }
1009
1011 //
1012 //
1013 //
1014 //
1015 //
1017
1019 void param_qcc::read(infile_base *file, ui32 num_comps)
1020 {
1021 if (file->read(&Lqcd, 2) != 2)
1022 OJPH_ERROR(0x000500A1, "error reading QCC marker");
1023 Lqcd = swap_byte(Lqcd);
1024 if (num_comps < 257)
1025 {
1026 ui8 v;
1027 if (file->read(&v, 1) != 1)
1028 OJPH_ERROR(0x000500A2, "error reading QCC marker");
1029 comp_idx = v;
1030 }
1031 else
1032 {
1033 if (file->read(&comp_idx, 2) != 2)
1034 OJPH_ERROR(0x000500A3, "error reading QCC marker");
1036 }
1037 if (file->read(&Sqcd, 1) != 1)
1038 OJPH_ERROR(0x000500A4, "error reading QCC marker");
1039 if ((Sqcd & 0x1F) == 0)
1040 {
1041 ui32 offset = num_comps < 257 ? 5 : 6;
1042 num_decomps = (Lqcd - offset) / 3;
1043 if (Lqcd != offset + 3 * num_decomps)
1044 OJPH_ERROR(0x000500A5, "wrong Lqcd value in QCC marker");
1045 for (ui32 i = 0; i < 1 + 3 * num_decomps; ++i)
1046 if (file->read(&u8_SPqcd[i], 1) != 1)
1047 OJPH_ERROR(0x000500A6, "error reading QCC marker");
1048 }
1049 else if ((Sqcd & 0x1F) == 1)
1050 {
1051 ui32 offset = num_comps < 257 ? 6 : 7;
1052 num_decomps = 0;
1053 OJPH_ERROR(0x000500AB,
1054 "Scalar derived quantization is not supported yet in QCC marker");
1055 if (Lqcd != offset)
1056 OJPH_ERROR(0x000500A7, "wrong Lqcc value in QCC marker");
1057 }
1058 else if ((Sqcd & 0x1F) == 2)
1059 {
1060 ui32 offset = num_comps < 257 ? 6 : 7;
1061 num_decomps = (Lqcd - offset) / 6;
1062 if (Lqcd != offset + 6 * num_decomps)
1063 OJPH_ERROR(0x000500A8, "wrong Lqcc value in QCC marker");
1064 for (ui32 i = 0; i < 1 + 3 * num_decomps; ++i)
1065 {
1066 if (file->read(&u16_SPqcd[i], 2) != 2)
1067 OJPH_ERROR(0x000500A9, "error reading QCC marker");
1068 u16_SPqcd[i] = swap_byte(u16_SPqcd[i]);
1069 }
1070 }
1071 else
1072 OJPH_ERROR(0x000500AA, "wrong Sqcc value in QCC marker");
1073 }
1074
1076 //
1077 //
1078 //
1079 //
1080 //
1082
1084 bool param_sot::write(outfile_base *file, ui32 payload_len)
1085 {
1086 char buf[4];
1087 bool result = true;
1088
1089 this->Psot = payload_len + 14; //inc. SOT marker, field & SOD
1090
1091 *(ui16*)buf = JP2K_MARKER::SOT;
1092 *(ui16*)buf = swap_byte(*(ui16*)buf);
1093 result &= file->write(&buf, 2) == 2;
1094 *(ui16*)buf = swap_byte(Lsot);
1095 result &= file->write(&buf, 2) == 2;
1096 *(ui16*)buf = swap_byte(Isot);
1097 result &= file->write(&buf, 2) == 2;
1098 *(ui32*)buf = swap_byte(Psot);
1099 result &= file->write(&buf, 4) == 4;
1100 *(ui8*)buf = TPsot;
1101 result &= file->write(&buf, 1) == 1;
1102 *(ui8*)buf = TNsot;
1103 result &= file->write(&buf, 1) == 1;
1104
1105 return result;
1106 }
1107
1109 bool param_sot::write(outfile_base *file, ui32 payload_len,
1110 ui8 TPsot, ui8 TNsot)
1111 {
1112 char buf[4];
1113 bool result = true;
1114
1115 *(ui16*)buf = JP2K_MARKER::SOT;
1116 *(ui16*)buf = swap_byte(*(ui16*)buf);
1117 result &= file->write(&buf, 2) == 2;
1118 *(ui16*)buf = swap_byte(Lsot);
1119 result &= file->write(&buf, 2) == 2;
1120 *(ui16*)buf = swap_byte(Isot);
1121 result &= file->write(&buf, 2) == 2;
1122 *(ui32*)buf = swap_byte(payload_len + 14);
1123 result &= file->write(&buf, 4) == 4;
1124 *(ui8*)buf = TPsot;
1125 result &= file->write(&buf, 1) == 1;
1126 *(ui8*)buf = TNsot;
1127 result &= file->write(&buf, 1) == 1;
1128
1129 return result;
1130 }
1131
1133 bool param_sot::read(infile_base *file, bool resilient)
1134 {
1135 if (resilient)
1136 {
1137 if (file->read(&Lsot, 2) != 2)
1138 {
1139 OJPH_INFO(0x00050091, "error reading SOT marker");
1140 Lsot = 0; Isot = 0; Psot = 0; TPsot = 0; TNsot = 0;
1141 return false;
1142 }
1143 Lsot = swap_byte(Lsot);
1144 if (Lsot != 10)
1145 {
1146 OJPH_INFO(0x00050092, "error in SOT length");
1147 Lsot = 0; Isot = 0; Psot = 0; TPsot = 0; TNsot = 0;
1148 return false;
1149 }
1150 if (file->read(&Isot, 2) != 2)
1151 {
1152 OJPH_INFO(0x00050093, "error reading tile index");
1153 Lsot = 0; Isot = 0; Psot = 0; TPsot = 0; TNsot = 0;
1154 return false;
1155 }
1156 Isot = swap_byte(Isot);
1157 if (Isot == 0xFFFF)
1158 {
1159 OJPH_INFO(0x00050094, "tile index in SOT marker cannot be 0xFFFF");
1160 Lsot = 0; Isot = 0; Psot = 0; TPsot = 0; TNsot = 0;
1161 return false;
1162 }
1163 if (file->read(&Psot, 4) != 4)
1164 {
1165 OJPH_INFO(0x00050095, "error reading SOT marker");
1166 Lsot = 0; Isot = 0; Psot = 0; TPsot = 0; TNsot = 0;
1167 return false;
1168 }
1169 Psot = swap_byte(Psot);
1170 if (file->read(&TPsot, 1) != 1)
1171 {
1172 OJPH_INFO(0x00050096, "error reading SOT marker");
1173 Lsot = 0; Isot = 0; Psot = 0; TPsot = 0; TNsot = 0;
1174 return false;
1175 }
1176 if (file->read(&TNsot, 1) != 1)
1177 {
1178 OJPH_INFO(0x00050097, "error reading SOT marker");
1179 Lsot = 0; Isot = 0; Psot = 0; TPsot = 0; TNsot = 0;
1180 return false;
1181 }
1182 }
1183 else
1184 {
1185 if (file->read(&Lsot, 2) != 2)
1186 OJPH_ERROR(0x00050091, "error reading SOT marker");
1187 Lsot = swap_byte(Lsot);
1188 if (Lsot != 10)
1189 OJPH_ERROR(0x00050092, "error in SOT length");
1190 if (file->read(&Isot, 2) != 2)
1191 OJPH_ERROR(0x00050093, "error reading SOT tile index");
1192 Isot = swap_byte(Isot);
1193 if (Isot == 0xFFFF)
1194 OJPH_ERROR(0x00050094, "tile index in SOT marker cannot be 0xFFFF");
1195 if (file->read(&Psot, 4) != 4)
1196 OJPH_ERROR(0x00050095, "error reading SOT marker");
1197 Psot = swap_byte(Psot);
1198 if (file->read(&TPsot, 1) != 1)
1199 OJPH_ERROR(0x00050096, "error reading SOT marker");
1200 if (file->read(&TNsot, 1) != 1)
1201 OJPH_ERROR(0x00050097, "error reading SOT marker");
1202 }
1203 return true;
1204 }
1205
1207 //
1208 //
1209 //
1210 //
1211 //
1213
1215 void param_tlm::init(ui32 num_pairs, Ttlm_Ptlm_pair *store)
1216 {
1217 if (4 + 6 * num_pairs > 65535)
1218 OJPH_ERROR(0x000500B1, "Trying to allocate more than 65535 bytes for "
1219 "a TLM marker; this can be resolved by having more than "
1220 "one TLM marker, but the code does not support this. "
1221 "In any case, this limit means that we have 10922 "
1222 "tileparts or more, which is a huge number.");
1223 this->num_pairs = num_pairs;
1224 pairs = (Ttlm_Ptlm_pair*)store;
1225 Ltlm = (ui16)(4 + 6 * num_pairs);
1226 Ztlm = 0;
1227 Stlm = 0x60;
1228 }
1229
1232 {
1233 assert(next_pair_index < num_pairs);
1234 pairs[next_pair_index].Ttlm = Ttlm;
1235 pairs[next_pair_index].Ptlm = Ptlm + 14;
1237 }
1238
1241 {
1242 assert(next_pair_index == num_pairs);
1243 char buf[4];
1244 bool result = true;
1245
1246 *(ui16*)buf = JP2K_MARKER::TLM;
1247 *(ui16*)buf = swap_byte(*(ui16*)buf);
1248 result &= file->write(&buf, 2) == 2;
1249 *(ui16*)buf = swap_byte(Ltlm);
1250 result &= file->write(&buf, 2) == 2;
1251 result &= file->write(&Ztlm, 1) == 1;
1252 result &= file->write(&Stlm, 1) == 1;
1253 for (ui32 i = 0; i < num_pairs; ++i)
1254 {
1255 *(ui16*)buf = swap_byte(pairs[i].Ttlm);
1256 result &= file->write(&buf, 2) == 2;
1257 *(ui32*)buf = swap_byte(pairs[i].Ptlm);
1258 result &= file->write(&buf, 4) == 4;
1259 }
1260 return result;
1261 }
1262
1263 }
1264
1265}
OJPH_EXPORT void set_data(char *data, ui16 len)
OJPH_EXPORT void set_string(char *str)
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
Definition: ojph_params.h:155
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
Definition: ojph_params.h:169
OJPH_EXPORT void set_tile_size(size s)
Definition: ojph_params.cpp:66
OJPH_EXPORT point get_image_extent() const
OJPH_EXPORT void set_component(ui32 comp_num, const point &downsampling, ui32 bit_depth, bool is_signed)
Definition: ojph_params.cpp:93
OJPH_EXPORT void set_num_components(ui32 num_comps)
Definition: ojph_params.cpp:87
OJPH_EXPORT ui32 get_bit_depth(ui32 comp_num) const
OJPH_EXPORT void set_tile_offset(point offset)
Definition: ojph_params.cpp:80
OJPH_EXPORT point get_image_offset() const
local::param_siz * state
Definition: ojph_params.h:104
OJPH_EXPORT void set_image_offset(point offset)
Definition: ojph_params.cpp:73
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)
Definition: ojph_params.cpp:59
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:110
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:130
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,...)
Definition: ojph_message.h:125
#define OJPH_ERROR(t,...)
Definition: ojph_message.h:131
#define OJPH_WARN(t,...)
Definition: ojph_message.h:128
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
ui8 get_num_decompositions() const
bool packets_may_use_sop() 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)
ui32 w
Definition: ojph_base.h:50
ui32 h
Definition: ojph_base.h:51