diff --git a/glymur/test/test_opj_suite.py b/glymur/test/test_opj_suite.py index 3bbcfda..4519024 100644 --- a/glymur/test/test_opj_suite.py +++ b/glymur/test/test_opj_suite.py @@ -41,9 +41,6 @@ from .fixtures import WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG from .fixtures import mse, peak_tolerance, read_pgx, opj_data_file -@unittest.skipIf(glymur.lib.openjp2.OPENJP2 is None and - glymur.lib.openjpeg.OPENJPEG is None, - "Missing openjpeg libraries.") @unittest.skipIf(OPJ_DATA_ROOT is None, "OPJ_DATA_ROOT environment variable not set") class TestSuite(unittest.TestCase): @@ -203,7 +200,115 @@ class TestSuite(unittest.TestCase): self.assertTrue(peak_tolerance(jpdata, pgxdata) < 624) self.assertTrue(mse(jpdata, pgxdata) < 3080) - @unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG) + def test_NR_DEC_Bretagne2_j2k_1_decode(self): + jfile = opj_data_file('input/nonregression/Bretagne2.j2k') + jp2 = Jp2k(jfile) + jp2.read() + self.assertTrue(True) + + def test_NR_DEC__00042_j2k_2_decode(self): + jfile = opj_data_file('input/nonregression/_00042.j2k') + jp2 = Jp2k(jfile) + jp2.read() + self.assertTrue(True) + + def test_NR_DEC_buxI_j2k_9_decode(self): + jfile = opj_data_file('input/nonregression/buxI.j2k') + Jp2k(jfile).read() + self.assertTrue(True) + + def test_NR_DEC_buxR_j2k_10_decode(self): + jfile = opj_data_file('input/nonregression/buxR.j2k') + Jp2k(jfile).read() + self.assertTrue(True) + + def test_NR_DEC_Cannotreaddatawithnosizeknown_j2k_11_decode(self): + relpath = 'input/nonregression/Cannotreaddatawithnosizeknown.j2k' + jfile = opj_data_file(relpath) + Jp2k(jfile).read() + self.assertTrue(True) + + def test_NR_DEC_cthead1_j2k_12_decode(self): + jfile = opj_data_file('input/nonregression/cthead1.j2k') + Jp2k(jfile).read() + self.assertTrue(True) + + def test_NR_DEC_CT_Phillips_JPEG2K_Decompr_Problem_j2k_13_decode(self): + relpath = 'input/nonregression/CT_Phillips_JPEG2K_Decompr_Problem.j2k' + jfile = opj_data_file(relpath) + Jp2k(jfile).read() + self.assertTrue(True) + + def test_NR_DEC_j2k32_j2k_15_decode(self): + jfile = opj_data_file('input/nonregression/j2k32.j2k') + Jp2k(jfile).read() + self.assertTrue(True) + + def test_NR_DEC_MarkerIsNotCompliant_j2k_17_decode(self): + jfile = opj_data_file('input/nonregression/MarkerIsNotCompliant.j2k') + Jp2k(jfile).read() + self.assertTrue(True) + + def test_NR_DEC_Marrin_jp2_18_decode(self): + jfile = opj_data_file('input/nonregression/Marrin.jp2') + Jp2k(jfile).read() + self.assertTrue(True) + + def test_NR_DEC_movie_00000_j2k_20_decode(self): + jfile = opj_data_file('input/nonregression/movie_00000.j2k') + Jp2k(jfile).read() + self.assertTrue(True) + + def test_NR_DEC_movie_00001_j2k_21_decode(self): + jfile = opj_data_file('input/nonregression/movie_00001.j2k') + Jp2k(jfile).read() + self.assertTrue(True) + + def test_NR_DEC_movie_00002_j2k_22_decode(self): + jfile = opj_data_file('input/nonregression/movie_00002.j2k') + Jp2k(jfile).read() + self.assertTrue(True) + + def test_NR_DEC_orb_blue_lin_j2k_j2k_23_decode(self): + jfile = opj_data_file('input/nonregression/orb-blue10-lin-j2k.j2k') + Jp2k(jfile).read() + self.assertTrue(True) + + def test_NR_DEC_orb_blue_win_j2k_j2k_24_decode(self): + jfile = opj_data_file('input/nonregression/orb-blue10-win-j2k.j2k') + Jp2k(jfile).read() + self.assertTrue(True) + + def test_NR_DEC_relax_jp2_27_decode(self): + jfile = opj_data_file('input/nonregression/relax.jp2') + Jp2k(jfile).read() + self.assertTrue(True) + + def test_NR_DEC_test_lossless_j2k_28_decode(self): + jfile = opj_data_file('input/nonregression/test_lossless.j2k') + Jp2k(jfile).read() + self.assertTrue(True) + + def test_NR_DEC_pacs_ge_j2k_30_decode(self): + jfile = opj_data_file('input/nonregression/pacs.ge.j2k') + Jp2k(jfile).read() + self.assertTrue(True) + + +@unittest.skipIf(OPJ_DATA_ROOT is None, + "OPJ_DATA_ROOT environment variable not set") +@unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG) +class TestSuiteWarns(unittest.TestCase): + """ + Identical setup to above, but these tests issue warnings. + """ + + def setUp(self): + pass + + def tearDown(self): + pass + def test_ETS_JP2_file1(self): jfile = opj_data_file('input/conformance/file1.jp2') with self.assertWarns(UserWarning): @@ -212,7 +317,6 @@ class TestSuite(unittest.TestCase): jpdata = jp2k.read() self.assertEqual(jpdata.shape, (512, 768, 3)) - @unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG) def test_ETS_JP2_file2(self): jfile = opj_data_file('input/conformance/file2.jp2') with self.assertWarns(UserWarning): @@ -220,7 +324,6 @@ class TestSuite(unittest.TestCase): jpdata = jp2k.read() self.assertEqual(jpdata.shape, (640, 480, 3)) - @unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG) @unittest.skipIf(glymur.version.openjpeg_version_tuple[0] < 2, "Functionality not implemented for 1.x") def test_ETS_JP2_file3(self): @@ -232,7 +335,6 @@ class TestSuite(unittest.TestCase): self.assertEqual(jpdata[1].shape, (320, 240)) self.assertEqual(jpdata[2].shape, (320, 240)) - @unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG) def test_ETS_JP2_file4(self): jfile = opj_data_file('input/conformance/file4.jp2') with self.assertWarns(UserWarning): @@ -240,7 +342,6 @@ class TestSuite(unittest.TestCase): jpdata = jp2k.read() self.assertEqual(jpdata.shape, (512, 768)) - @unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG) def test_ETS_JP2_file5(self): jfile = opj_data_file('input/conformance/file5.jp2') with self.assertWarns(UserWarning): @@ -250,7 +351,6 @@ class TestSuite(unittest.TestCase): jpdata = jp2k.read() self.assertEqual(jpdata.shape, (512, 768, 3)) - @unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG) def test_ETS_JP2_file6(self): jfile = opj_data_file('input/conformance/file6.jp2') with self.assertWarns(UserWarning): @@ -258,7 +358,6 @@ class TestSuite(unittest.TestCase): jpdata = jp2k.read() self.assertEqual(jpdata.shape, (512, 768)) - @unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG) def test_ETS_JP2_file7(self): jfile = opj_data_file('input/conformance/file7.jp2') with self.assertWarns(UserWarning): @@ -266,7 +365,6 @@ class TestSuite(unittest.TestCase): jpdata = jp2k.read() self.assertEqual(jpdata.shape, (640, 480, 3)) - @unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG) def test_ETS_JP2_file8(self): jfile = opj_data_file('input/conformance/file8.jp2') with self.assertWarns(UserWarning): @@ -274,7 +372,6 @@ class TestSuite(unittest.TestCase): jpdata = jp2k.read() self.assertEqual(jpdata.shape, (400, 700)) - @unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG) def test_ETS_JP2_file9(self): jfile = opj_data_file('input/conformance/file9.jp2') with self.assertWarns(UserWarning): @@ -282,7 +379,6 @@ class TestSuite(unittest.TestCase): jpdata = jp2k.read() self.assertEqual(jpdata.shape, (512, 768, 3)) - @unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG) def test_NR_broken_jp2_dump(self): jfile = opj_data_file('input/nonregression/broken.jp2') @@ -408,86 +504,6 @@ class TestSuite(unittest.TestCase): self.assertEqual(c.segment[6].exponent, [8] + [9, 9, 10] * 5) - def test_NR_DEC_Bretagne2_j2k_1_decode(self): - jfile = opj_data_file('input/nonregression/Bretagne2.j2k') - jp2 = Jp2k(jfile) - jp2.read() - self.assertTrue(True) - - def test_NR_DEC__00042_j2k_2_decode(self): - jfile = opj_data_file('input/nonregression/_00042.j2k') - jp2 = Jp2k(jfile) - jp2.read() - self.assertTrue(True) - - def test_NR_DEC_buxI_j2k_9_decode(self): - jfile = opj_data_file('input/nonregression/buxI.j2k') - Jp2k(jfile).read() - self.assertTrue(True) - - def test_NR_DEC_buxR_j2k_10_decode(self): - jfile = opj_data_file('input/nonregression/buxR.j2k') - Jp2k(jfile).read() - self.assertTrue(True) - - def test_NR_DEC_Cannotreaddatawithnosizeknown_j2k_11_decode(self): - relpath = 'input/nonregression/Cannotreaddatawithnosizeknown.j2k' - jfile = opj_data_file(relpath) - Jp2k(jfile).read() - self.assertTrue(True) - - def test_NR_DEC_cthead1_j2k_12_decode(self): - jfile = opj_data_file('input/nonregression/cthead1.j2k') - Jp2k(jfile).read() - self.assertTrue(True) - - def test_NR_DEC_CT_Phillips_JPEG2K_Decompr_Problem_j2k_13_decode(self): - relpath = 'input/nonregression/CT_Phillips_JPEG2K_Decompr_Problem.j2k' - jfile = opj_data_file(relpath) - Jp2k(jfile).read() - self.assertTrue(True) - - def test_NR_DEC_j2k32_j2k_15_decode(self): - jfile = opj_data_file('input/nonregression/j2k32.j2k') - Jp2k(jfile).read() - self.assertTrue(True) - - def test_NR_DEC_MarkerIsNotCompliant_j2k_17_decode(self): - jfile = opj_data_file('input/nonregression/MarkerIsNotCompliant.j2k') - Jp2k(jfile).read() - self.assertTrue(True) - - def test_NR_DEC_Marrin_jp2_18_decode(self): - jfile = opj_data_file('input/nonregression/Marrin.jp2') - Jp2k(jfile).read() - self.assertTrue(True) - - def test_NR_DEC_movie_00000_j2k_20_decode(self): - jfile = opj_data_file('input/nonregression/movie_00000.j2k') - Jp2k(jfile).read() - self.assertTrue(True) - - def test_NR_DEC_movie_00001_j2k_21_decode(self): - jfile = opj_data_file('input/nonregression/movie_00001.j2k') - Jp2k(jfile).read() - self.assertTrue(True) - - def test_NR_DEC_movie_00002_j2k_22_decode(self): - jfile = opj_data_file('input/nonregression/movie_00002.j2k') - Jp2k(jfile).read() - self.assertTrue(True) - - def test_NR_DEC_orb_blue_lin_j2k_j2k_23_decode(self): - jfile = opj_data_file('input/nonregression/orb-blue10-lin-j2k.j2k') - Jp2k(jfile).read() - self.assertTrue(True) - - def test_NR_DEC_orb_blue_win_j2k_j2k_24_decode(self): - jfile = opj_data_file('input/nonregression/orb-blue10-win-j2k.j2k') - Jp2k(jfile).read() - self.assertTrue(True) - - @unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG) def test_NR_DEC_orb_blue_lin_jp2_25_decode(self): jfile = opj_data_file('input/nonregression/orb-blue10-lin-jp2.jp2') with self.assertWarns(UserWarning): @@ -495,38 +511,20 @@ class TestSuite(unittest.TestCase): Jp2k(jfile).read() self.assertTrue(True) - @unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG) def test_NR_DEC_orb_blue_win_jp2_26_decode(self): jfile = opj_data_file('input/nonregression/orb-blue10-win-jp2.jp2') with self.assertWarns(UserWarning): Jp2k(jfile).read() self.assertTrue(True) - def test_NR_DEC_relax_jp2_27_decode(self): - jfile = opj_data_file('input/nonregression/relax.jp2') - Jp2k(jfile).read() - self.assertTrue(True) - - def test_NR_DEC_test_lossless_j2k_28_decode(self): - jfile = opj_data_file('input/nonregression/test_lossless.j2k') - Jp2k(jfile).read() - self.assertTrue(True) - - def test_NR_DEC_pacs_ge_j2k_30_decode(self): - jfile = opj_data_file('input/nonregression/pacs.ge.j2k') - Jp2k(jfile).read() - self.assertTrue(True) - @unittest.skipIf(OPJ_DATA_ROOT is None, "OPJ_DATA_ROOT environment variable not set") @unittest.skipIf(glymur.version.openjpeg_version_tuple[0] == 1, "Feature not supported in glymur until openjpeg 2.0") -class TestSuite_bands(unittest.TestCase): - """Runs tests introduced in version 1.x but only pass in glymur with 2.0 - - The deal here is that the feature works with 1.x, but glymur only supports - it with version 2.0. +class TestSuiteBands(unittest.TestCase): + """ + Test the read_bands method. """ def setUp(self): diff --git a/glymur/test/test_opj_suite_dump.py b/glymur/test/test_opj_suite_dump.py index 6c3253e..d99226b 100644 --- a/glymur/test/test_opj_suite_dump.py +++ b/glymur/test/test_opj_suite_dump.py @@ -103,141 +103,6 @@ class TestSuite(unittest.TestCase): self.assertIsNone(actual.icc_profile) - @unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG) - @unittest.skipIf(re.match("1.5|2.0.0", glymur.version.openjpeg_version), - "Test not passing on 1.5, 2.0: not introduced until 2.x") - def test_NR_DEC_issue188_beach_64bitsbox_jp2_41_decode(self): - """ - Has an 'XML ' box instead of 'xml '. Just verify we can read it. - """ - relpath = 'input/nonregression/issue188_beach_64bitsbox.jp2' - jfile = opj_data_file(relpath) - with self.assertWarns(UserWarning): - j = Jp2k(jfile) - d = j.read() - self.assertTrue(True) - - - @unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG) - def test_NR_broken4_jp2_dump(self): - jfile = opj_data_file('input/nonregression/broken4.jp2') - with self.assertWarns(UserWarning): - jp2 = Jp2k(jfile) - - self.assertEqual(jp2.box[-1].main_header.segment[-1].marker_id, 'QCC') - - @unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG) - @unittest.skipIf(sys.maxsize < 2**32, 'Do not run on 32-bit platforms') - def test_NR_broken3_jp2_dump(self): - """ - NR_broken3_jp2_dump - - The file in question here has a colr box with an erroneous box - length of over 1GB. Don't run it on 32-bit platforms. - """ - jfile = opj_data_file('input/nonregression/broken3.jp2') - with self.assertWarns(UserWarning): - # Bad box length. - jp2 = Jp2k(jfile) - - ids = [box.box_id for box in jp2.box] - self.assertEqual(ids, ['jP ', 'ftyp', 'jp2h', 'jp2c']) - - ids = [box.box_id for box in jp2.box[2].box] - self.assertEqual(ids, ['ihdr', 'colr']) - - self.verifySignatureBox(jp2.box[0]) - self.verifyFileTypeBox(jp2.box[1], 'jp2 ', ['jp2 ']) - - ihdr = glymur.jp2box.ImageHeaderBox(152, 203, num_components=3) - self.verifyImageHeaderBox(jp2.box[2].box[0], ihdr) - - colr = glymur.jp2box.ColourSpecificationBox(colorspace=glymur.core.SRGB) - self.verifyColourSpecificationBox(jp2.box[2].box[1], colr) - - c = jp2.box[3].main_header - - ids = [x.marker_id for x in c.segment] - expected = ['SOC', 'SIZ', 'CME', 'COD', 'QCD', 'QCC', 'QCC'] - self.assertEqual(ids, expected) - - kwargs = {'rsiz': 0, 'xysiz': (203, 152), 'xyosiz': (0, 0), - 'xytsiz': (203, 152), 'xytosiz': (0, 0), 'bitdepth': (8, 8, 8), - 'signed': (False, False, False), - 'xyrsiz': [(1, 1, 1), (1, 1, 1)]} - self.verifySizSegment(c.segment[1], glymur.codestream.SIZsegment(**kwargs)) - - # COM: comment - # Registration - self.assertEqual(c.segment[2].rcme, glymur.core.RCME_ISO_8859_1) - # Comment value - self.assertEqual(c.segment[2].ccme.decode('latin-1'), - "Creator: JasPer Vers)on 1.701.0") - - # COD: Coding style default - self.assertFalse(c.segment[3].scod & 2) # no sop - self.assertFalse(c.segment[3].scod & 4) # no eph - self.assertEqual(c.segment[3].spcod[0], glymur.core.LRCP) - self.assertEqual(c.segment[3].layers, 1) # layers = 1 - self.assertEqual(c.segment[3].spcod[3], 1) # mct - self.assertEqual(c.segment[3].spcod[4], 5) # level - self.assertEqual(tuple(c.segment[3].code_block_size), - (64, 64)) # cblk - # Selective arithmetic coding bypass - self.assertFalse(c.segment[3].spcod[7] & 0x01) - # Reset context probabilities - self.assertFalse(c.segment[3].spcod[7] & 0x02) - # Termination on each coding pass - self.assertFalse(c.segment[3].spcod[7] & 0x04) - # Vertically causal context - self.assertFalse(c.segment[3].spcod[7] & 0x08) - # Predictable termination - self.assertFalse(c.segment[3].spcod[7] & 0x0010) - # Segmentation symbols - self.assertFalse(c.segment[3].spcod[7] & 0x0020) - self.assertEqual(c.segment[3].spcod[8], - glymur.core.WAVELET_XFORM_5X3_REVERSIBLE) - self.assertEqual(len(c.segment[3].spcod), 9) - - # QCD: Quantization default - self.assertEqual(c.segment[4].sqcd & 0x1f, 0) - self.assertEqual(c.segment[4].guard_bits, 2) - self.assertEqual(c.segment[4].mantissa, [0] * 16) - self.assertEqual(c.segment[4].exponent, - [8] + [9, 9, 10] * 5) - - # QCC: Quantization component - # associated component - self.assertEqual(c.segment[5].cqcc, 1) - self.assertEqual(c.segment[5].guard_bits, 2) - # quantization type - self.assertEqual(c.segment[5].sqcc & 0x1f, 0) # none - self.assertEqual(c.segment[5].mantissa, [0] * 16) - self.assertEqual(c.segment[5].exponent, - [8] + [9, 9, 10] * 5) - - # QCC: Quantization component - # associated component - self.assertEqual(c.segment[6].cqcc, 2) - self.assertEqual(c.segment[6].guard_bits, 2) - # quantization type - self.assertEqual(c.segment[6].sqcc & 0x1f, 0) # none - self.assertEqual(c.segment[6].mantissa, [0] * 16) - self.assertEqual(c.segment[6].exponent, - [8] + [9, 9, 10] * 5) - - @unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG) - def test_NR_broken2_jp2_dump(self): - """ - Invalid marker ID in the codestream. - """ - jfile = opj_data_file('input/nonregression/broken2.jp2') - with self.assertWarns(UserWarning): - # Invalid marker ID on codestream. - jp2 = Jp2k(jfile) - - self.assertEqual(jp2.box[-1].main_header.segment[-1].marker_id, 'QCC') - def test_NR_file409752(self): jfile = opj_data_file('input/nonregression/file409752.jp2') jp2 = Jp2k(jfile) @@ -2464,307 +2329,6 @@ class TestSuite(unittest.TestCase): # EOC: end of codestream self.assertEqual(c.segment[-1].marker_id, 'EOC') - @unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG) - def test_NR_file1_dump(self): - jfile = opj_data_file('input/conformance/file1.jp2') - with self.assertWarns(UserWarning): - # Bad compatibility list item. - jp2 = Jp2k(jfile) - - ids = [box.box_id for box in jp2.box] - self.assertEqual(ids, ['jP ', 'ftyp', 'xml ', 'jp2h', 'xml ', - 'jp2c']) - - ids = [box.box_id for box in jp2.box[3].box] - self.assertEqual(ids, ['ihdr', 'colr']) - - self.verifySignatureBox(jp2.box[0]) - self.verifyFileTypeBox(jp2.box[1], 'jp2 ', ['jp2 ']) - - # XML box - tags = [x.tag for x in jp2.box[2].xml.getroot()] - self.assertEqual(tags, - ['{http://www.jpeg.org/jpx/1.0/xml}' - + 'GENERAL_CREATION_INFO']) - - ihdr = glymur.jp2box.ImageHeaderBox(512, 768, num_components=3) - self.verifyImageHeaderBox(jp2.box[3].box[0], ihdr) - - colr = glymur.jp2box.ColourSpecificationBox(colorspace=glymur.core.SRGB, - approximation=1) - self.verifyColourSpecificationBox(jp2.box[3].box[1], colr) - - # XML box - tags = [x.tag for x in jp2.box[4].xml.getroot()] - self.assertEqual(tags, ['{http://www.jpeg.org/jpx/1.0/xml}CAPTION', - '{http://www.jpeg.org/jpx/1.0/xml}LOCATION', - '{http://www.jpeg.org/jpx/1.0/xml}EVENT']) - - @unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG) - def test_NR_file2_dump(self): - jfile = opj_data_file('input/conformance/file2.jp2') - with self.assertWarns(UserWarning): - jp2 = Jp2k(jfile) - - ids = [box.box_id for box in jp2.box] - self.assertEqual(ids, ['jP ', 'ftyp', 'jp2h', 'jp2c']) - - ids = [box.box_id for box in jp2.box[2].box] - self.assertEqual(ids, ['ihdr', 'colr', 'cdef']) - - self.verifySignatureBox(jp2.box[0]) - self.verifyFileTypeBox(jp2.box[1], 'jp2 ', ['jp2 ']) - - ihdr = glymur.jp2box.ImageHeaderBox(640, 480, num_components=3) - self.verifyImageHeaderBox(jp2.box[2].box[0], ihdr) - - colr = glymur.jp2box.ColourSpecificationBox(colorspace=glymur.core.YCC, - approximation=1) - self.verifyColourSpecificationBox(jp2.box[2].box[1], colr) - - # Jp2 Header - # Channel Definition - self.assertEqual(jp2.box[2].box[2].index, (0, 1, 2)) - self.assertEqual(jp2.box[2].box[2].channel_type, (0, 0, 0)) # color - self.assertEqual(jp2.box[2].box[2].association, (3, 2, 1)) # reverse - - @unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG) - def test_NR_file3_dump(self): - # Three 8-bit components in the sRGB-YCC colourspace, with the Cb and - # Cr components being subsampled 2x in both the horizontal and - # vertical directions. The components are stored in the standard - # order. - jfile = opj_data_file('input/conformance/file3.jp2') - with self.assertWarns(UserWarning): - jp2 = Jp2k(jfile) - - ids = [box.box_id for box in jp2.box] - self.assertEqual(ids, ['jP ', 'ftyp', 'jp2h', 'jp2c']) - - ids = [box.box_id for box in jp2.box[2].box] - self.assertEqual(ids, ['ihdr', 'colr']) - - self.verifySignatureBox(jp2.box[0]) - self.verifyFileTypeBox(jp2.box[1], 'jp2 ', ['jp2 ']) - - ihdr = glymur.jp2box.ImageHeaderBox(640, 480, num_components=3) - self.verifyImageHeaderBox(jp2.box[2].box[0], ihdr) - - colr = glymur.jp2box.ColourSpecificationBox( - colorspace=glymur.core.YCC, - approximation=1) - self.verifyColourSpecificationBox(jp2.box[2].box[1], colr) - - # sub-sampling - codestream = jp2.get_codestream() - self.assertEqual(codestream.segment[1].xrsiz[0], 1) - self.assertEqual(codestream.segment[1].yrsiz[0], 1) - self.assertEqual(codestream.segment[1].xrsiz[1], 2) - self.assertEqual(codestream.segment[1].yrsiz[1], 2) - self.assertEqual(codestream.segment[1].xrsiz[2], 2) - self.assertEqual(codestream.segment[1].yrsiz[2], 2) - - @unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG) - def test_NR_file4_dump(self): - # One 8-bit component in the sRGB-grey colourspace. - jfile = opj_data_file('input/conformance/file4.jp2') - with self.assertWarns(UserWarning): - jp2 = Jp2k(jfile) - - ids = [box.box_id for box in jp2.box] - self.assertEqual(ids, ['jP ', 'ftyp', 'jp2h', 'jp2c']) - - ids = [box.box_id for box in jp2.box[2].box] - self.assertEqual(ids, ['ihdr', 'colr']) - - self.verifySignatureBox(jp2.box[0]) - self.verifyFileTypeBox(jp2.box[1], 'jp2 ', ['jp2 ']) - - ihdr = glymur.jp2box.ImageHeaderBox(512, 768) - self.verifyImageHeaderBox(jp2.box[2].box[0], ihdr) - - colr = glymur.jp2box.ColourSpecificationBox( - colorspace=glymur.core.GREYSCALE, approximation=1) - self.verifyColourSpecificationBox(jp2.box[2].box[1], colr) - - @unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG) - def test_NR_file5_dump(self): - # Three 8-bit components in the ROMM-RGB colourspace, encapsulated in a - # JPX file. The components have been transformed using - # the RCT. The colourspace is specified using both a Restricted ICC - # profile and using the JPX-defined enumerated code for the ROMM-RGB - # colourspace. - jfile = opj_data_file('input/conformance/file5.jp2') - with self.assertWarns(UserWarning): - # There's a warning for an unknown compatibility entry. - # Ignore it here. - jp2 = Jp2k(jfile) - - ids = [box.box_id for box in jp2.box] - self.assertEqual(ids, ['jP ', 'ftyp', 'rreq', 'jp2h', 'jp2c']) - - ids = [box.box_id for box in jp2.box[3].box] - self.assertEqual(ids, ['ihdr', 'colr', 'colr']) - - self.verifySignatureBox(jp2.box[0]) - self.verifyFileTypeBox(jp2.box[1], 'jpx ', ['jp2 ', 'jpx ', 'jpxb']) - - ihdr = glymur.jp2box.ImageHeaderBox(512, 768, num_components=3) - self.verifyImageHeaderBox(jp2.box[3].box[0], ihdr) - - colr = glymur.jp2box.ColourSpecificationBox( - method=glymur.core.RESTRICTED_ICC_PROFILE, - approximation=1, icc_profile=bytes([0] * 546)) - self.verifyColourSpecificationBox(jp2.box[3].box[1], colr) - self.assertEqual(jp2.box[3].box[1].icc_profile['Size'], 546) - - @unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG) - def test_NR_file6_dump(self): - jfile = opj_data_file('input/conformance/file6.jp2') - with self.assertWarns(UserWarning): - jp2 = Jp2k(jfile) - - ids = [box.box_id for box in jp2.box] - self.assertEqual(ids, ['jP ', 'ftyp', 'jp2h', 'jp2c']) - - ids = [box.box_id for box in jp2.box[2].box] - self.assertEqual(ids, ['ihdr', 'colr']) - - self.verifySignatureBox(jp2.box[0]) - self.verifyFileTypeBox(jp2.box[1], 'jp2 ', ['jp2 ']) - - ihdr = glymur.jp2box.ImageHeaderBox(512, 768, bits_per_component=12) - self.verifyImageHeaderBox(jp2.box[2].box[0], ihdr) - - colr = glymur.jp2box.ColourSpecificationBox( - colorspace=glymur.core.GREYSCALE, - method=glymur.core.ENUMERATED_COLORSPACE, - approximation=1) - self.verifyColourSpecificationBox(jp2.box[2].box[1], colr) - - @unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG) - def test_NR_file7_dump(self): - # Three 16-bit components in the e-sRGB colourspace, encapsulated in a - # JP2 compatible JPX file. The components have been transformed using - # the RCT. The colourspace is specified using both a Restricted ICC - # profile and using the JPX-defined enumerated code for the e-sRGB - # colourspace. - jfile = opj_data_file('input/conformance/file7.jp2') - with self.assertWarns(UserWarning): - jp2 = Jp2k(jfile) - - ids = [box.box_id for box in jp2.box] - self.assertEqual(ids, ['jP ', 'ftyp', 'rreq', 'jp2h', 'jp2c']) - - ids = [box.box_id for box in jp2.box[3].box] - self.assertEqual(ids, ['ihdr', 'colr', 'colr']) - - self.verifySignatureBox(jp2.box[0]) - - # File type box. - self.assertEqual(jp2.box[1].brand, 'jpx ') - self.assertEqual(jp2.box[1].compatibility_list[1], 'jp2 ') - - ihdr = glymur.jp2box.ImageHeaderBox(640, 480, - num_components=3, bits_per_component=16) - self.verifyImageHeaderBox(jp2.box[3].box[0], ihdr) - - colr = glymur.jp2box.ColourSpecificationBox( - method=glymur.core.RESTRICTED_ICC_PROFILE, - approximation=1) - self.verifyColourSpecificationBox(jp2.box[3].box[1], colr) - self.assertEqual(jp2.box[3].box[1].icc_profile['Size'], 13332) - - @unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG) - def test_NR_file8_dump(self): - # One 8-bit component in a gamma 1.8 space. The colourspace is - # specified using a Restricted ICC profile. - jfile = opj_data_file('input/conformance/file8.jp2') - with self.assertWarns(UserWarning): - jp2 = Jp2k(jfile) - - ids = [box.box_id for box in jp2.box] - self.assertEqual(ids, ['jP ', 'ftyp', 'jp2h', 'xml ', 'jp2c', - 'xml ']) - - ids = [box.box_id for box in jp2.box[2].box] - self.assertEqual(ids, ['ihdr', 'colr']) - - self.verifySignatureBox(jp2.box[0]) - - # File type box. - self.assertEqual(jp2.box[1].brand, 'jp2 ') - self.assertEqual(jp2.box[1].compatibility_list[1], 'jp2 ') - self.assertEqual(jp2.box[1].minor_version, 0) - - ihdr = glymur.jp2box.ImageHeaderBox(400, 700) - self.verifyImageHeaderBox(jp2.box[2].box[0], ihdr) - - colr = glymur.jp2box.ColourSpecificationBox( - method=glymur.core.RESTRICTED_ICC_PROFILE, - approximation=1) - self.verifyColourSpecificationBox(jp2.box[2].box[1], colr) - self.assertEqual(jp2.box[2].box[1].icc_profile['Size'], 414) - - # XML box - tags = [x.tag for x in jp2.box[3].xml.getroot()] - self.assertEqual(tags, - ['{http://www.jpeg.org/jpx/1.0/xml}' - + 'GENERAL_CREATION_INFO']) - - # XML box - tags = [x.tag for x in jp2.box[5].xml.getroot()] - self.assertEqual(tags, - ['{http://www.jpeg.org/jpx/1.0/xml}CAPTION', - '{http://www.jpeg.org/jpx/1.0/xml}LOCATION', - '{http://www.jpeg.org/jpx/1.0/xml}THING', - '{http://www.jpeg.org/jpx/1.0/xml}EVENT']) - - @unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG) - def test_NR_file9_dump(self): - # Colormap - jfile = opj_data_file('input/conformance/file9.jp2') - with self.assertWarns(UserWarning): - jp2 = Jp2k(jfile) - - ids = [box.box_id for box in jp2.box] - self.assertEqual(ids, ['jP ', 'ftyp', 'jp2h', 'jp2c']) - - ids = [box.box_id for box in jp2.box[2].box] - self.assertEqual(ids, ['ihdr', 'pclr', 'cmap', 'colr']) - - self.verifySignatureBox(jp2.box[0]) - - # File type box. - self.assertEqual(jp2.box[1].brand, 'jp2 ') - self.assertEqual(jp2.box[1].compatibility_list[1], 'jp2 ') - self.assertEqual(jp2.box[1].minor_version, 0) - - ihdr = glymur.jp2box.ImageHeaderBox(512, 768) - self.verifyImageHeaderBox(jp2.box[2].box[0], ihdr) - - # Palette box. - self.assertEqual(jp2.box[2].box[1].palette.shape, (256, 3)) - np.testing.assert_array_equal(jp2.box[2].box[1].palette[0, 0], 0) - np.testing.assert_array_equal(jp2.box[2].box[1].palette[0, 1], 0) - np.testing.assert_array_equal(jp2.box[2].box[1].palette[0, 2], 0) - np.testing.assert_array_equal(jp2.box[2].box[1].palette[128, 0], 73) - np.testing.assert_array_equal(jp2.box[2].box[1].palette[128, 1], 92) - np.testing.assert_array_equal(jp2.box[2].box[1].palette[128, 2], 53) - np.testing.assert_array_equal(jp2.box[2].box[1].palette[255, 0], 245) - np.testing.assert_array_equal(jp2.box[2].box[1].palette[255, 1], 245) - np.testing.assert_array_equal(jp2.box[2].box[1].palette[255, 2], 245) - - # Component mapping box - self.assertEqual(jp2.box[2].box[2].component_index, (0, 0, 0)) - self.assertEqual(jp2.box[2].box[2].mapping_type, (1, 1, 1)) - self.assertEqual(jp2.box[2].box[2].palette_index, (0, 1, 2)) - - colr = glymur.jp2box.ColourSpecificationBox( - colorspace=glymur.core.SRGB, - approximation=1) - self.verifyColourSpecificationBox(jp2.box[2].box[3], colr) - def test_NR_00042_j2k_dump(self): # Profile 3. jfile = opj_data_file('input/nonregression/_00042.j2k') @@ -3965,77 +3529,6 @@ class TestSuite(unittest.TestCase): self.assertEqual(c.segment[3].mantissa, [0] * 16) self.assertEqual(c.segment[3].exponent, [8] + [9, 9, 10] * 5) - @unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG) - def test_NR_issue188_beach_64bitsbox(self): - lst = ['input', 'nonregression', 'issue188_beach_64bitsbox.jp2'] - jfile = opj_data_file('/'.join(lst)) - with self.assertWarns(UserWarning): - # There's a warning for an unknown box. - jp2 = Jp2k(jfile) - - ids = [box.box_id for box in jp2.box] - self.assertEqual(ids, ['jP ', 'ftyp', 'jp2h', b'XML ', 'jp2c']) - - ids = [box.box_id for box in jp2.box[2].box] - self.assertEqual(ids, ['ihdr', 'colr']) - - self.verifySignatureBox(jp2.box[0]) - - # File type box. - self.assertEqual(jp2.box[1].brand, 'jp2 ') - self.assertEqual(jp2.box[1].minor_version, 0) - self.assertEqual(jp2.box[1].compatibility_list[0], 'jp2 ') - - ihdr = glymur.jp2box.ImageHeaderBox(200, 200, - num_components=3, colorspace_unknown=True) - self.verifyImageHeaderBox(jp2.box[2].box[0], ihdr) - - colr = glymur.jp2box.ColourSpecificationBox(colorspace=glymur.core.SRGB) - self.verifyColourSpecificationBox(jp2.box[2].box[1], colr) - - # Skip the 4th box, it is uknown. - - c = jp2.box[4].main_header - - ids = [x.marker_id for x in c.segment] - expected = ['SOC', 'SIZ', 'COD', 'QCD', 'CME', 'CME'] - self.assertEqual(ids, expected) - - kwargs = {'rsiz': 0, 'xysiz': (200, 200), 'xyosiz': (0, 0), - 'xytsiz': (200, 200), 'xytosiz': (0, 0), 'bitdepth': (8, 8, 8), - 'signed': (False, False, False), - 'xyrsiz': [(1, 1, 1), (1, 1, 1)]} - self.verifySizSegment(c.segment[1], glymur.codestream.SIZsegment(**kwargs)) - - # COD: Coding style default - self.assertFalse(c.segment[2].scod & 2) # no sop - self.assertFalse(c.segment[2].scod & 4) # no eph - self.assertEqual(c.segment[2].spcod[0], glymur.core.LRCP) - self.assertEqual(c.segment[2].layers, 1) # layers = 1 - self.assertEqual(c.segment[2].spcod[3], 1) # mct - self.assertEqual(c.segment[2].spcod[4], 5) # level - self.assertEqual(tuple(c.segment[2].code_block_size), - (64, 64)) # cblk - # Selective arithmetic coding bypass - self.assertFalse(c.segment[2].spcod[7] & 0x01) - # Reset context probabilities - self.assertFalse(c.segment[2].spcod[7] & 0x02) - # Termination on each coding pass - self.assertFalse(c.segment[2].spcod[7] & 0x04) - # Vertically causal context - self.assertFalse(c.segment[2].spcod[7] & 0x08) - # Predictable termination - self.assertFalse(c.segment[2].spcod[7] & 0x0010) - # Segmentation symbols - self.assertFalse(c.segment[2].spcod[7] & 0x0020) - self.assertEqual(c.segment[2].spcod[8], - glymur.core.WAVELET_XFORM_9X7_IRREVERSIBLE) - self.assertEqual(len(c.segment[2].spcod), 9) - - # QCD: Quantization default - self.assertEqual(c.segment[3].sqcd & 0x1f, 2) - self.assertEqual(c.segment[3].guard_bits, 1) - def test_NR_issue206_image_000_dump(self): jfile = opj_data_file('input/nonregression/issue206_image-000.jp2') jp2 = Jp2k(jfile) @@ -4361,7 +3854,505 @@ class TestSuite(unittest.TestCase): podvals = (glymur.core.LRCP, glymur.core.LRCP) self.assertEqual(c.segment[4].ppod, podvals) - @unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG) + +@unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG) +@unittest.skipIf(OPJ_DATA_ROOT is None, + "OPJ_DATA_ROOT environment variable not set") +class TestSuiteWarns(unittest.TestCase): + + @unittest.skipIf(re.match("1.5|2.0.0", glymur.version.openjpeg_version), + "Test not passing on 1.5, 2.0: not introduced until 2.x") + def test_NR_DEC_issue188_beach_64bitsbox_jp2_41_decode(self): + """ + Has an 'XML ' box instead of 'xml '. Just verify we can read it. + """ + relpath = 'input/nonregression/issue188_beach_64bitsbox.jp2' + jfile = opj_data_file(relpath) + with self.assertWarns(UserWarning): + j = Jp2k(jfile) + d = j.read() + self.assertTrue(True) + + + def test_NR_broken4_jp2_dump(self): + jfile = opj_data_file('input/nonregression/broken4.jp2') + with self.assertWarns(UserWarning): + jp2 = Jp2k(jfile) + + self.assertEqual(jp2.box[-1].main_header.segment[-1].marker_id, 'QCC') + + @unittest.skipIf(sys.maxsize < 2**32, 'Do not run on 32-bit platforms') + def test_NR_broken3_jp2_dump(self): + """ + NR_broken3_jp2_dump + + The file in question here has a colr box with an erroneous box + length of over 1GB. Don't run it on 32-bit platforms. + """ + jfile = opj_data_file('input/nonregression/broken3.jp2') + with self.assertWarns(UserWarning): + # Bad box length. + jp2 = Jp2k(jfile) + + ids = [box.box_id for box in jp2.box] + self.assertEqual(ids, ['jP ', 'ftyp', 'jp2h', 'jp2c']) + + ids = [box.box_id for box in jp2.box[2].box] + self.assertEqual(ids, ['ihdr', 'colr']) + + self.verifySignatureBox(jp2.box[0]) + self.verifyFileTypeBox(jp2.box[1], 'jp2 ', ['jp2 ']) + + ihdr = glymur.jp2box.ImageHeaderBox(152, 203, num_components=3) + self.verifyImageHeaderBox(jp2.box[2].box[0], ihdr) + + colr = glymur.jp2box.ColourSpecificationBox(colorspace=glymur.core.SRGB) + self.verifyColourSpecificationBox(jp2.box[2].box[1], colr) + + c = jp2.box[3].main_header + + ids = [x.marker_id for x in c.segment] + expected = ['SOC', 'SIZ', 'CME', 'COD', 'QCD', 'QCC', 'QCC'] + self.assertEqual(ids, expected) + + kwargs = {'rsiz': 0, 'xysiz': (203, 152), 'xyosiz': (0, 0), + 'xytsiz': (203, 152), 'xytosiz': (0, 0), 'bitdepth': (8, 8, 8), + 'signed': (False, False, False), + 'xyrsiz': [(1, 1, 1), (1, 1, 1)]} + self.verifySizSegment(c.segment[1], glymur.codestream.SIZsegment(**kwargs)) + + # COM: comment + # Registration + self.assertEqual(c.segment[2].rcme, glymur.core.RCME_ISO_8859_1) + # Comment value + self.assertEqual(c.segment[2].ccme.decode('latin-1'), + "Creator: JasPer Vers)on 1.701.0") + + # COD: Coding style default + self.assertFalse(c.segment[3].scod & 2) # no sop + self.assertFalse(c.segment[3].scod & 4) # no eph + self.assertEqual(c.segment[3].spcod[0], glymur.core.LRCP) + self.assertEqual(c.segment[3].layers, 1) # layers = 1 + self.assertEqual(c.segment[3].spcod[3], 1) # mct + self.assertEqual(c.segment[3].spcod[4], 5) # level + self.assertEqual(tuple(c.segment[3].code_block_size), + (64, 64)) # cblk + # Selective arithmetic coding bypass + self.assertFalse(c.segment[3].spcod[7] & 0x01) + # Reset context probabilities + self.assertFalse(c.segment[3].spcod[7] & 0x02) + # Termination on each coding pass + self.assertFalse(c.segment[3].spcod[7] & 0x04) + # Vertically causal context + self.assertFalse(c.segment[3].spcod[7] & 0x08) + # Predictable termination + self.assertFalse(c.segment[3].spcod[7] & 0x0010) + # Segmentation symbols + self.assertFalse(c.segment[3].spcod[7] & 0x0020) + self.assertEqual(c.segment[3].spcod[8], + glymur.core.WAVELET_XFORM_5X3_REVERSIBLE) + self.assertEqual(len(c.segment[3].spcod), 9) + + # QCD: Quantization default + self.assertEqual(c.segment[4].sqcd & 0x1f, 0) + self.assertEqual(c.segment[4].guard_bits, 2) + self.assertEqual(c.segment[4].mantissa, [0] * 16) + self.assertEqual(c.segment[4].exponent, + [8] + [9, 9, 10] * 5) + + # QCC: Quantization component + # associated component + self.assertEqual(c.segment[5].cqcc, 1) + self.assertEqual(c.segment[5].guard_bits, 2) + # quantization type + self.assertEqual(c.segment[5].sqcc & 0x1f, 0) # none + self.assertEqual(c.segment[5].mantissa, [0] * 16) + self.assertEqual(c.segment[5].exponent, + [8] + [9, 9, 10] * 5) + + # QCC: Quantization component + # associated component + self.assertEqual(c.segment[6].cqcc, 2) + self.assertEqual(c.segment[6].guard_bits, 2) + # quantization type + self.assertEqual(c.segment[6].sqcc & 0x1f, 0) # none + self.assertEqual(c.segment[6].mantissa, [0] * 16) + self.assertEqual(c.segment[6].exponent, + [8] + [9, 9, 10] * 5) + + def test_NR_broken2_jp2_dump(self): + """ + Invalid marker ID in the codestream. + """ + jfile = opj_data_file('input/nonregression/broken2.jp2') + with self.assertWarns(UserWarning): + # Invalid marker ID on codestream. + jp2 = Jp2k(jfile) + + self.assertEqual(jp2.box[-1].main_header.segment[-1].marker_id, 'QCC') + + def test_NR_file1_dump(self): + jfile = opj_data_file('input/conformance/file1.jp2') + with self.assertWarns(UserWarning): + # Bad compatibility list item. + jp2 = Jp2k(jfile) + + ids = [box.box_id for box in jp2.box] + self.assertEqual(ids, ['jP ', 'ftyp', 'xml ', 'jp2h', 'xml ', + 'jp2c']) + + ids = [box.box_id for box in jp2.box[3].box] + self.assertEqual(ids, ['ihdr', 'colr']) + + self.verifySignatureBox(jp2.box[0]) + self.verifyFileTypeBox(jp2.box[1], 'jp2 ', ['jp2 ']) + + # XML box + tags = [x.tag for x in jp2.box[2].xml.getroot()] + self.assertEqual(tags, + ['{http://www.jpeg.org/jpx/1.0/xml}' + + 'GENERAL_CREATION_INFO']) + + ihdr = glymur.jp2box.ImageHeaderBox(512, 768, num_components=3) + self.verifyImageHeaderBox(jp2.box[3].box[0], ihdr) + + colr = glymur.jp2box.ColourSpecificationBox(colorspace=glymur.core.SRGB, + approximation=1) + self.verifyColourSpecificationBox(jp2.box[3].box[1], colr) + + # XML box + tags = [x.tag for x in jp2.box[4].xml.getroot()] + self.assertEqual(tags, ['{http://www.jpeg.org/jpx/1.0/xml}CAPTION', + '{http://www.jpeg.org/jpx/1.0/xml}LOCATION', + '{http://www.jpeg.org/jpx/1.0/xml}EVENT']) + + def test_NR_file2_dump(self): + jfile = opj_data_file('input/conformance/file2.jp2') + with self.assertWarns(UserWarning): + jp2 = Jp2k(jfile) + + ids = [box.box_id for box in jp2.box] + self.assertEqual(ids, ['jP ', 'ftyp', 'jp2h', 'jp2c']) + + ids = [box.box_id for box in jp2.box[2].box] + self.assertEqual(ids, ['ihdr', 'colr', 'cdef']) + + self.verifySignatureBox(jp2.box[0]) + self.verifyFileTypeBox(jp2.box[1], 'jp2 ', ['jp2 ']) + + ihdr = glymur.jp2box.ImageHeaderBox(640, 480, num_components=3) + self.verifyImageHeaderBox(jp2.box[2].box[0], ihdr) + + colr = glymur.jp2box.ColourSpecificationBox(colorspace=glymur.core.YCC, + approximation=1) + self.verifyColourSpecificationBox(jp2.box[2].box[1], colr) + + # Jp2 Header + # Channel Definition + self.assertEqual(jp2.box[2].box[2].index, (0, 1, 2)) + self.assertEqual(jp2.box[2].box[2].channel_type, (0, 0, 0)) # color + self.assertEqual(jp2.box[2].box[2].association, (3, 2, 1)) # reverse + + def test_NR_file3_dump(self): + # Three 8-bit components in the sRGB-YCC colourspace, with the Cb and + # Cr components being subsampled 2x in both the horizontal and + # vertical directions. The components are stored in the standard + # order. + jfile = opj_data_file('input/conformance/file3.jp2') + with self.assertWarns(UserWarning): + jp2 = Jp2k(jfile) + + ids = [box.box_id for box in jp2.box] + self.assertEqual(ids, ['jP ', 'ftyp', 'jp2h', 'jp2c']) + + ids = [box.box_id for box in jp2.box[2].box] + self.assertEqual(ids, ['ihdr', 'colr']) + + self.verifySignatureBox(jp2.box[0]) + self.verifyFileTypeBox(jp2.box[1], 'jp2 ', ['jp2 ']) + + ihdr = glymur.jp2box.ImageHeaderBox(640, 480, num_components=3) + self.verifyImageHeaderBox(jp2.box[2].box[0], ihdr) + + colr = glymur.jp2box.ColourSpecificationBox( + colorspace=glymur.core.YCC, + approximation=1) + self.verifyColourSpecificationBox(jp2.box[2].box[1], colr) + + # sub-sampling + codestream = jp2.get_codestream() + self.assertEqual(codestream.segment[1].xrsiz[0], 1) + self.assertEqual(codestream.segment[1].yrsiz[0], 1) + self.assertEqual(codestream.segment[1].xrsiz[1], 2) + self.assertEqual(codestream.segment[1].yrsiz[1], 2) + self.assertEqual(codestream.segment[1].xrsiz[2], 2) + self.assertEqual(codestream.segment[1].yrsiz[2], 2) + + def test_NR_file4_dump(self): + # One 8-bit component in the sRGB-grey colourspace. + jfile = opj_data_file('input/conformance/file4.jp2') + with self.assertWarns(UserWarning): + jp2 = Jp2k(jfile) + + ids = [box.box_id for box in jp2.box] + self.assertEqual(ids, ['jP ', 'ftyp', 'jp2h', 'jp2c']) + + ids = [box.box_id for box in jp2.box[2].box] + self.assertEqual(ids, ['ihdr', 'colr']) + + self.verifySignatureBox(jp2.box[0]) + self.verifyFileTypeBox(jp2.box[1], 'jp2 ', ['jp2 ']) + + ihdr = glymur.jp2box.ImageHeaderBox(512, 768) + self.verifyImageHeaderBox(jp2.box[2].box[0], ihdr) + + colr = glymur.jp2box.ColourSpecificationBox( + colorspace=glymur.core.GREYSCALE, approximation=1) + self.verifyColourSpecificationBox(jp2.box[2].box[1], colr) + + def test_NR_file5_dump(self): + # Three 8-bit components in the ROMM-RGB colourspace, encapsulated in a + # JPX file. The components have been transformed using + # the RCT. The colourspace is specified using both a Restricted ICC + # profile and using the JPX-defined enumerated code for the ROMM-RGB + # colourspace. + jfile = opj_data_file('input/conformance/file5.jp2') + with self.assertWarns(UserWarning): + # There's a warning for an unknown compatibility entry. + # Ignore it here. + jp2 = Jp2k(jfile) + + ids = [box.box_id for box in jp2.box] + self.assertEqual(ids, ['jP ', 'ftyp', 'rreq', 'jp2h', 'jp2c']) + + ids = [box.box_id for box in jp2.box[3].box] + self.assertEqual(ids, ['ihdr', 'colr', 'colr']) + + self.verifySignatureBox(jp2.box[0]) + self.verifyFileTypeBox(jp2.box[1], 'jpx ', ['jp2 ', 'jpx ', 'jpxb']) + + ihdr = glymur.jp2box.ImageHeaderBox(512, 768, num_components=3) + self.verifyImageHeaderBox(jp2.box[3].box[0], ihdr) + + colr = glymur.jp2box.ColourSpecificationBox( + method=glymur.core.RESTRICTED_ICC_PROFILE, + approximation=1, icc_profile=bytes([0] * 546)) + self.verifyColourSpecificationBox(jp2.box[3].box[1], colr) + self.assertEqual(jp2.box[3].box[1].icc_profile['Size'], 546) + + def test_NR_file6_dump(self): + jfile = opj_data_file('input/conformance/file6.jp2') + with self.assertWarns(UserWarning): + jp2 = Jp2k(jfile) + + ids = [box.box_id for box in jp2.box] + self.assertEqual(ids, ['jP ', 'ftyp', 'jp2h', 'jp2c']) + + ids = [box.box_id for box in jp2.box[2].box] + self.assertEqual(ids, ['ihdr', 'colr']) + + self.verifySignatureBox(jp2.box[0]) + self.verifyFileTypeBox(jp2.box[1], 'jp2 ', ['jp2 ']) + + ihdr = glymur.jp2box.ImageHeaderBox(512, 768, bits_per_component=12) + self.verifyImageHeaderBox(jp2.box[2].box[0], ihdr) + + colr = glymur.jp2box.ColourSpecificationBox( + colorspace=glymur.core.GREYSCALE, + method=glymur.core.ENUMERATED_COLORSPACE, + approximation=1) + self.verifyColourSpecificationBox(jp2.box[2].box[1], colr) + + def test_NR_file7_dump(self): + # Three 16-bit components in the e-sRGB colourspace, encapsulated in a + # JP2 compatible JPX file. The components have been transformed using + # the RCT. The colourspace is specified using both a Restricted ICC + # profile and using the JPX-defined enumerated code for the e-sRGB + # colourspace. + jfile = opj_data_file('input/conformance/file7.jp2') + with self.assertWarns(UserWarning): + jp2 = Jp2k(jfile) + + ids = [box.box_id for box in jp2.box] + self.assertEqual(ids, ['jP ', 'ftyp', 'rreq', 'jp2h', 'jp2c']) + + ids = [box.box_id for box in jp2.box[3].box] + self.assertEqual(ids, ['ihdr', 'colr', 'colr']) + + self.verifySignatureBox(jp2.box[0]) + + # File type box. + self.assertEqual(jp2.box[1].brand, 'jpx ') + self.assertEqual(jp2.box[1].compatibility_list[1], 'jp2 ') + + ihdr = glymur.jp2box.ImageHeaderBox(640, 480, + num_components=3, bits_per_component=16) + self.verifyImageHeaderBox(jp2.box[3].box[0], ihdr) + + colr = glymur.jp2box.ColourSpecificationBox( + method=glymur.core.RESTRICTED_ICC_PROFILE, + approximation=1) + self.verifyColourSpecificationBox(jp2.box[3].box[1], colr) + self.assertEqual(jp2.box[3].box[1].icc_profile['Size'], 13332) + + def test_NR_file8_dump(self): + # One 8-bit component in a gamma 1.8 space. The colourspace is + # specified using a Restricted ICC profile. + jfile = opj_data_file('input/conformance/file8.jp2') + with self.assertWarns(UserWarning): + jp2 = Jp2k(jfile) + + ids = [box.box_id for box in jp2.box] + self.assertEqual(ids, ['jP ', 'ftyp', 'jp2h', 'xml ', 'jp2c', + 'xml ']) + + ids = [box.box_id for box in jp2.box[2].box] + self.assertEqual(ids, ['ihdr', 'colr']) + + self.verifySignatureBox(jp2.box[0]) + + # File type box. + self.assertEqual(jp2.box[1].brand, 'jp2 ') + self.assertEqual(jp2.box[1].compatibility_list[1], 'jp2 ') + self.assertEqual(jp2.box[1].minor_version, 0) + + ihdr = glymur.jp2box.ImageHeaderBox(400, 700) + self.verifyImageHeaderBox(jp2.box[2].box[0], ihdr) + + colr = glymur.jp2box.ColourSpecificationBox( + method=glymur.core.RESTRICTED_ICC_PROFILE, + approximation=1) + self.verifyColourSpecificationBox(jp2.box[2].box[1], colr) + self.assertEqual(jp2.box[2].box[1].icc_profile['Size'], 414) + + # XML box + tags = [x.tag for x in jp2.box[3].xml.getroot()] + self.assertEqual(tags, + ['{http://www.jpeg.org/jpx/1.0/xml}' + + 'GENERAL_CREATION_INFO']) + + # XML box + tags = [x.tag for x in jp2.box[5].xml.getroot()] + self.assertEqual(tags, + ['{http://www.jpeg.org/jpx/1.0/xml}CAPTION', + '{http://www.jpeg.org/jpx/1.0/xml}LOCATION', + '{http://www.jpeg.org/jpx/1.0/xml}THING', + '{http://www.jpeg.org/jpx/1.0/xml}EVENT']) + + def test_NR_file9_dump(self): + # Colormap + jfile = opj_data_file('input/conformance/file9.jp2') + with self.assertWarns(UserWarning): + jp2 = Jp2k(jfile) + + ids = [box.box_id for box in jp2.box] + self.assertEqual(ids, ['jP ', 'ftyp', 'jp2h', 'jp2c']) + + ids = [box.box_id for box in jp2.box[2].box] + self.assertEqual(ids, ['ihdr', 'pclr', 'cmap', 'colr']) + + self.verifySignatureBox(jp2.box[0]) + + # File type box. + self.assertEqual(jp2.box[1].brand, 'jp2 ') + self.assertEqual(jp2.box[1].compatibility_list[1], 'jp2 ') + self.assertEqual(jp2.box[1].minor_version, 0) + + ihdr = glymur.jp2box.ImageHeaderBox(512, 768) + self.verifyImageHeaderBox(jp2.box[2].box[0], ihdr) + + # Palette box. + self.assertEqual(jp2.box[2].box[1].palette.shape, (256, 3)) + np.testing.assert_array_equal(jp2.box[2].box[1].palette[0, 0], 0) + np.testing.assert_array_equal(jp2.box[2].box[1].palette[0, 1], 0) + np.testing.assert_array_equal(jp2.box[2].box[1].palette[0, 2], 0) + np.testing.assert_array_equal(jp2.box[2].box[1].palette[128, 0], 73) + np.testing.assert_array_equal(jp2.box[2].box[1].palette[128, 1], 92) + np.testing.assert_array_equal(jp2.box[2].box[1].palette[128, 2], 53) + np.testing.assert_array_equal(jp2.box[2].box[1].palette[255, 0], 245) + np.testing.assert_array_equal(jp2.box[2].box[1].palette[255, 1], 245) + np.testing.assert_array_equal(jp2.box[2].box[1].palette[255, 2], 245) + + # Component mapping box + self.assertEqual(jp2.box[2].box[2].component_index, (0, 0, 0)) + self.assertEqual(jp2.box[2].box[2].mapping_type, (1, 1, 1)) + self.assertEqual(jp2.box[2].box[2].palette_index, (0, 1, 2)) + + colr = glymur.jp2box.ColourSpecificationBox( + colorspace=glymur.core.SRGB, + approximation=1) + self.verifyColourSpecificationBox(jp2.box[2].box[3], colr) + + def test_NR_issue188_beach_64bitsbox(self): + lst = ['input', 'nonregression', 'issue188_beach_64bitsbox.jp2'] + jfile = opj_data_file('/'.join(lst)) + with self.assertWarns(UserWarning): + # There's a warning for an unknown box. + jp2 = Jp2k(jfile) + + ids = [box.box_id for box in jp2.box] + self.assertEqual(ids, ['jP ', 'ftyp', 'jp2h', b'XML ', 'jp2c']) + + ids = [box.box_id for box in jp2.box[2].box] + self.assertEqual(ids, ['ihdr', 'colr']) + + self.verifySignatureBox(jp2.box[0]) + + # File type box. + self.assertEqual(jp2.box[1].brand, 'jp2 ') + self.assertEqual(jp2.box[1].minor_version, 0) + self.assertEqual(jp2.box[1].compatibility_list[0], 'jp2 ') + + ihdr = glymur.jp2box.ImageHeaderBox(200, 200, + num_components=3, colorspace_unknown=True) + self.verifyImageHeaderBox(jp2.box[2].box[0], ihdr) + + colr = glymur.jp2box.ColourSpecificationBox(colorspace=glymur.core.SRGB) + self.verifyColourSpecificationBox(jp2.box[2].box[1], colr) + + # Skip the 4th box, it is uknown. + + c = jp2.box[4].main_header + + ids = [x.marker_id for x in c.segment] + expected = ['SOC', 'SIZ', 'COD', 'QCD', 'CME', 'CME'] + self.assertEqual(ids, expected) + + kwargs = {'rsiz': 0, 'xysiz': (200, 200), 'xyosiz': (0, 0), + 'xytsiz': (200, 200), 'xytosiz': (0, 0), 'bitdepth': (8, 8, 8), + 'signed': (False, False, False), + 'xyrsiz': [(1, 1, 1), (1, 1, 1)]} + self.verifySizSegment(c.segment[1], glymur.codestream.SIZsegment(**kwargs)) + + # COD: Coding style default + self.assertFalse(c.segment[2].scod & 2) # no sop + self.assertFalse(c.segment[2].scod & 4) # no eph + self.assertEqual(c.segment[2].spcod[0], glymur.core.LRCP) + self.assertEqual(c.segment[2].layers, 1) # layers = 1 + self.assertEqual(c.segment[2].spcod[3], 1) # mct + self.assertEqual(c.segment[2].spcod[4], 5) # level + self.assertEqual(tuple(c.segment[2].code_block_size), + (64, 64)) # cblk + # Selective arithmetic coding bypass + self.assertFalse(c.segment[2].spcod[7] & 0x01) + # Reset context probabilities + self.assertFalse(c.segment[2].spcod[7] & 0x02) + # Termination on each coding pass + self.assertFalse(c.segment[2].spcod[7] & 0x04) + # Vertically causal context + self.assertFalse(c.segment[2].spcod[7] & 0x08) + # Predictable termination + self.assertFalse(c.segment[2].spcod[7] & 0x0010) + # Segmentation symbols + self.assertFalse(c.segment[2].spcod[7] & 0x0020) + self.assertEqual(c.segment[2].spcod[8], + glymur.core.WAVELET_XFORM_9X7_IRREVERSIBLE) + self.assertEqual(len(c.segment[2].spcod), 9) + + # QCD: Quantization default + self.assertEqual(c.segment[3].sqcd & 0x1f, 2) + self.assertEqual(c.segment[3].guard_bits, 1) + def test_NR_orb_blue10_lin_jp2_dump(self): jfile = opj_data_file('input/nonregression/orb-blue10-lin-jp2.jp2') with self.assertWarns(UserWarning): @@ -4437,7 +4428,6 @@ class TestSuite(unittest.TestCase): self.assertEqual(c.segment[3].exponent, [8, 9, 9, 10, 9, 9, 10, 9, 9, 10, 9, 9, 10, 9, 9, 10]) - @unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG) def test_NR_orb_blue10_win_jp2_dump(self): jfile = opj_data_file('input/nonregression/orb-blue10-win-jp2.jp2') with self.assertWarns(UserWarning): diff --git a/glymur/test/test_printing.py b/glymur/test/test_printing.py index 147ab9f..ea47a14 100644 --- a/glymur/test/test_printing.py +++ b/glymur/test/test_printing.py @@ -644,7 +644,208 @@ class TestPrintingOpjDataRoot(unittest.TestCase): actual = fake_out.getvalue().strip() self.assertEqual(actual, fixtures.cinema2k_profile) - @unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG) + def test_crg(self): + """verify printing of CRG segment""" + filename = opj_data_file('input/conformance/p0_03.j2k') + j = glymur.Jp2k(filename) + codestream = j.get_codestream() + with patch('sys.stdout', new=StringIO()) as fake_out: + print(codestream.segment[-5]) + actual = fake_out.getvalue().strip() + lines = ['CRG marker segment @ (87, 6)', + ' Vertical, Horizontal offset: (0.50, 1.00)'] + expected = '\n'.join(lines) + self.assertEqual(actual, expected) + + def test_rgn(self): + """verify printing of RGN segment""" + filename = opj_data_file('input/conformance/p0_03.j2k') + j = glymur.Jp2k(filename) + codestream = j.get_codestream(header_only=False) + with patch('sys.stdout', new=StringIO()) as fake_out: + print(codestream.segment[12]) + actual = fake_out.getvalue().strip() + lines = ['RGN marker segment @ (310, 5)', + ' Associated component: 0', + ' ROI style: 0', + ' Parameter: 7'] + expected = '\n'.join(lines) + self.assertEqual(actual, expected) + + def test_sop(self): + """verify printing of SOP segment""" + filename = opj_data_file('input/conformance/p0_03.j2k') + j = glymur.Jp2k(filename) + codestream = j.get_codestream(header_only=False) + with patch('sys.stdout', new=StringIO()) as fake_out: + print(codestream.segment[-2]) + actual = fake_out.getvalue().strip() + lines = ['SOP marker segment @ (12836, 4)', + ' Nsop: 15'] + expected = '\n'.join(lines) + self.assertEqual(actual, expected) + + def test_cme(self): + """Test printing a CME or comment marker segment.""" + filename = opj_data_file('input/conformance/p0_02.j2k') + j = glymur.Jp2k(filename) + codestream = j.get_codestream() + # 2nd to last segment in the main header + with patch('sys.stdout', new=StringIO()) as fake_out: + print(codestream.segment[-2]) + actual = fake_out.getvalue().strip() + lines = ['CME marker segment @ (85, 45)', + ' "Creator: AV-J2K (c) 2000,2001 Algo Vision"'] + expected = '\n'.join(lines) + self.assertEqual(actual, expected) + + def test_plt_segment(self): + """verify printing of PLT segment""" + filename = opj_data_file('input/conformance/p0_07.j2k') + j = glymur.Jp2k(filename) + codestream = j.get_codestream(header_only=False) + with patch('sys.stdout', new=StringIO()) as fake_out: + print(codestream.segment[49935]) + actual = fake_out.getvalue().strip() + + lines = ['PLT marker segment @ (7871146, 38)', + ' Index: 0', + ' Iplt: [9, 122, 19, 30, 27, 9, 41, 62, 18, 29, 261,' + + ' 55, 82, 299, 93, 941, 951, 687, 1729, 1443, 1008, 2168,' + + ' 2188, 2223]'] + expected = '\n'.join(lines) + self.assertEqual(actual, expected) + + def test_pod_segment(self): + """verify printing of POD segment""" + filename = opj_data_file('input/conformance/p0_13.j2k') + j = glymur.Jp2k(filename) + codestream = j.get_codestream() + with patch('sys.stdout', new=StringIO()) as fake_out: + print(codestream.segment[8]) + actual = fake_out.getvalue().strip() + + lines = ['POD marker segment @ (878, 20)', + ' Progression change 0:', + ' Resolution index start: 0', + ' Component index start: 0', + ' Layer index end: 1', + ' Resolution index end: 33', + ' Component index end: 128', + ' Progression order: RLCP', + ' Progression change 1:', + ' Resolution index start: 0', + ' Component index start: 128', + ' Layer index end: 1', + ' Resolution index end: 33', + ' Component index end: 257', + ' Progression order: CPRL'] + + expected = '\n'.join(lines) + self.assertEqual(actual, expected) + + def test_ppm_segment(self): + """verify printing of PPM segment""" + filename = opj_data_file('input/conformance/p1_03.j2k') + j = glymur.Jp2k(filename) + codestream = j.get_codestream() + with patch('sys.stdout', new=StringIO()) as fake_out: + print(codestream.segment[9]) + actual = fake_out.getvalue().strip() + + lines = ['PPM marker segment @ (213, 43712)', + ' Index: 0', + ' Data: 43709 uninterpreted bytes'] + + expected = '\n'.join(lines) + self.assertEqual(actual, expected) + + def test_ppt_segment(self): + """verify printing of ppt segment""" + filename = opj_data_file('input/conformance/p1_06.j2k') + j = glymur.Jp2k(filename) + codestream = j.get_codestream(header_only=False) + with patch('sys.stdout', new=StringIO()) as fake_out: + print(codestream.segment[6]) + actual = fake_out.getvalue().strip() + + lines = ['PPT marker segment @ (155, 109)', + ' Index: 0', + ' Packet headers: 106 uninterpreted bytes'] + + expected = '\n'.join(lines) + self.assertEqual(actual, expected) + + def test_tlm_segment(self): + """verify printing of TLM segment""" + filename = opj_data_file('input/conformance/p0_15.j2k') + j = glymur.Jp2k(filename) + codestream = j.get_codestream() + with patch('sys.stdout', new=StringIO()) as fake_out: + print(codestream.segment[10]) + actual = fake_out.getvalue().strip() + + lines = ['TLM marker segment @ (268, 28)', + ' Index: 0', + ' Tile number: (0, 1, 2, 3)', + ' Length: (4267, 2117, 4080, 2081)'] + + expected = '\n'.join(lines) + self.assertEqual(actual, expected) + + def test_componentmapping_box_alpha(self): + """Verify __repr__ method on cmap box.""" + cmap = glymur.jp2box.ComponentMappingBox(component_index=(0, 0, 0), + mapping_type=(1, 1, 1), + palette_index=(0, 1, 2)) + newbox = eval(repr(cmap)) + self.assertEqual(newbox.box_id, 'cmap') + self.assertEqual(newbox.component_index, (0, 0, 0)) + self.assertEqual(newbox.mapping_type, (1, 1, 1)) + self.assertEqual(newbox.palette_index, (0, 1, 2)) + + def test_differing_subsamples(self): + """verify printing of SIZ with different subsampling... Issue 86.""" + filename = opj_data_file('input/conformance/p0_05.j2k') + j = glymur.Jp2k(filename) + codestream = j.get_codestream() + with patch('sys.stdout', new=StringIO()) as fake_out: + print(codestream.segment[1]) + actual = fake_out.getvalue().strip() + lines = ['SIZ marker segment @ (2, 50)', + ' Profile: 0', + ' Reference Grid Height, Width: (1024 x 1024)', + ' Vertical, Horizontal Reference Grid Offset: (0 x 0)', + ' Reference Tile Height, Width: (1024 x 1024)', + ' Vertical, Horizontal Reference Tile Offset: (0 x 0)', + ' Bitdepth: (8, 8, 8, 8)', + ' Signed: (False, False, False, False)', + ' Vertical, Horizontal Subsampling: ' + + '((1, 1), (1, 1), (2, 2), (2, 2))'] + expected = '\n'.join(lines) + self.assertEqual(actual, expected) + +@unittest.skipIf(OPJ_DATA_ROOT is None, + "OPJ_DATA_ROOT environment variable not set") +@unittest.skipIf(os.name == "nt", "Temporary file issue on window.") +@unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG) +class TestPrintingOpjDataRootWarns(unittest.TestCase): + """ + Tests for verifying printing. restricted to OPJ_DATA_ROOT files. + + These tests issue warnings. + """ + def setUp(self): + self.jpxfile = glymur.data.jpxfile() + self.jp2file = glymur.data.nemo() + self.j2kfile = glymur.data.goodstuff() + + # Reset printoptions for every test. + glymur.set_printoptions(short=False, xml=True, codestream=True) + + def tearDown(self): + pass + def test_invalid_colorspace(self): """An invalid colorspace shouldn't cause an error.""" filename = opj_data_file('input/nonregression/edf_c2_1103421.jp2') @@ -653,7 +854,6 @@ class TestPrintingOpjDataRoot(unittest.TestCase): with patch('sys.stdout', new=StringIO()) as fake_out: print(jp2) - @unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG) def test_bad_rsiz(self): """Should still be able to print if rsiz is bad, issue196""" filename = opj_data_file('input/nonregression/edf_c2_1002767.jp2') @@ -662,7 +862,6 @@ class TestPrintingOpjDataRoot(unittest.TestCase): with patch('sys.stdout', new=StringIO()) as fake_out: print(j) - @unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG) 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') @@ -671,7 +870,6 @@ class TestPrintingOpjDataRoot(unittest.TestCase): with patch('sys.stdout', new=StringIO()) as fake_out: print(jp2) - @unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG) 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') @@ -833,7 +1031,6 @@ class TestPrintingOpjDataRoot(unittest.TestCase): expected = '\n'.join(lines) self.assertEqual(actual, expected) - @unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG) def test_xml(self): """verify printing of XML box""" filename = opj_data_file('input/conformance/file1.jp2') @@ -844,7 +1041,6 @@ class TestPrintingOpjDataRoot(unittest.TestCase): actual = fake_out.getvalue().strip() self.assertEqual(actual, fixtures.file1_xml) - @unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG) def test_channel_definition(self): """verify printing of cdef box""" filename = opj_data_file('input/conformance/file2.jp2') @@ -861,7 +1057,6 @@ class TestPrintingOpjDataRoot(unittest.TestCase): expected = '\n'.join(lines) self.assertEqual(actual, expected) - @unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG) def test_component_mapping(self): """verify printing of cmap box""" filename = opj_data_file('input/conformance/file9.jp2') @@ -888,7 +1083,6 @@ class TestPrintingOpjDataRoot(unittest.TestCase): self.assertEqual(newbox.mapping_type, (1, 1, 1)) self.assertEqual(newbox.palette_index, (0, 1, 2)) - @unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG) def test_palette7(self): """verify printing of pclr box""" filename = opj_data_file('input/conformance/file9.jp2') @@ -902,7 +1096,6 @@ class TestPrintingOpjDataRoot(unittest.TestCase): expected = '\n'.join(lines) self.assertEqual(actual, expected) - @unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG) def test_rreq(self): """verify printing of reader requirements box""" filename = opj_data_file('input/nonregression/text_GBR.jp2') @@ -934,7 +1127,6 @@ class TestPrintingOpjDataRoot(unittest.TestCase): expected = '\n'.join(lines) self.assertEqual(actual, expected) - @unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG) def test_palette_box(self): """Verify that palette (pclr) boxes are printed without error.""" filename = opj_data_file('input/conformance/file9.jp2') @@ -948,7 +1140,6 @@ class TestPrintingOpjDataRoot(unittest.TestCase): expected = '\n'.join(lines) self.assertEqual(actual, expected) - @unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG) def test_icc_profile(self): """verify icc profile printing with a jpx""" # ICC profiles may be used in JP2, but the approximation field should @@ -970,7 +1161,6 @@ class TestPrintingOpjDataRoot(unittest.TestCase): self.assertEqual(actual, expected) - @unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG) def test_uuid(self): """verify printing of UUID box""" filename = opj_data_file('input/nonregression/text_GBR.jp2') @@ -987,7 +1177,6 @@ class TestPrintingOpjDataRoot(unittest.TestCase): expected = '\n'.join(lines) self.assertEqual(actual, expected) - @unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG) def test_issue182(self): """Should not show the format string in output.""" # The cmap box is wildly broken, but printing was still wrong. @@ -1002,7 +1191,6 @@ class TestPrintingOpjDataRoot(unittest.TestCase): actual = fake_out.getvalue().strip() self.assertEqual(actual, fixtures.issue_182_cmap) - @unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG) def test_issue183(self): filename = opj_data_file('input/nonregression/orb-blue10-lin-jp2.jp2') @@ -1014,7 +1202,6 @@ class TestPrintingOpjDataRoot(unittest.TestCase): actual = fake_out.getvalue().strip() self.assertEqual(actual, fixtures.issue_183_colr) - @unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG) def test_bom(self): """Byte order markers are illegal in UTF-8. Issue 185""" filename = opj_data_file(os.path.join('input',