diff --git a/glymur/lib/openjp2.py b/glymur/lib/openjp2.py index f0a5f09..5e58cf4 100644 --- a/glymur/lib/openjp2.py +++ b/glymur/lib/openjp2.py @@ -585,107 +585,6 @@ class ImageComptParmType(ctypes.Structure): return msg -class TccpInfo(ctypes.Structure): - """Tile-component coding parameters information. - - Corresponds to tccp_info_t type in openjp2 header file. - """ - _fields_ = [ - # component index - ("compno", ctypes.c_uint32), - - # coding style - ("csty", ctypes.c_uint32), - - # number of resolutions - ("numresolutions", ctypes.c_uint32), - - # code-blocks width - ("cblkw", ctypes.c_uint32), - - # code-blocks height - ("cblkh", ctypes.c_uint32), - - # code-block coding style - ("cblksty", ctypes.c_uint32), - - # discrete wavelet transform identifier - ("qmfbid", ctypes.c_uint32), - - # quantization style - ("qntsty", ctypes.c_uint32), - - # stepsizes used for quantization - ("stepsizes_mant", ctypes.c_uint32 * J2K_MAXBANDS), - ("stepsizes_expn", ctypes.c_uint32 * J2K_MAXBANDS), - - # stepsizes used for quantization - ("numgbits", ctypes.c_uint32), - - # region of interest shift - ("roishift", ctypes.c_int32), - - # precinct width - ("prcw", ctypes.c_uint32 * J2K_MAXRLVLS), - - # precinct width - ("prch", ctypes.c_uint32 * J2K_MAXRLVLS)] - - -class TileInfoV2(ctypes.Structure): - """Tile coding parameters information - - Corresponds to tile_info_v2_t type in openjp2 headers. - """ - _fields_ = [ - # number (index) of tile - ("tileno", ctypes.c_int32), - - # coding style - ("csty", ctypes.c_uint32), - - # progression order - ("prg", PROG_ORDER_TYPE), - - # number of layers - ("numlayers", ctypes.c_uint32), - - # multi-component transform identifier - ("mct", ctypes.c_uint32), - - # information concerning tile component parameters - ("tccp_info", ctypes.POINTER(TccpInfo))] - - -class CodestreamInfoV2(ctypes.Structure): - """information about the codestream. - - Corresponds to codestream_info_v2_t type in openjp2 header files. - """ - _fields_ = [ - # tile info - # tile origin in x, y (XTOsiz, YTOsiz) - ("tx0", ctypes.c_uint32), - ("ty0", ctypes.c_uint32), - - # tile size in x, y = XTsiz, YTsiz - ("tdx", ctypes.c_uint32), - ("tdy", ctypes.c_uint32), - - # number of tiles in X, Y - ("tw", ctypes.c_uint32), - ("th", ctypes.c_uint32), - - # number of components - ("nbcomps", ctypes.c_uint32), - - # default information regarding tiles inside of image - ("m_default_tile_info", TileInfoV2), - - # information regarding tiles inside of image - ("tile_info", ctypes.POINTER(TileInfoV2))] - - def check_error(status): """Set a generic function as the restype attribute of all OpenJPEG functions that return a BOOL_TYPE value. This way we do not have to check diff --git a/glymur/lib/test/test_openjp2.py b/glymur/lib/test/test_openjp2.py index 70ef9b6..988ace1 100644 --- a/glymur/lib/test/test_openjp2.py +++ b/glymur/lib/test/test_openjp2.py @@ -56,53 +56,6 @@ class TestOpenJP2(unittest.TestCase): self.assertEqual(dparams.DA_x1, 0) self.assertEqual(dparams.DA_y1, 0) - def tile_macro(self, codec, stream, imagep, tidx): - """called only by j2k_random_tile_access""" - openjp2.get_decoded_tile(codec, stream, imagep, tidx) - for j in range(imagep.contents.numcomps): - self.assertIsNotNone(imagep.contents.comps[j].data) - - def j2k_random_tile_access(self, filename, codec_format=None): - """fixture called by the test_rtaX methods""" - dparam = openjp2.set_default_decoder_parameters() - - infile = filename.encode() - nelts = openjp2.PATH_LEN - len(infile) - infile += b'0' * nelts - dparam.infile = infile - - dparam.decod_format = codec_format - - codec = openjp2.create_decompress(codec_format) - - openjp2.set_info_handler(codec, None) - openjp2.set_warning_handler(codec, None) - openjp2.set_error_handler(codec, None) - - stream = openjp2.stream_create_default_file_stream(filename, True) - - openjp2.setup_decoder(codec, dparam) - image = openjp2.read_header(stream, codec) - - cstr_info = openjp2.get_cstr_info(codec) - - tile_ul = 0 - tile_ur = cstr_info.contents.tw - 1 - tile_lr = cstr_info.contents.tw * cstr_info.contents.th - 1 - tile_ll = tile_lr - cstr_info.contents.tw - - self.tile_macro(codec, stream, image, tile_ul) - self.tile_macro(codec, stream, image, tile_ur) - self.tile_macro(codec, stream, image, tile_lr) - self.tile_macro(codec, stream, image, tile_ll) - - openjp2.destroy_cstr_info(cstr_info) - - openjp2.end_decompress(codec, stream) - openjp2.destroy_codec(codec) - openjp2.stream_destroy(stream) - openjp2.image_destroy(image) - def test_tte0(self): """Runs test designated tte0 in OpenJPEG test suite.""" with tempfile.NamedTemporaryFile(suffix=".j2k") as tfile: @@ -160,15 +113,6 @@ class TestOpenJP2(unittest.TestCase): tile_decoder(**kwargs) self.assertTrue(True) - def test_rta1(self): - """Runs test designated rta1 in OpenJPEG test suite.""" - with tempfile.NamedTemporaryFile(suffix=".j2k") as tfile: - self.xtx1_setup(tfile.name) - - codec_format = openjp2.CODEC_J2K - self.j2k_random_tile_access(tfile.name, codec_format) - self.assertTrue(True) - def test_tte2(self): """Runs test designated tte2 in OpenJPEG test suite.""" with tempfile.NamedTemporaryFile(suffix=".jp2") as tfile: @@ -190,62 +134,24 @@ class TestOpenJP2(unittest.TestCase): tile_decoder(**kwargs) self.assertTrue(True) - def test_rta2(self): - """Runs test designated rta2 in OpenJPEG test suite.""" - with tempfile.NamedTemporaryFile(suffix=".jp2") as tfile: - xtx2_setup(tfile.name) - - codec_format = openjp2.CODEC_JP2 - self.j2k_random_tile_access(tfile.name, codec_format) - def test_tte3(self): """Runs test designated tte3 in OpenJPEG test suite.""" with tempfile.NamedTemporaryFile(suffix=".j2k") as tfile: xtx3_setup(tfile.name) self.assertTrue(True) - def test_rta3(self): - """Runs test designated rta3 in OpenJPEG test suite.""" - with tempfile.NamedTemporaryFile(suffix=".j2k") as tfile: - xtx3_setup(tfile.name) - - codec_format = openjp2.CODEC_J2K - self.j2k_random_tile_access(tfile.name, codec_format) - self.assertTrue(True) - def test_tte4(self): """Runs test designated tte4 in OpenJPEG test suite.""" with tempfile.NamedTemporaryFile(suffix=".j2k") as tfile: xtx4_setup(tfile.name) self.assertTrue(True) - def test_rta4(self): - """Runs test designated rta4 in OpenJPEG test suite.""" - with tempfile.NamedTemporaryFile(suffix=".j2k") as tfile: - xtx4_setup(tfile.name) - - codec_format = openjp2.CODEC_J2K - self.j2k_random_tile_access(tfile.name, codec_format) - def test_tte5(self): """Runs test designated tte5 in OpenJPEG test suite.""" with tempfile.NamedTemporaryFile(suffix=".j2k") as tfile: xtx5_setup(tfile.name) self.assertTrue(True) - def test_rta5(self): - """Runs test designated rta5 in OpenJPEG test suite.""" - with tempfile.NamedTemporaryFile(suffix=".j2k") as tfile: - xtx5_setup(tfile.name) - - codec_format = openjp2.CODEC_J2K - self.j2k_random_tile_access(tfile.name, codec_format) - - -#def tile_encoder(num_comps=None, tile_width=None, tile_height=None, -# filename=None, codec=None, comp_prec=None, -# image_width=None, image_height=None, -# irreversible=None): def tile_encoder(**kwargs): """Fixture used by many tests.""" num_tiles = ((kwargs['image_width'] / kwargs['tile_width']) *