OpenJPH
Open-source implementation of JPEG2000 Part-15
Loading...
Searching...
No Matches
ojph_compress.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_compress.cpp
34// Author: Aous Naman
35// Date: 28 August 2019
36//***************************************************************************/
37
38
39#include <ctime>
40#include <iostream>
41
42#include "ojph_arg.h"
43#include "ojph_mem.h"
44#include "ojph_img_io.h"
45#include "ojph_file.h"
46#include "ojph_codestream.h"
47#include "ojph_params.h"
48#include "ojph_message.h"
49
52{
53 size_list_interpreter(const int max_num_elements, int& num_elements,
54 ojph::size* list)
55 : max_num_eles(max_num_elements), sizelist(list), num_eles(num_elements)
56 {}
57
58 virtual void operate(const char *str)
59 {
60 const char *next_char = str;
61 num_eles = 0;
62 do
63 {
64 if (num_eles)
65 {
66 if (*next_char != ',') //separate sizes by a comma
67 throw "sizes in a sizes list must be separated by a comma";
68 next_char++;
69 }
70
71 if (*next_char != '{')
72 throw "size must start with {";
73 next_char++;
74 char *endptr;
75 sizelist[num_eles].w = (ojph::ui32)strtoul(next_char, &endptr, 10);
76 if (endptr == next_char)
77 throw "size number is improperly formatted";
78 next_char = endptr;
79 if (*next_char != ',')
80 throw "size must have a "","" between the two numbers";
81 next_char++;
82 sizelist[num_eles].h = (ojph::ui32)strtoul(next_char, &endptr, 10);
83 if (endptr == next_char)
84 throw "number is improperly formatted";
85 next_char = endptr;
86 if (*next_char != '}')
87 throw "size must end with }";
88 next_char++;
89
90 ++num_eles;
91 }
92 while (*next_char == ',' && num_eles < max_num_eles);
94 {
95 if (*next_char)
96 throw "size elements must separated by a "",""";
97 }
98 else if (*next_char)
99 throw "there are too many elements in the size list";
100 }
101
102 const int max_num_eles;
105};
106
109{
110 point_list_interpreter(const ojph::ui32 max_num_elements,
111 ojph::ui32& num_elements,
112 ojph::point* list)
113 : max_num_eles(max_num_elements), pointlist(list), num_eles(num_elements)
114 { }
115
116 virtual void operate(const char *str)
117 {
118 const char *next_char = str;
119 num_eles = 0;
120 do
121 {
122 if (num_eles)
123 {
124 if (*next_char != ',') //separate sizes by a comma
125 throw "sizes in a sizes list must be separated by a comma";
126 next_char++;
127 }
128
129 if (*next_char != '{')
130 throw "size must start with {";
131 next_char++;
132 char *endptr;
133 pointlist[num_eles].x = (ojph::ui32)strtoul(next_char, &endptr, 10);
134 if (endptr == next_char)
135 throw "point number is improperly formatted";
136 next_char = endptr;
137 if (*next_char != ',')
138 throw "point must have a "","" between the two numbers";
139 next_char++;
140 pointlist[num_eles].y = (ojph::ui32)strtoul(next_char, &endptr, 10);
141 if (endptr == next_char)
142 throw "number is improperly formatted";
143 next_char = endptr;
144 if (*next_char != '}')
145 throw "point must end with }";
146 next_char++;
147
148 ++num_eles;
149 }
150 while (*next_char == ',' && num_eles < max_num_eles);
152 {
153 if (*next_char)
154 throw "size elements must separated by a "",""";
155 }
156 else if (*next_char)
157 throw "there are too many elements in the size list";
158 }
159
163};
164
167{
169 virtual void operate(const char *str)
170 {
171 const char *next_char = str;
172 if (*next_char != '{')
173 throw "size must start with {";
174 next_char++;
175 char *endptr;
176 val.w = (ojph::ui32)strtoul(next_char, &endptr, 10);
177 if (endptr == next_char)
178 throw "size number is improperly formatted";
179 next_char = endptr;
180 if (*next_char != ',')
181 throw "size must have a "","" between the two numbers";
182 next_char++;
183 val.h = (ojph::ui32)strtoul(next_char, &endptr, 10);
184 if (endptr == next_char)
185 throw "number is improperly formatted";
186 next_char = endptr;
187 if (*next_char != '}')
188 throw "size must end with }";
189 next_char++;
190 if (*next_char != '\0') //must be end of string
191 throw "size has extra characters";
192 }
194};
195
198{
200 virtual void operate(const char *str)
201 {
202 const char *next_char = str;
203 if (*next_char != '{')
204 throw "size must start with {";
205 next_char++;
206 char *endptr;
207 val.x = (ojph::ui32)strtoul(next_char, &endptr, 10);
208 if (endptr == next_char)
209 throw "size number is improperly formatted";
210 next_char = endptr;
211 if (*next_char != ',')
212 throw "size must have a "","" between the two numbers";
213 next_char++;
214 val.y = (ojph::ui32)strtoul(next_char, &endptr, 10);
215 if (endptr == next_char)
216 throw "number is improperly formatted";
217 next_char = endptr;
218 if (*next_char != '}')
219 throw "size must end with }";
220 next_char++;
221 if (*next_char != '\0') //must be end of string
222 throw "size has extra characters";
223 }
225};
226
227
230{
231 ui32_list_interpreter(const ojph::ui32 max_num_elements,
232 ojph::ui32& num_elements,
233 ojph::ui32* list)
234 : max_num_eles(max_num_elements), ui32list(list), num_eles(num_elements)
235 {}
236
237 virtual void operate(const char *str)
238 {
239 const char *next_char = str;
240 num_eles = 0;
241 do
242 {
243 if (num_eles)
244 {
245 if (*next_char != ',') //separate sizes by a comma
246 throw "sizes in a sizes list must be separated by a comma";
247 next_char++;
248 }
249 char *endptr;
250 ui32list[num_eles] = (ojph::ui32)strtoul(next_char, &endptr, 10);
251 if (endptr == next_char)
252 throw "size number is improperly formatted";
253 next_char = endptr;
254 ++num_eles;
255 }
256 while (*next_char == ',' && num_eles < max_num_eles);
258 {
259 if (*next_char)
260 throw "list elements must separated by a "",""";
261 }
262 else if (*next_char)
263 throw "there are too many elements in the size list";
264 }
265
269};
270
274{
276 ojph::ui32& num_elements,
277 ojph::si32* list)
278 : max_num_eles(max_num_elements), boollist(list), num_eles(num_elements) {}
279
280 virtual void operate(const char *str)
281 {
282 const char *next_char = str;
283 num_eles = 0;
284 do
285 {
286 if (num_eles)
287 {
288 if (*next_char != ',') //separate sizes by a comma
289 throw "sizes in a sizes list must be separated by a comma";
290 next_char++;
291 }
292 if (strncmp(next_char, "true", 4) == 0)
293 {
294 boollist[num_eles] = 1;
295 next_char += 4;
296 }
297 else if (strncmp(next_char, "false", 5) == 0)
298 {
299 boollist[num_eles] = 0;
300 next_char += 5;
301 }
302 else
303 throw "unknown bool value";
304 ++num_eles;
305 }
306 while (*next_char == ',' && num_eles < max_num_eles);
308 {
309 if (*next_char)
310 throw "size elements must separated by a "",""";
311 }
312 else if (*next_char)
313 throw "there are too many elements in the size list";
314 }
315
317
321};
322
326{
330
331 virtual void operate(const char *str)
332 {
333 size_t len = strlen(str);
334 if (len == 1 && strncmp(str, "C", 2) == 0)
335 {
336 at_resolutions = false;
337 at_components = true;
338 }
339 else if (len == 1 && strncmp(str, "R", 2) == 0)
340 {
341 at_resolutions = true;
342 at_components = false;
343 }
344 else if (len == 2 &&
345 (strncmp(str, "RC", 3) == 0 || strncmp(str, "CR", 3) == 0))
346 {
347 at_resolutions = true;
348 at_components = true;
349 }
350 else
351 throw "could not interpret -tileparts fields; allowed values are "
352 "\"R\" \"C\" and \"RC\"";
353 }
354
357};
358
360static
361bool get_arguments(int argc, char *argv[], char *&input_filename,
362 char *&output_filename, char *&progression_order,
363 char *&profile_string, ojph::ui32 &num_decompositions,
364 float &quantization_step, bool &reversible,
365 int &employ_color_transform,
366 const int max_num_precincts, int &num_precincts,
367 ojph::size *precinct_size, ojph::size& block_size,
368 ojph::size& dims, ojph::point& image_offset,
369 ojph::size& tile_size, ojph::point& tile_offset,
370 ojph::ui32& max_num_comps, ojph::ui32& num_comps,
371 ojph::ui32& num_comp_downsamps, ojph::point*& comp_downsamp,
372 ojph::ui32& num_bit_depths, ojph::ui32*& bit_depth,
373 ojph::ui32& num_is_signed, ojph::si32*& is_signed,
374 bool& tlm_marker, bool& tileparts_at_resolutions,
375 bool& tileparts_at_components, char *&com_string)
376{
377 ojph::cli_interpreter interpreter;
378 interpreter.init(argc, argv);
379
380 interpreter.reinterpret("-i", input_filename);
381 interpreter.reinterpret("-o", output_filename);
382 interpreter.reinterpret("-prog_order", progression_order);
383 interpreter.reinterpret("-profile", profile_string);
384 interpreter.reinterpret("-num_decomps", num_decompositions);
385 interpreter.reinterpret("-qstep", quantization_step);
386 interpreter.reinterpret("-reversible", reversible);
387 interpreter.reinterpret_to_bool("-colour_trans", employ_color_transform);
388 interpreter.reinterpret("-num_comps", num_comps);
389 interpreter.reinterpret("-tlm_marker", tlm_marker);
390 interpreter.reinterpret("-com", com_string);
391
392 size_interpreter block_interpreter(block_size);
393 size_interpreter dims_interpreter(dims);
394 size_list_interpreter sizelist(max_num_precincts, num_precincts,
395 precinct_size);
396
397 if (num_comps > 16384) {
398 printf("More than 16384 components is not supported in JPEG2000."
399 "You specified %d\n", num_comps);
400 return false;
401 }
402
403 if (num_comps > max_num_comps)
404 {
405 max_num_comps = num_comps;
406 comp_downsamp = new ojph::point[num_comps];
407 bit_depth = new ojph::ui32[num_comps];
408 is_signed = new ojph::si32[num_comps];
409 for (ojph::ui32 i = 0; i < num_comps; ++i)
410 {
411 comp_downsamp[i] = ojph::point(0, 0);
412 bit_depth[i] = 0;
413 is_signed[i] = -1;
414 }
415 }
416
417 point_list_interpreter pointlist(max_num_comps, num_comp_downsamps,
418 comp_downsamp);
419 ui32_list_interpreter ilist(max_num_comps, num_bit_depths, bit_depth);
420 si32_to_bool_list_interpreter blist(max_num_comps, num_is_signed, is_signed);
421 point_interpreter img_off_interpreter(image_offset);
422 size_interpreter tile_size_interpreter(tile_size);
423 point_interpreter tile_off_interpreter(tile_offset);
424 tileparts_division_interpreter tp_div_interpreter(tileparts_at_resolutions,
425 tileparts_at_components);
426 try
427 {
428 interpreter.reinterpret("-block_size", &block_interpreter);
429 interpreter.reinterpret("-dims", &dims_interpreter);
430 interpreter.reinterpret("-image_offset", &img_off_interpreter);
431 interpreter.reinterpret("-tile_size", &tile_size_interpreter);
432 interpreter.reinterpret("-tile_offset", &tile_off_interpreter);
433 interpreter.reinterpret("-precincts", &sizelist);
434 interpreter.reinterpret("-downsamp", &pointlist);
435 interpreter.reinterpret("-bit_depth", &ilist);
436 interpreter.reinterpret("-signed", &blist);
437 interpreter.reinterpret("-tileparts", &tp_div_interpreter);
438 }
439 catch (const char *s)
440 {
441 printf("%s\n",s);
442 return false;
443 }
444
445 if (interpreter.is_exhausted() == false) {
446 printf("The following arguments were not interpreted:\n");
447 ojph::argument t = interpreter.get_argument_zero();
448 t = interpreter.get_next_avail_argument(t);
449 while (t.is_valid()) {
450 printf("%s\n", t.arg);
451 t = interpreter.get_next_avail_argument(t);
452 }
453 return false;
454 }
455 return true;
456}
457
459static
460const char* get_file_extension(const char* filename)
461{
462 size_t len = strlen(filename);
463 const char* p = strrchr(filename, '.');
464 if (p == NULL || p == filename + len - 1)
465 OJPH_ERROR(0x01000071,
466 "no file extension is found, or there are no characters "
467 "after the dot \'.\' for filename \"%s\" \n", filename);
468 return p;
469}
470
472static
473bool is_matching(const char *ref, const char *other)
474{
475 size_t num_ele = strlen(ref);
476
477 if (num_ele != strlen(other))
478 return false;
479
480 for (ojph::ui32 i = 0; i < num_ele; ++i)
481 if (ref[i] != other[i] && ref[i] != tolower(other[i]))
482 return false;
483
484 return true;
485}
486
488// main
490
491int main(int argc, char * argv[]) {
492 char *input_filename = NULL;
493 char *output_filename = NULL;
494 char prog_order_store[] = "RPCL";
495 char *prog_order = prog_order_store;
496 char profile_string_store[] = "";
497 char *profile_string = profile_string_store;
498 char *com_string = NULL;
499 ojph::ui32 num_decompositions = 5;
500 float quantization_step = -1.0f;
501 bool reversible = false;
502 int employ_color_transform = -1;
503
504 const int max_precinct_sizes = 33; //maximum number of decompositions is 32
505 ojph::size precinct_size[max_precinct_sizes];
506 int num_precincts = -1;
507
508 ojph::size block_size(64,64);
509 ojph::size dims(0, 0);
510 ojph::size tile_size(0, 0);
511 ojph::point tile_offset(0, 0);
512 ojph::point image_offset(0, 0);
513 const ojph::ui32 initial_num_comps = 4;
514 ojph::ui32 max_num_comps = initial_num_comps;
515 ojph::ui32 num_components = 0;
516 ojph::ui32 num_is_signed = 0;
517 ojph::si32 is_signed_store[initial_num_comps] = {-1, -1, -1, -1};
518 ojph::si32 *is_signed = is_signed_store;
519 ojph::ui32 num_bit_depths = 0;
520 ojph::ui32 bit_depth_store[initial_num_comps] = {0, 0, 0, 0};
521 ojph::ui32 *bit_depth = bit_depth_store;
522 ojph::ui32 num_comp_downsamps = 0;
523 ojph::point downsampling_store[initial_num_comps];
524 ojph::point *comp_downsampling = downsampling_store;
525 bool tlm_marker = false;
526 bool tileparts_at_resolutions = false;
527 bool tileparts_at_components = false;
528
529 if (argc <= 1) {
530 std::cout <<
531 "\nThe following arguments are necessary:\n"
532#ifdef OJPH_ENABLE_TIFF_SUPPORT
533 " -i input file name (either pgm, ppm, pfm, tif(f), or raw(yuv))\n"
534#else
535 " -i input file name (either pgm, ppm, pfm, or raw(yuv))\n"
536#endif // !OJPH_ENABLE_TIFF_SUPPORT
537 " -o output file name\n\n"
538
539 "The following option has a default value (optional):\n"
540 " -num_decomps (5) number of decompositions\n"
541 " -qstep (0.00001...0.5) quantization step size for lossy\n"
542 " compression; quantization steps size for all subbands are\n"
543 " derived from this value. {The default value for 8bit\n"
544 " images is 0.0039}\n"
545 " -reversible <true | false> If this is 'false', an irreversible or\n"
546 " lossy compression is employed, using the 9/7 wavelet\n"
547 " transform; if 'true', a reversible compression is\n"
548 " performed, where the 5/3 wavelet is used.\n"
549 " Default value is 'false'.\n"
550 " -colour_trans <true | false> This option employs a color transform,\n"
551 " to transform RGB color images into the YUV domain.\n"
552 " This option should NOT be used with YUV images, because\n"
553 " they have already been transformed.\n"
554 " If there are three color components that are\n"
555 " downsampled by the same amount then this option can be\n"
556 " 'true' or 'false'. This option is also available when\n"
557 " there are more than three colour components, where it is\n"
558 " applied to the first three colour components.\n"
559 " -prog_order (RPCL) is the progression order, and can be one of:\n"
560 " LRCP, RLCP, RPCL, PCRL, CPRL.\n"
561 " -block_size {x,y} (64,64) where x and y are the height and width of\n"
562 " a codeblock. In unix-like environment, { and } must be\n"
563 " preceded by a ""\\"".\n"
564 " -precincts {x,y},{x,y},...,{x,y} where {x,y} is the precinct size\n"
565 " starting from the coarsest resolution; the last precinct\n"
566 " is repeated for all finer resolutions\n"
567 " -tile_offset {x,y} tile offset. \n"
568 " -tile_size {x,y} tile width and height. \n"
569 " -image_offset {x,y} image offset from origin. \n"
570 " -tileparts (None) employ tilepart divisions at each resolution, \n"
571 " indicated by the letter R, and/or component, indicated \n"
572 " by the letter C. For both, use \"-tileparts RC\".\n"
573 " -tlm_marker <true | false> if 'true', a TLM marker is inserted.\n"
574 " Default value is false.\n"
575 " -profile (None) is the profile, the code will check if the \n"
576 " selected options meet the profile. Currently only \n"
577 " BROADCAST and IMF are supported. This automatically \n"
578 " sets tlm_marker to true and tileparts to C.\n"
579 " -com (None) if set, inserts a COM marker with the specified\n"
580 " string. If the string has spaces, please use\n"
581 " double quotes, as in -com \"This is a comment\".\n"
582 "\n"
583
584 "When the input file is a YUV file, these arguments need to be \n"
585 " supplied: \n"
586 " -dims {x,y} x is image width, y is height\n"
587 " -num_comps number of components\n"
588 " -signed a comma-separated list of true or false parameters, one\n"
589 " for each component; for example: true,false,false\n"
590 " -bit_depth a comma-separated list of bit depth values, one per \n"
591 " component; for example: 12,10,10\n"
592 " -downsamp {x,y},{x,y},...,{x,y} a list of x,y points, one for each\n"
593 " component; for example {1,1},{2,2},{2,2}\n\n"
594 "\n"
595
596 ".pfm files receive special treatment. Currently, lossy compression\n"
597 "with these files is not supported, only lossless. When these files are\n"
598 "used, the NLT segment marker is automatically inserted into the\n"
599 "codestream when needed, as explained shortly. The following arguments\n"
600 "can be useful for this file type.\n"
601 " -signed a comma-separated list of true or false parameters, one\n"
602 " for each component; for example: true,false,false.\n"
603 " If you are sure that all sample values are positive or 0,\n"
604 " set the corresponding entry to false; otherwise set it to\n"
605 " true.\n"
606 " When a component entry is set to true, an NLT segment\n"
607 " marker segment is inserted into the codestream.\n"
608 " The NLT segment specifies a non-linear transform that\n"
609 " changes only negative values, producing better coding\n"
610 " efficiency.\n"
611 " The NLT segment marker might be less supported in other\n"
612 " encoders.\n"
613 " -bit_depth a comma-separated list of bit depth values, one per \n"
614 " component; for example: 12,10,10.\n"
615 " Floating value numbers are treated as integers, and they\n"
616 " are shifted to the right, keeping only the specified\n"
617 " number of bits. Up to 32 bits (which is the default) are\n"
618 " supported.\n"
619
620 "\n";
621 return -1;
622 }
623 if (!get_arguments(argc, argv, input_filename, output_filename,
624 prog_order, profile_string, num_decompositions,
625 quantization_step, reversible, employ_color_transform,
626 max_precinct_sizes, num_precincts, precinct_size,
627 block_size, dims, image_offset, tile_size, tile_offset,
628 max_num_comps, num_components,
629 num_comp_downsamps, comp_downsampling,
630 num_bit_depths, bit_depth, num_is_signed, is_signed,
631 tlm_marker, tileparts_at_resolutions,
632 tileparts_at_components, com_string))
633 {
634 return -1;
635 }
636
637 clock_t begin = clock();
638
639 try
640 {
641 ojph::codestream codestream;
642
643 ojph::ppm_in ppm;
644 ojph::pfm_in pfm;
645 ojph::yuv_in yuv;
646 ojph::raw_in raw;
647 ojph::dpx_in dpx;
648#ifdef OJPH_ENABLE_TIFF_SUPPORT
649 ojph::tif_in tif;
650#endif // !OJPH_ENABLE_TIFF_SUPPORT
651
652 ojph::image_in_base *base = NULL;
653 if (input_filename == NULL)
654 OJPH_ERROR(0x01000007, "please specify an input file name using"
655 " the -i command line option");
656 if (output_filename == NULL)
657 OJPH_ERROR(0x01000008, "please specify an output file name using"
658 " the -o command line option");
659 const char *v = get_file_extension(input_filename);
660
661 if (v)
662 {
663 if (is_matching(".pgm", v))
664 {
665 ppm.open(input_filename);
666 ojph::param_siz siz = codestream.access_siz();
667 siz.set_image_extent(ojph::point(image_offset.x + ppm.get_width(),
668 image_offset.y + ppm.get_height()));
669 ojph::ui32 num_comps = ppm.get_num_components();
670 assert(num_comps == 1);
671 siz.set_num_components(num_comps);
672 for (ojph::ui32 c = 0; c < num_comps; ++c)
674 ppm.get_bit_depth(c), ppm.get_is_signed(c));
675 siz.set_image_offset(image_offset);
676 siz.set_tile_size(tile_size);
677 siz.set_tile_offset(tile_offset);
678
679 ojph::param_cod cod = codestream.access_cod();
680 cod.set_num_decomposition(num_decompositions);
681 cod.set_block_dims(block_size.w, block_size.h);
682 if (num_precincts != -1)
683 cod.set_precinct_size(num_precincts, precinct_size);
684 cod.set_progression_order(prog_order);
685 cod.set_color_transform(false);
686 cod.set_reversible(reversible);
687 if (!reversible && quantization_step != -1.0f)
688 codestream.access_qcd().set_irrev_quant(quantization_step);
689 if (profile_string[0] != '\0')
690 codestream.set_profile(profile_string);
691 codestream.set_tilepart_divisions(tileparts_at_resolutions,
692 tileparts_at_components);
693 codestream.request_tlm_marker(tlm_marker);
694
695 if (employ_color_transform != -1)
696 OJPH_WARN(0x01000001,
697 "-colour_trans option is not needed and was not used\n");
698 if (dims.w != 0 || dims.h != 0)
699 OJPH_WARN(0x01000002,
700 "-dims option is not needed and was not used\n");
701 if (num_components != 0)
702 OJPH_WARN(0x01000003,
703 "-num_comps is not needed and was not used\n");
704 if (is_signed[0] != -1)
705 OJPH_WARN(0x01000004,
706 "-signed is not needed and was not used\n");
707 if (bit_depth[0] != 0)
708 OJPH_WARN(0x01000005,
709 "-bit_depth is not needed and was not used\n");
710 if (comp_downsampling[0].x != 0 || comp_downsampling[0].y != 0)
711 OJPH_WARN(0x01000006,
712 "-downsamp is not needed and was not used\n");
713
714 base = &ppm;
715 }
716 else if (is_matching(".ppm", v))
717 {
718 ppm.open(input_filename);
719 ojph::param_siz siz = codestream.access_siz();
720 siz.set_image_extent(ojph::point(image_offset.x + ppm.get_width(),
721 image_offset.y + ppm.get_height()));
722 ojph::ui32 num_comps = ppm.get_num_components();
723 assert(num_comps == 3);
724 siz.set_num_components(num_comps);
725 for (ojph::ui32 c = 0; c < num_comps; ++c)
727 ppm.get_bit_depth(c), ppm.get_is_signed(c));
728 siz.set_image_offset(image_offset);
729 siz.set_tile_size(tile_size);
730 siz.set_tile_offset(tile_offset);
731
732 ojph::param_cod cod = codestream.access_cod();
733 cod.set_num_decomposition(num_decompositions);
734 cod.set_block_dims(block_size.w, block_size.h);
735 if (num_precincts != -1)
736 cod.set_precinct_size(num_precincts, precinct_size);
737 cod.set_progression_order(prog_order);
738 if (employ_color_transform == -1)
739 cod.set_color_transform(true);
740 else
741 cod.set_color_transform(employ_color_transform == 1);
742 cod.set_reversible(reversible);
743 if (!reversible && quantization_step != -1.0f)
744 codestream.access_qcd().set_irrev_quant(quantization_step);
745 codestream.set_planar(false);
746 if (profile_string[0] != '\0')
747 codestream.set_profile(profile_string);
748 codestream.set_tilepart_divisions(tileparts_at_resolutions,
749 tileparts_at_components);
750 codestream.request_tlm_marker(tlm_marker);
751
752 if (dims.w != 0 || dims.h != 0)
753 OJPH_WARN(0x01000011,
754 "-dims option is not needed and was not used\n");
755 if (num_components != 0)
756 OJPH_WARN(0x01000012,
757 "-num_comps is not needed and was not used\n");
758 if (is_signed[0] != -1)
759 OJPH_WARN(0x01000013,
760 "-signed is not needed and was not used\n");
761 if (bit_depth[0] != 0)
762 OJPH_WARN(0x01000014,
763 "-bit_depth is not needed and was not used\n");
764 if (comp_downsampling[0].x != 0 || comp_downsampling[0].y != 0)
765 OJPH_WARN(0x01000015,
766 "-downsamp is not needed and was not used\n");
767
768 base = &ppm;
769 }
770 else if (is_matching(".pfm", v))
771 {
772 pfm.open(input_filename);
773 ojph::param_siz siz = codestream.access_siz();
774 siz.set_image_extent(ojph::point(image_offset.x + pfm.get_width(),
775 image_offset.y + pfm.get_height()));
776 ojph::ui32 num_comps = pfm.get_num_components();
777 assert(num_comps == 1 || num_comps == 3);
778 siz.set_num_components(num_comps);
779
780 if (bit_depth[0] != 0) // one was set
781 if (num_bit_depths < num_comps) // but if not enough, repeat
782 for (ojph::ui32 c = num_bit_depths; c < num_comps; ++c)
783 bit_depth[c] = bit_depth[num_bit_depths - 1];
784
785 bool all_the_same = true;
786 if (num_comps == 3)
787 all_the_same = all_the_same
788 && bit_depth[0] == bit_depth[1]
789 && bit_depth[1] == bit_depth[2];
790
791 for (ojph::ui32 c = 0; c < num_comps; ++c) {
792 if (bit_depth[c] == 0)
793 bit_depth[c] = 32;
794 siz.set_component(c, ojph::point(1,1), bit_depth[c], true);
795 }
796 pfm.configure(bit_depth);
797
798 siz.set_image_offset(image_offset);
799 siz.set_tile_size(tile_size);
800 siz.set_tile_offset(tile_offset);
801
802 ojph::param_cod cod = codestream.access_cod();
803 cod.set_num_decomposition(num_decompositions);
804 cod.set_block_dims(block_size.w, block_size.h);
805 if (num_precincts != -1)
806 cod.set_precinct_size(num_precincts, precinct_size);
807 cod.set_progression_order(prog_order);
808 if (num_comps == 1)
809 {
810 if (employ_color_transform != -1)
811 OJPH_WARN(0x01000091,
812 "-colour_trans option is not needed and was not used; "
813 "this is because the image has one component only\n");
814 }
815 else
816 {
817 if (employ_color_transform == -1)
818 cod.set_color_transform(true);
819 else
820 cod.set_color_transform(employ_color_transform == 1);
821 }
822 cod.set_reversible(reversible);
823 if (!reversible) {
824 const float min_step = 1.0f / 16384.0f;
825 if (quantization_step == -1.0f)
826 quantization_step = min_step;
827 else
828 quantization_step = ojph_max(quantization_step, min_step);
829 codestream.access_qcd().set_irrev_quant(quantization_step);
830 }
831
832 // Note: Even if only ALL_COMPS is set to
833 // OJPH_NLT_BINARY_COMPLEMENT_NLT, the library can decide if
834 // one ALL_COMPS NLT marker segment is needed, or multiple
835 // per component NLT marker segments are needed (when the components
836 // have different bit depths or signedness).
837 // Of course for .pfm images all components should have the same
838 // bit depth and signedness.
839 ojph::param_nlt nlt = codestream.access_nlt();
840 if (all_the_same)
843 else
844 for (ojph::ui32 c = 0; c < num_comps; ++c)
847
848 codestream.set_planar(false);
849 if (profile_string[0] != '\0')
850 codestream.set_profile(profile_string);
851 codestream.set_tilepart_divisions(tileparts_at_resolutions,
852 tileparts_at_components);
853 codestream.request_tlm_marker(tlm_marker);
854
855 if (dims.w != 0 || dims.h != 0)
856 OJPH_WARN(0x01000092,
857 "-dims option is not needed and was not used\n");
858 if (num_components != 0)
859 OJPH_WARN(0x01000093,
860 "-num_comps is not needed and was not used\n");
861 if (is_signed[0] != -1)
862 OJPH_WARN(0x01000094,
863 "-signed is not needed and was not used\n");
864 if (comp_downsampling[0].x != 0 || comp_downsampling[0].y != 0)
865 OJPH_WARN(0x01000095,
866 "-downsamp is not needed and was not used\n");
867
868 base = &pfm;
869 }
870#ifdef OJPH_ENABLE_TIFF_SUPPORT
871 else if (is_matching(".tif", v) || is_matching(".tiff", v))
872 {
873 tif.open(input_filename);
874 ojph::param_siz siz = codestream.access_siz();
875 siz.set_image_extent(ojph::point(image_offset.x + tif.get_size().w,
876 image_offset.y + tif.get_size().h));
877 ojph::ui32 num_comps = tif.get_num_components();
878 siz.set_num_components(num_comps);
879 if(num_bit_depths > 0 )
880 tif.set_bit_depth(num_bit_depths, bit_depth);
881 for (ojph::ui32 c = 0; c < num_comps; ++c)
882 siz.set_component(c, tif.get_comp_subsampling(c),
883 tif.get_bit_depth(c), tif.get_is_signed(c));
884 siz.set_image_offset(image_offset);
885 siz.set_tile_size(tile_size);
886 siz.set_tile_offset(tile_offset);
887
888 ojph::param_cod cod = codestream.access_cod();
889 cod.set_num_decomposition(num_decompositions);
890 cod.set_block_dims(block_size.w, block_size.h);
891 if (num_precincts != -1)
892 cod.set_precinct_size(num_precincts, precinct_size);
893 cod.set_progression_order(prog_order);
894 if (employ_color_transform == -1 && num_comps >= 3)
895 cod.set_color_transform(true);
896 else
897 cod.set_color_transform(employ_color_transform == 1);
898 cod.set_reversible(reversible);
899 if (!reversible && quantization_step != -1)
900 codestream.access_qcd().set_irrev_quant(quantization_step);
901 codestream.set_planar(false);
902 if (profile_string[0] != '\0')
903 codestream.set_profile(profile_string);
904 codestream.set_tilepart_divisions(tileparts_at_resolutions,
905 tileparts_at_components);
906 codestream.request_tlm_marker(tlm_marker);
907
908 if (dims.w != 0 || dims.h != 0)
909 OJPH_WARN(0x01000061,
910 "-dims option is not needed and was not used\n");
911 if (num_components != 0)
912 OJPH_WARN(0x01000062,
913 "-num_comps is not needed and was not used\n");
914 if (is_signed[0] != -1)
915 OJPH_WARN(0x01000063,
916 "-signed is not needed and was not used\n");
917 if (comp_downsampling[0].x != 0 || comp_downsampling[0].y != 0)
918 OJPH_WARN(0x01000065,
919 "-downsamp is not needed and was not used\n");
920
921 base = &tif;
922 }
923#endif // !OJPH_ENABLE_TIFF_SUPPORT
924 else if (is_matching(".yuv", v))
925 {
926 ojph::param_siz siz = codestream.access_siz();
927 if (dims.w == 0 || dims.h == 0)
928 OJPH_ERROR(0x01000021,
929 "-dims option must have positive dimensions\n");
930 siz.set_image_extent(ojph::point(image_offset.x + dims.w,
931 image_offset.y + dims.h));
932 if (num_components <= 0)
933 OJPH_ERROR(0x01000022,
934 "-num_comps option is missing and must be provided\n");
935 if (num_is_signed <= 0)
936 OJPH_ERROR(0x01000023,
937 "-signed option is missing and must be provided\n");
938 if (num_bit_depths <= 0)
939 OJPH_ERROR(0x01000024,
940 "-bit_depth option is missing and must be provided\n");
941 if (num_comp_downsamps <= 0)
942 OJPH_ERROR(0x01000025,
943 "-downsamp option is missing and must be provided\n");
944
945 yuv.set_img_props(dims, num_components, num_comp_downsamps,
946 comp_downsampling);
947 yuv.set_bit_depth(num_bit_depths, bit_depth);
948
949 ojph::ui32 last_signed_idx = 0, last_bit_depth_idx = 0;
950 ojph::ui32 last_downsamp_idx = 0;
951 siz.set_num_components(num_components);
952 for (ojph::ui32 c = 0; c < num_components; ++c)
953 {
954 ojph::point cp_ds = comp_downsampling
955 [c < num_comp_downsamps ? c : last_downsamp_idx];
956 last_downsamp_idx += last_downsamp_idx+1 < num_comp_downsamps ? 1:0;
957 ojph::ui32 bd = bit_depth[c<num_bit_depths ? c : last_bit_depth_idx];
958 last_bit_depth_idx += last_bit_depth_idx + 1 < num_bit_depths ? 1:0;
959 int is = is_signed[c < num_is_signed ? c : last_signed_idx];
960 last_signed_idx += last_signed_idx + 1 < num_is_signed ? 1 : 0;
961 siz.set_component(c, cp_ds, bd, is == 1);
962 }
963 siz.set_image_offset(image_offset);
964 siz.set_tile_size(tile_size);
965 siz.set_tile_offset(tile_offset);
966
967 ojph::param_cod cod = codestream.access_cod();
968 cod.set_num_decomposition(num_decompositions);
969 cod.set_block_dims(block_size.w, block_size.h);
970 if (num_precincts != -1)
971 cod.set_precinct_size(num_precincts, precinct_size);
972 cod.set_progression_order(prog_order);
973 if (employ_color_transform == -1)
974 cod.set_color_transform(false);
975 else
976 OJPH_ERROR(0x01000031,
977 "We currently do not support color transform on raw(yuv) files."
978 " In any case, this not a normal usage scenario. The OpenJPH "
979 "library however does support that, but ojph_compress.cpp must be "
980 "modified to send all lines from one component before moving to "
981 "the next component; this requires buffering components outside"
982 " of the OpenJPH library");
983 cod.set_reversible(reversible);
984 if (!reversible && quantization_step != -1.0f)
985 codestream.access_qcd().set_irrev_quant(quantization_step);
986 codestream.set_planar(true);
987 if (profile_string[0] != '\0')
988 codestream.set_profile(profile_string);
989 codestream.set_tilepart_divisions(tileparts_at_resolutions,
990 tileparts_at_components);
991 codestream.request_tlm_marker(tlm_marker);
992
993 yuv.open(input_filename);
994 base = &yuv;
995 }
996 else if (is_matching(".raw", v))
997 {
998 ojph::param_siz siz = codestream.access_siz();
999 if (dims.w == 0 || dims.h == 0)
1000 OJPH_ERROR(0x01000081,
1001 "-dims option must have positive dimensions\n");
1002 siz.set_image_extent(ojph::point(image_offset.x + dims.w,
1003 image_offset.y + dims.h));
1004 if (num_components != 1)
1005 OJPH_ERROR(0x01000082,
1006 "-num_comps must be 1\n");
1007 if (num_is_signed <= 0)
1008 OJPH_ERROR(0x01000083,
1009 "-signed option is missing and must be provided\n");
1010 if (num_bit_depths <= 0)
1011 OJPH_ERROR(0x01000084,
1012 "-bit_depth option is missing and must be provided\n");
1013 if (num_comp_downsamps <= 0)
1014 OJPH_ERROR(0x01000085,
1015 "-downsamp option is missing and must be provided\n");
1016
1017 raw.set_img_props(dims, bit_depth[0], is_signed);
1018
1019 siz.set_num_components(num_components);
1020 siz.set_component(0, comp_downsampling[0], bit_depth[0], is_signed[0]);
1021 siz.set_image_offset(image_offset);
1022 siz.set_tile_size(tile_size);
1023 siz.set_tile_offset(tile_offset);
1024
1025 ojph::param_cod cod = codestream.access_cod();
1026 cod.set_num_decomposition(num_decompositions);
1027 cod.set_block_dims(block_size.w, block_size.h);
1028 if (num_precincts != -1)
1029 cod.set_precinct_size(num_precincts, precinct_size);
1030 cod.set_progression_order(prog_order);
1031 if (employ_color_transform != -1)
1032 OJPH_ERROR(0x01000086,
1033 "color transform is meaningless since .raw files are single "
1034 "component files");
1035 cod.set_reversible(reversible);
1036 if (!reversible && quantization_step != -1.0f)
1037 codestream.access_qcd().set_irrev_quant(quantization_step);
1038 codestream.set_planar(true);
1039 if (profile_string[0] != '\0')
1040 codestream.set_profile(profile_string);
1041 codestream.set_tilepart_divisions(tileparts_at_resolutions,
1042 tileparts_at_components);
1043 codestream.request_tlm_marker(tlm_marker);
1044
1045 raw.open(input_filename);
1046 base = &raw;
1047 }
1048 else if (is_matching(".dpx", v))
1049 {
1050 dpx.open(input_filename);
1051 ojph::param_siz siz = codestream.access_siz();
1052 siz.set_image_extent(ojph::point(image_offset.x + dpx.get_size().w,
1053 image_offset.y + dpx.get_size().h));
1054 ojph::ui32 num_comps = dpx.get_num_components();
1055 siz.set_num_components(num_comps);
1056 //if (num_bit_depths > 0)
1057 // dpx.set_bit_depth(num_bit_depths, bit_depth);
1058 for (ojph::ui32 c = 0; c < num_comps; ++c)
1059 siz.set_component(c, dpx.get_comp_subsampling(c),
1060 dpx.get_bit_depth(c), dpx.get_is_signed(c));
1061 siz.set_image_offset(image_offset);
1062 siz.set_tile_size(tile_size);
1063 siz.set_tile_offset(tile_offset);
1064
1065 ojph::param_cod cod = codestream.access_cod();
1066 cod.set_num_decomposition(num_decompositions);
1067 cod.set_block_dims(block_size.w, block_size.h);
1068 if (num_precincts != -1)
1069 cod.set_precinct_size(num_precincts, precinct_size);
1070 cod.set_progression_order(prog_order);
1071 if (employ_color_transform == -1 && num_comps >= 3)
1072 cod.set_color_transform(true);
1073 else
1074 cod.set_color_transform(employ_color_transform == 1);
1075 cod.set_reversible(reversible);
1076 if (!reversible && quantization_step != -1)
1077 codestream.access_qcd().set_irrev_quant(quantization_step);
1078 codestream.set_planar(false);
1079 if (profile_string[0] != '\0')
1080 codestream.set_profile(profile_string);
1081 codestream.set_tilepart_divisions(tileparts_at_resolutions,
1082 tileparts_at_components);
1083 codestream.request_tlm_marker(tlm_marker);
1084
1085 if (dims.w != 0 || dims.h != 0)
1086 OJPH_WARN(0x01000071,
1087 "-dims option is not needed and was not used\n");
1088 if (num_components != 0)
1089 OJPH_WARN(0x01000072,
1090 "-num_comps is not needed and was not used\n");
1091 if (is_signed[0] != -1)
1092 OJPH_WARN(0x01000073,
1093 "-signed is not needed and was not used\n");
1094 if (comp_downsampling[0].x != 0 || comp_downsampling[0].y != 0)
1095 OJPH_WARN(0x01000075,
1096 "-downsamp is not needed and was not used\n");
1097
1098 base = &dpx;
1099 }
1100 else
1101#if defined( OJPH_ENABLE_TIFF_SUPPORT)
1102 OJPH_ERROR(0x01000041,
1103 "unknown input file extension; only pgm, ppm, dpx, tif(f),"
1104 " or raw(yuv) are supported\n");
1105#else
1106 OJPH_ERROR(0x01000041,
1107 "unknown input file extension; only pgm, ppm, dpx,"
1108 " or raw(yuv) are supported\n");
1109#endif // !OJPH_ENABLE_TIFF_SUPPORT
1110 }
1111 else
1112 OJPH_ERROR(0x01000051,
1113 "Please supply a proper input filename with a proper three-letter "
1114 "extension\n");
1115
1117 if (com_string)
1118 com_ex.set_string(com_string);
1119 ojph::j2c_outfile j2c_file;
1120 j2c_file.open(output_filename);
1121 codestream.write_headers(&j2c_file, &com_ex, com_string ? 1 : 0);
1122
1123 ojph::ui32 next_comp;
1124 ojph::line_buf* cur_line = codestream.exchange(NULL, next_comp);
1125 if (codestream.is_planar())
1126 {
1127 ojph::param_siz siz = codestream.access_siz();
1128 for (ojph::ui32 c = 0; c < siz.get_num_components(); ++c)
1129 {
1130 ojph::point p = siz.get_downsampling(c);
1131 ojph::ui32 height = ojph_div_ceil(siz.get_image_extent().y, p.y);
1132 height -= ojph_div_ceil(siz.get_image_offset().y, p.y);
1133 for (ojph::ui32 i = height; i > 0; --i)
1134 {
1135 assert(c == next_comp);
1136 base->read(cur_line, next_comp);
1137 cur_line = codestream.exchange(cur_line, next_comp);
1138 }
1139 }
1140 }
1141 else
1142 {
1143 ojph::param_siz siz = codestream.access_siz();
1144 ojph::ui32 height = siz.get_image_extent().y;
1145 height -= siz.get_image_offset().y;
1146 for (ojph::ui32 i = 0; i < height; ++i)
1147 {
1148 for (ojph::ui32 c = 0; c < siz.get_num_components(); ++c)
1149 {
1150 assert(c == next_comp);
1151 base->read(cur_line, next_comp);
1152 cur_line = codestream.exchange(cur_line, next_comp);
1153 }
1154 }
1155 }
1156
1157 codestream.flush();
1158 codestream.close();
1159 base->close();
1160
1161 if (max_num_comps != initial_num_comps)
1162 {
1163 delete[] comp_downsampling;
1164 delete[] bit_depth;
1165 delete[] is_signed;
1166 }
1167 }
1168 catch (const std::exception& e)
1169 {
1170 const char *p = e.what();
1171 if (strncmp(p, "ojph error", 10) != 0)
1172 printf("%s\n", p);
1173 exit(-1);
1174 }
1175
1176 clock_t end = clock();
1177 double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;
1178 printf("Elapsed time = %f\n", elapsed_secs);
1179
1180 return 0;
1181
1182}
bool is_valid()
Definition ojph_arg.h:58
void init(int argc, char *argv[])
Definition ojph_arg.h:73
void reinterpret_to_bool(const char *str, int &val)
Definition ojph_arg.h:216
void reinterpret(const char *str, int &val)
Definition ojph_arg.h:146
argument get_argument_zero()
Definition ojph_arg.h:126
argument get_next_avail_argument(const argument &arg)
Definition ojph_arg.h:133
The object represent a codestream.
param_siz access_siz()
Returns the underlying SIZ marker segment object.
param_cod access_cod()
Returns the underlying COD marker segment object.
void close()
Call this function to close the underlying file; works for both encoding and decoding codestreams.
void set_planar(bool planar)
Sets the sequence of pushing or pull rows from the machinery.
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...
void request_tlm_marker(bool needed)
Request the addition of the optional TLM marker segment. This request should occur before writing cod...
void set_profile(const char *s)
Sets the codestream profile.
param_qcd access_qcd()
Returns the underlying QCD marker segment object.
void set_tilepart_divisions(bool at_resolutions, bool at_components)
Sets the locations where a tile is partitioned into tile parts.
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...
param_nlt access_nlt()
Returns the underlying NLT marker segment object.
bool is_planar() const
Query if the codestream extraction is planar or not. See the documentation for ojph::codestream::set_...
void flush()
This is the last call to a writing (encoding) codestream. This will write encoded bitstream data to t...
void set_string(const char *str)
ui32 get_num_components()
bool get_is_signed(ui32 comp_num)
void open(const char *filename)
ui32 get_bit_depth(ui32 comp_num)
size get_size()
point get_comp_subsampling(ui32 comp_num)
virtual void close()
Definition ojph_img_io.h:71
virtual ui32 read(const line_buf *line, ui32 comp_num)=0
void open(const char *filename)
Definition ojph_file.cpp:62
void set_num_decomposition(ui32 num_decompositions)
void set_precinct_size(int num_levels, size *precinct_size)
void set_progression_order(const char *name)
void set_block_dims(ui32 width, ui32 height)
void set_color_transform(bool color_transform)
void set_reversible(bool reversible)
non-linearity point transformation object (implements NLT marker segment)
@ OJPH_NLT_BINARY_COMPLEMENT_NLT
void set_nonlinear_transform(ui32 comp_num, ui8 nl_type)
enables or disables type 3 nonlinearity for a component or the default setting
void set_irrev_quant(float delta)
Set the irreversible quantization base delta.
void set_tile_size(size s)
point get_image_extent() const
void set_component(ui32 comp_num, const point &downsampling, ui32 bit_depth, bool is_signed)
void set_num_components(ui32 num_comps)
void set_tile_offset(point offset)
point get_image_offset() const
void set_image_offset(point offset)
point get_downsampling(ui32 comp_num) const
void set_image_extent(point extent)
ui32 get_num_components() const
ui32 get_width()
ui32 get_height()
void open(const char *filename)
ui32 get_num_components()
void configure(ui32 *bit_depth)
ui32 get_height()
void open(const char *filename)
ui32 get_num_components()
ui32 get_width()
ui32 get_bit_depth(ui32 comp_num)
point get_comp_subsampling(ui32 comp_num)
bool get_is_signed(ui32 comp_num)
void set_img_props(const size &s, ui32 bit_depth, bool is_signed)
void open(const char *filename)
void open(const char *filename)
void set_img_props(const size &s, ui32 num_components, ui32 num_downsampling, const point *downsampling)
void set_bit_depth(ui32 num_bit_depths, ui32 *bit_depth)
int32_t si32
Definition ojph_defs.h:55
uint32_t ui32
Definition ojph_defs.h:54
int main(int argc, char *argv[])
static const char * get_file_extension(const char *filename)
static bool get_arguments(int argc, char *argv[], char *&input_filename, char *&output_filename, char *&progression_order, char *&profile_string, ojph::ui32 &num_decompositions, float &quantization_step, bool &reversible, int &employ_color_transform, const int max_num_precincts, int &num_precincts, ojph::size *precinct_size, ojph::size &block_size, ojph::size &dims, ojph::point &image_offset, ojph::size &tile_size, ojph::point &tile_offset, ojph::ui32 &max_num_comps, ojph::ui32 &num_comps, ojph::ui32 &num_comp_downsamps, ojph::point *&comp_downsamp, ojph::ui32 &num_bit_depths, ojph::ui32 *&bit_depth, ojph::ui32 &num_is_signed, ojph::si32 *&is_signed, bool &tlm_marker, bool &tileparts_at_resolutions, bool &tileparts_at_components, char *&com_string)
static bool is_matching(const char *ref, const char *other)
#define ojph_max(a, b)
Definition ojph_defs.h:73
#define ojph_div_ceil(a, b)
Definition ojph_defs.h:70
#define OJPH_ERROR(t,...)
#define OJPH_WARN(t,...)
point_interpreter(ojph::point &val)
virtual void operate(const char *str)
const ojph::ui32 max_num_eles
virtual void operate(const char *str)
point_list_interpreter(const ojph::ui32 max_num_elements, ojph::ui32 &num_elements, ojph::point *list)
si32_to_bool_list_interpreter(const ojph::ui32 max_num_elements, ojph::ui32 &num_elements, ojph::si32 *list)
virtual void operate(const char *str)
virtual void operate(const char *str)
size_interpreter(ojph::size &val)
virtual void operate(const char *str)
size_list_interpreter(const int max_num_elements, int &num_elements, ojph::size *list)
tileparts_division_interpreter(bool &at_resolutions, bool &at_components)
virtual void operate(const char *str)
virtual void operate(const char *str)
ui32_list_interpreter(const ojph::ui32 max_num_elements, ojph::ui32 &num_elements, ojph::ui32 *list)
const ojph::ui32 max_num_eles