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,
374 bool& tlm_marker,
bool& tileparts_at_resolutions,
375 bool& tileparts_at_components,
char *&com_string)
378 interpreter.
init(argc, argv);
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);
389 interpreter.
reinterpret(
"-tlm_marker", tlm_marker);
398 throw "more than 255 components is not supported";
399 if (num_comps > max_num_comps)
401 max_num_comps = num_comps;
421 tileparts_at_components);
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);
433 interpreter.
reinterpret(
"-tileparts", &tp_div_interpreter);
435 catch (
const char *s)
442 printf(
"The following arguments were not interpreted:\n");
446 printf(
"%s\n", t.
arg);
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;
496 float quantization_step = -1.0f;
497 bool reversible =
false;
498 int employ_color_transform = -1;
500 const int max_precinct_sizes = 33;
502 int num_precincts = -1;
513 ojph::si32 is_signed_store[initial_num_comps] = {-1, -1, -1, -1};
516 ojph::ui32 bit_depth_store[initial_num_comps] = {0, 0, 0, 0};
520 ojph::point *comp_downsampling = downsampling_store;
521 bool tlm_marker =
false;
522 bool tileparts_at_resolutions =
false;
523 bool tileparts_at_components =
false;
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"
531 " -i input file name (either pgm, ppm, pfm, or raw(yuv))\n"
533 " -o output file name\n\n"
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"
580 "When the input file is a YUV file, these arguments need to be \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"
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"
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"
607 " The NLT segment marker might be less supported in other\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"
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))
633 clock_t begin = clock();
644#ifdef OJPH_ENABLE_TIFF_SUPPORT
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");
661 ppm.
open(input_filename);
666 assert(num_comps == 1);
678 if (num_precincts != -1)
683 if (!reversible && quantization_step != -1.0f)
685 if (profile_string[0] !=
'\0')
688 tileparts_at_components);
691 if (employ_color_transform != -1)
693 "-colour_trans option is not needed and was not used\n");
694 if (dims.
w != 0 || dims.
h != 0)
696 "-dims option is not needed and was not used\n");
697 if (num_components != 0)
699 "-num_comps is not needed and was not used\n");
700 if (is_signed[0] != -1)
702 "-signed is not needed and was not used\n");
703 if (bit_depth[0] != 0)
705 "-bit_depth is not needed and was not used\n");
706 if (comp_downsampling[0].x != 0 || comp_downsampling[0].y != 0)
708 "-downsamp is not needed and was not used\n");
714 ppm.
open(input_filename);
719 assert(num_comps == 3);
731 if (num_precincts != -1)
734 if (employ_color_transform == -1)
739 if (!reversible && quantization_step != -1.0f)
742 if (profile_string[0] !=
'\0')
745 tileparts_at_components);
748 if (dims.
w != 0 || dims.
h != 0)
750 "-dims option is not needed and was not used\n");
751 if (num_components != 0)