90 static std::mutex mutex;
91 std::lock_guard
lock(mutex);
96 scope_info_ = std::make_unique<ScopeInfo>();
101 scope_info_->is_hdr = is_hdr_ || is_data_;
110 scope_gamut_to_rec709 = OCIO_XYZ_TO_REC709 *
math::invert(OCIO_XYZ_TO_P3);
113 scope_gamut_to_rec709 = OCIO_XYZ_TO_REC709 *
math::invert(OCIO_XYZ_TO_REC2020);
116 scope_info_->scope_gamut_to_rec709 =
float3x3(scope_gamut_to_rec709);
118 scope_info_->luma_coefficients = scope_info_->luma_coefficients *
119 scope_info_->scope_gamut_to_rec709;
129 const float kg = 1.0f - kr - kb;
131 float3(kr, -kr / (2.0f * (1.0f - kb)), 0.5f),
132 float3(kg, -kg / (2.0f * (1.0f - kb)), -kg / (2.0f * (1.0f - kr))),
133 float3(kb, 0.5f, -kb / (2.0f * (1.0f - kr))));
135 if (scope_info_->is_hdr) {
137 scope_info_->view_transform_max_nits =
max_nits();
138 if (scope_info_->view_transform_max_nits > 0) {
140 scope_info_->view_transform_max_nits);
147 const int max_nits = (scope_info_->view_transform_max_nits) ?
148 scope_info_->view_transform_max_nits :
157 for (
const int nits : nit_values) {
166 scope_info_->graticules.append(graticule);
171 const float values[] = {0.0f, 0.25f, 0.50f, 0.75f, 1.0f};
172 for (
const float val : values) {
174 graticule.
value = val;
176 scope_info_->graticules.append(graticule);
191 xyz_to_display_gamut = OCIO_XYZ_TO_REC709;
194 xyz_to_display_gamut = OCIO_XYZ_TO_P3;
197 xyz_to_display_gamut = OCIO_XYZ_TO_REC2020;
202 auto to_cie_xyz_d65 = OCIO_NAMESPACE::ColorSpaceTransform::Create();
203 to_cie_xyz_d65->setSrc(display_colorspace_->name().c_str());
204 to_cie_xyz_d65->setDst(lin_cie_xyz_d65_name.
c_str());
205 group->appendTransform(to_cie_xyz_d65);
208 auto to_lin_gamut = OCIO_NAMESPACE::MatrixTransform::Create();
209 to_lin_gamut->setMatrix(
math::transpose(xyz_to_display_gamut).base_ptr());
210 group->appendTransform(to_lin_gamut);
212 if (is_hdr_ || is_data_) {
216 auto clamp = OCIO_NAMESPACE::RangeTransform::Create();
217 clamp->setStyle(OCIO_NAMESPACE::RANGE_CLAMP);
218 clamp->setMinInValue(0.0);
219 clamp->setMinOutValue(0.0);
221 clamp->setMaxOutValue(1.0);
222 group->appendTransform(
clamp);
226 auto gamma = OCIO_NAMESPACE::ExponentTransform::Create();
228 gamma->setNegativeStyle(OCIO_NAMESPACE::NEGATIVE_CLAMP);
229 gamma->setDirection(OCIO_NAMESPACE::TRANSFORM_DIR_FORWARD);
230 group->appendTransform(gamma);
233 constexpr int LUT_SIZE = 1024;
234 auto lut = OCIO_NAMESPACE::Lut1DTransform::Create();
235 lut->setLength(LUT_SIZE);
236 for (
int i = 0; i < LUT_SIZE; i++) {
237 const float t =
float(i) /
float(LUT_SIZE - 1);
238 const float g = t * max_gamma_encoded;
241 lut->setValue(i, scope, scope, scope);
243 group->appendTransform(
lut);
247 auto clamp = OCIO_NAMESPACE::RangeTransform::Create();
248 clamp->setStyle(OCIO_NAMESPACE::RANGE_CLAMP);
249 clamp->setMinInValue(0.0);
250 clamp->setMinOutValue(0.0);
251 group->appendTransform(
clamp);
253 auto srgb = OCIO_NAMESPACE::ExponentWithLinearTransform::Create();
256 srgb->setDirection(OCIO_NAMESPACE::TRANSFORM_DIR_INVERSE);
257 group->appendTransform(srgb);