Closes #74
This commit is contained in:
parent
47965ac7b7
commit
8577c55d22
5 changed files with 38 additions and 27 deletions
|
|
@ -18,9 +18,9 @@ Glymur works on Python 2.6, 2.7, and 3.3. Python 3.3 is strongly recommended.
|
||||||
|
|
||||||
OpenJPEG Installation
|
OpenJPEG Installation
|
||||||
=====================
|
=====================
|
||||||
The OpenJPEG library version must be either 1.5.1 or the trunk/development
|
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.5.0
|
version of OpenJPEG. Version 2.0.0 or versions earlier than 1.4.0
|
||||||
are not supported. Furthermore, the 1.5.x version of OpenJPEG is
|
are not supported. Furthermore, the 1.4 and 1.5 versions of OpenJPEG are
|
||||||
currently only utilized for read-only purposes. For more information
|
currently only utilized for read-only purposes. For more information
|
||||||
about OpenJPEG, please consult http://www.openjpeg.org.
|
about OpenJPEG, please consult http://www.openjpeg.org.
|
||||||
|
|
||||||
|
|
@ -56,5 +56,5 @@ You can run the tests from within python as follows::
|
||||||
>>> glymur.runtests()
|
>>> glymur.runtests()
|
||||||
|
|
||||||
Many tests are currently skipped; in fact most of them are skipped if you
|
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.
|
not any tests fail.
|
||||||
|
|
|
||||||
|
|
@ -67,13 +67,6 @@ def load_openjpeg(libopenjpeg_path):
|
||||||
except OSError:
|
except OSError:
|
||||||
openjpeg_lib = None
|
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
|
return openjpeg_lib
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
# pylint: disable=R0903
|
# pylint: disable=R0903
|
||||||
|
|
||||||
import ctypes
|
import ctypes
|
||||||
|
import sys
|
||||||
|
|
||||||
from .config import glymur_config
|
from .config import glymur_config
|
||||||
_, OPENJPEG = glymur_config()
|
_, OPENJPEG = glymur_config()
|
||||||
|
|
@ -11,6 +12,20 @@ _, OPENJPEG = glymur_config()
|
||||||
PATH_LEN = 4096 # maximum allowed size for filenames
|
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):
|
class EventMgrType(ctypes.Structure):
|
||||||
"""Message handler object.
|
"""Message handler object.
|
||||||
|
|
||||||
|
|
@ -86,8 +101,10 @@ class DecompressionParametersType(ctypes.Structure):
|
||||||
("jpwl_max_tiles", ctypes.c_int),
|
("jpwl_max_tiles", ctypes.c_int),
|
||||||
# cp_limit_decoding: whether decoding should be done on the
|
# cp_limit_decoding: whether decoding should be done on the
|
||||||
# entire codestream or be limited to the main header
|
# entire codestream or be limited to the main header
|
||||||
("cp_limit_decoding", ctypes.c_int),
|
("cp_limit_decoding", ctypes.c_int)]
|
||||||
("flags", ctypes.c_uint)]
|
|
||||||
|
if _minor != '4':
|
||||||
|
_fields_.append(("flags", ctypes.c_uint))
|
||||||
|
|
||||||
|
|
||||||
class ImageCompType(ctypes.Structure):
|
class ImageCompType(ctypes.Structure):
|
||||||
|
|
@ -204,10 +221,3 @@ def setup_decoder(dinfo, dparams):
|
||||||
ctypes.POINTER(DecompressionParametersType)]
|
ctypes.POINTER(DecompressionParametersType)]
|
||||||
OPENJPEG.opj_setup_decoder.argtypes = argtypes
|
OPENJPEG.opj_setup_decoder.argtypes = argtypes
|
||||||
OPENJPEG.opj_setup_decoder(dinfo, dparams)
|
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')
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#pylint: disable-all
|
#pylint: disable-all
|
||||||
import ctypes
|
import ctypes
|
||||||
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
if sys.hexversion < 0x02070000:
|
if sys.hexversion < 0x02070000:
|
||||||
|
|
@ -21,13 +22,18 @@ class TestOpenJPEG(unittest.TestCase):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def test_version(self):
|
def test_version(self):
|
||||||
v = glymur.lib._openjpeg.version()
|
version = glymur.lib._openjpeg.version()
|
||||||
parts = v.split('.')
|
regex = re.compile('1.[45].[0-9]')
|
||||||
self.assertEqual(parts[0], '1')
|
if sys.hexversion <= 0x03020000:
|
||||||
self.assertEqual(parts[1], '5')
|
self.assertRegexpMatches(version, regex)
|
||||||
|
else:
|
||||||
|
self.assertRegex(version, regex)
|
||||||
|
|
||||||
def test_set_default_decoder_parameters(self):
|
def test_set_default_decoder_parameters(self):
|
||||||
# Verify that we properly set the default decode parameters.
|
# Verify that we properly set the default decode parameters.
|
||||||
|
version = glymur.lib._openjpeg.version()
|
||||||
|
minor = int(version.split('.')[1])
|
||||||
|
|
||||||
dp = glymur.lib._openjpeg.DecompressionParametersType()
|
dp = glymur.lib._openjpeg.DecompressionParametersType()
|
||||||
glymur.lib._openjpeg.set_default_decoder_parameters(ctypes.byref(dp))
|
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_exp_comps, 0)
|
||||||
self.assertEqual(dp.jpwl_max_tiles, 0)
|
self.assertEqual(dp.jpwl_max_tiles, 0)
|
||||||
self.assertEqual(dp.cp_limit_decoding, 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)
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,8 @@
|
||||||
| Fedora 18 | | X | Ships with 1.5.1. 167 of 445 tests |
|
| Fedora 18 | | X | Ships with 1.5.1. 167 of 445 tests |
|
||||||
| | | | should pass. |
|
| | | | should pass. |
|
||||||
+------------+------------+------------+--------------------------------------+
|
+------------+------------+------------+--------------------------------------+
|
||||||
| Fedora 17 | X | | Ships with 1.4. Should error out |
|
| Fedora 17 | X | | Ships with 1.4.0. 167 of 445 tests |
|
||||||
| | | | gracefully. |
|
| | | | should pass. |
|
||||||
+------------+------------+------------+--------------------------------------+
|
+------------+------------+------------+--------------------------------------+
|
||||||
|
|
||||||
Pylint on entire package should be at least 0.95.
|
Pylint on entire package should be at least 0.95.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue