added compression parameters printing
This commit is contained in:
parent
67456c3b89
commit
6abf184ad7
5 changed files with 194 additions and 87 deletions
|
|
@ -412,7 +412,7 @@ class CompressionParametersType(ctypes.Structure):
|
|||
for field_name, _ in self._fields_:
|
||||
|
||||
if field_name == 'poc':
|
||||
msg += " numpocs: {1}\n".format(self.numpocs)
|
||||
msg += " numpocs: {0}\n".format(self.numpocs)
|
||||
for j in range(self.numpocs):
|
||||
msg += " [#{0}]:".format(j)
|
||||
msg += " {0}".format(str(self.poc[j]))
|
||||
|
|
@ -424,6 +424,24 @@ class CompressionParametersType(ctypes.Structure):
|
|||
lst = [arr[j] for j in range(self.tcp_numlayers)]
|
||||
msg += " {0}: {1}\n".format(field_name, lst)
|
||||
|
||||
elif field_name in ['prcw_init', 'prch_init']:
|
||||
pass
|
||||
|
||||
elif field_name == 'res_spec':
|
||||
prcw_init = [self.prcw_init[j] for j in range(self.res_spec)]
|
||||
prch_init = [self.prch_init[j] for j in range(self.res_spec)]
|
||||
msg += " res_spec: {0}\n".format(self.res_spec)
|
||||
msg += " prch_init: {0}\n".format(prch_init)
|
||||
msg += " prcw_init: {0}\n".format(prcw_init)
|
||||
|
||||
elif field_name in [
|
||||
'jpwl_hprot_tph_tileno', 'jpwl_hprot_tph',
|
||||
'jpwl_pprot_tileno', 'jpwl_pprot_packno', 'jpwl_pprot',
|
||||
'jpwl_sens_tph_tileno', 'jpwl_sens_tph']:
|
||||
arr = getattr(self, field_name)
|
||||
lst = [arr[j] for j in range(JPWL_MAX_NO_TILESPECS)]
|
||||
msg += " {0}: {1}\n".format(field_name, lst)
|
||||
|
||||
else:
|
||||
msg += " {0}: {1}\n".format(
|
||||
field_name, getattr(self, field_name))
|
||||
|
|
|
|||
118
glymur/lib/test/fixtures.py
Normal file
118
glymur/lib/test/fixtures.py
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
decompression_parameters_type = """<class 'glymur.lib.openjp2.DecompressionParametersType'>:
|
||||
cp_reduce: 0
|
||||
cp_layer: 0
|
||||
infile: b''
|
||||
outfile: b''
|
||||
decod_format: -1
|
||||
cod_format: -1
|
||||
DA_x0: 0
|
||||
DA_x1: 0
|
||||
DA_y0: 0
|
||||
DA_y1: 0
|
||||
m_verbose: 0
|
||||
tile_index: 0
|
||||
nb_tile_to_decode: 0
|
||||
jpwl_correct: 0
|
||||
jpwl_exp_comps: 0
|
||||
jpwl_max_tiles: 0
|
||||
flags: 0"""
|
||||
|
||||
default_progression_order_changes_type = """<class 'glymur.lib.openjp2.PocType'>:
|
||||
resno0: 0
|
||||
compno0: 0
|
||||
layno1: 0
|
||||
resno1: 0
|
||||
compno1: 0
|
||||
layno0: 0
|
||||
precno0: 0
|
||||
precno1: 0
|
||||
prg1: 0
|
||||
prg: 0
|
||||
progorder: b''
|
||||
tile: 0
|
||||
tx0: 0
|
||||
tx1: 0
|
||||
ty0: 0
|
||||
ty1: 0
|
||||
layS: 0
|
||||
resS: 0
|
||||
compS: 0
|
||||
prcS: 0
|
||||
layE: 0
|
||||
resE: 0
|
||||
compE: 0
|
||||
prcE: 0
|
||||
txS: 0
|
||||
txE: 0
|
||||
tyS: 0
|
||||
tyE: 0
|
||||
dx: 0
|
||||
dy: 0
|
||||
lay_t: 0
|
||||
res_t: 0
|
||||
comp_t: 0
|
||||
prec_t: 0
|
||||
tx0_t: 0
|
||||
ty0_t: 0"""
|
||||
|
||||
default_compression_parameters_type = """<class 'glymur.lib.openjp2.CompressionParametersType'>:
|
||||
tile_size_on: 0
|
||||
cp_tx0: 0
|
||||
cp_ty0: 0
|
||||
cp_tdx: 0
|
||||
cp_tdy: 0
|
||||
cp_disto_alloc: 0
|
||||
cp_fixed_alloc: 0
|
||||
cp_fixed_quality: 0
|
||||
cp_matrice: None
|
||||
cp_comment: None
|
||||
csty: 0
|
||||
prog_order: 0
|
||||
numpocs: 0
|
||||
numpocs: 0
|
||||
tcp_numlayers: 0
|
||||
tcp_rates: []
|
||||
tcp_distoratio: []
|
||||
numresolution: 6
|
||||
cblockw_init: 64
|
||||
cblockh_init: 64
|
||||
mode: 0
|
||||
irreversible: 0
|
||||
roi_compno: -1
|
||||
roi_shift: 0
|
||||
res_spec: 0
|
||||
prch_init: []
|
||||
prcw_init: []
|
||||
infile: b''
|
||||
outfile: b''
|
||||
index_on: 0
|
||||
index: b''
|
||||
image_offset_x0: 0
|
||||
image_offset_y0: 0
|
||||
subsampling_dx: 1
|
||||
subsampling_dy: 1
|
||||
decod_format: -1
|
||||
cod_format: -1
|
||||
jpwl_epc_on: 0
|
||||
jpwl_hprot_mh: 0
|
||||
jpwl_hprot_tph_tileno: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
||||
jpwl_hprot_tph: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
||||
jpwl_pprot_tileno: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
||||
jpwl_pprot_packno: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
||||
jpwl_pprot: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
||||
jpwl_sens_size: 0
|
||||
jpwl_sens_addr: 0
|
||||
jpwl_sens_range: 0
|
||||
jpwl_sens_mh: 0
|
||||
jpwl_sens_tph_tileno: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
||||
jpwl_sens_tph: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
||||
cp_cinema: 0
|
||||
max_comp_size: 0
|
||||
cp_rsiz: 0
|
||||
tp_on: 0
|
||||
tp_flag: 0
|
||||
tcp_mct: 0
|
||||
jpip_on: 0
|
||||
mct_data: None
|
||||
max_cs_size: 0
|
||||
rsiz: 0"""
|
||||
57
glymur/lib/test/test_printing.py
Normal file
57
glymur/lib/test/test_printing.py
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""Test suite for printing.
|
||||
"""
|
||||
|
||||
import re
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
if sys.hexversion < 0x03000000:
|
||||
from mock import patch
|
||||
from StringIO import StringIO
|
||||
else:
|
||||
from unittest.mock import patch
|
||||
from io import StringIO
|
||||
|
||||
import glymur
|
||||
from . import fixtures
|
||||
|
||||
@unittest.skipIf(sys.hexversion < 0x03000000, "do not care about 2.7 here")
|
||||
@unittest.skipIf(re.match('1|2.0', glymur.version.openjpeg_version),
|
||||
"Requires openjpeg 2.1.0 or higher")
|
||||
class TestPrintingOpenjp2(unittest.TestCase):
|
||||
"""Tests for verifying how printing works on openjp2 library structures."""
|
||||
def setUp(self):
|
||||
self.jp2file = glymur.data.nemo()
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def test_decompression_parameters(self):
|
||||
"""printing DecompressionParametersType"""
|
||||
dparams = glymur.lib.openjp2.set_default_decoder_parameters()
|
||||
with patch('sys.stdout', new=StringIO()) as fake_out:
|
||||
print(dparams)
|
||||
actual = fake_out.getvalue().strip()
|
||||
expected = fixtures.decompression_parameters_type
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
def test_progression_order_changes(self):
|
||||
"""printing PocType"""
|
||||
ptype = glymur.lib.openjp2.PocType()
|
||||
with patch('sys.stdout', new=StringIO()) as fake_out:
|
||||
print(ptype)
|
||||
actual = fake_out.getvalue().strip()
|
||||
expected = fixtures.default_progression_order_changes_type
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
def test_default_compression_parameters(self):
|
||||
"""printing default compression parameters"""
|
||||
cparams = glymur.lib.openjp2.set_default_encoder_parameters()
|
||||
with patch('sys.stdout', new=StringIO()) as fake_out:
|
||||
print(cparams)
|
||||
actual = fake_out.getvalue().strip()
|
||||
expected = fixtures.default_compression_parameters_type
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
|
||||
|
|
@ -901,59 +901,3 @@ goodstuff_with_full_header = r"""Codestream:
|
|||
SOD marker segment @ (164, 0)
|
||||
EOC marker segment @ (115218, 0)"""
|
||||
|
||||
decompression_parameters_type = """<class 'glymur.lib.openjp2.DecompressionParametersType'>:
|
||||
cp_reduce: 0
|
||||
cp_layer: 0
|
||||
infile: b''
|
||||
outfile: b''
|
||||
decod_format: -1
|
||||
cod_format: -1
|
||||
DA_x0: 0
|
||||
DA_x1: 0
|
||||
DA_y0: 0
|
||||
DA_y1: 0
|
||||
m_verbose: 0
|
||||
tile_index: 0
|
||||
nb_tile_to_decode: 0
|
||||
jpwl_correct: 0
|
||||
jpwl_exp_comps: 0
|
||||
jpwl_max_tiles: 0
|
||||
flags: 0"""
|
||||
|
||||
default_progression_order_changes_type = """<class 'glymur.lib.openjp2.PocType'>:
|
||||
resno0: 0
|
||||
compno0: 0
|
||||
layno1: 0
|
||||
resno1: 0
|
||||
compno1: 0
|
||||
layno0: 0
|
||||
precno0: 0
|
||||
precno1: 0
|
||||
prg1: 0
|
||||
prg: 0
|
||||
progorder: b''
|
||||
tile: 0
|
||||
tx0: 0
|
||||
tx1: 0
|
||||
ty0: 0
|
||||
ty1: 0
|
||||
layS: 0
|
||||
resS: 0
|
||||
compS: 0
|
||||
prcS: 0
|
||||
layE: 0
|
||||
resE: 0
|
||||
compE: 0
|
||||
prcE: 0
|
||||
txS: 0
|
||||
txE: 0
|
||||
tyS: 0
|
||||
tyE: 0
|
||||
dx: 0
|
||||
dy: 0
|
||||
lay_t: 0
|
||||
res_t: 0
|
||||
comp_t: 0
|
||||
prec_t: 0
|
||||
tx0_t: 0
|
||||
ty0_t: 0"""
|
||||
|
|
|
|||
|
|
@ -618,36 +618,6 @@ class TestPrinting(unittest.TestCase):
|
|||
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
@unittest.skipIf(sys.hexversion < 0x03000000, "do not care about 2.7 here")
|
||||
@unittest.skipIf(re.match('1|2.0', glymur.version.openjpeg_version),
|
||||
"Requires openjpeg 2.1.0 or higher")
|
||||
class TestPrintingOpenjp2(unittest.TestCase):
|
||||
"""Tests for verifying how printing works on openjp2 library structures."""
|
||||
def setUp(self):
|
||||
self.jp2file = glymur.data.nemo()
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def test_decompression_parameters(self):
|
||||
"""printing DecompressionParametersType"""
|
||||
dparams = glymur.lib.openjp2.set_default_decoder_parameters()
|
||||
with patch('sys.stdout', new=StringIO()) as fake_out:
|
||||
print(dparams)
|
||||
actual = fake_out.getvalue().strip()
|
||||
expected = fixtures.decompression_parameters_type
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
def test_progression_order_changes(self):
|
||||
"""printing PocType"""
|
||||
ptype = glymur.lib.openjp2.PocType()
|
||||
with patch('sys.stdout', new=StringIO()) as fake_out:
|
||||
print(ptype)
|
||||
actual = fake_out.getvalue().strip()
|
||||
expected = fixtures.default_progression_order_changes_type
|
||||
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.")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue