Checking for bad wavelet transform while parsing. #195
Being more intelligent about printing in such cases.
This commit is contained in:
parent
d6cd57896f
commit
161833ee5c
3 changed files with 28 additions and 3 deletions
|
|
@ -52,9 +52,9 @@ _PROGRESSION_ORDER_DISPLAY = _keydefaultdict(_factory,
|
|||
PCRL: 'PCRL',
|
||||
CPRL: 'CPRL'})
|
||||
|
||||
_WAVELET_TRANSFORM_DISPLAY = {
|
||||
WAVELET_XFORM_9X7_IRREVERSIBLE: '9-7 irreversible',
|
||||
WAVELET_XFORM_5X3_REVERSIBLE: '5-3 reversible'}
|
||||
_WAVELET_TRANSFORM_DISPLAY = _keydefaultdict(_factory,
|
||||
{ WAVELET_XFORM_9X7_IRREVERSIBLE: '9-7 irreversible',
|
||||
WAVELET_XFORM_5X3_REVERSIBLE: '5-3 reversible'})
|
||||
|
||||
# Need a catch-all list of valid markers.
|
||||
# See table A-1 in ISO/IEC FCD15444-1.
|
||||
|
|
@ -390,6 +390,11 @@ class Codestream(object):
|
|||
msg = "Invalid progression order in COD segment: {0}."
|
||||
warnings.warn(msg.format(spcod[0]))
|
||||
|
||||
if spcod[8] not in [WAVELET_XFORM_9X7_IRREVERSIBLE,
|
||||
WAVELET_XFORM_5X3_REVERSIBLE]:
|
||||
msg = "Invalid wavelet transform in COD segment: {0}."
|
||||
warnings.warn(msg.format(spcod[8]))
|
||||
|
||||
sop = (scod & 2) > 0
|
||||
eph = (scod & 4) > 0
|
||||
|
||||
|
|
|
|||
|
|
@ -51,6 +51,17 @@ class TestCodestreamOpjData(unittest.TestCase):
|
|||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def test_bad_wavelet_transform(self):
|
||||
"""Should warn if wavelet transform is bad. Issue129"""
|
||||
filename = opj_data_file('input/nonregression/edf_c2_10025.jp2')
|
||||
if sys.hexversion < 0x03000000:
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter("ignore")
|
||||
j = Jp2k(filename)
|
||||
else:
|
||||
with self.assertWarns(UserWarning):
|
||||
j = Jp2k(filename)
|
||||
|
||||
def test_invalid_progression_order(self):
|
||||
"""Should still be able to parse even if prog order is invalid."""
|
||||
jfile = opj_data_file('input/nonregression/2977.pdf.asan.67.2198.jp2')
|
||||
|
|
|
|||
|
|
@ -653,6 +653,15 @@ class TestPrintingOpjDataRoot(unittest.TestCase):
|
|||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def test_bad_wavelet_transform(self):
|
||||
"""Should still be able to print if wavelet xform is bad, issue195"""
|
||||
filename = opj_data_file('input/nonregression/edf_c2_10025.jp2')
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter("ignore")
|
||||
j = Jp2k(filename)
|
||||
with patch('sys.stdout', new=StringIO()) as fake_out:
|
||||
print(j)
|
||||
|
||||
def test_invalid_progression_order(self):
|
||||
"""Should still be able to print even if prog order is invalid."""
|
||||
jfile = opj_data_file('input/nonregression/2977.pdf.asan.67.2198.jp2')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue