diff --git a/src/doc/imageioapi.md b/src/doc/imageioapi.md index 7afbab7fce..65a090848a 100644 --- a/src/doc/imageioapi.md +++ b/src/doc/imageioapi.md @@ -257,6 +257,20 @@ just exist in the OIIO namespace as general utilities. (See :::{doxygenfunction} OIIO::equivalent_colorspace ::: +(sec-colorspaceproperties)= + +## Color space properties + +`ColorConfig::get_chromaticities()` and `ColorConfig::get_transfer_gamma()` +report a color space's primaries and transfer function. See +{ref}`sec-pythoncolorconfig` for the Python bindings. + +:::{doxygenfunction} OIIO::ColorConfig::get_chromaticities +::: + +:::{doxygenfunction} OIIO::ColorConfig::get_transfer_gamma +::: + > (sec-startupshutdown)= ## Startup and Shutdown diff --git a/src/doc/pythonbindings.md b/src/doc/pythonbindings.md index afd8947c48..cb07c6c7d5 100644 --- a/src/doc/pythonbindings.md +++ b/src/doc/pythonbindings.md @@ -4040,6 +4040,36 @@ is provided for minimal color support. % TODO: The documentation for this class is incomplete. +:::{py:method} get_chromaticities (colorspace) +Get the RGB primaries and white point of a color space with a known Color +Interop ID, as `get_color_interop_id()` finds it: a sequence of eight floats +(Rx, Ry, Gx, Gy, Bx, By, Wx, Wy, CIE 1931 xy), or None if they are unknown. + +Example: + +```python +xy = colorconfig.get_chromaticities("ACEScg") +if xy: + rx, ry, gx, gy, bx, by, wx, wy = xy +``` + +This function was added in OpenImageIO 3.2. +::: + +:::{py:method} get_transfer_gamma (colorspace) +Get the exponent of a color space's transfer function if it decodes as a pure +power, 1.0 if it is linear, or 0 if it is neither or is unknown. Piecewise +curves such as sRGB's report 0. + +Example: + +```python +gamma = colorconfig.get_transfer_gamma("g22_rec709_scene") # 2.2 +``` + +This function was added in OpenImageIO 3.2. +::: + :::{py:method} get_cicp (colorspace) Find CICP code corresponding to the colorspace. Return a sequence of 4 ints, or None if not found. diff --git a/src/include/OpenImageIO/color.h b/src/include/OpenImageIO/color.h index 865b32ea68..db20767f2f 100644 --- a/src/include/OpenImageIO/color.h +++ b/src/include/OpenImageIO/color.h @@ -434,6 +434,26 @@ class OIIO_API ColorConfig { OIIO_NODISCARD string_view get_color_interop_id(string_view colorspace) const; + /// Get the RGB primaries and white point of a color space with a known + /// Color Interop ID + /// (https://github.com/AcademySoftwareFoundation/ColorInterop), as + /// `get_color_interop_id()` finds it: eight floats (Rx, Ry, Gx, Gy, Bx, + /// By, Wx, Wy, CIE 1931 xy), or an empty span if they are unknown. The + /// span points into OIIO's own table, so it stays valid. + /// + /// @version 3.2 + OIIO_NODISCARD cspan get_chromaticities(string_view colorspace) const; + + /// Get the exponent of a color space's transfer function if it decodes + /// as a pure power, 1.0 if it is linear, or 0 if it is neither or is + /// unknown. Piecewise curves such as sRGB's report 0. Like + /// `get_chromaticities()`, it answers for a known Color Interop ID, and + /// it reports 1.0 for any color space whose config declares a linear + /// encoding. + /// + /// @version 3.2 + OIIO_NODISCARD float get_transfer_gamma(string_view colorspace) const; + /// Find color interop ID corresponding to the CICP code. /// Returns empty string if not found. /// diff --git a/src/libOpenImageIO/color_ocio.cpp b/src/libOpenImageIO/color_ocio.cpp index 30b37d2fa8..80b528c525 100644 --- a/src/libOpenImageIO/color_ocio.cpp +++ b/src/libOpenImageIO/color_ocio.cpp @@ -215,6 +215,13 @@ class ColorConfig::Impl { OCIO::ConfigRcPtr config_; OCIO::ConfigRcPtr builtinconfig_; + // A color space's chromaticities (in the ColorInteropID table, or null) + // and transfer function gamma. + struct Properties { + const float* xy = nullptr; + float gamma = 0.0f; + }; + private: std::vector colorspaces; std::string scene_linear_alias; // Alias for a scene-linear color space @@ -305,6 +312,9 @@ class ColorConfig::Impl { return handle; } + // The properties get_chromaticities() and get_transfer_gamma() report. + Properties properties(string_view colorspace) const; + int getNumColorSpaces() const { return (int)colorspaces.size(); } const char* getColorSpaceNameByIndex(int index) const @@ -2339,23 +2349,53 @@ enum class CICPRange : int { Full = 1, }; +// Chromaticities (Rx, Ry, Gx, Gy, Bx, By, Wx, Wy) of the published gamuts. +constexpr float xy_rec709[] = { .64f, .33f, .30f, .60f, + .15f, .06f, .3127f, .329f }; +constexpr float xy_p3d65[] = { .68f, .32f, .265f, .69f, + .15f, .06f, .3127f, .329f }; +constexpr float xy_rec2020[] = { .708f, .292f, .17f, .797f, + .131f, .046f, .3127f, .329f }; +constexpr float xy_adobergb[] = { .64f, .33f, .21f, .71f, + .15f, .06f, .3127f, .329f }; +constexpr float xy_ap0[] = { .7347f, .2653f, 0.0f, 1.0f, + .0001f, -.077f, .32168f, .33767f }; +constexpr float xy_ap1[] = { .713f, .293f, .165f, .83f, + .128f, .044f, .32168f, .33767f }; +// CIE XYZ taken as RGB, so R = G = B is illuminant E. +constexpr float xy_xyz[] = { 1.0f, 0.0f, 0.0f, 1.0f, + 0.0f, 0.0f, 1.0f / 3, 1.0f / 3 }; + +// A color interop ID with what OIIO knows about it: a legacy alias for older +// configs, its CICP code if it has one, and its chromaticities (Rx, Ry, Gx, Gy, +// Bx, By, Wx, Wy) and gamma if it has RGB primaries. Gamma is 1 for linear, +// the exponent of a pure power, or 0 for any other curve (sRGB, extended +// sRGB, PQ, HLG). struct ColorInteropID { - constexpr ColorInteropID(const char* interop_id, const char* legacy_alias) + constexpr ColorInteropID(const char* interop_id, const char* legacy_alias, + const float* chromaticities = nullptr, + float gamma = 0.0f) : interop_id(interop_id) , legacy_alias(legacy_alias) , cicp({ 0, 0, 0, 0 }) , has_cicp(false) + , chromaticities(chromaticities) + , gamma(gamma) { } constexpr ColorInteropID(const char* interop_id, const char* legacy_alias, CICPPrimaries primaries, CICPTransfer transfer, - CICPMatrix matrix) + CICPMatrix matrix, + const float* chromaticities = nullptr, + float gamma = 0.0f) : interop_id(interop_id) , legacy_alias(legacy_alias) , cicp({ int(primaries), int(transfer), int(matrix), int(CICPRange::Full) }) , has_cicp(true) + , chromaticities(chromaticities) + , gamma(gamma) { } @@ -2363,6 +2403,8 @@ struct ColorInteropID { const char* legacy_alias; std::array cicp; bool has_cicp; + const float* chromaticities; + float gamma; }; // Mapping between color interop ID and CICP, based on Color Interop Forum @@ -2371,28 +2413,28 @@ constexpr ColorInteropID color_interop_ids[] = { // Scene referred interop IDs first so they are the default in automatic // conversion from CICP to interop ID. Some are not display color spaces // at all, but can be represented by CICP anyway. - { "lin_ap1_scene", "lin_ap1" }, - { "lin_ap0_scene", "lin_ap0" }, + { "lin_ap1_scene", "lin_ap1", xy_ap1, 1.0f }, + { "lin_ap0_scene", "lin_ap0", xy_ap0, 1.0f }, { "lin_rec709_scene", "lin_rec709", CICPPrimaries::Rec709, - CICPTransfer::Linear, CICPMatrix::BT709 }, + CICPTransfer::Linear, CICPMatrix::BT709, xy_rec709, 1.0f }, { "lin_p3d65_scene", "lin_p3d65", CICPPrimaries::P3D65, - CICPTransfer::Linear, CICPMatrix::BT709 }, + CICPTransfer::Linear, CICPMatrix::BT709, xy_p3d65, 1.0f }, { "lin_rec2020_scene", "lin_rec2020", CICPPrimaries::Rec2020, - CICPTransfer::Linear, CICPMatrix::Rec2020_CL }, - { "lin_adobergb_scene", "lin_adobergb" }, + CICPTransfer::Linear, CICPMatrix::Rec2020_CL, xy_rec2020, 1.0f }, + { "lin_adobergb_scene", "lin_adobergb", xy_adobergb, 1.0f }, { "lin_ciexyzd65_scene", "cie_xyz_d65", CICPPrimaries::XYZD65, - CICPTransfer::Linear, CICPMatrix::Unspecified }, + CICPTransfer::Linear, CICPMatrix::Unspecified, xy_xyz, 1.0f }, { "srgb_rec709_scene", "srgb_texture", CICPPrimaries::Rec709, - CICPTransfer::sRGB, CICPMatrix::BT709 }, - { "g24_rec709_scene", "g24_rec709" }, + CICPTransfer::sRGB, CICPMatrix::BT709, xy_rec709, 0.0f }, + { "g24_rec709_scene", "g24_rec709", xy_rec709, 2.4f }, { "g22_rec709_scene", "g22_rec709", CICPPrimaries::Rec709, - CICPTransfer::Gamma22, CICPMatrix::BT709 }, - { "g18_rec709_scene", "g18_rec709" }, - { "srgb_ap1_scene", "srgb_ap1" }, - { "g22_ap1_scene", "g22_ap1" }, + CICPTransfer::Gamma22, CICPMatrix::BT709, xy_rec709, 2.2f }, + { "g18_rec709_scene", "g18_rec709", xy_rec709, 1.8f }, + { "srgb_ap1_scene", "srgb_ap1", xy_ap1, 0.0f }, + { "g22_ap1_scene", "g22_ap1", xy_ap1, 2.2f }, { "srgb_p3d65_scene", "srgb_p3d65", CICPPrimaries::P3D65, - CICPTransfer::sRGB, CICPMatrix::BT709 }, - { "g22_adobergb_scene", nullptr }, + CICPTransfer::sRGB, CICPMatrix::BT709, xy_p3d65, 0.0f }, + { "g22_adobergb_scene", nullptr, xy_adobergb, 563.0f / 256.0f }, { "data", nullptr }, { "unknown", nullptr }, @@ -2400,37 +2442,39 @@ constexpr ColorInteropID color_interop_ids[] = { // The linear displays share their scene rows' codes, which come first, // so CICP input still reads as the scene identity. { "lin_rec709_display", nullptr, CICPPrimaries::Rec709, - CICPTransfer::Linear, CICPMatrix::BT709 }, + CICPTransfer::Linear, CICPMatrix::BT709, xy_rec709, 1.0f }, { "lin_p3d65_display", nullptr, CICPPrimaries::P3D65, CICPTransfer::Linear, - CICPMatrix::BT709 }, + CICPMatrix::BT709, xy_p3d65, 1.0f }, { "lin_rec2020_display", nullptr, CICPPrimaries::Rec2020, - CICPTransfer::Linear, CICPMatrix::Rec2020_CL }, + CICPTransfer::Linear, CICPMatrix::Rec2020_CL, xy_rec2020, 1.0f }, { "srgb_rec709_display", "srgb_display", CICPPrimaries::Rec709, - CICPTransfer::sRGB, CICPMatrix::BT709 }, + CICPTransfer::sRGB, CICPMatrix::BT709, xy_rec709, 0.0f }, // Not all software interprets this CICP the same, see the // "QuickTime Gamma Shift" issue. We follow the CIF recommendation and // interpret it as BT.1886. { "g24_rec709_display", "rec1886_rec709_display", CICPPrimaries::Rec709, - CICPTransfer::BT709, CICPMatrix::BT709 }, + CICPTransfer::BT709, CICPMatrix::BT709, xy_rec709, 2.4f }, { "srgb_p3d65_display", "displayp3_display", CICPPrimaries::P3D65, - CICPTransfer::sRGB, CICPMatrix::BT709 }, + CICPTransfer::sRGB, CICPMatrix::BT709, xy_p3d65, 0.0f }, { "srgbe_p3d65_display", "displayp3_hdr_display", CICPPrimaries::P3D65, - CICPTransfer::sRGB, CICPMatrix::BT709 }, + CICPTransfer::sRGB, CICPMatrix::BT709, xy_p3d65, 0.0f }, { "pq_p3d65_display", "st2084_p3d65_display", CICPPrimaries::P3D65, - CICPTransfer::PQ, CICPMatrix::Rec2020_NCL }, + CICPTransfer::PQ, CICPMatrix::Rec2020_NCL, xy_p3d65, 0.0f }, { "pq_rec2020_display", "rec2100_pq_display", CICPPrimaries::Rec2020, - CICPTransfer::PQ, CICPMatrix::Rec2020_NCL }, + CICPTransfer::PQ, CICPMatrix::Rec2020_NCL, xy_rec2020, 0.0f }, { "hlg_rec2020_display", "rec2100_hlg_display", CICPPrimaries::Rec2020, - CICPTransfer::HLG, CICPMatrix::Rec2020_NCL }, - // No CICP mapping to keep previous behavior unchanged, as Gamma 2.2 - // display is more likely meant to be written as sRGB. On read the - // scene referred interop ID will be used. - { "g22_rec709_display", nullptr - /* CICPPrimaries::Rec709, CICPTransfer::Gamma22, CICPMatrix::BT709 */ }, + CICPTransfer::HLG, CICPMatrix::Rec2020_NCL, xy_rec2020, 0.0f }, + // No CICP mapping (Rec709, Gamma22, BT709) to keep previous behavior + // unchanged, as Gamma 2.2 display is more likely meant to be written as + // sRGB. On read the scene referred interop ID will be used. + { "g22_rec709_display", nullptr, xy_rec709, 2.2f }, // No CICP code for Adobe RGB primaries. - { "g22_adobergb_display", nullptr }, + { "g22_adobergb_display", nullptr, xy_adobergb, 563.0f / 256.0f }, { "g26_p3d65_display", "p3d65_display", CICPPrimaries::P3D65, - CICPTransfer::Gamma26, CICPMatrix::BT709 }, + CICPTransfer::Gamma26, CICPMatrix::BT709, xy_p3d65, 2.6f }, + // The DCDM XYZ encodings have no properties: neither curve is a pure + // power (DCI headroom scaling precedes the 2.6 power), and no RGB + // primaries are reported for display XYZ encodings. { "g26_xyzd65_display", nullptr, CICPPrimaries::XYZD65, CICPTransfer::Gamma26, CICPMatrix::Unspecified }, { "pq_xyzd65_display", nullptr, CICPPrimaries::XYZD65, CICPTransfer::PQ, @@ -2504,6 +2548,58 @@ ColorConfig::get_cicp(string_view colorspace) const } + +ColorConfig::Impl::Properties +ColorConfig::Impl::properties(string_view colorspace) const +{ + // Identify the space as get_cicp() does, so that every name it accepts + // gives the same answer here. + const string_view interop_id = m_self->get_color_interop_id(colorspace); + OCIO::ConstColorSpaceRcPtr cs; + if (config_ && !disable_ocio && !colorspace.empty()) { + try { + cs = config_->getColorSpace(c_str(m_self->resolve(colorspace))); + } catch (const std::exception& e) { + DBG("OCIO exception looking up {}: {}\n", colorspace, e.what()); + } + } + if (cs && cs->isData()) + return {}; + const string_view encoding(cs ? cs->getEncoding() : ""); + const bool linear = encoding == "scene-linear" + || encoding == "display-linear"; + Properties result; + for (const ColorInteropID& interop : color_interop_ids) { + if (interop.chromaticities && interop_id == interop.interop_id) { + // An ID contradicting a declared linear encoding is ignored. + if (!(linear && interop.gamma != 1.0f)) + result = { interop.chromaticities, interop.gamma }; + break; + } + } + if (linear) + result.gamma = 1.0f; + return result; +} + + + +cspan +ColorConfig::get_chromaticities(string_view colorspace) const +{ + const float* xy = getImpl()->properties(colorspace).xy; + return xy ? cspan(xy, 8) : cspan(); +} + + + +float +ColorConfig::get_transfer_gamma(string_view colorspace) const +{ + return getImpl()->properties(colorspace).gamma; +} + + ////////////////////////////////////////////////////////////////////////// // // Image Processing Implementations diff --git a/src/libOpenImageIO/color_test.cpp b/src/libOpenImageIO/color_test.cpp index ba50f7bddc..65bc4a280e 100644 --- a/src/libOpenImageIO/color_test.cpp +++ b/src/libOpenImageIO/color_test.cpp @@ -196,6 +196,98 @@ test_gamma_pair_conversion() +static void +test_color_space_properties() +{ + if (!ColorConfig::supportsOpenColorIO()) + return; + + // Published IDs declared by name or alias, a linear encoding with no ID, + // one contradicting its ID, and a data space. + const std::string filename = Filesystem::temp_directory_path() + "/" + + Filesystem::unique_path() + ".ocio"; + OIIO_CHECK_ASSERT(Filesystem::write_text_file( + filename, + "ocio_profile_version: 2.3\n" + "roles: {default: ACEScg, scene_linear: ACEScg}\n" + "file_rules:\n - ! {name: Default, colorspace: default}\n" + "colorspaces:\n" + " - !\n name: ACEScg\n encoding: scene-linear\n" + " aliases: [lin_ap1_scene]\n" + " - ! {name: srgb_rec709_scene, encoding: sdr-video}\n" + " - ! {name: Adobe, aliases: [g22_adobergb_scene]}\n" + " - ! {name: Plain, encoding: scene-linear}\n" + " - !\n name: Mislabeled\n encoding: scene-linear\n" + " aliases: [g22_rec709_scene]\n" + " - ! {name: Data, isdata: true}\n" + " - ! {name: Texture, aliases: [srgb_texture]}\n")); + const float ap1[] = { .713f, .293f, .165f, .83f, + .128f, .044f, .32168f, .33767f }; + const float p3d65[] = { .68f, .32f, .265f, .69f, .15f, .06f, .3127f, .329f }; + cspan saved; + { + ColorConfig config(filename); + OIIO_CHECK_FALSE(config.has_error()); + saved = config.get_chromaticities("scene_linear"); + OIIO_CHECK_ASSERT(saved == cspan(ap1)); + OIIO_CHECK_EQUAL(config.get_transfer_gamma("scene_linear"), 1.0f); + OIIO_CHECK_EQUAL(config.get_transfer_gamma("srgb_rec709_scene"), 0.0f); + OIIO_CHECK_EQUAL(config.get_chromaticities("srgb_rec709_scene").size(), + 8); + // OIIO's built-in names resolve as they do in the other queries. + OIIO_CHECK_EQUAL(config.get_chromaticities("sRGB").size(), 8); + OIIO_CHECK_EQUAL(config.get_transfer_gamma("Adobe"), 563.0f / 256.0f); + for (auto name : { "Plain", "Mislabeled" }) { + OIIO_CHECK_EQUAL(config.get_transfer_gamma(name), 1.0f); + OIIO_CHECK_ASSERT(config.get_chromaticities(name).empty()); + } + for (auto name : { "Data", "data", "missing" }) { + OIIO_CHECK_EQUAL(config.get_transfer_gamma(name), 0.0f); + OIIO_CHECK_ASSERT(config.get_chromaticities(name).empty()); + } + // A legacy alias, and IDs this config doesn't define, answer as they + // do for get_color_interop_id() and get_cicp(). + OIIO_CHECK_EQUAL(config.get_color_interop_id("Texture"), + "srgb_rec709_scene"); + OIIO_CHECK_EQUAL(config.get_transfer_gamma("Texture"), 0.0f); + OIIO_CHECK_EQUAL(config.get_chromaticities("Texture").size(), 8); + OIIO_CHECK_EQUAL(config.get_transfer_gamma("lin_p3d65_display"), 1.0f); + OIIO_CHECK_ASSERT(config.get_chromaticities("lin_p3d65_display") + == cspan(p3d65)); + } + // The span stays valid after the config is gone. + OIIO_CHECK_ASSERT(saved == cspan(ap1)); + // OpenColorIO 2.3's built-in CG config gives its spaces only the legacy + // aliases, which identify them here too. + { + ColorConfig config("ocio://cg-config-v2.1.0_aces-v1.3_ocio-v2.3"); + OIIO_CHECK_ASSERT(config.get_chromaticities("ACEScg") + == cspan(ap1)); + OIIO_CHECK_EQUAL(config.get_chromaticities("sRGB - Texture").size(), 8); + OIIO_CHECK_EQUAL(config.get_transfer_gamma("sRGB - Texture"), 0.0f); + } + Filesystem::remove(filename); + + // OpenColorIO 2.5 reads a declared interop_id, which outranks the name. + if (ColorConfig::OpenColorIO_version_hex() >= 0x02050000) { + OIIO_CHECK_ASSERT(Filesystem::write_text_file( + filename, + "ocio_profile_version: 2.5\n" + "roles: {default: g18_rec709_scene}\n" + "file_rules:\n - ! {name: Default, colorspace: default}\n" + "colorspaces:\n - !\n name: g18_rec709_scene\n" + " interop_id: g22_ap1_scene\n")); + ColorConfig config(filename); + OIIO_CHECK_FALSE(config.has_error()); + OIIO_CHECK_EQUAL(config.get_transfer_gamma("g18_rec709_scene"), 2.2f); + OIIO_CHECK_ASSERT(config.get_chromaticities("g18_rec709_scene") + == cspan(ap1)); + Filesystem::remove(filename); + } +} + + + int main(int argc, char* argv[]) { @@ -214,6 +306,7 @@ main(int argc, char* argv[]) test_Rec709_conversion(); test_linear_display_cicp(); test_gamma_pair_conversion(); + test_color_space_properties(); return unit_test_failures != 0; } diff --git a/src/python/py_colorconfig.cpp b/src/python/py_colorconfig.cpp index ea267a8f9b..b25391da49 100644 --- a/src/python/py_colorconfig.cpp +++ b/src/python/py_colorconfig.cpp @@ -195,6 +195,24 @@ declare_colorconfig(py_module& m) } return std::nullopt; }) + .def( + "get_chromaticities", + [](const ColorConfig& self, const std::string& colorspace) + -> std::optional> { + cspan xy = self.get_chromaticities(colorspace); + if (xy.empty()) + return std::nullopt; + std::array result; + std::copy(xy.begin(), xy.end(), result.begin()); + return result; + }, + "colorspace"_a) + .def( + "get_transfer_gamma", + [](const ColorConfig& self, const std::string& colorspace) { + return self.get_transfer_gamma(colorspace); + }, + "colorspace"_a) .def("configname", &ColorConfig::configname) .def_static( "default_colorconfig", diff --git a/src/python/stubs/OpenImageIO/__init__.pyi b/src/python/stubs/OpenImageIO/__init__.pyi index 0e7de1cd65..71a13bb637 100644 --- a/src/python/stubs/OpenImageIO/__init__.pyi +++ b/src/python/stubs/OpenImageIO/__init__.pyi @@ -208,11 +208,13 @@ class ColorConfig: def getRoles(self) -> list[str]: ... def getViewNameByIndex(self, display: str = ..., *, index: typing.SupportsInt) -> str: ... def getViewNames(self, display: str = ...) -> list[str]: ... + def get_chromaticities(self, colorspace: str) -> list[float] | None: ... def get_cicp(self, *args, **kwargs): ... @overload def get_color_interop_id(self, arg0: str, /) -> str: ... @overload def get_color_interop_id(self, arg0, /) -> str: ... + def get_transfer_gamma(self, colorspace: str) -> float: ... def geterror(self) -> str: ... def isColorSpaceActive(self, name: str) -> bool: ... def parseColorSpaceFromString(self, arg0: str, /) -> str: ... diff --git a/testsuite/python-colorconfig/ref/out-ocio232.txt b/testsuite/python-colorconfig/ref/out-ocio232.txt index 7bdc8137a1..d6cd123fb8 100644 --- a/testsuite/python-colorconfig/ref/out-ocio232.txt +++ b/testsuite/python-colorconfig/ref/out-ocio232.txt @@ -65,5 +65,10 @@ ociodisplay #2 (apply default display/view again): [[[-2.123 0.671 0.8037]] ociodisplay #3 (inverse look): [[[-2.252 0.6714 0.8037]]] (sRGB (~2.22) - Display) ociodisplay #4 (forwards look): [[[-2.123 0.671 0.8037]]] (sRGB (~2.22) - Display) ociodisplay #5 (inverse look + forwards look): [[[-2.123 0.671 0.8037]]] (sRGB (~2.22) - Display) +'ACEScg': get_transfer_gamma=1 get_chromaticities=[0.713, 0.293, 0.165, 0.83, 0.128, 0.044, 0.32168, 0.33767] +'g24_rec709_display': get_transfer_gamma=2.4 get_chromaticities=[0.64, 0.33, 0.3, 0.6, 0.15, 0.06, 0.3127, 0.329] +'srgb_tx': get_transfer_gamma=0 get_chromaticities=[0.64, 0.33, 0.3, 0.6, 0.15, 0.06, 0.3127, 0.329] +'Raw': get_transfer_gamma=0 get_chromaticities=None +'no_such_space': get_transfer_gamma=0 get_chromaticities=None Done. diff --git a/testsuite/python-colorconfig/ref/out-ocio24.txt b/testsuite/python-colorconfig/ref/out-ocio24.txt index 9d35024fcd..8f8b5b5141 100644 --- a/testsuite/python-colorconfig/ref/out-ocio24.txt +++ b/testsuite/python-colorconfig/ref/out-ocio24.txt @@ -65,5 +65,10 @@ ociodisplay #2 (apply default display/view again): [[[-2.123 0.671 0.8037]] ociodisplay #3 (inverse look): [[[-2.252 0.6714 0.8037]]] (sRGB (~2.22) - Display) ociodisplay #4 (forwards look): [[[-2.123 0.671 0.8037]]] (sRGB (~2.22) - Display) ociodisplay #5 (inverse look + forwards look): [[[-2.123 0.671 0.8037]]] (sRGB (~2.22) - Display) +'ACEScg': get_transfer_gamma=1 get_chromaticities=[0.713, 0.293, 0.165, 0.83, 0.128, 0.044, 0.32168, 0.33767] +'g24_rec709_display': get_transfer_gamma=2.4 get_chromaticities=[0.64, 0.33, 0.3, 0.6, 0.15, 0.06, 0.3127, 0.329] +'srgb_tx': get_transfer_gamma=0 get_chromaticities=[0.64, 0.33, 0.3, 0.6, 0.15, 0.06, 0.3127, 0.329] +'Raw': get_transfer_gamma=0 get_chromaticities=None +'no_such_space': get_transfer_gamma=0 get_chromaticities=None Done. diff --git a/testsuite/python-colorconfig/ref/out-ocio25.txt b/testsuite/python-colorconfig/ref/out-ocio25.txt index 443c7c9e54..cdbecf4fc5 100644 --- a/testsuite/python-colorconfig/ref/out-ocio25.txt +++ b/testsuite/python-colorconfig/ref/out-ocio25.txt @@ -65,5 +65,10 @@ ociodisplay #2 (apply default display/view again): [[[-2.123 0.671 0.8037]] ociodisplay #3 (inverse look): [[[-2.252 0.6714 0.8037]]] (sRGB (~2.22) - Display) ociodisplay #4 (forwards look): [[[-2.123 0.671 0.8037]]] (sRGB (~2.22) - Display) ociodisplay #5 (inverse look + forwards look): [[[-2.123 0.671 0.8037]]] (sRGB (~2.22) - Display) +'ACEScg': get_transfer_gamma=1 get_chromaticities=[0.713, 0.293, 0.165, 0.83, 0.128, 0.044, 0.32168, 0.33767] +'g24_rec709_display': get_transfer_gamma=2.4 get_chromaticities=[0.64, 0.33, 0.3, 0.6, 0.15, 0.06, 0.3127, 0.329] +'srgb_tx': get_transfer_gamma=0 get_chromaticities=[0.64, 0.33, 0.3, 0.6, 0.15, 0.06, 0.3127, 0.329] +'Raw': get_transfer_gamma=0 get_chromaticities=None +'no_such_space': get_transfer_gamma=0 get_chromaticities=None Done. diff --git a/testsuite/python-colorconfig/ref/out-ocio26.txt b/testsuite/python-colorconfig/ref/out-ocio26.txt index 1f94528d76..7a05b1f38f 100644 --- a/testsuite/python-colorconfig/ref/out-ocio26.txt +++ b/testsuite/python-colorconfig/ref/out-ocio26.txt @@ -65,5 +65,10 @@ ociodisplay #2 (apply default display/view again): [[[-2.123 0.671 0.8037]] ociodisplay #3 (inverse look): [[[-2.252 0.6714 0.8037]]] (sRGB (~2.22) - Display) ociodisplay #4 (forwards look): [[[-2.123 0.671 0.8037]]] (sRGB (~2.22) - Display) ociodisplay #5 (inverse look + forwards look): [[[-2.123 0.671 0.8037]]] (sRGB (~2.22) - Display) +'ACEScg': get_transfer_gamma=1 get_chromaticities=[0.713, 0.293, 0.165, 0.83, 0.128, 0.044, 0.32168, 0.33767] +'g24_rec709_display': get_transfer_gamma=2.4 get_chromaticities=[0.64, 0.33, 0.3, 0.6, 0.15, 0.06, 0.3127, 0.329] +'srgb_tx': get_transfer_gamma=0 get_chromaticities=[0.64, 0.33, 0.3, 0.6, 0.15, 0.06, 0.3127, 0.329] +'Raw': get_transfer_gamma=0 get_chromaticities=None +'no_such_space': get_transfer_gamma=0 get_chromaticities=None Done. diff --git a/testsuite/python-colorconfig/ref/out.txt b/testsuite/python-colorconfig/ref/out.txt index e223c92c2f..393fb1faeb 100644 --- a/testsuite/python-colorconfig/ref/out.txt +++ b/testsuite/python-colorconfig/ref/out.txt @@ -65,5 +65,10 @@ ociodisplay #2 (apply default display/view again): [[[-2.123 0.671 0.8037]] ociodisplay #3 (inverse look): [[[-2.252 0.6714 0.8037]]] (sRGB (~2.22) - Display) ociodisplay #4 (forwards look): [[[-2.123 0.671 0.8037]]] (sRGB (~2.22) - Display) ociodisplay #5 (inverse look + forwards look): [[[-2.123 0.671 0.8037]]] (sRGB (~2.22) - Display) +'ACEScg': get_transfer_gamma=1 get_chromaticities=[0.713, 0.293, 0.165, 0.83, 0.128, 0.044, 0.32168, 0.33767] +'g24_rec709_display': get_transfer_gamma=2.4 get_chromaticities=[0.64, 0.33, 0.3, 0.6, 0.15, 0.06, 0.3127, 0.329] +'srgb_tx': get_transfer_gamma=0 get_chromaticities=[0.64, 0.33, 0.3, 0.6, 0.15, 0.06, 0.3127, 0.329] +'Raw': get_transfer_gamma=0 get_chromaticities=None +'no_such_space': get_transfer_gamma=0 get_chromaticities=None Done. diff --git a/testsuite/python-colorconfig/src/test_colorconfig.py b/testsuite/python-colorconfig/src/test_colorconfig.py index d950447891..bae0ce9471 100755 --- a/testsuite/python-colorconfig/src/test_colorconfig.py +++ b/testsuite/python-colorconfig/src/test_colorconfig.py @@ -107,6 +107,9 @@ print (f"ociodisplay #4 (forwards look): {buf.get_pixels(oiio.HALF)} ({buf.spec()['oiio:ColorSpace']})") buf = oiio.ImageBufAlgo.ociodisplay(buf, "", "", colorconfig=str(TEST_CONFIG_PATH), looks="-ACES 1.3 Reference Gamut Compression, +ACES 1.3 Reference Gamut Compression") print (f"ociodisplay #5 (inverse look + forwards look): {buf.get_pixels(oiio.HALF)} ({buf.spec()['oiio:ColorSpace']})") + for name in ("ACEScg", "g24_rec709_display", "srgb_tx", "Raw", "no_such_space"): + xy = config.get_chromaticities(name) + print (f"'{name}': get_transfer_gamma={config.get_transfer_gamma(name):g} get_chromaticities={xy and [round(v, 5) for v in xy]}") print ("") print ("Done.")