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 > 255)
398 throw "more than 255 components is not supported";
399 if (num_comps > max_num_comps)
400 {
401 max_num_comps = num_comps;
402 comp_downsamp = new ojph::point[num_comps];
403 bit_depth = new ojph::ui32[num_comps];
404 is_signed = new ojph::si32[num_comps];
405 for (ojph::ui32 i = 0; i < num_comps; ++i)
406 {
407 comp_downsamp[i] = ojph::point(0, 0);
408 bit_depth[i] = 0;
409 is_signed[i] = -1;
410 }
411 }
412
413 point_list_interpreter pointlist(max_num_comps, num_comp_downsamps,
414 comp_downsamp);
415 ui32_list_interpreter ilist(max_num_comps, num_bit_depths, bit_depth);
416 si32_to_bool_list_interpreter blist(max_num_comps, num_is_signed, is_signed);
417 point_interpreter img_off_interpreter(image_offset);
418 size_interpreter tile_size_interpreter(tile_size);
419 point_interpreter tile_off_interpreter(tile_offset);
420 tileparts_division_interpreter tp_div_interpreter(tileparts_at_resolutions,
421 tileparts_at_components);
422 try
423 {
424 interpreter.reinterpret("-block_size", &block_interpreter);
425 interpreter.reinterpret("-dims", &dims_interpreter);
426 interpreter.reinterpret("-image_offset", &img_off_interpreter);
427 interpreter.reinterpret("-tile_size", &tile_size_interpreter);
428 interpreter.reinterpret("-tile_offset", &tile_off_interpreter);
429 interpreter.reinterpret("-precincts", &sizelist);
430 interpreter.reinterpret("-downsamp", &pointlist);
431 interpreter.reinterpret("-bit_depth", &ilist);
432 interpreter.reinterpret("-signed", &blist);
433 interpreter.reinterpret("-tileparts", &tp_div_interpreter);
434 }
435 catch (const char *s)
436 {
437 printf("%s\n",s);
438 return false;
439 }
440
441 if (interpreter.is_exhausted() == false) {
442 printf("The following arguments were not interpreted:\n");
443 ojph::argument t = interpreter.get_argument_zero();
444 t = interpreter.get_next_avail_argument(t);
445 while (t.is_valid()) {
446 printf("%s\n", t.arg);
447 t = interpreter.get_next_avail_argument(t);
448 }
449 return false;
450 }
451 return true;
452}
453
455static
456const char* get_file_extension(const char* filename)
457{
458 size_t len = strlen(filename);
459 const char* p = strrchr(filename, '.');
460 if (p == NULL || p == filename + len - 1)
461 OJPH_ERROR(0x01000071,
462 "no file extension is found, or there are no characters "
463 "after the dot \'.\' for filename \"%s\" \n", filename);
464 return p;
465}
466
468static
469bool is_matching(const char *ref, const char *other)
470{
471 size_t num_ele = strlen(ref);
472
473 if (num_ele != strlen(other))
474 return false;
475
476 for (ojph::ui32 i = 0; i < num_ele; ++i)
477 if (ref[i] != other[i] && ref[i] != tolower(other[i]))
478 return false;
479
480 return true;
481}
482
484// main
486
487int main(int argc, char * argv[]) {
488 char *input_filename = NULL;
489 char *output_filename = NULL;
490 char prog_order_store[] = "RPCL";
491 char *prog_order = prog_order_store;
492 char profile_string_store[] = "";
493 char *profile_string = profile_string_store;
494 char *com_string = NULL;
495 ojph::ui32 num_decompositions = 5;
496 float quantization_step = -1.0f;
497 bool reversible = false;
498 int employ_color_transform = -1;
499
500 const int max_precinct_sizes = 33; //maximum number of decompositions is 32
501 ojph::size precinct_size[max_precinct_sizes];
502 int num_precincts = -1;
503
504 ojph::size block_size(64,64);
505 ojph::size dims(0, 0);
506 ojph::size tile_size(0, 0);
507 ojph::point tile_offset(0, 0);
508 ojph::point image_offset(0, 0);
509 const ojph::ui32 initial_num_comps = 4;
510 ojph::ui32 max_num_comps = initial_num_comps;
511 ojph::ui32 num_components = 0;
512 ojph::ui32 num_is_signed = 0;
513 ojph::si32 is_signed_store[initial_num_comps] = {-1, -1, -1, -1};
514 ojph::si32 *is_signed = is_signed_store;
515 ojph::ui32 num_bit_depths = 0;
516 ojph::ui32 bit_depth_store[initial_num_comps] = {0, 0, 0, 0};
517 ojph::ui32 *bit_depth = bit_depth_store;
518 ojph::ui32 num_comp_downsamps = 0;
519 ojph::point downsampling_store[initial_num_comps];
520 ojph::point *comp_downsampling = downsampling_store;
521 bool tlm_marker = false;
522 bool tileparts_at_resolutions = false;
523 bool tileparts_at_components = false;
524
525 if (argc <= 1) {
526 std::cout <<
527 "\nThe following arguments are necessary:\n"
528#ifdef OJPH_ENABLE_TIFF_SUPPORT
529 " -i input file name (either pgm, ppm, pfm, tif(f), or raw(yuv))\n"
530#else
531 " -i input file name (either pgm, ppm, pfm, or raw(yuv))\n"
532#endif // !OJPH_ENABLE_TIFF_SUPPORT
533 " -o output file name\n\n"
534
535 "The following option has a default value (optional):\n"
536 " -num_decomps (5) number of decompositions\n"
537 " -qstep (0.00001...0.5) quantization step size for lossy\n"
538 " compression; quantization steps size for all subbands are\n"
539 " derived from this value. {The default value for 8bit\n"
540 " images is 0.0039}\n"
541 " -reversible <true | false> If this is 'false', an irreversible or\n"
542 " lossy compression is employed, using the 9/7 wavelet\n"
543 " transform; if 'true', a reversible compression is\n"
544 " performed, where the 5/3 wavelet is used.\n"
545 " Default value is 'false'.\n"
546 " -colour_trans <true | false> This option employs a color transform,\n"
547 " to transform RGB color images into the YUV domain.\n"
548 " This option should NOT be used with YUV images, because\n"
549 " they have already been transformed.\n"
550 " If there are three color components that are\n"
551 " downsampled by the same amount then this option can be\n"
552 " 'true' or 'false'. This option is also available when\n"
553 " there are more than three colour components, where it is\n"
554 " applied to the first three colour components.\n"
555 " -prog_order (RPCL) is the progression order, and can be one of:\n"
556 " LRCP, RLCP, RPCL, PCRL, CPRL.\n"
557 " -block_size {x,y} (64,64) where x and y are the height and width of\n"
558 " a codeblock. In unix-like environment, { and } must be\n"
559 " preceded by a ""\\"".\n"
560 " -precincts {x,y},{x,y},...,{x,y} where {x,y} is the precinct size\n"
561 " starting from the coarsest resolution; the last precinct\n"
562 " is repeated for all finer resolutions\n"
563 " -tile_offset {x,y} tile offset. \n"
564 " -tile_size {x,y} tile width and height. \n"
565 " -image_offset {x,y} image offset from origin. \n"
566 " -tileparts (None) employ tilepart divisions at each resolution, \n"
567 " indicated by the letter R, and/or component, indicated \n"
568 " by the letter C. For both, use \"-tileparts RC\".\n"
569 " -tlm_marker <true | false> if 'true', a TLM marker is inserted.\n"
570 " Default value is false.\n"
571 " -profile (None) is the profile, the code will check if the \n"
572 " selected options meet the profile. Currently only \n"
573 " BROADCAST and IMF are supported. This automatically \n"
574 " sets tlm_marker to true and tileparts to C.\n"
575 " -com (None) if set, inserts a COM marker with the specified\n"
576 " string. If the string has spaces, please use\n"
577 " double quotes, as in -com \"This is a comment\".\n"
578 "\n"
579
580 "When the input file is a YUV file, these arguments need to be \n"
581 " supplied: \n"
582 " -dims {x,y} x is image width, y is height\n"
583 " -num_comps number of components\n"
584 " -signed a comma-separated list of true or false parameters, one\n"
585 " for each component; for example: true,false,false\n"
586 " -bit_depth a comma-separated list of bit depth values, one per \n"
587 " component; for example: 12,10,10\n"
588 " -downsamp {x,y},{x,y},...,{x,y} a list of x,y points, one for each\n"
589 " component; for example {1,1},{2,2},{2,2}\n\n"
590 "\n"
591
592 ".pfm files receive special treatment. Currently, lossy compression\n"
593 "with these files is not supported, only lossless. When these files are\n"
594 "used, the NLT segment marker is automatically inserted into the\n"
595 "codestream when needed, as explained shortly. The following arguments\n"
596 "can be useful for this file type.\n"
597 " -signed a comma-separated list of true or false parameters, one\n"
598 " for each component; for example: true,false,false.\n"
599 " If you are sure that all sample values are positive or 0,\n"
600 " set the corresponding entry to false; otherwise set it to\n"
601 " true.\n"
602 " When a component entry is set to true, an NLT segment\n"
603 " marker segment is inserted into the codestream.\n"
604 " The NLT segment specifies a non-linear transform that\n"
605 " changes only negative values, producing better coding\n"
606 " efficiency.\n"
607 " The NLT segment marker might be less supported in other\n"
608 " encoders.\n"
609 " -bit_depth a comma-separated list of bit depth values, one per \n"
610 " component; for example: 12,10,10.\n"
611 " Floating value numbers are treated as integers, and they\n"
612 " are shifted to the right, keeping only the specified\n"
613 " number of bits. Up to 32 bits (which is the default) are\n"
614 " supported.\n"
615
616 "\n";
617 return -1;
618 }
619 if (!get_arguments(argc, argv, input_filename, output_filename,
620 prog_order, profile_string, num_decompositions,
621 quantization_step, reversible, employ_color_transform,
622 max_precinct_sizes, num_precincts, precinct_size,
623 block_size, dims, image_offset, tile_size, tile_offset,
624 max_num_comps, num_components,
625 num_comp_downsamps, comp_downsampling,
626 num_bit_depths, bit_depth, num_is_signed, is_signed,
627 tlm_marker, tileparts_at_resolutions,
628 tileparts_at_components, com_string))
629 {
630 return -1;
631 }
632
633 clock_t begin = clock();
634
635 try
636 {
637 ojph::codestream codestream;
638
639 ojph::ppm_in ppm;
640 ojph::pfm_in pfm;
641 ojph::yuv_in yuv;
642 ojph::raw_in raw;
643 ojph::dpx_in dpx;
644#ifdef OJPH_ENABLE_TIFF_SUPPORT
645 ojph::tif_in tif;
646#endif // !OJPH_ENABLE_TIFF_SUPPORT
647
648 ojph::image_in_base *base = NULL;
649 if (input_filename == NULL)
650 OJPH_ERROR(0x01000007, "please specify an input file name using"
651 " the -i command line option");
652 if (output_filename == NULL)
653 OJPH_ERROR(0x01000008, "please specify an output file name using"
654 " the -o command line option");
655 const char *v = get_file_extension(input_filename);
656
657 if (v)
658 {
659 if (is_matching(".pgm", v))
660 {
661 ppm.open(input_filename);
662 ojph::param_siz siz = codestream.access_siz();
663 siz.set_image_extent(ojph::point(image_offset.x + ppm.get_width(),
664 image_offset.y + ppm.get_height()));
665 ojph::ui32 num_comps = ppm.get_num_components();
666 assert(num_comps == 1);
667 siz.set_num_components(num_comps);
668 for (ojph::ui32 c = 0; c < num_comps; ++c)
670 ppm.get_bit_depth(c), ppm.get_is_signed(c));
671 siz.set_image_offset(image_offset);
672 siz.set_tile_size(tile_size);
673 siz.set_tile_offset(tile_offset);
674
675 ojph::param_cod cod = codestream.access_cod();
676 cod.set_num_decomposition(num_decompositions);
677 cod.set_block_dims(block_size.w, block_size.h);
678 if (num_precincts != -1)
679 cod.set_precinct_size(num_precincts, precinct_size);
680 cod.set_progression_order(prog_order);
681 cod.set_color_transform(false);
682 cod.set_reversible(reversible);
683 if (!reversible && quantization_step != -1.0f)
684 codestream.access_qcd().set_irrev_quant(quantization_step);
685 if (profile_string[0] != '\0')
686 codestream.set_profile(profile_string);
687 codestream.set_tilepart_divisions(tileparts_at_resolutions,
688 tileparts_at_components);
689 codestream.request_tlm_marker(tlm_marker);
690
691 if (employ_color_transform != -1)
692 OJPH_WARN(0x01000001,
693 "-colour_trans option is not needed and was not used\n");
694 if (dims.w != 0 || dims.h != 0)
695 OJPH_WARN(0x01000002,
696 "-dims option is not needed and was not used\n");
697 if (num_components != 0)
698 OJPH_WARN(0x01000003,
699 "-num_comps is not needed and was not used\n");
700 if (is_signed[0] != -1)
701 OJPH_WARN(0x01000004,
702 "-signed is not needed and was not used\n");
703 if (bit_depth[0] != 0)
704 OJPH_WARN(0x01000005,
705 "-bit_depth is not needed and was not used\n");
706 if (comp_downsampling[0].x != 0 || comp_downsampling[0].y != 0)
707 OJPH_WARN(0x01000006,
708 "-downsamp is not needed and was not used\n");
709
710 base = &ppm;
711 }
712 else if (is_matching(".ppm", v))
713 {
714 ppm.open(input_filename);
715 ojph::param_siz siz = codestream.access_siz();
716 siz.set_image_extent(ojph::point(image_offset.x + ppm.get_width(),
717 image_offset.y + ppm.get_height()));
718 ojph::ui32 num_comps = ppm.get_num_components();
719 assert(num_comps == 3);
720 siz.set_num_components(num_comps);
721 for (ojph::ui32 c = 0; c < num_comps; ++c)
723 ppm.get_bit_depth(c), ppm.get_is_signed(c));
724 siz.set_image_offset(image_offset);
725 siz.set_tile_size(tile_size);
726 siz.set_tile_offset(tile_offset);
727
728 ojph::param_cod cod = codestream.access_cod();
729 cod.set_num_decomposition(num_decompositions);
730 cod.set_block_dims(block_size.w, block_size.h);
731 if (num_precincts != -1)
732 cod.set_precinct_size(num_precincts, precinct_size);
733 cod.set_progression_order(prog_order);
734 if (employ_color_transform == -1)
735 cod.set_color_transform(true);
736 else
737 cod.set_color_transform(employ_color_transform == 1);
738 cod.set_reversible(reversible);
739 if (!reversible && quantization_step != -1.0f)
740 codestream.access_qcd().set_irrev_quant(quantization_step);
741 codestream.set_planar(false);
742 if (profile_string[0] != '\0')
743 codestream.set_profile(profile_string);
744 codestream.set_tilepart_divisions(tileparts_at_resolutions,
745 tileparts_at_components);
746 codestream.request_tlm_marker(tlm_marker);
747
748 if (dims.w != 0 || dims.h != 0)
749 OJPH_WARN(0x01000011,
750 "-dims option is not needed and was not used\n");
751 if (num_components != 0)