Skip to content

Commit

Permalink
Multiple fixes to OCIO.
Browse files Browse the repository at this point in the history
  • Loading branch information
ggarra13 committed Mar 11, 2024
1 parent 324109c commit 03844eb
Show file tree
Hide file tree
Showing 14 changed files with 268 additions and 189 deletions.
23 changes: 20 additions & 3 deletions mrv2/docs/HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,30 @@ v1.0.9
- Fixed a bug in session loading when there was no Input Color Space specified
in the image, which got introduced in v1.0.8.
- Made pen size be able to be 1 pixel making the cursor one line only.
- Made Prores_ks (FFmpeg's native encoder) match Apple's Prores one at
4444p10le.
- Made prores_ks (FFmpeg's native encoder) match Apple's ProRes one at
4444p10le. It is now possible to take ProRes4444 encoded files to video
editors.
- Upgraded to FFmpeg v6.1.1.
- Fixed Darby's BT2020 (Ultra HD) coefficients, which I think were wrong.
- Improved rotation speed of movies from cell phones, by doing it in OpenGL
with metadata instead of with a C++ function.
- Added Creation, Modified Date and Disk Space to Media Info Panel.
- Removed Frame information from Start/End Time in Image Tab of Media Info
Panel.
- Made Start/End Time in Image Tab of Media Info Panel not use scientific
notation for seconds.
- Fixed changing frame rate from the Timeline toolbar not updating the FPS
indicator in the Image Tab of the Media Info Panel.
- Improved the performance of Media Info Panel when playing a sequence and
the Image tab was closed.
- Removed Default Speed information from Video Tab and moved it to Image Tab.
- Improved colors of deactivated enums showing too dark to read the black
text by default.
- It is now possible to use OpenColorIO's built-in configs. That is, those
stating with ocio://.
- Added a Choice menu in Preferences->OCIO to select any of the three built-in
OCIO configs.
- Set ocio default config to the built-in:
ocio://default


v1.0.8
Expand Down
2 changes: 1 addition & 1 deletion mrv2/lib/mrvFl/mrvLanguages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ namespace mrv
}
if (!language || strncmp(language, langcode, 2) != 0)
{
setenv("LANGUAGE", langcode, 1)
setenv("LANGUAGE", langcode, 1);
win32_execv();
exit(0);
}
Expand Down
2 changes: 2 additions & 0 deletions mrv2/lib/mrvFl/mrvOCIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ namespace mrv
{
namespace image
{
std::string ocioDefault = "ocio://default";

std::string ocioIcs()
{
auto uiICS = App::ui->uiICS;
Expand Down
2 changes: 2 additions & 0 deletions mrv2/lib/mrvFl/mrvOCIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ namespace mrv
{
namespace image
{
extern std::string ocioDefault;

int ocioIcsIndex(const std::string&);
std::string ocioIcs();
void setOcioIcs(const std::string&);
Expand Down
97 changes: 53 additions & 44 deletions mrv2/lib/mrvFl/mrvPreferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,36 +530,21 @@ namespace mrv
#ifdef TLRENDER_OCIO
// Check OCIO variable first, then saved prefs and finally if nothing,
// use this default.
std::string ocioDefault =
root + "/ocio/cg-config/cg-config-v1.0.0_aces-v1.3_ocio-v2.1.ocio";
static std::string old_ocio;

const char* var = getenv("OCIO");
const char* var = fl_getenv("OCIO");
if (!var || strlen(var) == 0)
{
ocio.get("config", tmpS, "", 2048);

if (strlen(tmpS) != 0)
{
if (file::isReadable(tmpS))
if (image::ocioDefault != tmpS)
{
mrvLOG_INFO(
"ocio", _("Setting OCIO config from preferences.")
<< std::endl);
uiPrefs->uiPrefsOCIOConfig->value(tmpS);
var = uiPrefs->uiPrefsOCIOConfig->value();
}
else
{
std::string root = tmpS;
if (root.find("mrv2") != std::string::npos)
{
mrvLOG_INFO(
"ocio", _("Setting OCIO config to default.")
<< std::endl);
uiPrefs->uiPrefsOCIOConfig->value(ocioDefault.c_str());
var = uiPrefs->uiPrefsOCIOConfig->value();
}
<< std::endl);
setOcioConfig(tmpS);
}
}
}
Expand All @@ -568,15 +553,14 @@ namespace mrv
mrvLOG_INFO(
"ocio", _("Setting OCIO config from OCIO "
"environment variable.")
<< std::endl);
uiPrefs->uiPrefsOCIOConfig->value(var);
<< std::endl);
setOcioConfig(var);
}

var = uiPrefs->uiPrefsOCIOConfig->value();
if (!var || strlen(var) == 0 || resetSettings)
{
mrvLOG_INFO(
"ocio", _("Setting OCIO config to default.") << std::endl);
uiPrefs->uiPrefsOCIOConfig->value(ocioDefault.c_str());
setOcioConfig(image::ocioDefault);
}

ocio.get("use_active_views", tmp, 1);
Expand Down Expand Up @@ -1900,32 +1884,57 @@ namespace mrv
//////////////////////////////////////////////////////
// OCIO
/////////////////////////////////////////////////////
void Preferences::OCIO(ViewerUI* ui)
void Preferences::setOcioConfig(std::string configName)
{
#ifdef TLRENDER_OCIO
PreferencesUI* uiPrefs = ui->uiPrefs;
static std::string oldConfigName;
static const char* kModule = "ocio";

static std::string old_ocio;
const char* var = uiPrefs->uiPrefsOCIOConfig->value();
if (var && strlen(var) > 0)
{
if (oldConfigName == configName)
return;

if (old_ocio != var)
PreferencesUI* uiPrefs = App::ui->uiPrefs;
if (configName.substr(0, 7) != "ocio://")
{
if (file::isReadable(configName))
{
old_ocio = var;
mrvLOG_INFO("ocio", _("OCIO config is now:") << std::endl);
mrvLOG_INFO("ocio", var << std::endl);
LOG_INFO(_("OCIO config is now:"));
}

std::string parsed = expandVariables(var, "%", '%');
parsed = expandVariables(parsed, "${", '}');
if (old_ocio != parsed)
else
{
mrvLOG_INFO("ocio", _("Expanded OCIO config to:") << std::endl);
mrvLOG_INFO("ocio", parsed << std::endl);
std::string msg =
tl::string::Format(
_("OCIO file \"{0}\" not found or not readable."))
.arg(configName);
LOG_ERROR(msg);
LOG_INFO(_("Setting OCIO config to default:"));
configName = image::ocioDefault;
}
}
else if (configName == image::ocioDefault)
{
LOG_INFO(_("Setting OCIO config to default:"));
configName = image::ocioDefault;
}
else
{
LOG_INFO(_("Setting OCIO config to built-in:"));
}

LOG_INFO(configName);
uiPrefs->uiPrefsOCIOConfig->value(configName.c_str());
oldConfigName = configName;
}

void Preferences::OCIO(ViewerUI* ui)
{
#ifdef TLRENDER_OCIO
PreferencesUI* uiPrefs = ui->uiPrefs;

uiPrefs->uiPrefsOCIOConfig->value(var);
static std::string old_ocio;
const char* var = uiPrefs->uiPrefsOCIOConfig->value();
if (var && strlen(var) > 0)
{
setOcioConfig(var);

// First, remove all additional defaults if any from pulldown
// menu
Expand All @@ -1936,8 +1945,8 @@ namespace mrv

try
{

config = OCIO::Config::CreateFromFile(parsed.c_str());
const char* configName = uiPrefs->uiPrefsOCIOConfig->value();
config = OCIO::Config::CreateFromFile(configName);

uiPrefs->uiPrefsOCIOConfig->tooltip(config->getDescription());

Expand Down
2 changes: 2 additions & 0 deletions mrv2/lib/mrvFl/mrvPreferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ namespace mrv
protected:
static bool set_transforms();

static void setOcioConfig(std::string config);

public:
static ColorSchemes schemes;
static bool native_file_chooser;
Expand Down
20 changes: 15 additions & 5 deletions mrv2/lib/mrvFl/mrvSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,12 @@ namespace mrv

std::string config = ui->uiPrefs->uiPrefsOCIOConfig->value();

file::Path path(config);
config = getRelativePath(path, fileName).get();

if (config.substr(0, 7) != "ocio://")
{
file::Path path(config);
config = getRelativePath(path, fileName).get();
}

int ics = ui->uiICS->value();
int view = ui->OCIOView->value();
int layer = ui->uiColorChannel->value();
Expand Down Expand Up @@ -494,10 +497,17 @@ namespace mrv
j = session["ocio"];
std::string config = j["config"];

replace_path(config);
if (config.substr(0, 7) != "ocio://")
{
replace_path(config);

if (file::isReadable(config))
if (file::isReadable(config))
ui->uiPrefs->uiPrefsOCIOConfig->value(config.c_str());
}
else
{
ui->uiPrefs->uiPrefsOCIOConfig->value(config.c_str());
}

Preferences::OCIO(ui);

Expand Down
3 changes: 3 additions & 0 deletions mrv2/lib/mrvFl/mrvTimelinePlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,9 @@ namespace mrv
pushMessage("setSpeed", value);

_p->player->setSpeed(value);

if (panel::imageInfoPanel)
panel::imageInfoPanel->refresh();
}

void TimelinePlayer::setPlayback(timeline::Playback value)
Expand Down
Loading

0 comments on commit 03844eb

Please sign in to comment.