Skip to content

Commit 646cf51

Browse files
authored
Merge branch 'main' into feature/add_rgba_for_metal
2 parents 7b611ef + 4944d6e commit 646cf51

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+2995
-1071
lines changed

docs/api/python/src/pyopencolorio_gradingprimary.rst

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,42 @@
66
:members:
77
:undoc-members:
88
:special-members: __init__, __str__
9+
10+
.. attribute:: brightness
11+
:type: GradingRGBM
12+
13+
.. attribute:: clampBlack
14+
:type: float
15+
16+
.. attribute:: clampWhite
17+
:type: float
18+
19+
.. attribute:: contrast
20+
:type: GradingRGBM
21+
22+
.. attribute:: exposure
23+
:type: GradingRGBM
24+
25+
.. attribute:: gain
26+
:type: GradingRGBM
27+
28+
.. attribute:: gamma
29+
:type: GradingRGBM
30+
31+
.. attribute:: lift
32+
:type: GradingRGBM
33+
34+
.. attribute:: offset
35+
:type: GradingRGBM
36+
37+
.. attribute:: pivot
38+
:type: float
39+
40+
.. attribute:: pivotBlack
41+
:type: float
42+
43+
.. attribute:: pivotWhite
44+
:type: float
45+
46+
.. attribute:: saturation
47+
:type: float

docs/guides/using_ocio/compatible_software.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,9 +334,12 @@ PhotoFlow supports OCIO via a dedicated tool that can load a given configuration
334334
Website : `<https://github.com/aferrero2707/PhotoFlow>`__
335335

336336

337-
Photoshop
337+
Photoshop (beta)
338338
*********
339+
OCIO can be enabled via a technology preview checkbox in preferences. For more details see `OpenColorIO and 32-bit Editing now available in Photoshop Beta <https://community.adobe.com/t5/photoshop-beta-discussions/new-feature-opencolorio-and-32-bit-editing-now-available-in-photoshop-beta/td-p/14767506>`__.
339340

341+
Photoshop
342+
*********
340343
OpenColorIO display luts can be exported as ICC profiles for use in photoshop. The core idea is to create an .icc profile, with a valid description, and then to save it to the proper OS icc directory. (On OSX, ``~/Library/ColorSync/Profiles/``). Upon a Photoshop relaunch, Edit->Assign Profile, and then select your new OCIO lut.
341344

342345
Website : `<https://www.adobe.com/products/photoshop.html>`__

src/OpenColorIO/OCIOYaml.cpp

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4034,7 +4034,7 @@ inline void load(const YAML::Node & node, ViewingRulesRcPtr & vr)
40344034
catch (Exception & ex)
40354035
{
40364036
std::ostringstream os;
4037-
os << "File rules: " << ex.what();
4037+
os << "Viewing rules: " << ex.what();
40384038
throwError(node, os.str().c_str());
40394039
}
40404040
}
@@ -4658,13 +4658,15 @@ inline void load(const YAML::Node& node, ConfigRcPtr & config, const char* filen
46584658
config->setWorkingDir(configrootdir.c_str());
46594659
}
46604660

