Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions share/dev/windows/ocio.bat
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ if !DO_CONFIGURE!==1 (
-DPython_ROOT="!PYTHON_PATH!"^
-DBUILD_SHARED_LIBS=ON^
-DOCIO_BUILD_APPS=ON^
-DOCIO_BUILD_OPENFX=ON^
-DOCIO_BUILD_TESTS=ON^
-DOCIO_BUILD_GPU_TESTS=ON^
-DOCIO_BUILD_DOCS=OFF^
Expand Down
2 changes: 1 addition & 1 deletion share/dev/windows/ocio_deps.bat
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ if ErrorLevel 1 (

echo Checking for Microsoft Visual Studio...
set MSVS=0
for /d %%a in ("%programfiles%\Microsoft Visual Studio*") do (
for /d %%a in ("D:\Program Files\Microsoft Visual Studio*") do (
for /f "tokens=3 delims=\" %%x in ("%%a") do set MSVS=1
)

Expand Down
Binary file added share/openfx/resources/OpenColorIO.OCIOFile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions share/openfx/resources/OpenColorIO.OCIOFile.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions vendor/openfx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
set(SOURCES
OCIOColorSpace.cpp
OCIODisplayView.cpp
OCIOFile.cpp
OCIOMain.cpp
OCIOProcessor.cpp
OCIOUtils.cpp
Expand All @@ -26,6 +27,8 @@ set(RESOURCES
${PROJECT_SOURCE_DIR}/share/openfx/resources/OpenColorIO.OCIOColorSpace.svg
${PROJECT_SOURCE_DIR}/share/openfx/resources/OpenColorIO.OCIODisplayView.png
${PROJECT_SOURCE_DIR}/share/openfx/resources/OpenColorIO.OCIODisplayView.svg
${PROJECT_SOURCE_DIR}/share/openfx/resources/OpenColorIO.OCIOFile.png
${PROJECT_SOURCE_DIR}/share/openfx/resources/OpenColorIO.OCIOFile.svg
)

add_library(ofxplugin MODULE ${SOURCES} ${OFXS_SOURCES})
Expand Down
126 changes: 126 additions & 0 deletions vendor/openfx/OCIOFile.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
// SPDX-License-Identifier: BSD-3-Clause
// Copyright Contributors to the OpenColorIO Project.

#include "OCIOFile.h"
#include "OCIOProcessor.h"
#include "OCIOUtils.h"

namespace OCIO = OCIO_NAMESPACE;

namespace
{
const std::string PLUGIN_TYPE = "OCIOFile";

} // namespace

OCIOFile::OCIOFile(OfxImageEffectHandle handle)
: ImageEffect(handle)
, dstClip_(0)
, srcClip_(0)
, srcPathNameParam_(0)
, inverseParam_(0)
{
dstClip_ = fetchClip(kOfxImageEffectOutputClipName);
srcClip_ = fetchClip(kOfxImageEffectSimpleSourceClipName);

srcPathNameParam_ = fetchStringParam(kOfxParamStringIsFilePath);

inverseParam_ = fetchBooleanParam("inverse");

fetchContextParams(*this, contextParams_);
}

void OCIOFile::render(const OFX::RenderArguments& args)
{
// Get images
std::unique_ptr<OFX::Image> dst(dstClip_->fetchImage(args.time));
std::unique_ptr<OFX::Image> src(srcClip_->fetchImage(args.time));

// Get file path
std::string srcFileName;
srcPathNameParam_->getValue(srcFileName);

bool inverse = inverseParam_->getValue();

// Create context with overrides
OCIO::ContextRcPtr context = createOCIOContext(contextParams_);

// Build file transform
OCIO::FileTransformRcPtr tr = OCIO::FileTransform::Create();
tr->setSrc(srcFileName.c_str());

// Setup and apply processor
OCIOProcessor proc(*this);

proc.setDstImg(dst.get());
proc.setSrcImg(src.get());
proc.setRenderWindow(args.renderWindow);
proc.setTransform(context, tr, (inverse ? OCIO::TRANSFORM_DIR_INVERSE
: OCIO::TRANSFORM_DIR_FORWARD));

proc.process();
}

bool OCIOFile::isIdentity(const OFX::IsIdentityArguments& args,
OFX::Clip*& identityClip,
double& identityTime)
{

std::string srcFileName;
srcPathNameParam_->getValue(srcFileName);

// Is processing needed?
if (srcFileName.empty())
{
identityClip = srcClip_;
identityTime = args.time;
return true;
}

return false;
}

void OCIOFile::changedParam(const OFX::InstanceChangedArgs& /*args*/,
const std::string& paramName)
{
// Store context overrides
contextParamChanged(*this, paramName);
}

void OCIOFileFactory::describe(OFX::ImageEffectDescriptor& desc)
{
baseDescribe(PLUGIN_TYPE, desc);
}

void OCIOFileFactory::describeInContext(OFX::ImageEffectDescriptor& desc,
OFX::ContextEnum /*context*/)
{
baseDescribeInContext(desc);

// Define parameters
OFX::PageParamDescriptor* page = desc.definePageParam(PARAM_NAME_PAGE_0);

// Src path string
defineStringParam(desc, page,
"src_path",
"Source File Path",
"Source file path name",
0);

// Inverse
defineBooleanParam(desc, page,
"inverse",
"Inverse",
"Invert the transform",
0);

// Context overrides
defineContextParams(desc, page);
}

OFX::ImageEffect* OCIOFileFactory::createInstance(
OfxImageEffectHandle handle,
OFX::ContextEnum /*context*/)
{
return new OCIOFile(handle);
}
44 changes: 44 additions & 0 deletions vendor/openfx/OCIOFile.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// SPDX-License-Identifier: BSD-3-Clause
// Copyright Contributors to the OpenColorIO Project.

#ifndef INCLUDED_OFX_OCIOFILE_H
#define INCLUDED_OFX_OCIOFILE_H

#include "OCIOUtils.h"

#include <string>

#include "ofxsImageEffect.h"

class OCIOFile : public OFX::ImageEffect
{
protected:
// Do not need to delete these. The ImageEffect is managing them for us.
OFX::Clip* dstClip_;
OFX::Clip* srcClip_;

OFX::StringParam* srcPathNameParam_;
OFX::BooleanParam* inverseParam_;

ParamMap contextParams_;

public:
OCIOFile(OfxImageEffectHandle handle);

/* Override the render */
void render(const OFX::RenderArguments& args) override;

/* Override identity (~no-op) check */
bool isIdentity(const OFX::IsIdentityArguments& args,
OFX::Clip*& identityClip,
double& identityTime) override;

/* Override changedParam */
void changedParam(const OFX::InstanceChangedArgs& args,
const std::string& paramName) override;

};

mDeclarePluginFactory(OCIOFileFactory, {}, {});

#endif // INCLUDED_OFX_OCIOFILE_H
9 changes: 7 additions & 2 deletions vendor/openfx/OCIOMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

#include "OCIOColorSpace.h"
#include "OCIODisplayView.h"
#include "OCIOFile.h"

void OFX::Plugin::getPluginIDs(OFX::PluginFactoryArray & ids)
void OFX::Plugin::getPluginIDs(OFX::PluginFactoryArray& ids)
{
static OCIOColorSpaceFactory ocioColorSpace(
"OpenColorIO.OCIOColorSpace", 1, 0);
Expand All @@ -13,4 +14,8 @@ void OFX::Plugin::getPluginIDs(OFX::PluginFactoryArray & ids)
static OCIODisplayViewFactory ocioDisplayView(
"OpenColorIO.OCIODisplayView", 1, 0);
ids.push_back(&ocioDisplayView);
}

static OCIOFileFactory ocioFile(
"OpenColorIO.OCIOFile", 1, 0);
ids.push_back(&ocioFile);
}