Restored ssiz attribute to SIZsegment. #140

This commit is contained in:
jevans 2013-11-14 20:07:15 -05:00
commit 9e87780ed3
3 changed files with 22 additions and 3 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

@ -117,6 +117,17 @@ 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(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))
class TestCodestreamRepr(unittest.TestCase): class TestCodestreamRepr(unittest.TestCase):
def setUp(self): def setUp(self):