This commit is contained in:
jevans 2013-07-09 20:22:50 -04:00
commit 4c1d029198
11 changed files with 488 additions and 429 deletions

View file

@ -13,9 +13,9 @@ import warnings
import numpy as np import numpy as np
from .core import LRCP, RLCP, RPCL, PCRL, CPRL from .core import LRCP, RLCP, RPCL, PCRL, CPRL
from .core import WAVELET_TRANSFORM_9x7_IRREVERSIBLE from .core import WAVELET_XFORM_9X7_IRREVERSIBLE
from .core import WAVELET_TRANSFORM_5x3_REVERSIBLE from .core import WAVELET_XFORM_5X3_REVERSIBLE
from .core import _capabilities_display from .core import _CAPABILITIES_DISPLAY
from .lib import openjp2 as opj2 from .lib import openjp2 as opj2
_PROGRESSION_ORDER_DISPLAY = { _PROGRESSION_ORDER_DISPLAY = {
@ -26,8 +26,8 @@ _PROGRESSION_ORDER_DISPLAY = {
CPRL: 'CPRL'} CPRL: 'CPRL'}
_WAVELET_TRANSFORM_DISPLAY = { _WAVELET_TRANSFORM_DISPLAY = {
WAVELET_TRANSFORM_9x7_IRREVERSIBLE: '9-7 irreversible', WAVELET_XFORM_9X7_IRREVERSIBLE: '9-7 irreversible',
WAVELET_TRANSFORM_5x3_REVERSIBLE: '5-3 reversible'} WAVELET_XFORM_5X3_REVERSIBLE: '5-3 reversible'}
# Need a catch-all list of valid markers. # Need a catch-all list of valid markers.
# See table A-1 in ISO/IEC FCD15444-1. # See table A-1 in ISO/IEC FCD15444-1.
@ -1134,7 +1134,7 @@ class SIZsegment(Segment):
'Signed: {10}', 'Signed: {10}',
'Vertical, Horizontal Subsampling: {11}'] 'Vertical, Horizontal Subsampling: {11}']
msg += '\n '.join(lines) msg += '\n '.join(lines)
msg = msg.format(_capabilities_display[self.rsiz], msg = msg.format(_CAPABILITIES_DISPLAY[self.rsiz],
self.ysiz, self.xsiz, self.ysiz, self.xsiz,
self.yosiz, self.xosiz, self.yosiz, self.xosiz,
self.ytsiz, self.xtsiz, self.ytsiz, self.xtsiz,

View file

@ -1,3 +1,5 @@
"""Core definitions to be shared amongst the modules.
"""
# Progression order # Progression order
LRCP = 0 LRCP = 0
RLCP = 1 RLCP = 1
@ -12,8 +14,8 @@ PROGRESSION_ORDER = {
'PCRL': PCRL, 'PCRL': PCRL,
'CPRL': CPRL} 'CPRL': CPRL}
WAVELET_TRANSFORM_9x7_IRREVERSIBLE = 0 WAVELET_XFORM_9X7_IRREVERSIBLE = 0
WAVELET_TRANSFORM_5x3_REVERSIBLE = 1 WAVELET_XFORM_5X3_REVERSIBLE = 1
ENUMERATED_COLORSPACE = 1 ENUMERATED_COLORSPACE = 1
RESTRICTED_ICC_PROFILE = 2 RESTRICTED_ICC_PROFILE = 2
@ -32,7 +34,7 @@ YCC = 18
E_SRGB = 20 E_SRGB = 20
ROMM_RGB = 21 ROMM_RGB = 21
_colorspace_map_display = { _COLORSPACE_MAP_DISPLAY = {
CMYK: 'CMYK', CMYK: 'CMYK',
SRGB: 'sRGB', SRGB: 'sRGB',
GREYSCALE: 'greyscale', GREYSCALE: 'greyscale',
@ -45,7 +47,7 @@ _COLOR = 0
_OPACITY = 1 _OPACITY = 1
_PRE_MULTIPLIED_OPACITY = 2 _PRE_MULTIPLIED_OPACITY = 2
_UNSPECIFIED = 65535 _UNSPECIFIED = 65535
_color_type_map_display = { _COLOR_TYPE_MAP_DISPLAY = {
_COLOR: 'color', _COLOR: 'color',
_OPACITY: 'opacity', _OPACITY: 'opacity',
_PRE_MULTIPLIED_OPACITY: 'pre-multiplied opacity', _PRE_MULTIPLIED_OPACITY: 'pre-multiplied opacity',
@ -58,103 +60,15 @@ BLUE = 3
GREY = 1 GREY = 1
# enumerated color channel associations # enumerated color channel associations
_rgb_colorspace = {"R": 1, "G": 2, "B": 3} _COLORSPACE = {SRGB: {"R": 1, "G": 2, "B": 3},
_greyscale_colorspace = {"Y": 1} GREYSCALE: {"Y": 1},
_ycbcr_colorspace = {"Y": 1, "Cb": 2, "Cr": 3} YCC: {"Y": 1, "Cb": 2, "Cr": 3},
_colorspace = {SRGB: _rgb_colorspace, E_SRGB: {"R": 1, "G": 2, "B": 3},
GREYSCALE: _greyscale_colorspace, ROMM_RGB: {"R": 1, "G": 2, "B": 3}}
YCC: _ycbcr_colorspace,
E_SRGB: _rgb_colorspace,
ROMM_RGB: _rgb_colorspace}
# How to display the codestream profile. # How to display the codestream profile.
_capabilities_display = { _CAPABILITIES_DISPLAY = {
0: '2', 0: '2',
1: '0', 1: '0',
2: '1', 2: '1',
3: '3'} 3: '3'}
# Reader requirements
_reader_requirements_display = {
0: 'File not completely understood',
1: 'Deprecated',
2: 'Contains multiple composition layers',
3: 'Deprecated',
4: 'JPEG 2000 Part 1 Profile 1 codestream',
5: 'Unrestricted JPEG 2000 Part 1 codestream, ITU-T Rec. T.800 '
+ '| ISO/IEC 15444-1',
6: 'Unrestricted JPEG 2000 Part 2 codestream',
7: 'JPEG codestream as defined in ISO/IEC 10918-1',
8: 'Deprecated',
9: 'Non-premultiplied opacity channel',
10: 'Premultiplied opacity channel',
11: 'Chroma-key based opacity',
12: 'Deprecated',
13: 'Fragmented codestream where all fragments are in file and in order',
14: 'Fragmented codestream where all fragments are in file '
+ 'but are out of order',
15: 'Fragmented codestream where not all fragments are within the file '
+ 'but are all in locally accessible files',
16: 'Fragmented codestream where some fragments may be accessible '
+ 'only through a URL specified network connection',
17: 'Compositing required to produce rendered result from multiple '
+ 'compositing layers',
18: 'Deprecated',
19: 'Deprecated',
20: 'Deprecated',
21: 'At least one compositing layer consists of multiple codestreams',
22: 'Deprecated',
23: 'Colourspace transformations are required to combine compositing '
+ 'layers; not all compositing layers are in the same colourspace',
24: 'Deprecated',
25: 'Deprecated',
26: 'First animation layer does not cover entire rendered result',
27: 'Deprecated',
28: 'Reuse of animation layers',
29: 'Deprecated',
30: 'Some animated frames are non-persistent',
31: 'Deprecated',
32: 'Rendered result involves scaling within a layer',
33: 'Rendered result involves scaling between layers',
34: 'ROI metadata',
35: 'IPR metadata',
36: 'Content metadata',
37: 'History metadata',
38: 'Creation metadata',
39: 'JPX digital signatures',
40: 'JPX checksums',
41: 'Desires Graphics Arts Reproduction specified',
42: 'Deprecated',
43: '(Deprecated) compositing layer uses restricted ICC profile',
44: 'Compositing layer uses Any ICC profile',
45: 'Deprecated',
46: 'Deprecated',
47: 'BiLevel 1 enumerated colourspace',
48: 'BiLevel 2 enumerated colourspace',
49: 'YCbCr 1 enumerated colourspace',
50: 'YCbCr 2 enumerated colourspace',
51: 'YCbCr 3 enumerated colourspace',
52: 'PhotoYCC enumerated colourspace',
53: 'YCCK enumerated colourspace',
54: 'CMY enumerated colourspace',
55: 'CMYK enumerated colorspace',
56: 'CIELab enumerated colourspace with default parameters',
57: 'CIELab enumerated colourspace with non-default parameters',
58: 'CIEJab enumerated colourspace with default parameters',
59: 'CIEJab enumerated colourspace with non-default parameters',
60: 'e-sRGB enumerated colorspace',
61: 'ROMM_RGB enumerated colorspace',
62: 'Non-square samples',
63: 'Deprecated',
64: 'Deprecated',
65: 'Deprecated',
66: 'Deprecated',
67: 'GIS metadata XML box',
68: 'JPSEC extensions in codestream as specified by ISO/IEC 15444-8',
69: 'JP3D extensions in codestream as specified by ISO/IEC 15444-10',
70: 'Deprecated',
71: 'e-sYCC enumerated colourspace',
72: 'JPEG 2000 Part 2 codestream as restricted by baseline conformance '
+ 'requirements in M.9.2.3',
73: 'YPbPr(1125/60) enumerated colourspace',
74: 'YPbPr(1250/50) enumerated colourspace'}

View file

@ -27,9 +27,8 @@ import xml.etree.cElementTree as ET
import numpy as np import numpy as np
from .codestream import Codestream from .codestream import Codestream
from .core import _colorspace_map_display from .core import _COLORSPACE_MAP_DISPLAY
from .core import _color_type_map_display from .core import _COLOR_TYPE_MAP_DISPLAY
from .core import _reader_requirements_display
from .core import ENUMERATED_COLORSPACE, RESTRICTED_ICC_PROFILE from .core import ENUMERATED_COLORSPACE, RESTRICTED_ICC_PROFILE
from .core import ANY_ICC_PROFILE, VENDOR_COLOR_METHOD from .core import ANY_ICC_PROFILE, VENDOR_COLOR_METHOD
@ -207,7 +206,7 @@ class ColourSpecificationBox(Jp2kBox):
dispvalue = _approximation_display[self.approximation] dispvalue = _approximation_display[self.approximation]
msg += '\n Approximation: {0}'.format(dispvalue) msg += '\n Approximation: {0}'.format(dispvalue)
if self.colorspace is not None: if self.colorspace is not None:
dispvalue = _colorspace_map_display[self.colorspace] dispvalue = _COLORSPACE_MAP_DISPLAY[self.colorspace]
msg += '\n Colorspace: {0}'.format(dispvalue) msg += '\n Colorspace: {0}'.format(dispvalue)
else: else:
# 2.7 has trouble pretty-printing ordered dicts so we just have # 2.7 has trouble pretty-printing ordered dicts so we just have
@ -234,10 +233,10 @@ class ColourSpecificationBox(Jp2kBox):
fptr.write('colr'.encode()) fptr.write('colr'.encode())
read_buffer = struct.pack('>BBBI', read_buffer = struct.pack('>BBBI',
self.method, self.method,
self.precedence, self.precedence,
self.approximation, self.approximation,
self.colorspace) self.colorspace)
fptr.write(read_buffer) fptr.write(read_buffer)
@staticmethod @staticmethod
@ -259,7 +258,8 @@ class ColourSpecificationBox(Jp2kBox):
""" """
# Read the brand, minor version. # Read the brand, minor version.
read_buffer = fptr.read(3) read_buffer = fptr.read(3)
(method, precedence, approximation) = struct.unpack('>BBB', read_buffer) (method, precedence, approximation) = struct.unpack('>BBB',
read_buffer)
if method == 1: if method == 1:
# enumerated colour space # enumerated colour space
@ -445,7 +445,7 @@ class ChannelDefinitionBox(Jp2kBox):
def __str__(self): def __str__(self):
msg = Jp2kBox.__str__(self) msg = Jp2kBox.__str__(self)
for j in range(len(self.association)): for j in range(len(self.association)):
color_type_string = _color_type_map_display[self.channel_type[j]] color_type_string = _COLOR_TYPE_MAP_DISPLAY[self.channel_type[j]]
if self.association[j] == 0: if self.association[j] == 0:
assn = 'whole image' assn = 'whole image'
else: else:
@ -463,9 +463,9 @@ class ChannelDefinitionBox(Jp2kBox):
fptr.write(struct.pack('>H', num_components)) fptr.write(struct.pack('>H', num_components))
for j in range(num_components): for j in range(num_components):
fptr.write(struct.pack('>' + 'H' * 3, fptr.write(struct.pack('>' + 'H' * 3,
self.index[j], self.index[j],
self.channel_type[j], self.channel_type[j],
self.association[j])) self.association[j]))
@staticmethod @staticmethod
def _parse(fptr, offset, length): def _parse(fptr, offset, length):
@ -624,7 +624,8 @@ class ContiguousCodestreamBox(Jp2kBox):
ContiguousCodestreamBox instance ContiguousCodestreamBox instance
""" """
main_header = Codestream(fptr, header_only=True) main_header = Codestream(fptr, header_only=True)
box = ContiguousCodestreamBox(main_header, length=length, offset=offset) box = ContiguousCodestreamBox(main_header, length=length,
offset=offset)
return box return box
@ -801,13 +802,13 @@ class ImageHeaderBox(Jp2kBox):
bit_depth_signedness = 0x80 if self.signed else 0x00 bit_depth_signedness = 0x80 if self.signed else 0x00
bit_depth_signedness |= self.bits_per_component - 1 bit_depth_signedness |= self.bits_per_component - 1
read_buffer = struct.pack('>IIHBBBB', read_buffer = struct.pack('>IIHBBBB',
self.height, self.height,
self.width, self.width,
self.num_components, self.num_components,
bit_depth_signedness, bit_depth_signedness,
self.compression, self.compression,
1 if self.colorspace_unknown else 0, 1 if self.colorspace_unknown else 0,
1 if self.ip_provided else 0) 1 if self.ip_provided else 0)
fptr.write(read_buffer) fptr.write(read_buffer)
@staticmethod @staticmethod
@ -1135,7 +1136,90 @@ class PaletteBox(Jp2kBox):
offset=offset) offset=offset)
return box return box
# Map rreq codes to display text.
_READER_REQUIREMENTS_DISPLAY = {
0: 'File not completely understood',
1: 'Deprecated',
2: 'Contains multiple composition layers',
3: 'Deprecated',
4: 'JPEG 2000 Part 1 Profile 1 codestream',
5: 'Unrestricted JPEG 2000 Part 1 codestream, ITU-T Rec. T.800 '
+ '| ISO/IEC 15444-1',
6: 'Unrestricted JPEG 2000 Part 2 codestream',
7: 'JPEG codestream as defined in ISO/IEC 10918-1',
8: 'Deprecated',
9: 'Non-premultiplied opacity channel',
10: 'Premultiplied opacity channel',
11: 'Chroma-key based opacity',
12: 'Deprecated',
13: 'Fragmented codestream where all fragments are in file and in order',
14: 'Fragmented codestream where all fragments are in file '
+ 'but are out of order',
15: 'Fragmented codestream where not all fragments are within the file '
+ 'but are all in locally accessible files',
16: 'Fragmented codestream where some fragments may be accessible '
+ 'only through a URL specified network connection',
17: 'Compositing required to produce rendered result from multiple '
+ 'compositing layers',
18: 'Deprecated',
19: 'Deprecated',
20: 'Deprecated',
21: 'At least one compositing layer consists of multiple codestreams',
22: 'Deprecated',
23: 'Colourspace transformations are required to combine compositing '
+ 'layers; not all compositing layers are in the same colourspace',
24: 'Deprecated',
25: 'Deprecated',
26: 'First animation layer does not cover entire rendered result',
27: 'Deprecated',
28: 'Reuse of animation layers',
29: 'Deprecated',
30: 'Some animated frames are non-persistent',
31: 'Deprecated',
32: 'Rendered result involves scaling within a layer',
33: 'Rendered result involves scaling between layers',
34: 'ROI metadata',
35: 'IPR metadata',
36: 'Content metadata',
37: 'History metadata',
38: 'Creation metadata',
39: 'JPX digital signatures',
40: 'JPX checksums',
41: 'Desires Graphics Arts Reproduction specified',
42: 'Deprecated',
43: '(Deprecated) compositing layer uses restricted ICC profile',
44: 'Compositing layer uses Any ICC profile',
45: 'Deprecated',
46: 'Deprecated',
47: 'BiLevel 1 enumerated colourspace',
48: 'BiLevel 2 enumerated colourspace',
49: 'YCbCr 1 enumerated colourspace',
50: 'YCbCr 2 enumerated colourspace',
51: 'YCbCr 3 enumerated colourspace',
52: 'PhotoYCC enumerated colourspace',
53: 'YCCK enumerated colourspace',
54: 'CMY enumerated colourspace',
55: 'CMYK enumerated colorspace',
56: 'CIELab enumerated colourspace with default parameters',
57: 'CIELab enumerated colourspace with non-default parameters',
58: 'CIEJab enumerated colourspace with default parameters',
59: 'CIEJab enumerated colourspace with non-default parameters',
60: 'e-sRGB enumerated colorspace',
61: 'ROMM_RGB enumerated colorspace',
62: 'Non-square samples',
63: 'Deprecated',
64: 'Deprecated',
65: 'Deprecated',
66: 'Deprecated',
67: 'GIS metadata XML box',
68: 'JPSEC extensions in codestream as specified by ISO/IEC 15444-8',
69: 'JP3D extensions in codestream as specified by ISO/IEC 15444-10',
70: 'Deprecated',
71: 'e-sYCC enumerated colourspace',
72: 'JPEG 2000 Part 2 codestream as restricted by baseline conformance '
+ 'requirements in M.9.2.3',
73: 'YPbPr(1125/60) enumerated colourspace',
74: 'YPbPr(1250/50) enumerated colourspace'}
class ReaderRequirementsBox(Jp2kBox): class ReaderRequirementsBox(Jp2kBox):
"""Container for reader requirements box information. """Container for reader requirements box information.
@ -1182,7 +1266,7 @@ class ReaderRequirementsBox(Jp2kBox):
msg += '\n Standard Features:' msg += '\n Standard Features:'
for j in range(len(self.standard_flag)): for j in range(len(self.standard_flag)):
sfl = self.standard_flag[j] sfl = self.standard_flag[j]
rrdisp = _reader_requirements_display[self.standard_flag[j]] rrdisp = _READER_REQUIREMENTS_DISPLAY[self.standard_flag[j]]
msg += '\n Feature {0:03d}: {1}'.format(sfl, rrdisp) msg += '\n Feature {0:03d}: {1}'.format(sfl, rrdisp)
msg += '\n Vendor Features:' msg += '\n Vendor Features:'
@ -1803,7 +1887,7 @@ class UUIDBox(Jp2kBox):
---------- ----------
the_uuid : uuid.UUID the_uuid : uuid.UUID
Identifies the type of UUID box. Identifies the type of UUID box.
raw_data : raw_data : byte array
This is the "payload" of data for the specified UUID. This is the "payload" of data for the specified UUID.
length : int length : int
length of the box in bytes. length of the box in bytes.

View file

@ -146,8 +146,8 @@ class Jp2k(Jp2kBox):
box_length = values[0] box_length = values[0]
box_id = values[1] box_id = values[1]
signature = values[2:] signature = values[2:]
if ((box_length != 12) or (box_id != b'jP ') or if (((box_length != 12) or (box_id != b'jP ') or
(signature != (13, 10, 135, 10))): (signature != (13, 10, 135, 10)))):
msg = '{0} is not a JPEG 2000 file.'.format(self.filename) msg = '{0} is not a JPEG 2000 file.'.format(self.filename)
raise IOError(msg) raise IOError(msg)
@ -378,7 +378,7 @@ class Jp2k(Jp2kBox):
else: else:
raise RuntimeError("unhandled datatype") raise RuntimeError("unhandled datatype")
comptparms = (_opj2.image_comptparm_t * num_comps)() comptparms = (_opj2.ImageComptParmType * num_comps)()
for j in range(num_comps): for j in range(num_comps):
comptparms[j].dx = cparams.subsampling_dx comptparms[j].dx = cparams.subsampling_dx
comptparms[j].dy = cparams.subsampling_dy comptparms[j].dy = cparams.subsampling_dy
@ -551,7 +551,8 @@ class Jp2k(Jp2kBox):
else: else:
# OK, I'm a jp2 file. Need to find out where the # OK, I'm a jp2 file. Need to find out where the
# raw codestream actually starts. # raw codestream actually starts.
jp2c = [box for box in self.box if box.box_id == 'jp2c'] jp2c = [box for box in self.box
if box.box_id == 'jp2c']
jp2c = jp2c[0] jp2c = jp2c[0]
ofile.write(struct.pack('>I', jp2c.length + 8)) ofile.write(struct.pack('>I', jp2c.length + 8))
ofile.write('jp2c'.encode()) ofile.write('jp2c'.encode())
@ -647,10 +648,9 @@ class Jp2k(Jp2kBox):
msg += "using OPENJP2 instead." msg += "using OPENJP2 instead."
raise RuntimeError(msg) raise RuntimeError(msg)
with ExitStack() as stack: with ExitStack() as stack:
# Set decoding parameters. # Set decoding parameters.
dparameters = _opj.dparameters_t() dparameters = _opj.DecompressionParametersType()
_opj.set_default_decoder_parameters(ctypes.byref(dparameters)) _opj.set_default_decoder_parameters(ctypes.byref(dparameters))
dparameters.cp_reduce = rlevel dparameters.cp_reduce = rlevel
dparameters.decod_format = self._codec_format dparameters.decod_format = self._codec_format
@ -662,13 +662,13 @@ class Jp2k(Jp2kBox):
dinfo = _opj.create_decompress(dparameters.decod_format) dinfo = _opj.create_decompress(dparameters.decod_format)
event_mgr = _opj.event_mgr_t() event_mgr = _opj.EventMgrType()
info_handler = ctypes.cast(_INFO_CALLBACK, ctypes.c_void_p) info_handler = ctypes.cast(_INFO_CALLBACK, ctypes.c_void_p)
event_mgr.info_handler = info_handler if verbose else None event_mgr.info_handler = info_handler if verbose else None
event_mgr.warning_handler = ctypes.cast(_WARNING_CALLBACK, event_mgr.warning_handler = ctypes.cast(_WARNING_CALLBACK,
ctypes.c_void_p) ctypes.c_void_p)
event_mgr.error_handler = ctypes.cast(_ERROR_CALLBACK, event_mgr.error_handler = ctypes.cast(_ERROR_CALLBACK,
ctypes.c_void_p) ctypes.c_void_p)
_opj.set_event_mgr(dinfo, ctypes.byref(event_mgr)) _opj.set_event_mgr(dinfo, ctypes.byref(event_mgr))
_opj.setup_decoder(dinfo, dparameters) _opj.setup_decoder(dinfo, dparameters)
@ -722,7 +722,7 @@ class Jp2k(Jp2kBox):
warnings.simplefilter("ignore") warnings.simplefilter("ignore")
nelts = nrows * ncols nelts = nrows * ncols
band = np.ctypeslib.as_array( band = np.ctypeslib.as_array(
(ctypes.c_int32 * nelts).from_address(addr)) (ctypes.c_int32 * nelts).from_address(addr))
data[:, :, k] = np.reshape(band.astype(dtype), data[:, :, k] = np.reshape(band.astype(dtype),
(nrows, ncols)) (nrows, ncols))
@ -909,7 +909,7 @@ class Jp2k(Jp2kBox):
with warnings.catch_warnings(): with warnings.catch_warnings():
warnings.simplefilter("ignore") warnings.simplefilter("ignore")
band = np.ctypeslib.as_array( band = np.ctypeslib.as_array(
(ctypes.c_int32 * nrows * ncols).from_address(addr)) (ctypes.c_int32 * nrows * ncols).from_address(addr))
if as_bands: if as_bands:
data.append(np.reshape(band.astype(dtype), (nrows, ncols))) data.append(np.reshape(band.astype(dtype), (nrows, ncols)))
else: else:

View file

@ -5,6 +5,7 @@ import ctypes
from ctypes.util import find_library from ctypes.util import find_library
import os import os
import platform import platform
import warnings
import sys import sys
if sys.hexversion <= 0x03000000: if sys.hexversion <= 0x03000000:
@ -39,8 +40,10 @@ def glymurrc_fname():
def get_openjpeg_config(): def get_openjpeg_config():
""" Try to find openjpeg library on the system path first.
"""
libopenjpeg_path = find_library('openjpeg') libopenjpeg_path = find_library('openjpeg')
# If we could not find it, then look in some likely locations. # If we could not find it, then look in some likely locations.
if libopenjpeg_path is None: if libopenjpeg_path is None:
if platform.system() == 'Darwin': if platform.system() == 'Darwin':
@ -56,23 +59,27 @@ def get_openjpeg_config():
try: try:
if os.name == "nt": if os.name == "nt":
openjpeg_lib = ctypes.windll.LoadLibrary(libopenjpeg_path) openjpeg_lib = ctypes.windll.LoadLibrary(libopenjpeg_path)
else: else:
openjpeg_lib = ctypes.CDLL(libopenjpeg_path) openjpeg_lib = ctypes.CDLL(libopenjpeg_path)
except OSError: except OSError:
openjpeg_lib = None openjpeg_lib = None
if openjpeg_lib is not None: if openjpeg_lib is not None:
# Must be at least 1.5.0 # Must be at least 1.5.0
openjpeg_lib.opj_version.restype = ctypes.c_char_p openjpeg_lib.opj_version.restype = ctypes.c_char_p
v = openjpeg_lib.opj_version() version = openjpeg_lib.opj_version().decode('utf-8')
v = v.decode('utf-8') _, minor, _ = version.split('.')
major, minor, patch = v.split('.')
if minor != '5': if minor != '5':
openjpeg_lib = None openjpeg_lib = None
return openjpeg_lib return openjpeg_lib
def get_openjp2_config(): def get_openjp2_config():
"""
We expect to not find openjp2 on the system path since the only version
that we currently care about is still in the svn trunk at openjpeg.org.
We must use a configuration file that the user must write.
"""
filename = glymurrc_fname() filename = glymurrc_fname()
if filename is not None: if filename is not None:
# Read the configuration file for the library location. # Read the configuration file for the library location.
@ -106,6 +113,7 @@ def glymur_config():
openjpeg_lib = get_openjpeg_config() openjpeg_lib = get_openjpeg_config()
return openjp2_lib, openjpeg_lib return openjp2_lib, openjpeg_lib
def get_configdir(): def get_configdir():
"""Return string representing the configuration directory. """Return string representing the configuration directory.
@ -121,4 +129,5 @@ def get_configdir():
if 'USERPROFILE' in os.environ: if 'USERPROFILE' in os.environ:
# Windows? # Windows?
return os.path.join(os.environ['USERPROFILE'], 'Application Data', 'glymur') return os.path.join(os.environ['USERPROFILE'], 'Application Data',
'glymur')

View file

@ -1,30 +1,23 @@
""" """
Wraps individual functions in openjp2 library. Wraps individual functions in openjp2 library.
""" """
# pylint: disable=C0302,R0903
import ctypes import ctypes
from ctypes.util import find_library
import warnings
from .config import glymur_config from .config import glymur_config
OPENJP2, OPENJPEG = glymur_config() OPENJP2, OPENJPEG = glymur_config()
# Progression order
LRCP = 0
RLCP = 1
RPCL = 2
PCRL = 3
CPRL = 4
ERROR_MSG_LST = [] ERROR_MSG_LST = []
# Map certain atomic OpenJPEG datatypes to the ctypes equivalents. # Map certain atomic OpenJPEG datatypes to the ctypes equivalents.
bool_t = ctypes.c_int32 BOOL_TYPE = ctypes.c_int32
codec_t_p = ctypes.c_void_p CODEC_TYPE = ctypes.c_void_p
prog_order_t_p = ctypes.c_int32 PROG_ORDER_TYPE = ctypes.c_int32
cinema_mode_t = ctypes.c_int32 CINEMA_MODE_TYPE = ctypes.c_int32
rsiz_capabilities_t = ctypes.c_int32 RSIZ_CAPABILITIES_TYPE = ctypes.c_int32
stream_t_p = ctypes.c_void_p STREAM_TYPE_P = ctypes.c_void_p
PATH_LEN = 4096 PATH_LEN = 4096
J2K_MAXRLVLS = 33 J2K_MAXRLVLS = 33
@ -41,18 +34,21 @@ CLRSPC_UNSPECIFIED = 0
CLRSPC_SRGB = 1 CLRSPC_SRGB = 1
CLRSPC_GRAY = 2 CLRSPC_GRAY = 2
CLRSPC_YCC = 3 CLRSPC_YCC = 3
color_space_t = ctypes.c_int COLOR_SPACE_TYPE = ctypes.c_int
# supported codec # supported codec
codec_format_t = ctypes.c_int CODEC_FORMAT_TYPE = ctypes.c_int
CODEC_UNKNOWN = -1 CODEC_UNKNOWN = -1
CODEC_J2K = 0 CODEC_J2K = 0
CODEC_JPT = 1 CODEC_JPT = 1
CODEC_JP2 = 2 CODEC_JP2 = 2
class poc_t(ctypes.Structure): class PocType(ctypes.Structure):
"""Progression order changes.""" """Progression order changes.
Corresponds to poc_t type in openjp2 headers.
"""
# Resolution num start, Component num start, given by POC # Resolution num start, Component num start, given by POC
_fields_ = [ _fields_ = [
("resno0", ctypes.c_uint32), ("resno0", ctypes.c_uint32),
@ -69,8 +65,8 @@ class poc_t(ctypes.Structure):
("precno1", ctypes.c_uint32), ("precno1", ctypes.c_uint32),
# Progression order enum # Progression order enum
("prg1", prog_order_t_p), ("prg1", PROG_ORDER_TYPE),
("prg", prog_order_t_p), ("prg", PROG_ORDER_TYPE),
# Progression order string # Progression order string
("progorder", ctypes.c_char * 5), ("progorder", ctypes.c_char * 5),
@ -114,8 +110,11 @@ class poc_t(ctypes.Structure):
("ty0_t", ctypes.c_uint32)] ("ty0_t", ctypes.c_uint32)]
class dparameters_t(ctypes.Structure): class DecompressionParametersType(ctypes.Structure):
"""Decompression parameters""" """Decompression parameters.
Corresponds to dparameters_t type in openjp2 headers.
"""
_fields_ = [ _fields_ = [
# Set the number of highest resolutio levels to be discarded. The # Set the number of highest resolutio levels to be discarded. The
# image resolution is effectively divided by 2 to the power of # image resolution is effectively divided by 2 to the power of
@ -153,7 +152,7 @@ class dparameters_t(ctypes.Structure):
("DA_y1", ctypes.c_uint32), ("DA_y1", ctypes.c_uint32),
# verbose mode # verbose mode
("m_verbose", bool_t), ("m_verbose", BOOL_TYPE),
# tile number of the decoded tile # tile number of the decoded tile
("tile_index", ctypes.c_uint32), ("tile_index", ctypes.c_uint32),
@ -162,7 +161,7 @@ class dparameters_t(ctypes.Structure):
("nb_tile_to_decode", ctypes.c_uint32), ("nb_tile_to_decode", ctypes.c_uint32),
# activates the JPWL correction capabilities # activates the JPWL correction capabilities
("jpwl_correct", bool_t), ("jpwl_correct", BOOL_TYPE),
# activates the JPWL correction capabilities # activates the JPWL correction capabilities
("jpwl_exp_comps", ctypes.c_int32), ("jpwl_exp_comps", ctypes.c_int32),
@ -174,13 +173,16 @@ class dparameters_t(ctypes.Structure):
("flags", ctypes.c_uint32)] ("flags", ctypes.c_uint32)]
class cparameters_t(ctypes.Structure): class CompressionParametersType(ctypes.Structure):
"""Compression parameters""" """Compression parameters.
Corresponds to cparameters_t type in openjp2 headers.
"""
_fields_ = [ _fields_ = [
# size of tile: # size of tile:
# tile_size_on = false (not in argument) or # tile_size_on = false (not in argument) or
# = true (in argument) # = true (in argument)
("tile_size_on", bool_t), ("tile_size_on", BOOL_TYPE),
# XTOsiz, YTOsiz # XTOsiz, YTOsiz
("cp_tx0", ctypes.c_int), ("cp_tx0", ctypes.c_int),
@ -212,7 +214,7 @@ class cparameters_t(ctypes.Structure):
("prog_order", ctypes.c_int), ("prog_order", ctypes.c_int),
# progression order changes # progression order changes
("poc", poc_t * 32), ("poc", PocType * 32),
# number of progression order changes (POC), default to 0 # number of progression order changes (POC), default to 0
("numpocs", ctypes.c_uint), ("numpocs", ctypes.c_uint),
@ -286,7 +288,7 @@ class cparameters_t(ctypes.Structure):
# JPWL encoding parameters # JPWL encoding parameters
# enables writing of EPC in MH, thus activating JPWL # enables writing of EPC in MH, thus activating JPWL
("jpwl_epc_on", bool_t), ("jpwl_epc_on", BOOL_TYPE),
# error protection method for MH (0,1,16,32,37-128) # error protection method for MH (0,1,16,32,37-128)
("jpwl_hprot_mh", ctypes.c_int), ("jpwl_hprot_mh", ctypes.c_int),
@ -325,14 +327,14 @@ class cparameters_t(ctypes.Structure):
("jpwl_sens_tph", ctypes.c_int * JPWL_MAX_NO_TILESPECS), ("jpwl_sens_tph", ctypes.c_int * JPWL_MAX_NO_TILESPECS),
# Digital Cinema compliance 0-not compliant, 1-compliant # Digital Cinema compliance 0-not compliant, 1-compliant
("cp_cinema", cinema_mode_t), ("cp_cinema", CINEMA_MODE_TYPE),
# Maximum rate for each component. # Maximum rate for each component.
# If == 0, component size limitation is not considered # If == 0, component size limitation is not considered
("max_comp_size", ctypes.c_int), ("max_comp_size", ctypes.c_int),
# Profile name # Profile name
("cp_rsiz", rsiz_capabilities_t), ("cp_rsiz", RSIZ_CAPABILITIES_TYPE),
# Tile part generation # Tile part generation
("tp_on", ctypes.c_uint8), ("tp_on", ctypes.c_uint8),
@ -344,15 +346,18 @@ class cparameters_t(ctypes.Structure):
("tcp_mct", ctypes.c_uint8), ("tcp_mct", ctypes.c_uint8),
# Enable JPIP indexing # Enable JPIP indexing
("jpip_on", bool_t), ("jpip_on", BOOL_TYPE),
# Naive implementation of MCT restricted to a single reversible array # Naive implementation of MCT restricted to a single reversible array
# based encoding without offset concerning all the components. # based encoding without offset concerning all the components.
("mct_data", ctypes.c_void_p)] ("mct_data", ctypes.c_void_p)]
class image_comp_t(ctypes.Structure): class ImageCompType(ctypes.Structure):
"""defines a single image component""" """Defines a single image component.
Corresponds to image_comp_t type in openjp2 headers.
"""
_fields_ = [ _fields_ = [
# XRsiz, YRsiz: horizontal, vertical separation of ith component with # XRsiz, YRsiz: horizontal, vertical separation of ith component with
# respect to the reference grid # respect to the reference grid
@ -387,8 +392,11 @@ class image_comp_t(ctypes.Structure):
("data", ctypes.POINTER(ctypes.c_int32))] ("data", ctypes.POINTER(ctypes.c_int32))]
class image_t(ctypes.Structure): class ImageType(ctypes.Structure):
"""defines image data and characteristics""" """Defines image data and characteristics.
Corresponds to image_t type in openjp2 headers.
"""
_fields_ = [ _fields_ = [
# XOsiz, YOsiz: horizontal and vertical offset from the origin of the # XOsiz, YOsiz: horizontal and vertical offset from the origin of the
# reference grid to the left side of the image area # reference grid to the left side of the image area
@ -403,10 +411,10 @@ class image_t(ctypes.Structure):
("numcomps", ctypes.c_uint32), ("numcomps", ctypes.c_uint32),
# color space: should be sRGB, greyscale, or YUV # color space: should be sRGB, greyscale, or YUV
("color_space", color_space_t), ("color_space", COLOR_SPACE_TYPE),
# image components # image components
("comps", ctypes.POINTER(image_comp_t)), ("comps", ctypes.POINTER(ImageCompType)),
# restricted ICC profile buffer # restricted ICC profile buffer
("icc_profile_buf", ctypes.POINTER(ctypes.c_uint8)), ("icc_profile_buf", ctypes.POINTER(ctypes.c_uint8)),
@ -415,8 +423,11 @@ class image_t(ctypes.Structure):
("icc_profile_len", ctypes.c_uint32)] ("icc_profile_len", ctypes.c_uint32)]
class image_comptparm_t(ctypes.Structure): class ImageComptParmType(ctypes.Structure):
"""component parameters structure used by image_create function""" """Component parameters structure used by image_create function.
Corresponds to image_comptparm_t type in openjp2 headers.
"""
_fields_ = [ _fields_ = [
# XRsiz, YRsiz: horizontal, vertical separation of a sample of ith # XRsiz, YRsiz: horizontal, vertical separation of a sample of ith
# component with respect to the reference grid # component with respect to the reference grid
@ -441,8 +452,11 @@ class image_comptparm_t(ctypes.Structure):
("sgnd", ctypes.c_uint32)] ("sgnd", ctypes.c_uint32)]
class tccp_info_t(ctypes.Structure): class TccpInfo(ctypes.Structure):
"""tile-component coding parameters information""" """Tile-component coding parameters information.
Corresponds to tccp_info_t type in openjp2 header file.
"""
_fields_ = [ _fields_ = [
# component index # component index
("compno", ctypes.c_uint32), ("compno", ctypes.c_uint32),
@ -485,8 +499,11 @@ class tccp_info_t(ctypes.Structure):
("prch", ctypes.c_uint32 * J2K_MAXRLVLS)] ("prch", ctypes.c_uint32 * J2K_MAXRLVLS)]
class tile_info_v2_t(ctypes.Structure): class TileInfoV2(ctypes.Structure):
"""tile coding parameters information""" """Tile coding parameters information
Corresponds to tile_info_v2_t type in openjp2 headers.
"""
_fields_ = [ _fields_ = [
# number (index) of tile # number (index) of tile
("tileno", ctypes.c_int32), ("tileno", ctypes.c_int32),
@ -495,7 +512,7 @@ class tile_info_v2_t(ctypes.Structure):
("csty", ctypes.c_uint32), ("csty", ctypes.c_uint32),
# progression order # progression order
("prg", prog_order_t_p), ("prg", PROG_ORDER_TYPE),
# number of layers # number of layers
("numlayers", ctypes.c_uint32), ("numlayers", ctypes.c_uint32),
@ -504,11 +521,14 @@ class tile_info_v2_t(ctypes.Structure):
("mct", ctypes.c_uint32), ("mct", ctypes.c_uint32),
# information concerning tile component parameters # information concerning tile component parameters
("tccp_info", ctypes.POINTER(tccp_info_t))] ("tccp_info", ctypes.POINTER(TccpInfo))]
class codestream_info_v2_t(ctypes.Structure): class CodestreamInfoV2(ctypes.Structure):
"""information about the codestream""" """information about the codestream.
Corresponds to codestream_info_v2_t type in openjp2 header files.
"""
_fields_ = [ _fields_ = [
# tile info # tile info
# tile origin in x, y (XTOsiz, YTOsiz) # tile origin in x, y (XTOsiz, YTOsiz)
@ -527,65 +547,65 @@ class codestream_info_v2_t(ctypes.Structure):
("nbcomps", ctypes.c_uint32), ("nbcomps", ctypes.c_uint32),
# default information regarding tiles inside of image # default information regarding tiles inside of image
("m_default_tile_info", tile_info_v2_t), ("m_default_tile_info", TileInfoV2),
# information regarding tiles inside of image # information regarding tiles inside of image
("tile_info", ctypes.POINTER(tile_info_v2_t))] ("tile_info", ctypes.POINTER(TileInfoV2))]
# Restrict the input and output argument types for each function used in the # Restrict the input and output argument types for each function used in the
# API. # API.
if OPENJP2 is not None: if OPENJP2 is not None:
OPENJP2.opj_create_compress.restype = codec_t_p OPENJP2.opj_create_compress.restype = CODEC_TYPE
OPENJP2.opj_create_compress.argtypes = [codec_format_t] OPENJP2.opj_create_compress.argtypes = [CODEC_FORMAT_TYPE]
OPENJP2.opj_create_decompress.argtypes = [codec_format_t] OPENJP2.opj_create_decompress.argtypes = [CODEC_FORMAT_TYPE]
OPENJP2.opj_create_decompress.restype = codec_t_p OPENJP2.opj_create_decompress.restype = CODEC_TYPE
ARGTYPES = [codec_t_p, stream_t_p, ctypes.POINTER(image_t)] ARGTYPES = [CODEC_TYPE, STREAM_TYPE_P, ctypes.POINTER(ImageType)]
OPENJP2.opj_decode.argtypes = ARGTYPES OPENJP2.opj_decode.argtypes = ARGTYPES
ARGTYPES = [codec_t_p, ctypes.c_uint32, ARGTYPES = [CODEC_TYPE, ctypes.c_uint32,
ctypes.POINTER(ctypes.c_uint8), ctypes.POINTER(ctypes.c_uint8),
ctypes.c_uint32, ctypes.c_uint32,
stream_t_p] STREAM_TYPE_P]
OPENJP2.opj_decode_tile_data.argtypes = ARGTYPES OPENJP2.opj_decode_tile_data.argtypes = ARGTYPES
ARGTYPES = [ctypes.POINTER(ctypes.POINTER(codestream_info_v2_t))] ARGTYPES = [ctypes.POINTER(ctypes.POINTER(CodestreamInfoV2))]
OPENJP2.opj_destroy_cstr_info.argtypes = ARGTYPES OPENJP2.opj_destroy_cstr_info.argtypes = ARGTYPES
OPENJP2.opj_destroy_cstr_info.restype = ctypes.c_void_p OPENJP2.opj_destroy_cstr_info.restype = ctypes.c_void_p
ARGTYPES = [codec_t_p, stream_t_p] ARGTYPES = [CODEC_TYPE, STREAM_TYPE_P]
OPENJP2.opj_encode.argtypes = ARGTYPES OPENJP2.opj_encode.argtypes = ARGTYPES
OPENJP2.opj_get_cstr_info.argtypes = [codec_t_p] OPENJP2.opj_get_cstr_info.argtypes = [CODEC_TYPE]
OPENJP2.opj_get_cstr_info.restype = ctypes.POINTER(codestream_info_v2_t) OPENJP2.opj_get_cstr_info.restype = ctypes.POINTER(CodestreamInfoV2)
ARGTYPES = [codec_t_p, ARGTYPES = [CODEC_TYPE,
stream_t_p, STREAM_TYPE_P,
ctypes.POINTER(image_t), ctypes.POINTER(ImageType),
ctypes.c_uint32] ctypes.c_uint32]
OPENJP2.opj_get_decoded_tile.argtypes = ARGTYPES OPENJP2.opj_get_decoded_tile.argtypes = ARGTYPES
ARGTYPES = [ctypes.c_uint32, ARGTYPES = [ctypes.c_uint32,
ctypes.POINTER(image_comptparm_t), ctypes.POINTER(ImageComptParmType),
color_space_t] COLOR_SPACE_TYPE]
OPENJP2.opj_image_create.argtypes = ARGTYPES OPENJP2.opj_image_create.argtypes = ARGTYPES
OPENJP2.opj_image_create.restype = ctypes.POINTER(image_t) OPENJP2.opj_image_create.restype = ctypes.POINTER(ImageType)
ARGTYPES = [ctypes.c_uint32, ARGTYPES = [ctypes.c_uint32,
ctypes.POINTER(image_comptparm_t), ctypes.POINTER(ImageComptParmType),
color_space_t] COLOR_SPACE_TYPE]
OPENJP2.opj_image_tile_create.argtypes = ARGTYPES OPENJP2.opj_image_tile_create.argtypes = ARGTYPES
OPENJP2.opj_image_tile_create.restype = ctypes.POINTER(image_t) OPENJP2.opj_image_tile_create.restype = ctypes.POINTER(ImageType)
OPENJP2.opj_image_destroy.argtypes = [ctypes.POINTER(image_t)] OPENJP2.opj_image_destroy.argtypes = [ctypes.POINTER(ImageType)]
ARGTYPES = [stream_t_p, codec_t_p, ARGTYPES = [STREAM_TYPE_P, CODEC_TYPE,
ctypes.POINTER(ctypes.POINTER(image_t))] ctypes.POINTER(ctypes.POINTER(ImageType))]
OPENJP2.opj_read_header.argtypes = ARGTYPES OPENJP2.opj_read_header.argtypes = ARGTYPES
ARGTYPES = [codec_t_p, ARGTYPES = [CODEC_TYPE,
stream_t_p, STREAM_TYPE_P,
ctypes.POINTER(ctypes.c_uint32), ctypes.POINTER(ctypes.c_uint32),
ctypes.POINTER(ctypes.c_uint32), ctypes.POINTER(ctypes.c_uint32),
ctypes.POINTER(ctypes.c_int32), ctypes.POINTER(ctypes.c_int32),
@ -593,56 +613,56 @@ if OPENJP2 is not None:
ctypes.POINTER(ctypes.c_int32), ctypes.POINTER(ctypes.c_int32),
ctypes.POINTER(ctypes.c_int32), ctypes.POINTER(ctypes.c_int32),
ctypes.POINTER(ctypes.c_uint32), ctypes.POINTER(ctypes.c_uint32),
ctypes.POINTER(bool_t)] ctypes.POINTER(BOOL_TYPE)]
OPENJP2.opj_read_tile_header.argtypes = ARGTYPES OPENJP2.opj_read_tile_header.argtypes = ARGTYPES
ARGTYPES = [codec_t_p, ctypes.POINTER(image_t), ctypes.c_int32, ARGTYPES = [CODEC_TYPE, ctypes.POINTER(ImageType), ctypes.c_int32,
ctypes.c_int32, ctypes.c_int32, ctypes.c_int32] ctypes.c_int32, ctypes.c_int32, ctypes.c_int32]
OPENJP2.opj_set_decode_area.argtypes = ARGTYPES OPENJP2.opj_set_decode_area.argtypes = ARGTYPES
ARGTYPES = [ctypes.POINTER(cparameters_t)] ARGTYPES = [ctypes.POINTER(CompressionParametersType)]
OPENJP2.opj_set_default_encoder_parameters.argtypes = ARGTYPES OPENJP2.opj_set_default_encoder_parameters.argtypes = ARGTYPES
ARGTYPES = [ctypes.POINTER(dparameters_t)] ARGTYPES = [ctypes.POINTER(DecompressionParametersType)]
OPENJP2.opj_set_default_decoder_parameters.argtypes = ARGTYPES OPENJP2.opj_set_default_decoder_parameters.argtypes = ARGTYPES
ARGTYPES = [codec_t_p, ctypes.c_void_p, ctypes.c_void_p] ARGTYPES = [CODEC_TYPE, ctypes.c_void_p, ctypes.c_void_p]
OPENJP2.opj_set_error_handler.argtypes = ARGTYPES OPENJP2.opj_set_error_handler.argtypes = ARGTYPES
OPENJP2.opj_set_info_handler.argtypes = ARGTYPES OPENJP2.opj_set_info_handler.argtypes = ARGTYPES
OPENJP2.opj_set_warning_handler.argtypes = ARGTYPES OPENJP2.opj_set_warning_handler.argtypes = ARGTYPES
ARGTYPES = [codec_t_p, ctypes.POINTER(dparameters_t)] ARGTYPES = [CODEC_TYPE, ctypes.POINTER(DecompressionParametersType)]
OPENJP2.opj_setup_decoder.argtypes = ARGTYPES OPENJP2.opj_setup_decoder.argtypes = ARGTYPES
ARGTYPES = [codec_t_p, ARGTYPES = [CODEC_TYPE,
ctypes.POINTER(cparameters_t), ctypes.POINTER(CompressionParametersType),
ctypes.POINTER(image_t)] ctypes.POINTER(ImageType)]
OPENJP2.opj_setup_encoder.argtypes = ARGTYPES OPENJP2.opj_setup_encoder.argtypes = ARGTYPES
ARGTYPES = [ctypes.c_char_p, ctypes.c_int32] ARGTYPES = [ctypes.c_char_p, ctypes.c_int32]
OPENJP2.opj_stream_create_default_file_stream_v3.argtypes = ARGTYPES OPENJP2.opj_stream_create_default_file_stream_v3.argtypes = ARGTYPES
OPENJP2.opj_stream_create_default_file_stream_v3.restype = stream_t_p OPENJP2.opj_stream_create_default_file_stream_v3.restype = STREAM_TYPE_P
ARGTYPES = [codec_t_p, ctypes.POINTER(image_t), stream_t_p] ARGTYPES = [CODEC_TYPE, ctypes.POINTER(ImageType), STREAM_TYPE_P]
OPENJP2.opj_start_compress.argtypes = ARGTYPES OPENJP2.opj_start_compress.argtypes = ARGTYPES
OPENJP2.opj_end_compress.argtypes = [codec_t_p, stream_t_p] OPENJP2.opj_end_compress.argtypes = [CODEC_TYPE, STREAM_TYPE_P]
OPENJP2.opj_end_decompress.argtypes = [codec_t_p, stream_t_p] OPENJP2.opj_end_decompress.argtypes = [CODEC_TYPE, STREAM_TYPE_P]
OPENJP2.opj_stream_destroy_v3.argtypes = [stream_t_p] OPENJP2.opj_stream_destroy_v3.argtypes = [STREAM_TYPE_P]
OPENJP2.opj_destroy_codec.argtypes = [codec_t_p] OPENJP2.opj_destroy_codec.argtypes = [CODEC_TYPE]
ARGTYPES = [codec_t_p, ARGTYPES = [CODEC_TYPE,
ctypes.c_uint32, ctypes.c_uint32,
ctypes.POINTER(ctypes.c_uint8), ctypes.POINTER(ctypes.c_uint8),
ctypes.c_uint32, ctypes.c_uint32,
stream_t_p] STREAM_TYPE_P]
OPENJP2.opj_write_tile.argtypes = ARGTYPES OPENJP2.opj_write_tile.argtypes = ARGTYPES
def check_error(status): def check_error(status):
"""Set a generic function as the restype attribute of all OpenJPEG """Set a generic function as the restype attribute of all OpenJPEG
functions that return a bool_t value. This way we do not have to check functions that return a BOOL_TYPE value. This way we do not have to check
for error status in each wrapping function and an exception will always be for error status in each wrapping function and an exception will always be
appropriately raised. appropriately raised.
""" """
@ -683,7 +703,7 @@ def create_compress(codec_format):
Returns Returns
------- -------
codec : Reference to codec_t_p instance. codec : Reference to CODEC_TYPE instance.
""" """
codec = OPENJP2.opj_create_compress(codec_format) codec = OPENJP2.opj_create_compress(codec_format)
return codec return codec
@ -696,11 +716,11 @@ def decode(codec, stream, image):
Parameters Parameters
---------- ----------
codec : codec_t_p codec : CODEC_TYPE
The JPEG2000 codec The JPEG2000 codec
stream : stream_t_p stream : STREAM_TYPE_P
The stream to decode. The stream to decode.
image : image_t image : ImageType
Output image structure. Output image structure.
Raises Raises
@ -718,7 +738,7 @@ def decode_tile_data(codec, tidx, data, data_size, stream):
Parameters Parameters
---------- ----------
codec : codec_t_p codec : CODEC_TYPE
The JPEG2000 codec The JPEG2000 codec
tile_index : int tile_index : int
The index of the tile being decoded The index of the tile being decoded
@ -726,7 +746,7 @@ def decode_tile_data(codec, tidx, data, data_size, stream):
Holds a memory block into which data will be decoded. Holds a memory block into which data will be decoded.
data_size : int data_size : int
The size of data in bytes The size of data in bytes
stream : stream_t_p stream : STREAM_TYPE_P
The stream to decode. The stream to decode.
Raises Raises
@ -755,7 +775,7 @@ def create_decompress(codec_format):
Returns Returns
------- -------
codec : Reference to codec_t_p instance. codec : Reference to CODEC_TYPE instance.
""" """
codec = OPENJP2.opj_create_decompress(codec_format) codec = OPENJP2.opj_create_decompress(codec_format)
return codec return codec
@ -768,7 +788,7 @@ def destroy_codec(codec):
Parameters Parameters
---------- ----------
codec : codec_t_p codec : CODEC_TYPE
Decompressor handle to destroy. Decompressor handle to destroy.
""" """
OPENJP2.opj_destroy_codec(codec) OPENJP2.opj_destroy_codec(codec)
@ -781,9 +801,9 @@ def encode(codec, stream):
Parameters Parameters
---------- ----------
codec : codec_t_p codec : CODEC_TYPE
The jpeg2000 codec. The jpeg2000 codec.
stream : stream_t_p stream : STREAM_TYPE_P
The stream to which data is written. The stream to which data is written.
Raises Raises
@ -801,12 +821,12 @@ def get_cstr_info(codec):
Parameters Parameters
---------- ----------
codec : codec_t_p codec : CODEC_TYPE
The jpeg2000 codec. The jpeg2000 codec.
Returns Returns
------- -------
cstr_info_p : codestream_info_v2_t cstr_info_p : CodestreamInfoV2
Reference to codestream information. Reference to codestream information.
""" """
cstr_info_p = OPENJP2.opj_get_cstr_info(codec) cstr_info_p = OPENJP2.opj_get_cstr_info(codec)
@ -820,11 +840,11 @@ def get_decoded_tile(codec, stream, imagep, tile_index):
Parameters Parameters
---------- ----------
codec : codec_t_p codec : CODEC_TYPE
The jpeg2000 codec. The jpeg2000 codec.
stream : stream_t_p stream : STREAM_TYPE_P
The input stream. The input stream.
image : image_t image : ImageType
Output image structure. Output image structure.
tiler_index : int tiler_index : int
Index of the tile which will be decoded. Index of the tile which will be decoded.
@ -844,7 +864,7 @@ def destroy_cstr_info(cstr_info_p):
Parameters Parameters
---------- ----------
cstr_info_p : codestream_info_v2_t pointer cstr_info_p : CodestreamInfoV2 pointer
Pointer to codestream info structure. Pointer to codestream info structure.
""" """
OPENJP2.opj_destroy_cstr_info(ctypes.byref(cstr_info_p)) OPENJP2.opj_destroy_cstr_info(ctypes.byref(cstr_info_p))
@ -857,9 +877,9 @@ def end_compress(codec, stream):
Parameters Parameters
---------- ----------
codec : codec_t_p codec : CODEC_TYPE
Compressor handle. Compressor handle.
stream : stream_t_p stream : STREAM_TYPE_P
Output stream buffer. Output stream buffer.
Raises Raises
@ -877,9 +897,9 @@ def end_decompress(codec, stream):
Parameters Parameters
---------- ----------
codec : codec_t_p codec : CODEC_TYPE
Compressor handle. Compressor handle.
stream : stream_t_p stream : STREAM_TYPE_P
Output stream buffer. Output stream buffer.
Raises Raises
@ -897,7 +917,7 @@ def image_destroy(image):
Parameters Parameters
---------- ----------
image : image_t pointer image : ImageType pointer
Image resource to be disposed. Image resource to be disposed.
""" """
OPENJP2.opj_image_destroy(image) OPENJP2.opj_image_destroy(image)
@ -917,12 +937,12 @@ def image_create(comptparms, clrspc):
Returns Returns
------- -------
image : image_t image : ImageType
Reference to image_t instance. Reference to ImageType instance.
""" """
image = OPENJP2.opj_image_create(len(comptparms), image = OPENJP2.opj_image_create(len(comptparms),
comptparms, comptparms,
clrspc) clrspc)
return image return image
@ -940,12 +960,12 @@ def image_tile_create(comptparms, clrspc):
Returns Returns
------- -------
image : image_t image : ImageType
Reference to image_t instance. Reference to ImageType instance.
""" """
image = OPENJP2.opj_image_tile_create(len(comptparms), image = OPENJP2.opj_image_tile_create(len(comptparms),
comptparms, comptparms,
clrspc) clrspc)
return image return image
@ -956,14 +976,14 @@ def read_header(stream, codec):
Parameters Parameters
---------- ----------
stream: stream_t_p stream: STREAM_TYPE_P
The JPEG2000 stream. The JPEG2000 stream.
codec: codec_t codec: codec_t
The JPEG2000 codec to read. The JPEG2000 codec to read.
Returns Returns
------- -------
imagep : reference to image_t instance imagep : reference to ImageType instance
The image structure initialized with image characteristics. The image structure initialized with image characteristics.
Raises Raises
@ -971,7 +991,7 @@ def read_header(stream, codec):
RuntimeError RuntimeError
If the OpenJPEG library routine opj_read_header fails. If the OpenJPEG library routine opj_read_header fails.
""" """
imagep = ctypes.POINTER(image_t)() imagep = ctypes.POINTER(ImageType)()
OPENJP2.opj_read_header(stream, codec, ctypes.byref(imagep)) OPENJP2.opj_read_header(stream, codec, ctypes.byref(imagep))
return imagep return imagep
@ -985,7 +1005,7 @@ def read_tile_header(codec, stream):
---------- ----------
codec : codec_t codec : codec_t
The JPEG2000 codec to read. The JPEG2000 codec to read.
stream : stream_t_p stream : STREAM_TYPE_P
The JPEG2000 stream. The JPEG2000 stream.
Returns Returns
@ -1015,17 +1035,17 @@ def read_tile_header(codec, stream):
col1 = ctypes.c_int32() col1 = ctypes.c_int32()
row1 = ctypes.c_int32() row1 = ctypes.c_int32()
ncomps = ctypes.c_uint32() ncomps = ctypes.c_uint32()
go_on = bool_t() go_on = BOOL_TYPE()
OPENJP2.opj_read_tile_header(codec, OPENJP2.opj_read_tile_header(codec,
stream, stream,
ctypes.byref(tile_index), ctypes.byref(tile_index),
ctypes.byref(data_size), ctypes.byref(data_size),
ctypes.byref(col0), ctypes.byref(col0),
ctypes.byref(row0), ctypes.byref(row0),
ctypes.byref(col1), ctypes.byref(col1),
ctypes.byref(row1), ctypes.byref(row1),
ctypes.byref(ncomps), ctypes.byref(ncomps),
ctypes.byref(go_on)) ctypes.byref(go_on))
go_on = bool(go_on.value) go_on = bool(go_on.value)
return (tile_index.value, return (tile_index.value,
data_size.value, data_size.value,
@ -1045,9 +1065,9 @@ def set_decode_area(codec, image, start_x=0, start_y=0, end_x=0, end_y=0):
Parameters Parameters
---------- ----------
codec : codec_t_p codec : CODEC_TYPE
Codec initialized by create_decompress function. Codec initialized by create_decompress function.
image : image_t pointer image : ImageType pointer
The decoded image previously set by read_header. The decoded image previously set by read_header.
start_x, start_y : optional, int start_x, start_y : optional, int
The left and upper position of the rectangle to decode. The left and upper position of the rectangle to decode.
@ -1073,10 +1093,10 @@ def set_default_decoder_parameters():
Returns Returns
------- -------
dparam : dparameters_t dparam : DecompressionParametersType
Decompression parameters. Decompression parameters.
""" """
dparams = dparameters_t() dparams = DecompressionParametersType()
OPENJP2.opj_set_default_decoder_parameters(ctypes.byref(dparams)) OPENJP2.opj_set_default_decoder_parameters(ctypes.byref(dparams))
return dparams return dparams
@ -1108,10 +1128,10 @@ def set_default_encoder_parameters():
Returns Returns
------- -------
cparameters : cparameters_t cparameters : CompressionParametersType
Compression parameters. Compression parameters.
""" """
cparams = cparameters_t() cparams = CompressionParametersType()
OPENJP2.opj_set_default_encoder_parameters(ctypes.byref(cparams)) OPENJP2.opj_set_default_encoder_parameters(ctypes.byref(cparams))
return cparams return cparams
@ -1123,7 +1143,7 @@ def set_error_handler(codec, handler, data=None):
Parameters Parameters
---------- ----------
codec : codec_t_p codec : CODEC_TYPE
Codec initialized by create_compress function. Codec initialized by create_compress function.
handler : python function handler : python function
The callback function to be used. The callback function to be used.
@ -1145,7 +1165,7 @@ def set_info_handler(codec, handler, data=None):
Parameters Parameters
---------- ----------
codec : codec_t_p codec : CODEC_TYPE
Codec initialized by create_compress function. Codec initialized by create_compress function.
handler : python function handler : python function
The callback function to be used. The callback function to be used.
@ -1167,7 +1187,7 @@ def set_warning_handler(codec, handler, data=None):
Parameters Parameters
---------- ----------
codec : codec_t_p codec : CODEC_TYPE
Codec initialized by create_compress function. Codec initialized by create_compress function.
handler : python function handler : python function
The callback function to be used. The callback function to be used.
@ -1189,9 +1209,9 @@ def setup_decoder(codec, dparams):
Parameters Parameters
---------- ----------
codec: codec_t_p codec: CODEC_TYPE
Codec initialized by create_compress function. Codec initialized by create_compress function.
dparams: dparameters_t dparams: DecompressionParametersType
Decompression parameters. Decompression parameters.
Raises Raises
@ -1210,11 +1230,11 @@ def setup_encoder(codec, cparams, image):
Parameters Parameters
---------- ----------
codec : codec_t_p codec : CODEC_TYPE
codec initialized by create_compress function codec initialized by create_compress function
cparams : cparameters_t cparams : CompressionParametersType
compression parameters compression parameters
image : image_t image : ImageType
input-filled image input-filled image
Raises Raises
@ -1232,11 +1252,11 @@ def start_compress(codec, image, stream):
Parameters Parameters
---------- ----------
codec : codec_t_p codec : CODEC_TYPE
Compressor handle. Compressor handle.
image : pointer to image_t image : pointer to ImageType
Input filled image. Input filled image.
stream : stream_t_p stream : STREAM_TYPE_P
Input stream. Input stream.
Raises Raises
@ -1278,7 +1298,7 @@ def stream_destroy_v3(stream):
Parameters Parameters
---------- ----------
stream : stream_t_p stream : STREAM_TYPE_P
The file stream. The file stream.
""" """
OPENJP2.opj_stream_destroy_v3(stream) OPENJP2.opj_stream_destroy_v3(stream)
@ -1291,7 +1311,7 @@ def write_tile(codec, tile_index, data, data_size, stream):
Parameters Parameters
---------- ----------
codec : codec_t_p codec : CODEC_TYPE
The jpeg2000 codec The jpeg2000 codec
tile_index : int tile_index : int
The index of the tile to write, zero-indexing assumed The index of the tile to write, zero-indexing assumed
@ -1299,7 +1319,7 @@ def write_tile(codec, tile_index, data, data_size, stream):
Image data arranged in usual C-order Image data arranged in usual C-order
data_size : int data_size : int
Size of a tile in bytes Size of a tile in bytes
stream : stream_t_p stream : STREAM_TYPE_P
The stream to write data to The stream to write data to
Raises Raises
@ -1309,10 +1329,10 @@ def write_tile(codec, tile_index, data, data_size, stream):
""" """
datap = data.ctypes.data_as(ctypes.POINTER(ctypes.c_uint8)) datap = data.ctypes.data_as(ctypes.POINTER(ctypes.c_uint8))
OPENJP2.opj_write_tile(codec, OPENJP2.opj_write_tile(codec,
ctypes.c_uint32(int(tile_index)), ctypes.c_uint32(int(tile_index)),
datap, datap,
ctypes.c_uint32(int(data_size)), ctypes.c_uint32(int(data_size)),
stream) stream)
def set_error_message(msg): def set_error_message(msg):

View file

@ -1,27 +1,30 @@
"""Wraps library calls to openjpeg. """Wraps library calls to openjpeg.
""" """
# pylint: disable=R0903
import ctypes import ctypes
from ctypes.util import find_library
import platform
import os
from .config import glymur_config from .config import glymur_config
_, OPENJPEG = glymur_config() _, OPENJPEG = glymur_config()
PATH_LEN = 4096 # maximum allowed size for filenames PATH_LEN = 4096 # maximum allowed size for filenames
class event_mgr_t(ctypes.Structure):
class EventMgrType(ctypes.Structure):
"""Message handler object. """Message handler object.
Corresponds to event_mgr_t type in openjpeg headers.
""" """
_fields_ = [("error_handler", ctypes.c_void_p), _fields_ = [("error_handler", ctypes.c_void_p),
("warning_handler", ctypes.c_void_p), ("warning_handler", ctypes.c_void_p),
("info_handler", ctypes.c_void_p)] ("info_handler", ctypes.c_void_p)]
class common_struct_t(ctypes.Structure):
class CommonStructType(ctypes.Structure):
"""Common fields between JPEG 2000 compression and decompression contextx. """Common fields between JPEG 2000 compression and decompression contextx.
""" """
_fields_ = [("event_mgr", ctypes.POINTER(event_mgr_t)), _fields_ = [("event_mgr", ctypes.POINTER(EventMgrType)),
("client_data", ctypes.c_void_p), ("client_data", ctypes.c_void_p),
("is_decompressor", ctypes.c_bool), ("is_decompressor", ctypes.c_bool),
("codec_format", ctypes.c_int), ("codec_format", ctypes.c_int),
@ -30,16 +33,20 @@ class common_struct_t(ctypes.Structure):
("mj2_handle", ctypes.c_void_p)] ("mj2_handle", ctypes.c_void_p)]
class dinfo_t(ctypes.Structure): class DecompressionInfoType(ctypes.Structure):
"""Common fields between JPEG 2000 compression and decompression contextx. """This is for decompression contexts.
This is for decompression contexts.
Corresponds to dinfo_t type in openjpeg headers.
""" """
pass pass
class cio_t(ctypes.Structure): class CioType(ctypes.Structure):
_fields_ = [# codec context """Byte input-output stream (CIO)
("cinfo", ctypes.POINTER(common_struct_t)),
Corresponds to cio_t in openjpeg headers.
"""
_fields_ = [("cinfo", ctypes.POINTER(CommonStructType)), # codec context
# STREAM_READ or STREAM_WRITE # STREAM_READ or STREAM_WRITE
("openmode", ctypes.c_int), ("openmode", ctypes.c_int),
# pointer to start of buffer # pointer to start of buffer
@ -54,7 +61,11 @@ class cio_t(ctypes.Structure):
("bp", ctypes.c_char_p)] ("bp", ctypes.c_char_p)]
class dparameters_t(ctypes.Structure): class DecompressionParametersType(ctypes.Structure):
"""Decompression parameters.
Corresponds to dparameters_t type in openjpeg headers.
"""
# cp_reduce: the number of highest resolution levels to be discarded # cp_reduce: the number of highest resolution levels to be discarded
_fields_ = [("cp_reduce", ctypes.c_int), _fields_ = [("cp_reduce", ctypes.c_int),
# cp_layer: the maximum number of quality layers to decode # cp_layer: the maximum number of quality layers to decode
@ -79,8 +90,11 @@ class dparameters_t(ctypes.Structure):
("flags", ctypes.c_uint)] ("flags", ctypes.c_uint)]
class image_comp_t(ctypes.Structure): class ImageCompType(ctypes.Structure):
"""Defines a single image component. """ """Defines a single image component.
Corresponds to image_comp_t type in openjpeg.
"""
_fields_ = [("dx", ctypes.c_int), _fields_ = [("dx", ctypes.c_int),
("dy", ctypes.c_int), ("dy", ctypes.c_int),
("w", ctypes.c_int), ("w", ctypes.c_int),
@ -95,65 +109,79 @@ class image_comp_t(ctypes.Structure):
("data", ctypes.POINTER(ctypes.c_int))] ("data", ctypes.POINTER(ctypes.c_int))]
class image_t(ctypes.Structure): class ImageType(ctypes.Structure):
"""Defines image data and characteristics.""" """Defines image data and characteristics.
Corresponds to image_t type in openjpeg headers.
"""
_fields_ = [("x0", ctypes.c_int), _fields_ = [("x0", ctypes.c_int),
("y0", ctypes.c_int), ("y0", ctypes.c_int),
("x1", ctypes.c_int), ("x1", ctypes.c_int),
("y1", ctypes.c_int), ("y1", ctypes.c_int),
("numcomps", ctypes.c_int), ("numcomps", ctypes.c_int),
("color_space", ctypes.c_int), ("color_space", ctypes.c_int),
("comps", ctypes.POINTER(image_comp_t)), ("comps", ctypes.POINTER(ImageCompType)),
("icc_profile_buf", ctypes.c_char_p), ("icc_profile_buf", ctypes.c_char_p),
("icc_profile_len", ctypes.c_int)] ("icc_profile_len", ctypes.c_int)]
def cio_open(cinfo, src): def cio_open(cinfo, src):
"""Wrapper for openjpeg library function opj_cio_open.""" """Wrapper for openjpeg library function opj_cio_open."""
argtypes = [ctypes.POINTER(common_struct_t), ctypes.c_char_p, ctypes.c_int] argtypes = [ctypes.POINTER(CommonStructType), ctypes.c_char_p,
ctypes.c_int]
OPENJPEG.opj_cio_open.argtypes = argtypes OPENJPEG.opj_cio_open.argtypes = argtypes
OPENJPEG.opj_cio_open.restype = ctypes.POINTER(cio_t) OPENJPEG.opj_cio_open.restype = ctypes.POINTER(CioType)
cio = OPENJPEG.opj_cio_open(ctypes.cast(cinfo, ctypes.POINTER(common_struct_t)), cio = OPENJPEG.opj_cio_open(ctypes.cast(cinfo,
ctypes.POINTER(CommonStructType)),
src, len(src)) src, len(src))
return cio return cio
def cio_close(cio): def cio_close(cio):
"""Wraps openjpeg library function cio_close. """Wraps openjpeg library function cio_close.
""" """
OPENJPEG.opj_cio_close.argtypes = [ctypes.POINTER(cio_t)] OPENJPEG.opj_cio_close.argtypes = [ctypes.POINTER(CioType)]
OPENJPEG.opj_cio_close(cio) OPENJPEG.opj_cio_close(cio)
def create_decompress(fmt): def create_decompress(fmt):
"""Wraps openjpeg library function opj_create_decompress. """Wraps openjpeg library function opj_create_decompress.
""" """
OPENJPEG.opj_create_decompress.argtypes = [ctypes.c_int] OPENJPEG.opj_create_decompress.argtypes = [ctypes.c_int]
OPENJPEG.opj_create_decompress.restype = ctypes.POINTER(dinfo_t) restype = ctypes.POINTER(DecompressionInfoType)
OPENJPEG.opj_create_decompress.restype = restype
dinfo = OPENJPEG.opj_create_decompress(fmt) dinfo = OPENJPEG.opj_create_decompress(fmt)
return dinfo return dinfo
def decode(dinfo, cio): def decode(dinfo, cio):
"""Wrapper for opj_decode. """Wrapper for opj_decode.
""" """
argtypes = [ctypes.POINTER(dinfo_t), ctypes.POINTER(cio_t)] argtypes = [ctypes.POINTER(DecompressionInfoType), ctypes.POINTER(CioType)]
OPENJPEG.opj_decode.argtypes = argtypes OPENJPEG.opj_decode.argtypes = argtypes
OPENJPEG.opj_decode.restype = ctypes.POINTER(image_t) OPENJPEG.opj_decode.restype = ctypes.POINTER(ImageType)
image = OPENJPEG.opj_decode(dinfo, cio) image = OPENJPEG.opj_decode(dinfo, cio)
return image return image
def destroy_decompress(dinfo): def destroy_decompress(dinfo):
"""Wraps openjpeg library function opj_destroy_decompress.""" """Wraps openjpeg library function opj_destroy_decompress."""
OPENJPEG.opj_destroy_decompress.argtypes = [ctypes.POINTER(dinfo_t)] argtypes = [ctypes.POINTER(DecompressionInfoType)]
OPENJPEG.opj_destroy_decompress.argtypes = argtypes
OPENJPEG.opj_destroy_decompress(dinfo) OPENJPEG.opj_destroy_decompress(dinfo)
def image_destroy(image): def image_destroy(image):
"""Wraps openjpeg library function opj_image_destroy.""" """Wraps openjpeg library function opj_image_destroy."""
OPENJPEG.opj_image_destroy.argtypes = [ctypes.POINTER(image_t)] OPENJPEG.opj_image_destroy.argtypes = [ctypes.POINTER(ImageType)]
OPENJPEG.opj_image_destroy(image) OPENJPEG.opj_image_destroy(image)
def set_default_decoder_parameters(dparams_p): def set_default_decoder_parameters(dparams_p):
"""Wrapper for opj_set_default_decoder_parameters. """Wrapper for opj_set_default_decoder_parameters.
""" """
argtypes = [ctypes.POINTER(dparameters_t)] argtypes = [ctypes.POINTER(DecompressionParametersType)]
OPENJPEG.opj_set_default_decoder_parameters.argtypes = argtypes OPENJPEG.opj_set_default_decoder_parameters.argtypes = argtypes
OPENJPEG.opj_set_default_decoder_parameters(dparams_p) OPENJPEG.opj_set_default_decoder_parameters(dparams_p)
@ -161,21 +189,25 @@ def set_default_decoder_parameters(dparams_p):
def set_event_mgr(dinfo, event_mgr, context=None): def set_event_mgr(dinfo, event_mgr, context=None):
"""Wrapper for openjpeg library function opj_set_event_mgr. """Wrapper for openjpeg library function opj_set_event_mgr.
""" """
argtypes = [ctypes.POINTER(common_struct_t), argtypes = [ctypes.POINTER(CommonStructType),
ctypes.POINTER(event_mgr_t), ctypes.POINTER(EventMgrType),
ctypes.c_void_p] ctypes.c_void_p]
OPENJPEG.opj_set_event_mgr.argtypes = argtypes
OPENJPEG.opj_set_event_mgr(ctypes.cast(dinfo, OPENJPEG.opj_set_event_mgr(ctypes.cast(dinfo,
ctypes.POINTER(common_struct_t)), ctypes.POINTER(CommonStructType)),
event_mgr, context) event_mgr, context)
def setup_decoder(dinfo, dparams): def setup_decoder(dinfo, dparams):
"""Wrapper for openjpeg library function opj_setup_decoder.""" """Wrapper for openjpeg library function opj_setup_decoder."""
argtypes = [ctypes.POINTER(dinfo_t), ctypes.POINTER(dparameters_t)] argtypes = [ctypes.POINTER(DecompressionInfoType),
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(): def version():
"""Wrapper for opj_version library routine.""" """Wrapper for opj_version library routine."""
OPENJPEG.opj_version.restype = ctypes.c_char_p OPENJPEG.opj_version.restype = ctypes.c_char_p
v = OPENJPEG.opj_version() library_version = OPENJPEG.opj_version()
return v.decode('utf-8') return library_version.decode('utf-8')

View file

@ -32,7 +32,7 @@ class TestOpenJP2(unittest.TestCase):
self.assertEqual(cparams.subsampling_dx, 1) self.assertEqual(cparams.subsampling_dx, 1)
self.assertEqual(cparams.subsampling_dy, 1) self.assertEqual(cparams.subsampling_dy, 1)
self.assertEqual(cparams.mode, 0) self.assertEqual(cparams.mode, 0)
self.assertEqual(cparams.prog_order, glymur.lib._openjp2.LRCP) self.assertEqual(cparams.prog_order, glymur.core.LRCP)
self.assertEqual(cparams.roi_shift, 0) self.assertEqual(cparams.roi_shift, 0)
self.assertEqual(cparams.cp_tx0, 0) self.assertEqual(cparams.cp_tx0, 0)
self.assertEqual(cparams.cp_ty0, 0) self.assertEqual(cparams.cp_ty0, 0)
@ -164,9 +164,9 @@ class TestOpenJP2(unittest.TestCase):
l_param.numresolution = 6 l_param.numresolution = 6
l_param.prog_order = glymur.lib._openjp2.LRCP l_param.prog_order = glymur.core.LRCP
l_params = (glymur.lib._openjp2.image_comptparm_t * num_comps)() l_params = (glymur.lib._openjp2.ImageComptParmType * num_comps)()
for j in range(num_comps): for j in range(num_comps):
l_params[j].dx = 1 l_params[j].dx = 1
l_params[j].dy = 1 l_params[j].dy = 1

View file

@ -21,7 +21,7 @@ class TestOpenJPEG(unittest.TestCase):
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.
dp = glymur.lib._openjpeg.dparameters_t() 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))
self.assertEqual(dp.cp_reduce, 0) self.assertEqual(dp.cp_reduce, 0)

View file

@ -1569,7 +1569,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[3].spcod[7] & 0x0020) self.assertFalse(c.segment[3].spcod[7] & 0x0020)
self.assertEqual(c.segment[3].spcod[8], self.assertEqual(c.segment[3].spcod[8],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
# SOT: start of tile part # SOT: start of tile part
self.assertEqual(c.segment[4].isot, 0) self.assertEqual(c.segment[4].isot, 0)
@ -1623,7 +1623,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertTrue(c.segment[2].spcod[7] & 0x0020) self.assertTrue(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_9x7_IRREVERSIBLE) glymur.core.WAVELET_XFORM_9X7_IRREVERSIBLE)
# COC: Coding style component # COC: Coding style component
self.assertEqual(c.segment[3].ccoc, 0) self.assertEqual(c.segment[3].ccoc, 0)
@ -1643,7 +1643,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertTrue(c.segment[3].spcoc[3] & 0x0020) self.assertTrue(c.segment[3].spcoc[3] & 0x0020)
self.assertEqual(c.segment[3].spcoc[4], self.assertEqual(c.segment[3].spcoc[4],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
# QCD: Quantization default # QCD: Quantization default
# quantization type # quantization type
@ -1729,7 +1729,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
# QCD: Quantization default # QCD: Quantization default
# quantization type # quantization type
@ -1846,7 +1846,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_9x7_IRREVERSIBLE) glymur.core.WAVELET_XFORM_9X7_IRREVERSIBLE)
self.assertEqual(c.segment[2]._precinct_size, self.assertEqual(c.segment[2]._precinct_size,
[(128, 128), (128, 128), (128, 128), (128, 128), [(128, 128), (128, 128), (128, 128), (128, 128),
(128, 128), (128, 128), (128, 128)]) (128, 128), (128, 128), (128, 128)])
@ -1955,7 +1955,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_9x7_IRREVERSIBLE) glymur.core.WAVELET_XFORM_9X7_IRREVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
# COC: Coding style component # COC: Coding style component
@ -1976,7 +1976,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[3].spcoc[3] & 0x0020) self.assertFalse(c.segment[3].spcoc[3] & 0x0020)
self.assertEqual(c.segment[3].spcoc[4], self.assertEqual(c.segment[3].spcoc[4],
glymur.core.WAVELET_TRANSFORM_9x7_IRREVERSIBLE) glymur.core.WAVELET_XFORM_9X7_IRREVERSIBLE)
# COC: Coding style component # COC: Coding style component
self.assertEqual(c.segment[4].ccoc, 3) self.assertEqual(c.segment[4].ccoc, 3)
@ -1996,7 +1996,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[4].spcoc[3] & 0x0020) self.assertFalse(c.segment[4].spcoc[3] & 0x0020)
self.assertEqual(c.segment[4].spcoc[4], self.assertEqual(c.segment[4].spcoc[4],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
# QCD: Quantization default # QCD: Quantization default
# quantization type # quantization type
@ -2098,7 +2098,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_9x7_IRREVERSIBLE) glymur.core.WAVELET_XFORM_9X7_IRREVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
# QCD: Quantization default # QCD: Quantization default
@ -2167,7 +2167,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[7].spcoc[3] & 0x0020) self.assertFalse(c.segment[7].spcoc[3] & 0x0020)
self.assertEqual(c.segment[7].spcoc[4], self.assertEqual(c.segment[7].spcoc[4],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
# RGN: region of interest # RGN: region of interest
self.assertEqual(c.segment[8].crgn, 0) # component self.assertEqual(c.segment[8].crgn, 0) # component
@ -2235,7 +2235,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
# QCD: Quantization default # QCD: Quantization default
@ -2320,7 +2320,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
# COC: Coding style component # COC: Coding style component
@ -2341,7 +2341,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[3].spcoc[3] & 0x0020) self.assertFalse(c.segment[3].spcoc[3] & 0x0020)
self.assertEqual(c.segment[3].spcoc[4], self.assertEqual(c.segment[3].spcoc[4],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
# COC: Coding style component # COC: Coding style component
self.assertEqual(c.segment[4].ccoc, 1) self.assertEqual(c.segment[4].ccoc, 1)
@ -2361,7 +2361,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[4].spcoc[3] & 0x0020) self.assertFalse(c.segment[4].spcoc[3] & 0x0020)
self.assertEqual(c.segment[4].spcoc[4], self.assertEqual(c.segment[4].spcoc[4],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
# COC: Coding style component # COC: Coding style component
self.assertEqual(c.segment[5].ccoc, 2) self.assertEqual(c.segment[5].ccoc, 2)
@ -2381,7 +2381,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[5].spcoc[3] & 0x0020) self.assertFalse(c.segment[5].spcoc[3] & 0x0020)
self.assertEqual(c.segment[5].spcoc[4], self.assertEqual(c.segment[5].spcoc[4],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
# QCD: Quantization default # QCD: Quantization default
# quantization type # quantization type
@ -2473,7 +2473,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_9x7_IRREVERSIBLE) glymur.core.WAVELET_XFORM_9X7_IRREVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
# QCD: Quantization default # QCD: Quantization default
@ -2553,7 +2553,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
# QCD: Quantization default # QCD: Quantization default
@ -2694,7 +2694,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertTrue(c.segment[2].spcod[7] & 0x0020) self.assertTrue(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
self.assertEqual(c.segment[2]._precinct_size, [(128, 2)]) self.assertEqual(c.segment[2]._precinct_size, [(128, 2)])
# QCD: Quantization default # QCD: Quantization default
@ -2775,7 +2775,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
# QCD: Quantization default # QCD: Quantization default
@ -2856,7 +2856,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
# COC: Coding style component # COC: Coding style component
@ -2876,7 +2876,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[3].spcoc[3] & 0x0020) self.assertFalse(c.segment[3].spcoc[3] & 0x0020)
self.assertEqual(c.segment[3].spcoc[4], self.assertEqual(c.segment[3].spcoc[4],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
# QCD: Quantization default # QCD: Quantization default
# quantization type # quantization type
@ -2982,7 +2982,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
# QCD: Quantization default # QCD: Quantization default
@ -3058,7 +3058,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
# QCD: Quantization default # QCD: Quantization default
@ -3212,7 +3212,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
# QCD: Quantization default # QCD: Quantization default
@ -3280,7 +3280,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertTrue(c.segment[2].spcod[7] & 0x0020) self.assertTrue(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_9x7_IRREVERSIBLE) glymur.core.WAVELET_XFORM_9X7_IRREVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
# COC: Coding style component # COC: Coding style component
@ -3300,7 +3300,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertTrue(c.segment[3].spcoc[3] & 0x0020) self.assertTrue(c.segment[3].spcoc[3] & 0x0020)
self.assertEqual(c.segment[3].spcoc[4], self.assertEqual(c.segment[3].spcoc[4],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
# QCD: Quantization default # QCD: Quantization default
# quantization type # quantization type
@ -3381,7 +3381,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_9x7_IRREVERSIBLE) glymur.core.WAVELET_XFORM_9X7_IRREVERSIBLE)
self.assertEqual(c.segment[2]._precinct_size, self.assertEqual(c.segment[2]._precinct_size,
[(128, 128), (256, 256), (512, 512), (1024, 1024), [(128, 128), (256, 256), (512, 512), (1024, 1024),
(2048, 2048), (4096, 4096), (8192, 8192)]) (2048, 2048), (4096, 4096), (8192, 8192)])
@ -3495,7 +3495,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_9x7_IRREVERSIBLE) glymur.core.WAVELET_XFORM_9X7_IRREVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
# COC: Coding style component # COC: Coding style component
@ -3515,7 +3515,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[3].spcoc[3] & 0x0020) self.assertFalse(c.segment[3].spcoc[3] & 0x0020)
self.assertEqual(c.segment[3].spcoc[4], self.assertEqual(c.segment[3].spcoc[4],
glymur.core.WAVELET_TRANSFORM_9x7_IRREVERSIBLE) glymur.core.WAVELET_XFORM_9X7_IRREVERSIBLE)
# COC: Coding style component # COC: Coding style component
self.assertEqual(c.segment[4].ccoc, 3) self.assertEqual(c.segment[4].ccoc, 3)
@ -3534,7 +3534,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[4].spcoc[3] & 0x0020) self.assertFalse(c.segment[4].spcoc[3] & 0x0020)
self.assertEqual(c.segment[4].spcoc[4], self.assertEqual(c.segment[4].spcoc[4],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
# QCD: Quantization default # QCD: Quantization default
# quantization type # quantization type
@ -3641,7 +3641,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_9x7_IRREVERSIBLE) glymur.core.WAVELET_XFORM_9X7_IRREVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
# QCD: Quantization default # QCD: Quantization default
@ -3768,7 +3768,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_9x7_IRREVERSIBLE) glymur.core.WAVELET_XFORM_9X7_IRREVERSIBLE)
self.assertEqual(c.segment[2]._precinct_size, [(16, 16)] * 8) self.assertEqual(c.segment[2]._precinct_size, [(16, 16)] * 8)
self.assertEqual(c.segment[3].sqcd & 0x1f, 2) # expounded self.assertEqual(c.segment[3].sqcd & 0x1f, 2) # expounded
@ -3856,7 +3856,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertTrue(c.segment[2].spcod[7] & 0x0020) self.assertTrue(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_9x7_IRREVERSIBLE) glymur.core.WAVELET_XFORM_9X7_IRREVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
# QCD: Quantization default # QCD: Quantization default
@ -3949,7 +3949,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
self.assertEqual(c.segment[2]._precinct_size, [(1, 1), (2, 2)]) self.assertEqual(c.segment[2]._precinct_size, [(1, 1), (2, 2)])
# COC: Coding style component # COC: Coding style component
@ -3969,7 +3969,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[3].spcoc[3] & 0x0020) self.assertFalse(c.segment[3].spcoc[3] & 0x0020)
self.assertEqual(c.segment[3].spcoc[4], self.assertEqual(c.segment[3].spcoc[4],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
self.assertEqual(c.segment[3]._precinct_size, [(2, 2), (4, 4)]) self.assertEqual(c.segment[3]._precinct_size, [(2, 2), (4, 4)])
# QCD: Quantization default # QCD: Quantization default
@ -4489,7 +4489,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_9x7_IRREVERSIBLE) glymur.core.WAVELET_XFORM_9X7_IRREVERSIBLE)
self.assertEqual(c.segment[2]._precinct_size[0], (128, 128)) self.assertEqual(c.segment[2]._precinct_size[0], (128, 128))
self.assertEqual(c.segment[2]._precinct_size[1:], [(256, 256)] * 5) self.assertEqual(c.segment[2]._precinct_size[1:], [(256, 256)] * 5)
@ -4521,7 +4521,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[4].spcoc[3] & 0x0020) self.assertFalse(c.segment[4].spcoc[3] & 0x0020)
self.assertEqual(c.segment[4].spcoc[4], self.assertEqual(c.segment[4].spcoc[4],
glymur.core.WAVELET_TRANSFORM_9x7_IRREVERSIBLE) glymur.core.WAVELET_XFORM_9X7_IRREVERSIBLE)
# QCC: Quantization component # QCC: Quantization component
# associated component # associated component
@ -4553,7 +4553,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[6].spcoc[3] & 0x0020) self.assertFalse(c.segment[6].spcoc[3] & 0x0020)
self.assertEqual(c.segment[6].spcoc[4], self.assertEqual(c.segment[6].spcoc[4],
glymur.core.WAVELET_TRANSFORM_9x7_IRREVERSIBLE) glymur.core.WAVELET_XFORM_9X7_IRREVERSIBLE)
# QCC: Quantization component # QCC: Quantization component
# associated component # associated component
@ -4641,7 +4641,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
self.assertEqual(c.segment[2]._precinct_size, self.assertEqual(c.segment[2]._precinct_size,
[(16, 16), (32, 32), (64, 64), (128, 128), [(16, 16), (32, 32), (64, 64), (128, 128),
(128, 128), (128, 128)]) (128, 128), (128, 128)])
@ -4698,7 +4698,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_9x7_IRREVERSIBLE) glymur.core.WAVELET_XFORM_9X7_IRREVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
ids = [x.marker_id for x in c.segment] ids = [x.marker_id for x in c.segment]
@ -4751,7 +4751,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
ids = [x.marker_id for x in c.segment] ids = [x.marker_id for x in c.segment]
@ -4813,7 +4813,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
# QCD: Quantization default # QCD: Quantization default
@ -4875,7 +4875,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_9x7_IRREVERSIBLE) glymur.core.WAVELET_XFORM_9X7_IRREVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
# QCD: Quantization default # QCD: Quantization default
@ -4946,7 +4946,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
# QCD: Quantization default # QCD: Quantization default
@ -5023,7 +5023,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
# QCD: Quantization default # QCD: Quantization default
@ -5083,7 +5083,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
# QCD: Quantization default # QCD: Quantization default
@ -5149,7 +5149,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
# QCD: Quantization default # QCD: Quantization default
@ -5234,7 +5234,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
# QCD: Quantization default # QCD: Quantization default
@ -5294,7 +5294,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
# QCD: Quantization default # QCD: Quantization default
@ -5352,7 +5352,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
# QCD: Quantization default # QCD: Quantization default
@ -5410,7 +5410,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
# QCD: Quantization default # QCD: Quantization default
@ -5471,7 +5471,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
# QCD: Quantization default # QCD: Quantization default
@ -5532,7 +5532,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
# QCD: Quantization default # QCD: Quantization default
@ -5592,7 +5592,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
# QCD: Quantization default # QCD: Quantization default
@ -5662,7 +5662,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
# QCD: Quantization default # QCD: Quantization default
@ -5732,7 +5732,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
# QCD: Quantization default # QCD: Quantization default
@ -5794,7 +5794,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
# QCD: Quantization default # QCD: Quantization default
@ -5857,7 +5857,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_9x7_IRREVERSIBLE) glymur.core.WAVELET_XFORM_9X7_IRREVERSIBLE)
self.assertEqual(c.segment[2]._precinct_size, self.assertEqual(c.segment[2]._precinct_size,
[(128, 128)] + [(256, 256)] * 5) [(128, 128)] + [(256, 256)] * 5)
@ -5973,7 +5973,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[3].spcod[7] & 0x0020) self.assertFalse(c.segment[3].spcod[7] & 0x0020)
self.assertEqual(c.segment[3].spcod[8], self.assertEqual(c.segment[3].spcod[8],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
self.assertEqual(len(c.segment[3].spcod), 9) self.assertEqual(len(c.segment[3].spcod), 9)
# QCD: Quantization default # QCD: Quantization default
@ -6107,7 +6107,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[3].spcod[7] & 0x0020) self.assertFalse(c.segment[3].spcod[7] & 0x0020)
self.assertEqual(c.segment[3].spcod[8], self.assertEqual(c.segment[3].spcod[8],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
self.assertEqual(len(c.segment[3].spcod), 9) self.assertEqual(len(c.segment[3].spcod), 9)
# QCD: Quantization default # QCD: Quantization default
@ -6229,7 +6229,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_9x7_IRREVERSIBLE) glymur.core.WAVELET_XFORM_9X7_IRREVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
# QCD: Quantization default # QCD: Quantization default
@ -6383,7 +6383,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
# QCD: Quantization default # QCD: Quantization default
@ -6484,7 +6484,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_9x7_IRREVERSIBLE) glymur.core.WAVELET_XFORM_9X7_IRREVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
# QCD: Quantization default # QCD: Quantization default
@ -6583,7 +6583,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_9x7_IRREVERSIBLE) glymur.core.WAVELET_XFORM_9X7_IRREVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
# QCD: Quantization default # QCD: Quantization default
@ -6687,7 +6687,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_9x7_IRREVERSIBLE) glymur.core.WAVELET_XFORM_9X7_IRREVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
# QCD: Quantization default # QCD: Quantization default
@ -6815,7 +6815,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
# QCD: Quantization default # QCD: Quantization default
@ -6930,7 +6930,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
# QCD: Quantization default # QCD: Quantization default
@ -7025,7 +7025,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
# QCD: Quantization default # QCD: Quantization default
@ -7133,7 +7133,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
# QCD: Quantization default # QCD: Quantization default
@ -7233,7 +7233,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
# QCD: Quantization default # QCD: Quantization default
@ -7342,7 +7342,7 @@ class TestSuiteDump(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
# QCD: Quantization default # QCD: Quantization default

View file

@ -125,7 +125,7 @@ class TestSuiteWrite(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
def test_NR_ENC_Bretagne1_ppm_2_encode(self): def test_NR_ENC_Bretagne1_ppm_2_encode(self):
@ -183,7 +183,7 @@ class TestSuiteWrite(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
def test_NR_ENC_Bretagne1_ppm_3_encode(self): def test_NR_ENC_Bretagne1_ppm_3_encode(self):
@ -242,7 +242,7 @@ class TestSuiteWrite(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
self.assertEqual(c.segment[2]._precinct_size, self.assertEqual(c.segment[2]._precinct_size,
[(2, 2), (4, 4), (8, 8), (16, 16), (32, 32), [(2, 2), (4, 4), (8, 8), (16, 16), (32, 32),
(64, 64)]) (64, 64)])
@ -305,7 +305,7 @@ class TestSuiteWrite(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
self.assertEqual(c.segment[2]._precinct_size, self.assertEqual(c.segment[2]._precinct_size,
[(16, 16), (32, 32), (64, 64)] + [(128, 128)] * 3) [(16, 16), (32, 32), (64, 64)] + [(128, 128)] * 3)
@ -363,7 +363,7 @@ class TestSuiteWrite(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
def test_NR_ENC_Bretagne2_ppm_6_encode(self): def test_NR_ENC_Bretagne2_ppm_6_encode(self):
@ -420,7 +420,7 @@ class TestSuiteWrite(unittest.TestCase):
# Segmentation symbols # Segmentation symbols
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
# 18 SOP segments. # 18 SOP segments.
@ -480,7 +480,7 @@ class TestSuiteWrite(unittest.TestCase):
# Segmentation symbols, SEGMARK(SEGSYSM) # Segmentation symbols, SEGMARK(SEGSYSM)
self.assertTrue(c.segment[2].spcod[7] & 0x0020) self.assertTrue(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
# 18 EPH segments. # 18 EPH segments.
@ -541,7 +541,7 @@ class TestSuiteWrite(unittest.TestCase):
# Segmentation symbols, SEGMARK(SEGSYSM) # Segmentation symbols, SEGMARK(SEGSYSM)
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
def test_NR_ENC_Cevennes1_bmp_9_encode(self): def test_NR_ENC_Cevennes1_bmp_9_encode(self):
@ -597,7 +597,7 @@ class TestSuiteWrite(unittest.TestCase):
# Segmentation symbols, SEGMARK(SEGSYSM) # Segmentation symbols, SEGMARK(SEGSYSM)
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
def test_NR_ENC_Cevennes2_ppm_10_encode(self): def test_NR_ENC_Cevennes2_ppm_10_encode(self):
@ -653,7 +653,7 @@ class TestSuiteWrite(unittest.TestCase):
# Segmentation symbols, SEGMARK(SEGSYSM) # Segmentation symbols, SEGMARK(SEGSYSM)
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
def test_NR_ENC_Rome_bmp_11_encode(self): def test_NR_ENC_Rome_bmp_11_encode(self):
@ -744,7 +744,7 @@ class TestSuiteWrite(unittest.TestCase):
# Segmentation symbols, SEGMARK(SEGSYSM) # Segmentation symbols, SEGMARK(SEGSYSM)
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
@unittest.skip("Known failure in openjpeg test suite.") @unittest.skip("Known failure in openjpeg test suite.")
@ -804,7 +804,7 @@ class TestSuiteWrite(unittest.TestCase):
# Segmentation symbols, SEGMARK(SEGSYSM) # Segmentation symbols, SEGMARK(SEGSYSM)
self.assertFalse(c.segment[2].spcod[7] & 0x0020) self.assertFalse(c.segment[2].spcod[7] & 0x0020)
self.assertEqual(c.segment[2].spcod[8], self.assertEqual(c.segment[2].spcod[8],
glymur.core.WAVELET_TRANSFORM_5x3_REVERSIBLE) glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
self.assertEqual(len(c.segment[2].spcod), 9) self.assertEqual(len(c.segment[2].spcod), 9)
if __name__ == "__main__": if __name__ == "__main__":