Merge branch 'issue140' into devel

This commit is contained in:
jevans 2014-01-20 20:07:43 -05:00
commit b43a79cb5d
3 changed files with 42 additions and 5 deletions

View file

@ -1,6 +1,5 @@
Oct 29, 2013 - Palette box now a 2D numpy array instead of a list of Nov 11, 2013 - Palette box now a 2D numpy array instead of a list of
1D arrays. Super box constructors now take optional box list argument. 1D arrays. Super box constructors now take optional box list argument.
Removed ssiz attribute from SIZsegment class.
Oct 29, 2013 - v0.5.9 Fixed bad library load on linux as a result of 0.5.8 Oct 29, 2013 - v0.5.9 Fixed bad library load on linux as a result of 0.5.8

View file

@ -662,7 +662,7 @@ class Codestream(object):
component_buffer) component_buffer)
bitdepth = tuple(((x & 0x7f) + 1) for x in data[0::3]) bitdepth = tuple(((x & 0x7f) + 1) for x in data[0::3])
signed = tuple(((x & 0xb0) > 0) for x in data[0::3]) signed = tuple(((x & 0x80) > 0) for x in data[0::3])
xrsiz = data[1::3] xrsiz = data[1::3]
yrsiz = data[2::3] yrsiz = data[2::3]
@ -1506,6 +1506,15 @@ class SIZsegment(Segment):
self.signed = signed self.signed = signed
self.xrsiz, self.yrsiz = xyrsiz self.xrsiz, self.yrsiz = xyrsiz
# ssiz attribute to be removed in 1.0.0
lst = []
for bitdepth, signed in zip(self.bitdepth, self.signed):
if signed:
lst.append((bitdepth - 1) | 0x80)
else:
lst.append(bitdepth - 1)
self.ssiz = tuple(lst)
num_tiles_x = (self.xsiz - self.xosiz) / (self.xtsiz - self.xtosiz) num_tiles_x = (self.xsiz - self.xosiz) / (self.xtsiz - self.xtosiz)
num_tiles_y = (self.ysiz - self.yosiz) / (self.ytsiz - self.ytosiz) num_tiles_y = (self.ysiz - self.yosiz) / (self.ytsiz - self.ytosiz)
numtiles = math.ceil(num_tiles_x) * math.ceil(num_tiles_y) numtiles = math.ceil(num_tiles_x) * math.ceil(num_tiles_y)

View file

@ -32,8 +32,6 @@ except:
raise raise
@unittest.skipIf(DATA_ROOT is None,
"OPJ_DATA_ROOT environment variable not set")
class TestCodestream(unittest.TestCase): class TestCodestream(unittest.TestCase):
"""Test suite for unusual codestream cases.""" """Test suite for unusual codestream cases."""
@ -43,6 +41,8 @@ class TestCodestream(unittest.TestCase):
def tearDown(self): def tearDown(self):
pass pass
@unittest.skipIf(DATA_ROOT is None,
"OPJ_DATA_ROOT environment variable not set")
@unittest.skipIf(os.name == "nt", "Temporary file issue on window.") @unittest.skipIf(os.name == "nt", "Temporary file issue on window.")
def test_reserved_marker_segment(self): def test_reserved_marker_segment(self):
"""Reserved marker segments are ok.""" """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].length, 3)
self.assertEqual(codestream.segment[2].data, b'\x00') 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, @unittest.skipIf(sys.hexversion < 0x03020000,
"Uses features introduced in 3.2.") "Uses features introduced in 3.2.")
@unittest.skipIf(os.name == "nt", "Temporary file issue on window.") @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].length, 3)
self.assertEqual(codestream.segment[2].data, b'\x00') 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): def test_psot_is_zero(self):
"""Psot=0 in SOT is perfectly legal. Issue #78.""" """Psot=0 in SOT is perfectly legal. Issue #78."""
filename = os.path.join(DATA_ROOT, filename = os.path.join(DATA_ROOT,
@ -117,6 +121,31 @@ class TestCodestream(unittest.TestCase):
self.assertEqual(codestream.segment[-1].marker_id, 'EOC') self.assertEqual(codestream.segment[-1].marker_id, 'EOC')
def test_siz_segment_ssiz_unsigned(self):
"""ssiz attribute to be removed in future release"""
j = Jp2k(self.jp2file)
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, (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): class TestCodestreamRepr(unittest.TestCase):
def setUp(self): def setUp(self):