Merge branch 'issue74' into devel

This commit is contained in:
John Evans 2013-07-13 15:30:26 -04:00
commit 0da92f99a3
5 changed files with 38 additions and 27 deletions

View file

@ -18,9 +18,9 @@ Glymur works on Python 2.6, 2.7, and 3.3. Python 3.3 is strongly recommended.
OpenJPEG Installation
=====================
The OpenJPEG library version must be either 1.5.1 or the trunk/development
version of OpenJPEG. Version 2.0.0 or versions earlier than 1.5.0
are not supported. Furthermore, the 1.5.x version of OpenJPEG is
The OpenJPEG library version must be either 1.4, 1.5, or the trunk/development
version of OpenJPEG. Version 2.0.0 or versions earlier than 1.4.0
are not supported. Furthermore, the 1.4 and 1.5 versions of OpenJPEG are
currently only utilized for read-only purposes. For more information
about OpenJPEG, please consult http://www.openjpeg.org.
@ -56,5 +56,5 @@ You can run the tests from within python as follows::
>>> glymur.runtests()
Many tests are currently skipped; in fact most of them are skipped if you
are relying on OpenJPEG 1.5.1. But the important thing, though, is whether or
are relying on OpenJPEG 1.4 or 1.5. But the important thing, though, is whether or
not any tests fail.

View file

@ -67,13 +67,6 @@ def load_openjpeg(libopenjpeg_path):
except OSError:
openjpeg_lib = None
if openjpeg_lib is not None:
# Must be at least 1.5.0
openjpeg_lib.opj_version.restype = ctypes.c_char_p
version = openjpeg_lib.opj_version().decode('utf-8')
_, minor, _ = version.split('.')
if minor != '5':
openjpeg_lib = None
return openjpeg_lib

View file

@ -4,6 +4,7 @@
# pylint: disable=R0903
import ctypes
import sys
from .config import glymur_config
_, OPENJPEG = glymur_config()
@ -11,6 +12,20 @@ _, OPENJPEG = glymur_config()
PATH_LEN = 4096 # maximum allowed size for filenames
def version():
"""Wrapper for opj_version library routine."""
OPENJPEG.opj_version.restype = ctypes.c_char_p
library_version = OPENJPEG.opj_version()
if sys.hexversion >= 0x03000000:
return library_version.decode('utf-8')
else:
return library_version
# Need to get the minor version, make sure we are at least at 1.4.x
#import pdb; pdb.set_trace()
_minor = version().split('.')[1]
class EventMgrType(ctypes.Structure):
"""Message handler object.
@ -86,8 +101,10 @@ class DecompressionParametersType(ctypes.Structure):
("jpwl_max_tiles", ctypes.c_int),
# cp_limit_decoding: whether decoding should be done on the
# entire codestream or be limited to the main header
("cp_limit_decoding", ctypes.c_int),
("flags", ctypes.c_uint)]
("cp_limit_decoding", ctypes.c_int)]
if _minor != '4':
_fields_.append(("flags", ctypes.c_uint))
class ImageCompType(ctypes.Structure):
@ -204,10 +221,3 @@ def setup_decoder(dinfo, dparams):
ctypes.POINTER(DecompressionParametersType)]
OPENJPEG.opj_setup_decoder.argtypes = argtypes
OPENJPEG.opj_setup_decoder(dinfo, dparams)
def version():
"""Wrapper for opj_version library routine."""
OPENJPEG.opj_version.restype = ctypes.c_char_p
library_version = OPENJPEG.opj_version()
return library_version.decode('utf-8')

View file

@ -1,5 +1,6 @@
#pylint: disable-all
import ctypes
import re
import sys
if sys.hexversion < 0x02070000:
@ -21,13 +22,18 @@ class TestOpenJPEG(unittest.TestCase):
pass
def test_version(self):
v = glymur.lib._openjpeg.version()
parts = v.split('.')
self.assertEqual(parts[0], '1')
self.assertEqual(parts[1], '5')
version = glymur.lib._openjpeg.version()
regex = re.compile('1.[45].[0-9]')
if sys.hexversion <= 0x03020000:
self.assertRegexpMatches(version, regex)
else:
self.assertRegex(version, regex)
def test_set_default_decoder_parameters(self):
# Verify that we properly set the default decode parameters.
version = glymur.lib._openjpeg.version()
minor = int(version.split('.')[1])
dp = glymur.lib._openjpeg.DecompressionParametersType()
glymur.lib._openjpeg.set_default_decoder_parameters(ctypes.byref(dp))
@ -41,4 +47,6 @@ class TestOpenJPEG(unittest.TestCase):
self.assertEqual(dp.jpwl_exp_comps, 0)
self.assertEqual(dp.jpwl_max_tiles, 0)
self.assertEqual(dp.cp_limit_decoding, 0)
self.assertEqual(dp.flags, 0)
if minor > 4:
# Introduced in 1.5.x
self.assertEqual(dp.flags, 0)

View file

@ -21,8 +21,8 @@
| Fedora 18 | | X | Ships with 1.5.1. 167 of 445 tests |
| | | | should pass. |
+------------+------------+------------+--------------------------------------+
| Fedora 17 | X | | Ships with 1.4. Should error out |
| | | | gracefully. |
| Fedora 17 | X | | Ships with 1.4.0. 167 of 445 tests |
| | | | should pass. |
+------------+------------+------------+--------------------------------------+
Pylint on entire package should be at least 0.95.