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

Adding support for NLT marker segment of type 3 #154

Merged
merged 20 commits into from
Sep 22, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
0f21481
Added support for NLT marker only, but not tested.
aous72 Sep 17, 2024
5d888b5
This is for lossless compression. It removes the 1.1f factor.
aous72 Sep 17, 2024
5f29603
This should complete all code changed for the library. We need to te…
aous72 Sep 17, 2024
517e1be
Getting rid of some of the warnings
aous72 Sep 17, 2024
2626fe2
2nd attempt to get rid of warnings.
aous72 Sep 17, 2024
fcd652c
Small bug fix for wasm
aous72 Sep 17, 2024
086a5a5
A bug fix, and addressing the float to double type conversion.
aous72 Sep 17, 2024
5921b01
Added support for .pfm in ojph_compress and ojph_expand -- not happy…
aous72 Sep 18, 2024
2a36ea4
Bug fixes, pfm with different bit_depth/signedness are supported now.
aous72 Sep 20, 2024
27c9a2e
This fixes the one component case.
aous72 Sep 20, 2024
0c6dfd3
Removes compilation warnings.
aous72 Sep 20, 2024
9f8011c
This fixes a bug in the block decoder code. The bug can happen when …
aous72 Sep 20, 2024
7b0f5c8
Improvement for pfm_in, and a bug fix for handling signed pfm data.
aous72 Sep 20, 2024
b6ddad9
This should address "strict-aliasing". Cosmetic change to a wasm file…
aous72 Sep 20, 2024
1580ae7
This address one more warning.
aous72 Sep 20, 2024
9e97f99
Hopefully, this will remove warnings.
aous72 Sep 20, 2024
bcc4d3b
Added usage text for ojph_compress. Also , the end user must now spe…
aous72 Sep 20, 2024
11307b6
Change default signedness of .pfm to true.
aous72 Sep 22, 2024
57c7af3
This adds some codestream checking in ojph_expand.
aous72 Sep 22, 2024
796fb6b
Spelling mistake fix.
aous72 Sep 22, 2024
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
6 changes: 6 additions & 0 deletions src/core/codestream/ojph_codestream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ namespace ojph {
return param_qcd(&state->qcd);
}

////////////////////////////////////////////////////////////////////////////
param_nlt codestream::access_nlt()
{
return param_nlt(&state->nlt);
}