4661-
auto defaultCS = config->getColorSpace(ROLE_DEFAULT);
46624661
if (!fileRulesFound)
46634662
{
46644663
if (config->getMajorVersion() >= 2)
46654664
{
4666-
if (!defaultCS)
4665+
if (!config->hasRole(ROLE_DEFAULT))
46674666
{
4667+
// Note that no validation of the default color space is done (e.g. to check that
4668+
// it exists in the config) in order to enable loading configs that are only
4669+
// partially complete. The caller may use config->validate() after, if desired.
46684670
throwError(node, "The config must contain either a Default file rule or "
46694671
"the 'default' role.");
46704672
}
@@ -4683,6 +4685,7 @@ inline void load(const YAML::Node& node, ConfigRcPtr & config, const char* filen
46834685
else
46844686
{
46854687
// If default role is also defined.
4688+
auto defaultCS = config->getColorSpace(ROLE_DEFAULT);
46864689
if (defaultCS)
46874690
{
46884691
const auto defaultRule = fileRules->getNumEntries() - 1;
@@ -4815,18 +4818,11 @@ inline void save(YAML::Emitter & out, const Config & config)
48154818
const char* role = config.getRoleName(i);
48164819
if(role && *role)
48174820
{
4818-
ConstColorSpaceRcPtr colorspace = config.getColorSpace(role);
4819-
if(colorspace)
4820-
{
4821-
out << YAML::Key << role;
4822-
out << YAML::Value << config.getColorSpace(role)->getName();
4823-
}
4824-
else
4825-
{
4826-
std::ostringstream os;
4827-
os << "Colorspace associated to the role '" << role << "', does not exist.";
4828-
throw Exception(os.str().c_str());
4829-
}
4821+
// Note that no validation of the name strings is done here (e.g. to check that
4822+
// they exist in the config) in order to enable serializing configs that are only
4823+
// partially complete. The caller may use config->validate() first, if desired.
4824+
out << YAML::Key << role;
4825+
out << YAML::Value << config.getRoleColorSpace(i);
48304826
}
48314827
}
48324828
out << YAML::EndMap;

src/apps/ocioconvert/main.cpp

Lines changed: 109 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -49,34 +49,40 @@ int main(int argc, const char **argv)
4949
std::vector<std::string> intAttrs;
5050
std::vector<std::string> stringAttrs;
5151

52-
bool usegpu = false;
53-
bool usegpuLegacy = false;
54-
bool outputgpuInfo = false;
55-
bool verbose = false;
56-
bool help = false;
57-
bool useLut = false;
58-
bool useDisplayView = false;
59-
bool useInvertView = false;
52+
bool usegpu = false;
53+
bool usegpuLegacy = false;
54+
bool outputgpuInfo = false;
55+
bool verbose = false;
56+
bool help = false;
57+
bool useLut = false;
58+
bool useDisplayView = false;
59+
bool useInvertView = false;
60+
bool useNamedTransform = false;
61+
bool useInvNamedTransform = false;
6062

6163
ap.options("ocioconvert -- apply colorspace transform to an image \n\n"
6264
"usage: ocioconvert [options] inputimage inputcolorspace outputimage outputcolorspace\n"
6365
" or: ocioconvert [options] --lut lutfile inputimage outputimage\n"
6466
" or: ocioconvert [options] --view inputimage inputcolorspace outputimage displayname viewname\n"
65-
" or: ocioconvert [options] --invertview inputimage displayname viewname outputimage outputcolorspace\n\n",
67+
" or: ocioconvert [options] --invertview inputimage displayname viewname outputimage outputcolorspace\n"
68+
" or: ocioconvert [options] --namedtransform transformname inputimage outputimage\n"
69+
" or: ocioconvert [options] --invnamedtransform transformname inputimage outputimage\n\n",
6670
"%*", parse_end_args, "",
6771
"<SEPARATOR>", "Options:",
68-
"--lut", &useLut, "Convert using a LUT rather than a config file",
69-
"--view", &useDisplayView, "Convert to a (display,view) pair rather than to "
70-
"an output color space",
71-
"--invertview", &useInvertView, "Convert from a (display,view) pair rather than "
72-
"from a color space",
73-
"--gpu", &usegpu, "Use GPU color processing instead of CPU (CPU is the default)",
74-
"--gpulegacy", &usegpuLegacy, "Use the legacy (i.e. baked) GPU color processing "
75-
"instead of the CPU one (--gpu is ignored)",
76-
"--gpuinfo", &outputgpuInfo, "Output the OCIO shader program",
77-
"--h", &help, "Display the help and exit",
78-
"--help", &help, "Display the help and exit",
79-
"-v" , &verbose, "Display general information",
72+
"--lut", &useLut, "Convert using a LUT rather than a config file",
73+
"--view", &useDisplayView, "Convert to a (display,view) pair rather than to "
74+
"an output color space",
75+
"--invertview", &useInvertView, "Convert from a (display,view) pair rather than "
76+
"from a color space",
77+
"--namedtransform", &useNamedTransform, "Convert using a named transform in the forward direction",
78+
"--invnamedtransform", &useInvNamedTransform, "Convert using a named transform in the inverse direction",
79+
"--gpu", &usegpu, "Use GPU color processing instead of CPU (CPU is the default)",
80+
"--gpulegacy", &usegpuLegacy, "Use the legacy (i.e. baked) GPU color processing "
81+
"instead of the CPU one (--gpu is ignored)",
82+
"--gpuinfo", &outputgpuInfo, "Output the OCIO shader program",
83+
"--h", &help, "Display the help and exit",
84+
"--help", &help, "Display the help and exit",
85+
"-v" , &verbose, "Display general information",
8086
"<SEPARATOR>", "\nOpenImageIO or OpenEXR options:",
8187
"--float-attribute %L", &floatAttrs, "\"name=float\" pair defining OIIO float attribute "
8288
"for outputimage",
@@ -109,15 +115,16 @@ int main(int argc, const char **argv)
109115
}
110116
#endif // OCIO_GPU_ENABLED
111117

112-
const char * inputimage = nullptr;
113-
const char * inputcolorspace = nullptr;
114-
const char * outputimage = nullptr;
115-
const char * outputcolorspace = nullptr;
116-
const char * lutFile = nullptr;
117-
const char * display = nullptr;
118-
const char * view = nullptr;
119-
120-
if (!useLut && !useDisplayView && !useInvertView)
118+
const char * inputimage = nullptr;
119+
const char * inputcolorspace = nullptr;
120+
const char * outputimage = nullptr;
121+
const char * outputcolorspace = nullptr;
122+
const char * lutFile = nullptr;
123+
const char * display = nullptr;
124+
const char * view = nullptr;
125+
const char * namedtransform = nullptr;
126+
127+
if (!useLut && !useDisplayView && !useInvertView && !useNamedTransform && !useInvNamedTransform)
121128
{
122129
if (args.size() != 4)
123130
{
@@ -186,6 +193,50 @@ int main(int argc, const char **argv)
186193
outputimage = args[3].c_str();
187194
outputcolorspace = args[4].c_str();
188195
}
196+
else if (useNamedTransform)
197+
{
198+
if (useLut || useDisplayView || useInvertView || useInvNamedTransform)
199+
{
200+
std::cerr << "ERROR: Option namedtransform can't be used with lut, view, invertview, \
201+
or invnamedtransform at the same time." << std::endl;
202+
ap.usage();
203+
exit(1);
204+
}
205+
206+
if (args.size() != 3)
207+
{
208+
std::cerr << "ERROR: Expecting 3 arguments for --namedtransform option, found "
209+
<< args.size() << "." << std::endl;
210+
ap.usage();
211+
exit(1);
212+
}
213+
214+
namedtransform = args[0].c_str();
215+
inputimage = args[1].c_str();
216+
outputimage = args[2].c_str();
217+
}
218+
else if (useInvNamedTransform)
219+
{
220+
if (useLut || useDisplayView || useInvertView || useNamedTransform)
221+
{
222+
std::cerr << "ERROR: Option invnamedtransform can't be used with lut, view, invertview, \
223+
or namedtransform at the same time." << std::endl;
224+
ap.usage();
225+
exit(1);
226+
}
227+
228+
if (args.size() != 3)
229+
{
230+
std::cerr << "ERROR: Expecting 3 arguments for --invnamedtransform option, found "
231+
<< args.size() << "." << std::endl;
232+
ap.usage();
233+
exit(1);
234+
}
235+
236+
namedtransform = args[0].c_str();
237+
inputimage = args[1].c_str();
238+
outputimage = args[2].c_str();
239+
}
189240

190241
if (verbose)
191242
{
@@ -343,6 +394,34 @@ int main(int argc, const char **argv)
343394
t->setView(view);
344395
processor = config->getProcessor(t, OCIO::TRANSFORM_DIR_INVERSE);
345396
}
397+
else if (useNamedTransform)
398+
{
399+
auto nt = config->getNamedTransform(namedtransform);
400+
401+
if (nt)
402+
{
403+
processor = config->getProcessor(nt, OCIO::TRANSFORM_DIR_FORWARD);
404+
}
405+
else
406+
{
407+
std::cout << "ERROR: Could not get NamedTransform " << namedtransform << std::endl;
408+
exit(1);
409+
}
410+
}
411+
else if (useInvNamedTransform)
412+
{
413+
auto nt = config->getNamedTransform(namedtransform);
414+
415+
if (nt)
416+
{
417+
processor = config->getProcessor(nt, OCIO::TRANSFORM_DIR_INVERSE);
418+
}
419+
else
420+
{
421+
std::cout << "ERROR: Could not get NamedTransform " << namedtransform << std::endl;
422+
exit(1);
423+
}
424+
}
346425
else
347426
{
348427
processor = config->getProcessor(inputcolorspace, outputcolorspace);

src/apps/ocioview/main.py

Lines changed: 4 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,17 @@
11
# SPDX-License-Identifier: BSD-3-Clause
22
# Copyright Contributors to the OpenColorIO Project.
33

4-
import logging
5-
import os
64
import sys
7-
from pathlib import Path
85

9-
import PyOpenColorIO as ocio
10-
from PySide6 import QtCore, QtGui, QtWidgets
11-
12-
import ocioview.log_handlers # Import to initialize logging
136
from ocioview.main_window import OCIOView
14-
from ocioview.style import QSS, DarkPalette
15-
16-
17-
ROOT_DIR = Path(__file__).resolve().parent.parent
18-
FONTS_DIR = ROOT_DIR / "fonts"
19-
20-
21-
def excepthook(exc_type, exc_value, exc_tb):
22-
"""Log uncaught errors"""
23-
if issubclass(exc_type, KeyboardInterrupt):
24-
sys.__excepthook__(exc_type, exc_value, exc_tb)
25-
return
26-
logging.error(f"{exc_value}", exc_info=exc_value)
7+
from ocioview.setup import setup_app
278

289

2910
if __name__ == "__main__":
30-
sys.excepthook = excepthook
31-
32-
# OpenGL core profile needed on macOS to access programmatic pipeline
33-
gl_format = QtGui.QSurfaceFormat()
34-
gl_format.setProfile(QtGui.QSurfaceFormat.CoreProfile)
35-
gl_format.setSwapInterval(1)
36-
gl_format.setVersion(4, 0)
37-
QtGui.QSurfaceFormat.setDefaultFormat(gl_format)
38-
39-
# Create app
40-
app = QtWidgets.QApplication(sys.argv)
41-
42-
# Initialize style
43-
app.setStyle("fusion")
44-
app.setPalette(DarkPalette())
45-
app.setStyleSheet(QSS)
46-
app.setEffectEnabled(QtCore.Qt.UI_AnimateCombo, False)
47-
48-
font = app.font()
49-
font.setPointSize(8)
50-
app.setFont(font)
51-
52-
# Clean OCIO environment to isolate working config
53-
for env_var in (
54-
ocio.OCIO_CONFIG_ENVVAR,
55-
ocio.OCIO_ACTIVE_VIEWS_ENVVAR,
56-
ocio.OCIO_ACTIVE_DISPLAYS_ENVVAR,
57-
ocio.OCIO_INACTIVE_COLORSPACES_ENVVAR,
58-
ocio.OCIO_OPTIMIZATION_FLAGS_ENVVAR,
59-
ocio.OCIO_USER_CATEGORIES_ENVVAR,
60-
):
61-
if env_var in os.environ:
62-
del os.environ[env_var]
11+
app = setup_app()
6312

6413
# Start ocioview
65-
ocioview = OCIOView()
66-
ocioview.show()
14+
ocio_view = OCIOView()
15+
ocio_view.show()
6716

6817
sys.exit(app.exec_())

0 commit comments

Comments
 (0)