Validated through 2686. #139
This commit is contained in:
parent
8827908b28
commit
de6984e204
4 changed files with 78 additions and 34 deletions
|
|
@ -166,6 +166,11 @@ class Jp2k(Jp2kBox):
|
|||
fps : int
|
||||
Frames per second, should be either 24 or 48.
|
||||
"""
|
||||
if version.openjpeg_version_tuple[0] == 1:
|
||||
msg = "Writing Cinema2K or Cinema4K files is not supported with "
|
||||
msg += 'openjpeg library versions less than 2.0.1.'
|
||||
raise IOError(msg)
|
||||
|
||||
if cinema_mode == 'cinema2k':
|
||||
if fps == 24:
|
||||
cparams.cp_cinema = CINEMA_MODE['cinema2k_24']
|
||||
|
|
@ -331,8 +336,8 @@ class Jp2k(Jp2kBox):
|
|||
colorspace : int
|
||||
Either CLRSPC_SRGB or CLRSPC_GRAY
|
||||
"""
|
||||
|
||||
if ('cinema2k' in kwargs or 'cinema4k' in kwargs) and len(set(kwargs)) > 1:
|
||||
if (('cinema2k' in kwargs or 'cinema4k' in kwargs) and
|
||||
(len(set(kwargs)) > 1)):
|
||||
msg = "Cannot specify cinema2k/cinema4k along with other options."
|
||||
raise IOError(msg)
|
||||
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ if HAS_PYTHON_XMP_TOOLKIT:
|
|||
from libxmp import XMPMeta
|
||||
|
||||
from .fixtures import OPJ_DATA_ROOT, opj_data_file
|
||||
from . import fixtures
|
||||
|
||||
|
||||
# Doc tests should be run as well.
|
||||
|
|
@ -376,6 +377,10 @@ class TestJp2k(unittest.TestCase):
|
|||
creator_tool = xmp.get_property(libxmp.consts.XMP_NS_XMP, 'CreatorTool')
|
||||
self.assertEqual(creator_tool, 'Google')
|
||||
|
||||
@unittest.skipIf(fixtures.OPENJP2_IS_V2_OFFICIAL,
|
||||
"Feature not supported in 2.0.0 official")
|
||||
@unittest.skipIf(glymur.version.openjpeg_version_tuple[0] == 1,
|
||||
"Feature not supported in 1.5")
|
||||
def test_jpx_mult_codestreams_jp2_brand(self):
|
||||
"""Read JPX codestream when jp2-compatible."""
|
||||
# The file in question has multiple codestreams.
|
||||
|
|
|
|||
|
|
@ -23,6 +23,31 @@ from glymur import Jp2k
|
|||
import glymur
|
||||
|
||||
|
||||
@unittest.skipIf(re.match(r"""1\.[01234]""", glymur.version.openjpeg_version),
|
||||
"Functionality not implemented for 1.3, 1.4")
|
||||
@unittest.skipIf(OPJ_DATA_ROOT is None,
|
||||
"OPJ_OPJ_DATA_ROOT environment variable not set")
|
||||
class TestSuiteNegative2pointzero(unittest.TestCase):
|
||||
"""Feature set not supported for versions less than 2.0"""
|
||||
|
||||
def setUp(self):
|
||||
self.jp2file = glymur.data.nemo()
|
||||
self.j2kfile = glymur.data.goodstuff()
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
@unittest.skipIf(os.name == "nt", "Temporary file issue on window.")
|
||||
def test_cinema_mode(self):
|
||||
"""Cinema mode not supported for less than 2.0.1."""
|
||||
infile = opj_data_file('input/nonregression/Bretagne1.ppm')
|
||||
data = read_image(infile)
|
||||
with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile:
|
||||
j = Jp2k(tfile.name, 'wb')
|
||||
with self.assertRaises(IOError):
|
||||
j.write(data, psnr=[30, 35, 40], cratios=[2, 3, 4])
|
||||
|
||||
|
||||
@unittest.skipIf(re.match(r"""1\.[01234]""", glymur.version.openjpeg_version),
|
||||
"Functionality not implemented for 1.3, 1.4")
|
||||
@unittest.skipIf(OPJ_DATA_ROOT is None,
|
||||
|
|
|
|||
|
|
@ -21,18 +21,21 @@ except ((ImportError, RuntimeError)):
|
|||
|
||||
from .fixtures import read_image, NO_READ_BACKEND, NO_READ_BACKEND_MSG
|
||||
from .fixtures import OPJ_DATA_ROOT, opj_data_file
|
||||
from . import fixtures
|
||||
|
||||
from glymur import Jp2k
|
||||
import glymur
|
||||
|
||||
@unittest.skipIf(not _HAS_SKIMAGE_FREEIMAGE_SUPPORT,
|
||||
"Cannot read input image without scikit-image/freeimage")
|
||||
@unittest.skipIf(os.name == "nt", "no write support on windows, period")
|
||||
@unittest.skipIf(re.match(r"""1\.[01234]\.\d""",
|
||||
glymur.version.openjpeg_version) is not None,
|
||||
"Writing only supported with openjpeg version 1.5+.")
|
||||
@unittest.skipIf(NO_READ_BACKEND, NO_READ_BACKEND_MSG)
|
||||
@unittest.skipIf(fixtures.OPENJP2_IS_V2_OFFICIAL,
|
||||
"Feature not supported in 2.0.0 official")
|
||||
@unittest.skipIf(glymur.version.openjpeg_version_tuple[0] == 1,
|
||||
"Feature not supported in 1.5")
|
||||
@unittest.skipIf(OPJ_DATA_ROOT is None,
|
||||
"OPJ_DATA_ROOT environment variable not set")
|
||||
class TestSuiteWrite(unittest.TestCase):
|
||||
class TestSuiteWriteCinema(unittest.TestCase):
|
||||
"""Tests for writing with openjp2 backend.
|
||||
|
||||
These tests either roughly correspond with those tests with similar names
|
||||
|
|
@ -148,8 +151,6 @@ class TestSuiteWrite(unittest.TestCase):
|
|||
|
||||
|
||||
|
||||
@unittest.skipIf(not _HAS_SKIMAGE_FREEIMAGE_SUPPORT,
|
||||
"Cannot read input image without scikit-image/freeimage")
|
||||
def test_NR_ENC_ElephantDream_4K_tif_21_encode(self):
|
||||
relfile = 'input/nonregression/ElephantDream_4K.tif'
|
||||
infile = opj_data_file(relfile)
|
||||
|
|
@ -162,8 +163,6 @@ class TestSuiteWrite(unittest.TestCase):
|
|||
self.check_cinema4k_codestream(codestream, (4096, 2160))
|
||||
|
||||
|
||||
@unittest.skipIf(not _HAS_SKIMAGE_FREEIMAGE_SUPPORT,
|
||||
"Cannot read input image without scikit-image/freeimage")
|
||||
def test_NR_ENC_X_5_2K_24_235_CBR_STEM24_000_tif_19_encode(self):
|
||||
relfile = 'input/nonregression/X_5_2K_24_235_CBR_STEM24_000.tif'
|
||||
infile = opj_data_file(relfile)
|
||||
|
|
@ -176,8 +175,6 @@ class TestSuiteWrite(unittest.TestCase):
|
|||
self.check_cinema2k_codestream(codestream, (2048, 857))
|
||||
|
||||
|
||||
@unittest.skipIf(not _HAS_SKIMAGE_FREEIMAGE_SUPPORT,
|
||||
"Cannot read input image without scikit-image/freeimage")
|
||||
def test_NR_ENC_X_6_2K_24_FULL_CBR_CIRCLE_000_tif_20_encode(self):
|
||||
relfile = 'input/nonregression/X_6_2K_24_FULL_CBR_CIRCLE_000.tif'
|
||||
infile = opj_data_file(relfile)
|
||||
|
|
@ -190,8 +187,6 @@ class TestSuiteWrite(unittest.TestCase):
|
|||
self.check_cinema2k_codestream(codestream, (2048, 1080))
|
||||
|
||||
|
||||
@unittest.skipIf(not _HAS_SKIMAGE_FREEIMAGE_SUPPORT,
|
||||
"Cannot read input image without scikit-image/freeimage")
|
||||
def test_NR_ENC_X_6_2K_24_FULL_CBR_CIRCLE_000_tif_17_encode(self):
|
||||
relfile = 'input/nonregression/X_6_2K_24_FULL_CBR_CIRCLE_000.tif'
|
||||
infile = opj_data_file(relfile)
|
||||
|
|
@ -204,8 +199,6 @@ class TestSuiteWrite(unittest.TestCase):
|
|||
self.check_cinema2k_codestream(codestream, (2048, 1080))
|
||||
|
||||
|
||||
@unittest.skipIf(not _HAS_SKIMAGE_FREEIMAGE_SUPPORT,
|
||||
"Cannot read input image without scikit-image/freeimage")
|
||||
def test_NR_ENC_X_5_2K_24_235_CBR_STEM24_000_tif_16_encode(self):
|
||||
relfile = 'input/nonregression/X_5_2K_24_235_CBR_STEM24_000.tif'
|
||||
infile = opj_data_file(relfile)
|
||||
|
|
@ -218,8 +211,6 @@ class TestSuiteWrite(unittest.TestCase):
|
|||
self.check_cinema2k_codestream(codestream, (2048, 857))
|
||||
|
||||
|
||||
@unittest.skipIf(not _HAS_SKIMAGE_FREEIMAGE_SUPPORT,
|
||||
"Cannot read input image without scikit-image/freeimage")
|
||||
def test_NR_ENC_X_4_2K_24_185_CBR_WB_000_tif_18_encode(self):
|
||||
relfile = 'input/nonregression/X_4_2K_24_185_CBR_WB_000.tif'
|
||||
infile = opj_data_file(relfile)
|
||||
|
|
@ -232,32 +223,50 @@ class TestSuiteWrite(unittest.TestCase):
|
|||
self.check_cinema2k_codestream(codestream, (1998, 1080))
|
||||
|
||||
|
||||
@unittest.skipIf(not _HAS_SKIMAGE_FREEIMAGE_SUPPORT,
|
||||
"Cannot read input image without scikit-image/freeimage")
|
||||
def test_NR_ENC_X_4_2K_24_185_CBR_WB_000_tif_15_encode(self):
|
||||
relfile = 'input/nonregression/X_4_2K_24_185_CBR_WB_000.tif'
|
||||
infile = opj_data_file(relfile)
|
||||
data = skimage.io.imread(infile)
|
||||
with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile:
|
||||
j = Jp2k(tfile.name, 'wb')
|
||||
j.write(data, cinema2k=24)
|
||||
@unittest.skipIf(os.name == "nt", "Temporary file issue on window.")
|
||||
@unittest.skipIf(re.match(r"""2\.0""", glymur.version.openjpeg_version),
|
||||
"Functionality implemented for 2.1")
|
||||
@unittest.skipIf(OPJ_DATA_ROOT is None,
|
||||
"OPJ_OPJ_DATA_ROOT environment variable not set")
|
||||
class TestSuiteNegative2pointzero(unittest.TestCase):
|
||||
"""Feature set not supported for versions less than 2.0"""
|
||||
|
||||
codestream = j.get_codestream()
|
||||
self.check_cinema2k_codestream(codestream, (1998, 1080))
|
||||
def setUp(self):
|
||||
self.jp2file = glymur.data.nemo()
|
||||
self.j2kfile = glymur.data.goodstuff()
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
@unittest.skipIf(not _HAS_SKIMAGE_FREEIMAGE_SUPPORT,
|
||||
"Cannot read input image without scikit-image/freeimage")
|
||||
def test_cinema2k_bad_frame_rate(self):
|
||||
def test_cinema_mode(self):
|
||||
relfile = 'input/nonregression/X_4_2K_24_185_CBR_WB_000.tif'
|
||||
infile = opj_data_file(relfile)
|
||||
data = skimage.io.imread(infile)
|
||||
with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile:
|
||||
j = Jp2k(tfile.name, 'wb')
|
||||
with self.assertRaises(IOError):
|
||||
j.write(data, cinema2k=36)
|
||||
j.write(data, cinema2k=48)
|
||||
|
||||
|
||||
@unittest.skipIf(os.name == "nt", "no write support on windows, period")
|
||||
@unittest.skipIf(re.match(r"""1\.[01234]\.\d""",
|
||||
glymur.version.openjpeg_version) is not None,
|
||||
"Writing only supported with openjpeg version 1.5+.")
|
||||
@unittest.skipIf(NO_READ_BACKEND, NO_READ_BACKEND_MSG)
|
||||
@unittest.skipIf(OPJ_DATA_ROOT is None,
|
||||
"OPJ_DATA_ROOT environment variable not set")
|
||||
class TestSuiteWrite(unittest.TestCase):
|
||||
"""Tests for writing with openjp2 backend.
|
||||
|
||||
These tests either roughly correspond with those tests with similar names
|
||||
in the OpenJPEG test suite or are closely associated.
|
||||
"""
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def test_NR_ENC_Bretagne1_ppm_1_encode(self):
|
||||
"""NR-ENC-Bretagne1.ppm-1-encode"""
|
||||
infile = opj_data_file('input/nonregression/Bretagne1.ppm')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue