mirror of
https://github.com/blender/blender
synced 2026-09-29 04:37:17 +03:00
Cycles: Making Cycles build against a older OIIO and OpenColorIO versions
This commit is contained in:
parent
fb40eaffc1
commit
1f55c8eb5c
3 changed files with 62 additions and 14 deletions
|
|
@ -45,9 +45,6 @@ set(LIB
|
|||
PRIVATE bf::dependencies::opencolorio
|
||||
PRIVATE bf::dependencies::zstd
|
||||
PRIVATE bf::dependencies::openexr
|
||||
# Used by OpenImageIO headers, which fallback to a bundled version. But we
|
||||
# need to use the same version as Blender to avoid symbol conflicts.
|
||||
PRIVATE bf::dependencies::fmt
|
||||
)
|
||||
|
||||
set(SRC_HEADERS
|
||||
|
|
|
|||
|
|
@ -264,9 +264,17 @@ const char *ColorSpaceManager::colorspace_interop_id(ustring colorspace)
|
|||
"srgb_p3d65_scene",
|
||||
"g22_adobergb_scene"};
|
||||
for (const char *interop_id : interop_ids) {
|
||||
# if OCIO_VERSION_MAJOR == 2 && OCIO_VERSION_MINOR == 2
|
||||
for (int i = 0; i < space->getNumAliases(); i++) {
|
||||
if (strcmp(space->getAlias(i), interop_id) == 0) {
|
||||
return interop_id;
|
||||
}
|
||||
}
|
||||
# else
|
||||
if (space->hasAlias(interop_id)) {
|
||||
return interop_id;
|
||||
}
|
||||
# endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -299,9 +307,31 @@ ustring ColorSpaceManager::detect_known_colorspace(ustring colorspace,
|
|||
colorspace = file_colorspace;
|
||||
}
|
||||
else {
|
||||
# if OCIO_VERSION_MAJOR == 2 && OCIO_VERSION_MINOR == 2
|
||||
int default_float_id = 0;
|
||||
int default_byte_id = 0;
|
||||
int default_id = 0;
|
||||
for (int i = 0; i < config->getNumRoles(); i++) {
|
||||
const char *role_name = config->getRoleName(i);
|
||||
if (strcmp(role_name, "default_float") == 0) {
|
||||
default_float_id = i;
|
||||
}
|
||||
else if (strcmp(role_name, "default_byte") == 0) {
|
||||
default_byte_id = i;
|
||||
}
|
||||
else if (strcmp(role_name, "default") == 0) {
|
||||
default_id = i;
|
||||
}
|
||||
}
|
||||
const char *role_colorspace = (is_float) ? config->getRoleColorSpace(default_float_id) :
|
||||
config->getRoleColorSpace(default_byte_id);
|
||||
role_colorspace = (role_colorspace) ? role_colorspace :
|
||||
config->getRoleColorSpace(default_id);
|
||||
# else
|
||||
const char *role_colorspace = (is_float) ? config->getRoleColorSpace("default_float") :
|
||||
config->getRoleColorSpace("default_byte");
|
||||
role_colorspace = (role_colorspace) ? role_colorspace : config->getRoleColorSpace("default");
|
||||
# endif
|
||||
if (role_colorspace) {
|
||||
colorspace = role_colorspace;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,8 +12,6 @@
|
|||
#include <iostream>
|
||||
#include <memory>
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include <OpenImageIO/Imath.h>
|
||||
#include <OpenImageIO/color.h>
|
||||
#include <OpenImageIO/filesystem.h>
|
||||
|
|
@ -45,13 +43,13 @@ static std::string datestring(time_t t)
|
|||
{
|
||||
struct tm mytm;
|
||||
OIIO::Sysutil::get_local_time(&t, &mytm);
|
||||
return fmt::format("{:4d}:{:02d}:{:02d} {:02d}:{:02d}:{:02d}",
|
||||
mytm.tm_year + 1900,
|
||||
mytm.tm_mon + 1,
|
||||
mytm.tm_mday,
|
||||
mytm.tm_hour,
|
||||
mytm.tm_min,
|
||||
mytm.tm_sec);
|
||||
return string_printf("%04d:%02d:%02d %02d:%02d:%02d",
|
||||
mytm.tm_year + 1900,
|
||||
mytm.tm_mon + 1,
|
||||
mytm.tm_mday,
|
||||
mytm.tm_hour,
|
||||
mytm.tm_min,
|
||||
mytm.tm_sec);
|
||||
}
|
||||
|
||||
template<class SRCTYPE>
|
||||
|
|
@ -128,7 +126,12 @@ static bool resize_block_(OIIO::ImageBuf &dst,
|
|||
int x0 = roi.xbegin, x1 = roi.xend, y0 = roi.ybegin, y1 = roi.yend;
|
||||
|
||||
const ImageSpec &dstspec(dst.spec());
|
||||
#if OIIO_VERSION_MAJOR > 3 || (OIIO_VERSION_MAJOR == 3 && OIIO_VERSION_MINOR >= 0)
|
||||
OIIO::span<float> pel = OIIO::OIIO_ALLOCA_SPAN(float, dstspec.nchannels);
|
||||
#else
|
||||
std::vector<float> pel_buf(dstspec.nchannels);
|
||||
OIIO::span<float> pel(pel_buf.data(), dstspec.nchannels);
|
||||
#endif
|
||||
float xoffset = (float)dstspec.x;
|
||||
float yoffset = (float)dstspec.y;
|
||||
float xscale = 1.0f / (float)dstspec.width;
|
||||
|
|
@ -244,8 +247,17 @@ static bool resize_block(OIIO::ImageBuf &dst,
|
|||
static void fix_latl_edges(OIIO::ImageBuf &buf)
|
||||
{
|
||||
int n = buf.nchannels();
|
||||
|
||||
#if OIIO_VERSION_MAJOR > 3 || (OIIO_VERSION_MAJOR == 3 && OIIO_VERSION_MINOR >= 0)
|
||||
OIIO::span<float> left = OIIO::OIIO_ALLOCA_SPAN(float, n);
|
||||
OIIO::span<float> right = OIIO::OIIO_ALLOCA_SPAN(float, n);
|
||||
#else
|
||||
std::vector<float> left_buf(n);
|
||||
std::vector<float> right_buf(n);
|
||||
|
||||
OIIO::span<float> left(left_buf.data(), n);
|
||||
OIIO::span<float> right(right_buf.data(), n);
|
||||
#endif
|
||||
|
||||
/* Make the whole first and last row be solid, since they are exactly on the pole. */
|
||||
float wscale = 1.0f / (buf.spec().width);
|
||||
|
|
@ -256,7 +268,11 @@ static void fix_latl_edges(OIIO::ImageBuf &buf)
|
|||
left[c] = 0.0f;
|
||||
}
|
||||
for (int x = buf.xbegin(); x < buf.xend(); ++x) {
|
||||
#if OIIO_VERSION_MAJOR > 3 || (OIIO_VERSION_MAJOR == 3 && OIIO_VERSION_MINOR >= 0)
|
||||
buf.getpixel(x, y, right);
|
||||
#else
|
||||
buf.getpixel(x, y, right.data());
|
||||
#endif
|
||||
for (int c = 0; c < n; ++c) {
|
||||
left[c] += right[c];
|
||||
}
|
||||
|
|
@ -271,8 +287,13 @@ static void fix_latl_edges(OIIO::ImageBuf &buf)
|
|||
|
||||
/* Make the left and right match, since they are both right on the prime meridian. */
|
||||
for (int y = buf.ybegin(); y < buf.yend(); ++y) {
|
||||
#if OIIO_VERSION_MAJOR > 3 || (OIIO_VERSION_MAJOR == 3 && OIIO_VERSION_MINOR >= 0)
|
||||
buf.getpixel(buf.xbegin(), y, left);
|
||||
buf.getpixel(buf.xend() - 1, y, right);
|
||||
#else
|
||||
buf.getpixel(buf.xbegin(), y, left.data());
|
||||
buf.getpixel(buf.xend() - 1, y, right.data());
|
||||
#endif
|
||||
for (int c = 0; c < n; ++c) {
|
||||
left[c] = 0.5f * left[c] + 0.5f * right[c];
|
||||
}
|
||||
|
|
@ -528,7 +549,7 @@ static void write_stats_tx(OIIO::ImageBuf &buf, const bool use_openexr)
|
|||
buf.specmod().attribute("oiio:ConstantColor", colstr);
|
||||
}
|
||||
else {
|
||||
desc += fmt::format("{}oiio:ConstantColor={}", desc.length() ? " " : "", colstr);
|
||||
desc += string_printf("%soiio:ConstantColor=%s", desc.length() ? " " : "", colstr.c_str());
|
||||
}
|
||||
LOG_DEBUG << " ConstantColor: " << colstr;
|
||||
}
|
||||
|
|
@ -539,7 +560,7 @@ static void write_stats_tx(OIIO::ImageBuf &buf, const bool use_openexr)
|
|||
buf.specmod().attribute("oiio:AverageColor", avgstr);
|
||||
}
|
||||
else {
|
||||
desc += fmt::format("{}oiio:AverageColor={}", desc.length() ? " " : "", avgstr);
|
||||
desc += string_printf("%soiio:AverageColor=%s", desc.length() ? " " : "", avgstr.c_str());
|
||||
}
|
||||
LOG_DEBUG << " AverageColor: " << avgstr;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue