Skip to content

Commit

Permalink
This fixes a bug in the block decoder code. The bug can happen when t…
Browse files Browse the repository at this point in the history
…he data is around 16bits/sample of more, coded losslessly.
  • Loading branch information
aous72 committed Sep 20, 2024
1 parent 0c6dfd3 commit 9f8011c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
4 changes: 2 additions & 2 deletions src/core/codestream/ojph_codeblock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,11 @@ namespace ojph {
if (result == false)
{
if (resilient == true) {
OJPH_INFO(0x000300A1, "Error decoding a codeblock");
OJPH_INFO(0x000300A1, "Error decoding a codeblock.");
zero_block = true;
}
else
OJPH_ERROR(0x000300A1, "Error decoding a codeblock");
OJPH_ERROR(0x000300A1, "Error decoding a codeblock.");
}
}
else
Expand Down
14 changes: 7 additions & 7 deletions src/core/coding/ojph_block_decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -753,14 +753,14 @@ namespace ojph {
{
OJPH_WARN(0x00010001, "A malformed codeblock that has more than "
"one coding pass, but zero length for "
"2nd and potential 3rd pass");
"2nd and potential 3rd pass.");
num_passes = 1;
}

if (num_passes > 3)
{
OJPH_WARN(0x00010002, "We do not support more than 3 coding passes; "
"This codeblocks has %d passes",
"This codeblocks has %d passes.",
num_passes);
return false;
}
Expand All @@ -772,7 +772,7 @@ namespace ojph {
insufficient_precision = true;
OJPH_WARN(0x00010003, "32 bits are not enough to decode this "
"codeblock. This message will not be "
"displayed again");
"displayed again.");
}
return false;
}
Expand All @@ -783,7 +783,7 @@ namespace ojph {
OJPH_WARN(0x00010004, "Not enough precision to decode the cleanup "
"pass. The code can be modified to support "
"this case. This message will not be "
"displayed again");
"displayed again.");
}
return false; // 32 bits are not enough to decode this
}
Expand All @@ -796,7 +796,7 @@ namespace ojph {
OJPH_WARN(0x00010005, "Not enough precision to decode the SgnProp "
"nor MagRef passes; both will be skipped. "
"This message will not be displayed "
"again");
"again.");
}
}
}
Expand All @@ -806,7 +806,7 @@ namespace ojph {

if (lengths1 < 2)
{
OJPH_WARN(0x00010006, "Wrong codeblock length");
OJPH_WARN(0x00010006, "Wrong codeblock length.");
return false;
}

Expand Down Expand Up @@ -1079,7 +1079,7 @@ namespace ojph {
// quad 0 length
len = uvlc_entry & 0x7; // quad 0 suffix length
uvlc_entry >>= 3;
ui16 u_q = (ui16)((uvlc_entry & 7) + (tmp & ~(0xFU << len))); //u_q
ui16 u_q = (ui16)((uvlc_entry & 7) + (tmp & ~(0xFFU << len)));
sp[1] = u_q;
u_q = (ui16)((uvlc_entry >> 3) + (tmp >> len)); // u_q
sp[3] = u_q;
Expand Down
14 changes: 7 additions & 7 deletions src/core/coding/ojph_block_decoder_avx2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1077,14 +1077,14 @@ namespace ojph {
{
OJPH_WARN(0x00010001, "A malformed codeblock that has more than "
"one coding pass, but zero length for "
"2nd and potential 3rd pass");
"2nd and potential 3rd pass.");
num_passes = 1;
}

if (num_passes > 3)
{
OJPH_WARN(0x00010002, "We do not support more than 3 coding passes; "
"This codeblocks has %d passes",
"This codeblocks has %d passes.",
num_passes);
return false;
}
Expand All @@ -1096,7 +1096,7 @@ namespace ojph {
insufficient_precision = true;
OJPH_WARN(0x00010003, "32 bits are not enough to decode this "
"codeblock. This message will not be "
"displayed again");
"displayed again.");
}
return false;
}
Expand All @@ -1107,7 +1107,7 @@ namespace ojph {
OJPH_WARN(0x00010004, "Not enough precision to decode the cleanup "
"pass. The code can be modified to support "
"this case. This message will not be "
"displayed again");
"displayed again.");
}
return false; // 32 bits are not enough to decode this
}
Expand All @@ -1120,7 +1120,7 @@ namespace ojph {
OJPH_WARN(0x00010005, "Not enough precision to decode the SgnProp "
"nor MagRef passes; both will be skipped. "
"This message will not be displayed "
"again");
"again.");
}
}
}
Expand All @@ -1130,7 +1130,7 @@ namespace ojph {

if (lengths1 < 2)
{
OJPH_WARN(0x00010006, "Wrong codeblock length");
OJPH_WARN(0x00010006, "Wrong codeblock length.");
return false;
}

Expand Down Expand Up @@ -1407,7 +1407,7 @@ namespace ojph {
// quad 0 length
len = uvlc_entry & 0x7; // quad 0 suffix length
uvlc_entry >>= 3;
ui16 u_q = (ui16)((uvlc_entry & 7) + (tmp & ~(0xFU << len))); //u_q
ui16 u_q = (ui16)((uvlc_entry & 7) + (tmp & ~(0xFFU << len)));
sp[1] = u_q;
u_q = (ui16)((uvlc_entry >> 3) + (tmp >> len)); // u_q
sp[3] = u_q;
Expand Down
14 changes: 7 additions & 7 deletions src/core/coding/ojph_block_decoder_ssse3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1033,14 +1033,14 @@ namespace ojph {
{
OJPH_WARN(0x00010001, "A malformed codeblock that has more than "
"one coding pass, but zero length for "
"2nd and potential 3rd pass");
"2nd and potential 3rd pass.");
num_passes = 1;
}

if (num_passes > 3)
{
OJPH_WARN(0x00010002, "We do not support more than 3 coding passes; "
"This codeblocks has %d passes",
"This codeblocks has %d passes.",
num_passes);
return false;
}
Expand All @@ -1052,7 +1052,7 @@ namespace ojph {
insufficient_precision = true;
OJPH_WARN(0x00010003, "32 bits are not enough to decode this "
"codeblock. This message will not be "
"displayed again");
"displayed again.");
}
return false;
}
Expand All @@ -1063,7 +1063,7 @@ namespace ojph {
OJPH_WARN(0x00010004, "Not enough precision to decode the cleanup "
"pass. The code can be modified to support "
"this case. This message will not be "
"displayed again");
"displayed again.");
}
return false; // 32 bits are not enough to decode this
}
Expand All @@ -1076,7 +1076,7 @@ namespace ojph {
OJPH_WARN(0x00010005, "Not enough precision to decode the SgnProp "
"nor MagRef passes; both will be skipped. "
"This message will not be displayed "
"again");
"again.");
}
}
}
Expand All @@ -1086,7 +1086,7 @@ namespace ojph {

if (lengths1 < 2)
{
OJPH_WARN(0x00010006, "Wrong codeblock length");
OJPH_WARN(0x00010006, "Wrong codeblock length.");
return false;
}

Expand Down Expand Up @@ -1361,7 +1361,7 @@ namespace ojph {
// quad 0 length
len = uvlc_entry & 0x7; // quad 0 suffix length
uvlc_entry >>= 3;
ui16 u_q = (ui16)((uvlc_entry & 7) + (tmp & ~(0xFU << len))); //u_q
ui16 u_q = (ui16)((uvlc_entry & 7) + (tmp & ~(0xFFU << len)));
sp[1] = u_q;
u_q = (ui16)((uvlc_entry >> 3) + (tmp >> len)); // u_q
sp[3] = u_q;
Expand Down

0 comments on commit 9f8011c

Please sign in to comment.