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

Merge/aous72 20240802 #149

Closed
Closed
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 src/core/codestream/ojph_codestream_local.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ namespace ojph {
cur_comp = 0;
cur_line = 0;
cur_tile_row = 0;
resilient = false;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My thinking is that an incomplete file is a catastrophic error.
So the default behavior should be to terminate with an error rather than terminate gracefully.
If the end user accepts this incompleteness, they can use the enable_resilience() function call to enable resilience.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, we do partial decodes all the time for being able to perform streaming decode, and that is enabled by default now, so we always want to allow it.

resilient = true;
skipped_res_for_read = skipped_res_for_recon = 0;

precinct_scratch_needed_bytes = 0;
Expand Down Expand Up @@ -1046,7 +1046,8 @@ namespace ojph {
int marker_idx = find_marker(infile, next_markers, 2);
if (marker_idx == -1)
{
OJPH_INFO(0x00030067, "File terminated early");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will get back to you on this one -- I need to check the code.
If you do not want to get any messages, which might be a good idea for WebAssembly, you can use
set_message_level(OJPH_MSG_LEVEL::NO_MSG)

// This is common, so don't log unless needed
// OJPH_INFO(0x00030067, "File terminated early");
break;
}
else if (marker_idx == 0)
Expand Down
30 changes: 15 additions & 15 deletions src/core/codestream/ojph_params.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -600,45 +600,45 @@ namespace ojph {
void param_siz::read(infile_base *file)
{
if (file->read(&Lsiz, 2) != 2)
OJPH_ERROR(0x00050041, "error reading SIZ marker");
OJPH_ERROR(0x00050041, "error reading SIZ marker, truncated file");
Lsiz = swap_byte(Lsiz);
int num_comps = (Lsiz - 38) / 3;
if (Lsiz != 38 + 3 * num_comps)
OJPH_ERROR(0x00050042, "error in SIZ marker length");
OJPH_ERROR(0x00050042, "error in SIZ marker length %d with components %d", Lsiz, num_comps);
if (file->read(&Rsiz, 2) != 2)
OJPH_ERROR(0x00050043, "error reading SIZ marker");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From this position downwards.
This fine granularity might be useful for a developer; it is of little use to a normal user.
The Rsiz, XSIZ, YSIZ, ... etc. are parameters within the SIZ marker segment. See the following table.

image

OJPH_ERROR(0x00050043, "error reading RSIZ marker");
Rsiz = swap_byte(Rsiz);
if ((Rsiz & 0x4000) == 0)
OJPH_ERROR(0x00050044,
"Rsiz bit 14 is not set (this is not a JPH file)");
if ((Rsiz & 0x8000) != 0 && (Rsiz & 0xF5F) != 0)
OJPH_WARN(0x00050001, "Rsiz in SIZ has unimplemented fields");
if (file->read(&Xsiz, 4) != 4)
OJPH_ERROR(0x00050045, "error reading SIZ marker");
OJPH_ERROR(0x00050045, "error reading XSIZ marker");
Xsiz = swap_byte(Xsiz);
if (file->read(&Ysiz, 4) != 4)
OJPH_ERROR(0x00050046, "error reading SIZ marker");
OJPH_ERROR(0x00050046, "error reading YSIZ marker");
Ysiz = swap_byte(Ysiz);
if (file->read(&XOsiz, 4) != 4)
OJPH_ERROR(0x00050047, "error reading SIZ marker");
OJPH_ERROR(0x00050047, "error reading XOSIZ marker");
XOsiz = swap_byte(XOsiz);
if (file->read(&YOsiz, 4) != 4)
OJPH_ERROR(0x00050048, "error reading SIZ marker");
OJPH_ERROR(0x00050048, "error reading YOSIZ marker");
YOsiz = swap_byte(YOsiz);
if (file->read(&XTsiz, 4) != 4)
OJPH_ERROR(0x00050049, "error reading SIZ marker");
OJPH_ERROR(0x00050049, "error reading XTSIZ marker");
XTsiz = swap_byte(XTsiz);
if (file->read(&YTsiz, 4) != 4)
OJPH_ERROR(0x0005004A, "error reading SIZ marker");
OJPH_ERROR(0x0005004A, "error reading YTSIZ marker");
YTsiz = swap_byte(YTsiz);
if (file->read(&XTOsiz, 4) != 4)
OJPH_ERROR(0x0005004B, "error reading SIZ marker");
OJPH_ERROR(0x0005004B, "error reading XTOSIZ marker");
XTOsiz = swap_byte(XTOsiz);
if (file->read(&YTOsiz, 4) != 4)
OJPH_ERROR(0x0005004C, "error reading SIZ marker");
OJPH_ERROR(0x0005004C, "error reading YTOSIZ marker");
YTOsiz = swap_byte(YTOsiz);
if (file->read(&Csiz, 2) != 2)
OJPH_ERROR(0x0005004D, "error reading SIZ marker");
OJPH_ERROR(0x0005004D, "error reading CSIZ marker");
Csiz = swap_byte(Csiz);
if (Csiz != num_comps)
OJPH_ERROR(0x0005004E, "Csiz does not match the SIZ marker size");
Expand All @@ -652,11 +652,11 @@ namespace ojph {
for (int c = 0; c < Csiz; ++c)
{
if (file->read(&cptr[c].SSiz, 1) != 1)
OJPH_ERROR(0x00050051, "error reading SIZ marker");
OJPH_ERROR(0x00050051, "error reading SSIZ marker");
if (file->read(&cptr[c].XRsiz, 1) != 1)
OJPH_ERROR(0x00050052, "error reading SIZ marker");
OJPH_ERROR(0x00050052, "error reading XRSIZ marker");
if (file->read(&cptr[c].YRsiz, 1) != 1)
OJPH_ERROR(0x00050053, "error reading SIZ marker");
OJPH_ERROR(0x00050053, "error reading YRSIZ marker");
}

ws_kern_support_needed = (Rsiz & 0x20) != 0;
Expand Down
4 changes: 2 additions & 2 deletions subprojects/js/build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
mkdir -p build
#(cd build && emcmake cmake -DCMAKE_BUILD_TYPE=Debug ..)
(cd build && emcmake cmake ..)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes the default build is debug.
Is that the intention? can you elaborate?

(cd build && emcmake cmake -DCMAKE_BUILD_TYPE=Debug ..)
#(cd build && emcmake cmake ..)
(cd build && emmake make VERBOSE=1 -j)
Loading