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