Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix .jph related things #152

Merged
merged 2 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ To see a help, use `-h` option.
## Supported file types
### Encoder
- input image formats: .pgm, .ppm, .pgx, .tif (libtiff required)
- output codestreams: .j2k, .j2c, .jphc (Part 15 codestream), .jph (Part 15 file format)
- output codestreams: .jhc (Part 15 codestream, .j2k and .j2c can be used as aliases), .jph (Part 15 file format)
- Note: Specifying .jph as the output triggers a JPH file creation, otherwise just a codestream will be generated.
### Decoder
- input codestreams : .j2k, .j2c, .jphc
- input codestreams : .j2k, .j2c, .jhc
- output image formats: .raw, .ppm, .pgm, .pgx
6 changes: 3 additions & 3 deletions source/apps/decoder/main_dec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void print_help(char *cmd) {
printf("JPEG 2000 Part 1 and Part 15 decoder\n");
printf("USAGE: %s [options]\n\n", cmd);
printf("OPTIONS:\n");
printf("-i: Input file. .j2k, .j2c, .jhc, and .jphc are supported.\n");
printf("-i: Input file. .j2k, .j2c, and .jhc are supported.\n");
printf(" .jp2 and .jph (box based file-format) are not supported.\n");
printf("-o: Output file. Supported formats are PPM, PGM, PGX and RAW.\n");
printf("-reduce n: Number of DWT resolution reduction.\n");
Expand All @@ -67,8 +67,8 @@ int main(int argc, char *argv[]) {
}
infile_ext_name = strrchr(infile_name, '.');
if (strcmp(infile_ext_name, ".j2k") != 0 && strcmp(infile_ext_name, ".j2c") != 0
&& strcmp(infile_ext_name, ".jhc") != 0 && strcmp(infile_ext_name, ".jphc") != 0) {
printf("ERROR: Supported extensions are .j2k, .j2c, .jhc, and .jphc\n");
&& strcmp(infile_ext_name, ".jhc") != 0) {
printf("ERROR: Supported extensions are .j2k, .j2c, .jhc\n");
exit(EXIT_FAILURE);
}
if (nullptr == (outfile_name = get_command_option(argc, argv, "-o"))) {
Expand Down
5 changes: 4 additions & 1 deletion source/apps/encoder/enc_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ void print_help(char *cmd) {
printf("%s: JPEG 2000 Part 15 encoder\n", cmd);
printf("USAGE: %s -i input-image(s) -o output-codestream [options...]\n\n", cmd);
printf("-i: Input-image(s)\n PGM, PPM, and TIFF (optional, 8 or 16 bpp only) are supported.\n");
printf("-o: Output codestream\n `.jhc` or `.j2c` are recommended as the extension.\n");
printf(
"-o: Output codestream/file\n To create a codestream, `.jhc` or `.j2c` are recommended as the "
"extension.\n");
printf(" Specifying `.jph` triggers a JPH file creation.\n");
printf(" Note: If this option is unspecified, encoding result is placed on a memory buffer.\n\n");
printf("OPTIONS:\n");
printf(
Expand Down
6 changes: 3 additions & 3 deletions source/core/jph/jph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ image_header_box::image_header_box(j2k_main_header &hdr) : box_base(22, 0x696864
HEIGHT = siz.y - Osiz.y;
WIDTH = siz.x - Osiz.x;
NC = hdr.SIZ->get_num_components();
uint8_t val = hdr.SIZ->get_bitdepth(0);
uint8_t val = hdr.SIZ->get_bitdepth(0) - 1;
for (uint16_t c = 1; c < NC; ++c) {
if (val != hdr.SIZ->get_bitdepth(c)) {
if (val != hdr.SIZ->get_bitdepth(c) - 1) {
val = 0xFF;
break;
}
}
BPC = val;
BPC = val | static_cast<uint8_t>((hdr.SIZ->is_signed(0)) ? 0x80 : 0);
}
bool image_header_box::needBPCC() {
bool val = false;
Expand Down
Loading