Merge branch 'issue227' into devel
This commit is contained in:
commit
9fc3395693
3 changed files with 70 additions and 64 deletions
|
|
@ -38,56 +38,47 @@ CINEMA2K_24 = 1
|
|||
CINEMA2K_48 = 2
|
||||
CINEMA4K_24 = 3
|
||||
|
||||
CINEMA_MODE = {
|
||||
'off': OFF,
|
||||
'cinema2k_24': CINEMA2K_24,
|
||||
'cinema2k_48': CINEMA2K_48,
|
||||
'cinema4k_24': CINEMA4K_24, }
|
||||
OPJ_OFF = 0 # Not Digital Cinema
|
||||
OPJ_CINEMA2K_24 = 1 # 2K Digital Cinema at 24 fps
|
||||
OPJ_CINEMA2K_48 = 2 # 2K Digital Cinema at 48 fps
|
||||
OPJ_CINEMA4K_24 = 3 # 4K Digital Cinema at 24 fps
|
||||
|
||||
PROFILE = {
|
||||
# no profile, conform to 15444-1
|
||||
'none': 0x0000,
|
||||
# profile 0 as described in 15444-1,Table A.45
|
||||
'0': 0x0001,
|
||||
'zero': 0x0001,
|
||||
0: 0x0001,
|
||||
# profile 1 as described in 15444-1,Table A.45
|
||||
'1': 0x0002,
|
||||
'one': 0x0002,
|
||||
1: 0x0002,
|
||||
# at least 1 extension defined in 15444-2 (Part-2)
|
||||
'2': 0x8000,
|
||||
2: 0x8000,
|
||||
'two': 0x8000,
|
||||
# 2K cinema profile defined in 15444-1 AMD1
|
||||
'cinema_2k': 0x0003,
|
||||
# 4K cinema profile defined in 15444-1 AMD1
|
||||
'cinema_4k': 0x0004,
|
||||
# scalable 2K cinema profile defined in 15444-1 AMD2
|
||||
'cinema_s2k': 0x0005,
|
||||
# scalable 4K cinema profile defined in 15444-1 AMD2
|
||||
'cinema_s4k': 0x0006,
|
||||
# long term storage cinema profile defined in 15444-1 AMD2
|
||||
'cinema_lts': 0x0007,
|
||||
# Single Multi Tile Broadcast profile defined in 15444-1 AMD3
|
||||
'bc_single': 0x0100,
|
||||
# Multi Tile Broadcast profile defined in 15444-1 AMD3
|
||||
'bc_multi': 0x0200,
|
||||
# Multi Tile Reversible Broadcast profile defined in 15444-1 AMD3
|
||||
'bc_multi_r': 0x0300,
|
||||
# 2K Single Tile Lossy IMF profile defined in 15444-1 AMD 8
|
||||
'imf_2k': 0x0400,
|
||||
# 4K Single Tile Lossy IMF profile defined in 15444-1 AMD 8
|
||||
'imf_4k': 0x0401,
|
||||
# 8K Single Tile Lossy IMF profile defined in 15444-1 AMD 8
|
||||
'imf_8k': 0x0402,
|
||||
# 2K Single/Multi Tile Reversible IMF profile defined in 15444-1 AMD 8
|
||||
'imf_2k_r': 0x0403,
|
||||
# 4K Single/Multi Tile Reversible IMF profile defined in 15444-1 AMD 8
|
||||
'imf_4k_r': 0x0800,
|
||||
# 8K Single/Multi Tile Reversible IMF profile defined in 15444-1 AMD 8
|
||||
'imf_8k_r': 0x0801,
|
||||
}
|
||||
# no profile, conform to 15444-1
|
||||
OPJ_PROFILE_NONE = 0x0000
|
||||
# Profile 0 as described in 15444-1,Table A.45
|
||||
OPJ_PROFILE_0 = 0x0001
|
||||
# Profile 1 as described in 15444-1,Table A.45
|
||||
OPJ_PROFILE_1 = 0x0002
|
||||
# At least 1 extension defined in 15444-2 (Part-2)
|
||||
OPJ_PROFILE_PART2 = 0x8000
|
||||
# 2K cinema profile defined in 15444-1 AMD1
|
||||
OPJ_PROFILE_CINEMA_2K = 0x0003
|
||||
# 4K cinema profile defined in 15444-1 AMD1
|
||||
OPJ_PROFILE_CINEMA_4K = 0x0004
|
||||
# Scalable 2K cinema profile defined in 15444-1 AMD2
|
||||
OPJ_PROFILE_CINEMA_S2K = 0x0005
|
||||
# Scalable 4K cinema profile defined in 15444-1 AMD2
|
||||
OPJ_PROFILE_CINEMA_S4K = 0x0006
|
||||
# Long term storage cinema profile defined in 15444-1 AMD2
|
||||
OPJ_PROFILE_CINEMA_LTS = 0x0007
|
||||
# Single Tile Broadcast profile defined in 15444-1 AMD3
|
||||
OPJ_PROFILE_BC_SINGLE = 0x0100
|
||||
# Multi Tile Broadcast profile defined in 15444-1 AMD3
|
||||
OPJ_PROFILE_BC_MULTI = 0x0200
|
||||
# Multi Tile Reversible Broadcast profile defined in 15444-1 AMD3
|
||||
OPJ_PROFILE_BC_MULTI_R = 0x0300
|
||||
# 2K Single Tile Lossy IMF profile defined in 15444-1 AMD 8
|
||||
OPJ_PROFILE_IMF_2K = 0x0400
|
||||
# 4K Single Tile Lossy IMF profile defined in 15444-1 AMD 8
|
||||
OPJ_PROFILE_IMF_4K = 0x0401
|
||||
# 8K Single Tile Lossy IMF profile defined in 15444-1 AMD 8
|
||||
OPJ_PROFILE_IMF_8K = 0x0402
|
||||
# 2K Single/Multi Tile Reversible IMF profile defined in 15444-1 AMD 8
|
||||
OPJ_PROFILE_IMF_2K_R = 0x0403
|
||||
# 4K Single/Multi Tile Reversible IMF profile defined in 15444-1 AMD 8
|
||||
OPJ_PROFILE_IMF_4K_R = 0x0800
|
||||
# 8K Single/Multi Tile Reversible IMF profile defined in 15444-1 AMD 8
|
||||
OPJ_PROFILE_IMF_8K_R = 0x0801
|
||||
|
||||
# JPEG 2000 codestream and component size limits in cinema profiles
|
||||
#
|
||||
|
|
|
|||
|
|
@ -180,28 +180,28 @@ class Jp2k(Jp2kBox):
|
|||
if re.match("2.0", version.openjpeg_version) is not None:
|
||||
# 2.0 API
|
||||
if fps == 24:
|
||||
cparams.cp_cinema = core.CINEMA_MODE['cinema2k_24']
|
||||
cparams.cp_cinema = core.OPJ_CINEMA_2K_24
|
||||
else:
|
||||
cparams.cp_cinema = core.CINEMA_MODE['cinema2k_48']
|
||||
cparams.cp_cinema = core.OPJ_CINEMA_2K_48
|
||||
else:
|
||||
# 2.1 API
|
||||
if fps == 24:
|
||||
cparams.rsiz = core.PROFILE['cinema_2k']
|
||||
cparams.max_comp_size = core.CINEMA_24_COMP
|
||||
cparams.max_cs_size = core.CINEMA_24_CS
|
||||
cparams.rsiz = core.OPJ_PROFILE_CINEMA_2K
|
||||
cparams.max_comp_size = core.OPJ_CINEMA_24_COMP
|
||||
cparams.max_cs_size = core.OPJ_CINEMA_24_CS
|
||||
else:
|
||||
cparams.rsiz = core.PROFILE['cinema_2k']
|
||||
cparams.max_comp_size = core.CINEMA_48_COMP
|
||||
cparams.max_cs_size = core.CINEMA_48_CS
|
||||
cparams.rsiz = core.OPJ_PROFILE_CINEMA_2K
|
||||
cparams.max_comp_size = core.OPJ_CINEMA_48_COMP
|
||||
cparams.max_cs_size = core.OPJ_CINEMA_48_CS
|
||||
|
||||
else:
|
||||
# cinema4k
|
||||
if re.match("2.0", version.openjpeg_version) is not None:
|
||||
# 2.0 API
|
||||
cparams.cp_cinema = core.CINEMA_MODE['cinema4k_24']
|
||||
cparams.cp_cinema = core.OPJ_CINEMA_4K_24
|
||||
else:
|
||||
# 2.1 API
|
||||
cparams.rsiz = core.PROFILE['cinema_4k']
|
||||
cparams.rsiz = core.OPJ_PROFILE_CINEMA_4K
|
||||
|
||||
return
|
||||
|
||||
|
|
@ -1642,9 +1642,17 @@ def _populate_image_struct(cparams, image, imgdata):
|
|||
|
||||
# Stage the image data to the openjpeg data structure.
|
||||
for k in range(0, num_comps):
|
||||
if cparams.cp_cinema:
|
||||
image.contents.comps[k].prec = 12
|
||||
image.contents.comps[k].bpp = 12
|
||||
if re.match("2.0", version.openjpeg_version) is not None:
|
||||
# 2.0 API
|
||||
if cparams.cp_cinema:
|
||||
image.contents.comps[k].prec = 12
|
||||
image.contents.comps[k].bpp = 12
|
||||
else:
|
||||
# 2.1 API
|
||||
if cparams.rsiz in (core.OPJ_PROFILE_CINEMA_2K,
|
||||
core.OPJ_PROFILE_CINEMA_4K):
|
||||
image.contents.comps[k].prec = 12
|
||||
image.contents.comps[k].bpp = 12
|
||||
|
||||
layer = np.ascontiguousarray(imgdata[:, :, k], dtype=np.int32)
|
||||
dest = image.contents.comps[k].data
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import re
|
|||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
import warnings
|
||||
|
||||
try:
|
||||
import skimage.io
|
||||
|
|
@ -156,7 +157,10 @@ class TestSuiteWriteCinema(unittest.TestCase):
|
|||
data = skimage.io.imread(infile)
|
||||
with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile:
|
||||
j = Jp2k(tfile.name, 'wb')
|
||||
j.write(data, cinema4k=True)
|
||||
with warnings.catch_warnings():
|
||||
# Just turn off warnings.
|
||||
warnings.simplefilter("ignore")
|
||||
j.write(data, cinema4k=True)
|
||||
|
||||
codestream = j.get_codestream()
|
||||
self.check_cinema4k_codestream(codestream, (4096, 2160))
|
||||
|
|
@ -216,7 +220,10 @@ class TestSuiteWriteCinema(unittest.TestCase):
|
|||
data = skimage.io.imread(infile)
|
||||
with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile:
|
||||
j = Jp2k(tfile.name, 'wb')
|
||||
j.write(data, cinema2k=48)
|
||||
with warnings.catch_warnings():
|
||||
# Just turn off warnings.
|
||||
warnings.simplefilter("ignore")
|
||||
j.write(data, cinema2k=48)
|
||||
|
||||
codestream = j.get_codestream()
|
||||
self.check_cinema2k_codestream(codestream, (1998, 1080))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue