Handling the case of signed data as well. #140.
This commit is contained in:
parent
9e87780ed3
commit
09d96c1769
2 changed files with 22 additions and 4 deletions
|
|
@ -1510,7 +1510,7 @@ class SIZsegment(Segment):
|
|||
lst = []
|
||||
for bitdepth, signed in zip(self.bitdepth, self.signed):
|
||||
if signed:
|
||||
lst.append((bitdepth - 1) & 0x80)
|
||||
lst.append((bitdepth - 1) | 0x80)
|
||||
else:
|
||||
lst.append(bitdepth - 1)
|
||||
self.ssiz = tuple(lst)
|
||||
|
|
|
|||
|
|
@ -32,8 +32,6 @@ except:
|
|||
raise
|
||||
|
||||
|
||||
@unittest.skipIf(DATA_ROOT is None,
|
||||
"OPJ_DATA_ROOT environment variable not set")
|
||||
class TestCodestream(unittest.TestCase):
|
||||
"""Test suite for unusual codestream cases."""
|
||||
|
||||
|
|
@ -43,6 +41,8 @@ class TestCodestream(unittest.TestCase):
|
|||
def tearDown(self):
|
||||
pass
|
||||
|
||||
@unittest.skipIf(DATA_ROOT is None,
|
||||
"OPJ_DATA_ROOT environment variable not set")
|
||||
@unittest.skipIf(os.name == "nt", "Temporary file issue on window.")
|
||||
def test_reserved_marker_segment(self):
|
||||
"""Reserved marker segments are ok."""
|
||||
|
|
@ -74,6 +74,8 @@ class TestCodestream(unittest.TestCase):
|
|||
self.assertEqual(codestream.segment[2].length, 3)
|
||||
self.assertEqual(codestream.segment[2].data, b'\x00')
|
||||
|
||||
@unittest.skipIf(DATA_ROOT is None,
|
||||
"OPJ_DATA_ROOT environment variable not set")
|
||||
@unittest.skipIf(sys.hexversion < 0x03020000,
|
||||
"Uses features introduced in 3.2.")
|
||||
@unittest.skipIf(os.name == "nt", "Temporary file issue on window.")
|
||||
|
|
@ -105,6 +107,8 @@ class TestCodestream(unittest.TestCase):
|
|||
self.assertEqual(codestream.segment[2].length, 3)
|
||||
self.assertEqual(codestream.segment[2].data, b'\x00')
|
||||
|
||||
@unittest.skipIf(DATA_ROOT is None,
|
||||
"OPJ_DATA_ROOT environment variable not set")
|
||||
def test_psot_is_zero(self):
|
||||
"""Psot=0 in SOT is perfectly legal. Issue #78."""
|
||||
filename = os.path.join(DATA_ROOT,
|
||||
|
|
@ -117,7 +121,7 @@ class TestCodestream(unittest.TestCase):
|
|||
self.assertEqual(codestream.segment[-1].marker_id, 'EOC')
|
||||
|
||||
|
||||
def test_siz_segment_ssiz(self):
|
||||
def test_siz_segment_ssiz_unsigned(self):
|
||||
"""ssiz attribute to be removed in future release"""
|
||||
j = Jp2k(self.jp2file)
|
||||
codestream = j.get_codestream()
|
||||
|
|
@ -128,6 +132,20 @@ class TestCodestream(unittest.TestCase):
|
|||
self.assertEqual(codestream.segment[1].ssiz, (7, 7, 7))
|
||||
|
||||
|
||||
@unittest.skipIf(DATA_ROOT is None,
|
||||
"OPJ_DATA_ROOT environment variable not set")
|
||||
def test_siz_segment_ssiz_signed(self):
|
||||
"""ssiz attribute to be removed in future release"""
|
||||
filename = os.path.join(DATA_ROOT, 'input/conformance/p0_03.j2k')
|
||||
j = Jp2k(filename)
|
||||
codestream = j.get_codestream()
|
||||
|
||||
# The ssiz attribute was simply a tuple of raw bytes.
|
||||
# The first 7 bits are interpreted as the bitdepth, the MSB determines
|
||||
# whether or not it is signed.
|
||||
self.assertEqual(codestream.segment[1].ssiz, (131,))
|
||||
|
||||
|
||||
class TestCodestreamRepr(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue