Merge branch 'issue141'

This commit is contained in:
jevans 2014-01-28 20:25:50 -05:00
commit b78009ebf2
7 changed files with 83 additions and 7 deletions

View file

@ -1,3 +1,6 @@
Jan 28, 2014 - v0.5.10 Fixed bad warning when reader requirements box mask
length is unsupported.
Oct 29, 2013 - v0.5.9 Fixed bad library load on linux as a result of 0.5.8
Oct 29, 2013 - v0.5.8 Fixed unnecessary warnings when default locations for

View file

@ -78,7 +78,7 @@ copyright = u'2013, John Evans'
# The short X.Y version.
version = '0.5'
# The full version, including alpha/beta/rc tags.
release = '0.5.9'
release = '0.5.10'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.

View file

@ -9,3 +9,4 @@ Here's an incomplete list of what I'd like to focus on in the future.
* investigate adding write support for UUID/XMP boxes (potentially a big project)
* investigate JPIP (likely to be an even bigger project)
Support for Python 2.6 will be dropped with the 0.6.0 release.

View file

@ -1465,13 +1465,24 @@ class ReaderRequirementsBox(Jp2kBox):
# Decodes Completely Mask
read_buffer = fptr.read(2 * mask_length)
fuam = dcm = standard_flag = standard_mask = []
vendor_feature = vendor_mask = []
# The mask length tells us the format string to use when unpacking
# from the buffer read from file.
mask_format = {1: 'B', 2: 'H', 4: 'I'}[mask_length]
fuam, dcm = struct.unpack('>' + mask_format * 2, read_buffer)
try:
mask_format = {1: 'B', 2: 'H', 4: 'I', 8: 'Q'}[mask_length]
fuam, dcm = struct.unpack('>' + mask_format * 2, read_buffer)
standard_flag, standard_mask = _parse_standard_flag(fptr,
mask_length)
vendor_feature, vendor_mask = _parse_vendor_features(fptr,
mask_length)
standard_flag, standard_mask = _parse_standard_flag(fptr, mask_length)
vendor_feature, vendor_mask = _parse_vendor_features(fptr, mask_length)
except KeyError:
msg = 'The ReaderRequirements box (rreq) has a mask length of {0} '
msg += 'bytes, but only values of 1, 2, 4, or 8 are supported. '
msg += 'The box contents will not be interpreted.'
warnings.warn(msg.format(mask_length), UserWarning)
box = ReaderRequirementsBox(fuam, dcm, standard_flag, standard_mask,
vendor_feature, vendor_mask,

View file

@ -0,0 +1,61 @@
# -*- coding: utf-8 -*-
"""
Test suite specifically targeting JPX box layout.
"""
import os
import struct
import sys
import tempfile
import warnings
import xml.etree.cElementTree as ET
if sys.hexversion < 0x02070000:
import unittest2 as unittest
else:
import unittest
import glymur
from glymur import Jp2k
from glymur.jp2box import ReaderRequirementsBox
@unittest.skipIf(sys.hexversion < 0x03000000, "Warning assert on 2.x.")
@unittest.skipIf(os.name == "nt", "Temporary file issue on window.")
class TestReaderRequirements(unittest.TestCase):
"""Test suite for XML boxes."""
def setUp(self):
self.jp2file = glymur.data.nemo()
pass
def tearDown(self):
pass
def test_mask_length_is_3(self):
"""The standard says that the mask length should be 1, 2, 4, or 8."""
# Rewrite nemo to include this kind of rreq box.
with tempfile.NamedTemporaryFile(suffix=".jpx") as tfile:
with open(self.jp2file, 'rb') as nemof:
# Read the jP and ftyp boxes as-is.
write_buffer = nemof.read(32)
tfile.write(write_buffer)
# Fake a rreq box with ML = 3.
write_buffer = struct.pack('>I4sB', 74, b'rreq', 3)
tfile.write(write_buffer)
# pad the rest with zeros
write_buffer = struct.pack('>65s', b'\x00' * 65)
tfile.write(write_buffer)
# Write the rest of nemo.
tfile.write(nemof.read())
tfile.flush()
with self.assertWarns(UserWarning):
j = Jp2k(tfile.name)
self.assertEqual(j.box[2].box_id, 'rreq')
self.assertEqual(type(j.box[2]),
glymur.jp2box.ReaderRequirementsBox)

View file

@ -15,7 +15,7 @@ from .lib import openjp2 as opj2
# Do not change the format of this next line! Doing so risks breaking
# setup.py
version = "0.5.9"
version = "0.5.10"
_sv = LooseVersion(version)
version_tuple = _sv.version

View file

@ -7,7 +7,7 @@ kwargs = {'name': 'Glymur',
'description': 'Tools for accessing JPEG2000 files',
'long_description': open('README.md').read(),
'author': 'John Evans',
'author_email': 'john.g.evans.ne at gmail dot com',
'author_email': 'john.g.evans.ne@gmail.com',
'url': 'https://github.com/quintusdias/glymur',
'packages': ['glymur', 'glymur.data', 'glymur.test', 'glymur.lib',
'glymur.lib.test'],