////////////////////////////////////////////////////////////////////////////
void codestream::set_planar(bool planar)
{
Expand Down
59 changes: 37 additions & 22 deletions src/core/codestream/ojph_codestream_local.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,7 @@ namespace ojph {
cod.update_atk(atk);
qcd.check_validity(siz, cod);
cap.check_validity(cod, qcd);
nlt.check_validity(siz);
if (profile == OJPH_PN_IMF)
check_imf_validity();
else if (profile == OJPH_PN_BROADCAST)
Expand Down Expand Up @@ -632,6 +633,9 @@ namespace ojph {
if (!qcd.write(file))
OJPH_ERROR(0x00030026, "Error writing to file");

if (!nlt.write(file))
OJPH_ERROR(0x00030027, "Error writing to file");

char buf[] = " OpenJPH Ver "
OJPH_INT_TO_STRING(OPENJPH_VERSION_MAJOR) "."
OJPH_INT_TO_STRING(OPENJPH_VERSION_MINOR) "."
Expand All @@ -642,23 +646,23 @@ namespace ojph {
//1 for General use (IS 8859-15:1999 (Latin) values)
*(ui16*)(buf + 4) = swap_byte((ui16)(1));
if (file->write(buf, len) != len)
OJPH_ERROR(0x00030027, "Error writing to file");
OJPH_ERROR(0x00030028, "Error writing to file");

if (comments != NULL) {
for (ui32 i = 0; i < num_comments; ++i)
{
t = swap_byte(JP2K_MARKER::COM);
if (file->write(&t, 2) != 2)
OJPH_ERROR(0x00030028, "Error writing to file");
OJPH_ERROR(0x00030029, "Error writing to file");
t = swap_byte((ui16)(comments[i].len + 4));
if (file->write(&t, 2) != 2)
OJPH_ERROR(0x00030029, "Error writing to file");
OJPH_ERROR(0x0003002A, "Error writing to file");
//1 for General use (IS 8859-15:1999 (Latin) values)
t = swap_byte(comments[i].Rcom);
if (file->write(&t, 2) != 2)
OJPH_ERROR(0x0003002A, "Error writing to file");
if (file->write(comments[i].data, comments[i].len)!=comments[i].len)
OJPH_ERROR(0x0003002B, "Error writing to file");
if (file->write(comments[i].data, comments[i].len)!=comments[i].len)
OJPH_ERROR(0x0003002C, "Error writing to file");
}
}
}
Expand Down Expand Up @@ -728,16 +732,16 @@ namespace ojph {
//////////////////////////////////////////////////////////////////////////
void codestream::read_headers(infile_base *file)
{
ui16 marker_list[19] = { SOC, SIZ, CAP, PRF, CPF, COD, COC, QCD, QCC,
RGN, POC, PPM, TLM, PLM, CRG, COM, DFS, ATK, SOT };
ui16 marker_list[20] = { SOC, SIZ, CAP, PRF, CPF, COD, COC, QCD, QCC,
RGN, POC, PPM, TLM, PLM, CRG, COM, DFS, ATK, NLT, SOT };
find_marker(file, marker_list, 1); //find SOC
find_marker(file, marker_list + 1, 1); //find SIZ
siz.read(file);
int marker_idx = 0;
int received_markers = 0; //check that COD, & QCD received
while (true)
{
marker_idx = find_marker(file, marker_list + 2, 17);
marker_idx = find_marker(file, marker_list + 2, 18);
if (marker_idx == 0)
cap.read(file);
else if (marker_idx == 1)
Expand Down Expand Up @@ -813,6 +817,8 @@ namespace ojph {
else if (marker_idx == 15)
atk[2].read(file);
else if (marker_idx == 16)
nlt.read(file);
else if (marker_idx == 17)
break;
else
OJPH_ERROR(0x00030051, "File ended before finding a tile segment");
Expand Down Expand Up @@ -902,19 +908,20 @@ namespace ojph {
}

bool sod_found = false;
ui16 other_tile_part_markers[6] = { SOT, POC, PPT, PLT, COM, SOD };
ui16 other_tile_part_markers[7] = { SOT, POC, PPT, PLT, COM,
NLT, SOD };
while (true)
{
int marker_idx = 0;
int result = 0;
marker_idx = find_marker(infile, other_tile_part_markers + 1, 5);
marker_idx = find_marker(infile, other_tile_part_markers + 1, 6);
if (marker_idx == 0)
result = skip_marker(infile, "POC",
"POC in a tile is not supported yet",
"POC marker segment in a tile is not supported yet",
OJPH_MSG_LEVEL::WARN, resilient);
else if (marker_idx == 1)
result = skip_marker(infile, "PPT",
"PPT in a tile is not supported yet",
"PPT marker segment in a tile is not supported yet",
OJPH_MSG_LEVEL::WARN, resilient);
else if (marker_idx == 2)
//Skipping PLT marker segment;this should not cause any issues
Expand All @@ -924,6 +931,10 @@ namespace ojph {
result = skip_marker(infile, "COM", NULL,
OJPH_MSG_LEVEL::NO_MSG, resilient);
else if (marker_idx == 4)
result = skip_marker(infile, "NLT",
"NLT marker in tile is not supported yet",
OJPH_MSG_LEVEL::WARN, resilient);
else if (marker_idx == 5)
{
sod_found = true;
break;
Expand Down Expand Up @@ -961,40 +972,40 @@ namespace ojph {
else
{ //first tile part
bool sod_found = false;
ui16 first_tile_part_markers[11] = { SOT, COD, COC, QCD, QCC, RGN,
POC, PPT, PLT, COM, SOD };
ui16 first_tile_part_markers[12] = { SOT, COD, COC, QCD, QCC, RGN,
POC, PPT, PLT, COM, NLT, SOD };
while (true)
{
int marker_idx = 0;
int result = 0;
marker_idx = find_marker(infile, first_tile_part_markers+1, 10);
marker_idx = find_marker(infile, first_tile_part_markers+1, 11);
if (marker_idx == 0)
result = skip_marker(infile, "COD",
"COD in a tile is not supported yet",
"COD marker segment in a tile is not supported yet",
OJPH_MSG_LEVEL::WARN, resilient);
else if (marker_idx == 1)
result = skip_marker(infile, "COC",
"COC in a tile is not supported yet",
"COC marker segment in a tile is not supported yet",
OJPH_MSG_LEVEL::WARN, resilient);
else if (marker_idx == 2)
result = skip_marker(infile, "QCD",
"QCD in a tile is not supported yet",
"QCD marker segment in a tile is not supported yet",
OJPH_MSG_LEVEL::WARN, resilient);
else if (marker_idx == 3)
result = skip_marker(infile, "QCC",
"QCC in a tile is not supported yet",
"QCC marker segment in a tile is not supported yet",
OJPH_MSG_LEVEL::WARN, resilient);
else if (marker_idx == 4)
result = skip_marker(infile, "RGN",
"RGN in a tile is not supported yet",
"RGN marker segment in a tile is not supported yet",
OJPH_MSG_LEVEL::WARN, resilient);
else if (marker_idx == 5)
result = skip_marker(infile, "POC",
"POC in a tile is not supported yet",
"POC marker segment in a tile is not supported yet",
OJPH_MSG_LEVEL::WARN, resilient);
else if (marker_idx == 6)
result = skip_marker(infile, "PPT",
"PPT in a tile is not supported yet",
"PPT marker segment in a tile is not supported yet",
OJPH_MSG_LEVEL::WARN, resilient);
else if (marker_idx == 7)
//Skipping PLT marker segment;this should not cause any issues
Expand All @@ -1004,6 +1015,10 @@ namespace ojph {
result = skip_marker(infile, "COM", NULL,
OJPH_MSG_LEVEL::NO_MSG, resilient);
else if (marker_idx == 9)
result = skip_marker(infile, "NLT",
"PPT marker segment in a tile is not supported yet",
OJPH_MSG_LEVEL::WARN, resilient);
else if (marker_idx == 10)
{
sod_found = true;
break;
Expand Down
3 changes: 3 additions & 0 deletions src/core/codestream/ojph_codestream_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ namespace ojph {
}
const param_dfs* access_dfs()
{ if (dfs.exists()) return &dfs; else return NULL; }
const param_nlt* get_nlt()
{ return &nlt; }
mem_fixed_allocator* get_allocator() { return allocator; }
mem_elastic_allocator* get_elastic_alloc() { return elastic_alloc; }
outfile_base* get_file() { return outfile; }
Expand Down Expand Up @@ -161,6 +163,7 @@ namespace ojph {
param_cap cap; // extended capabilities
param_qcd qcd; // quantization default
param_tlm tlm; // tile-part lengths
param_nlt nlt; // non-linearity point transformation

private: // this is to handle qcc and coc
int used_qcc_fields;
Expand Down
Loading
Loading