Skip to content

Commit

Permalink
After Effects update, Photoshop plug-in (#476)
Browse files Browse the repository at this point in the history
* Stop accepting .ccc files while we don't have a way to get the ID

* Getting video space buffers for Premiere

* Check for empty paths

Seems like the smart thing to do, eh?

* Manually update version

* #define OLDYAML; the new YAML requires Boost so we'll avaoid it on Mac

* Manually update version

* Switch to new YAML

Wave of the future, dude.

* Add ext/.gitignore

* Add FileFormatCDL.cpp

* Add FileFormatCDL.cpp on win

* Add hierarchical menu for color spaces

* New menu for Windows

* Photoshop plug-in added

* Small changes to the AE plug-in for integration with PS

* 4ByteStruct configurations

Funny story! I built the AE plug-in with the default struct alignment,
not the 4 Byte version that AE plug-ins are supposed to use.
Interestingly, it does not seem to cause any problems, although
switching it now will cause problems with current projects.

Then there's the question of which version behaves well with projects
coming from the Mac. We assume the current one?

Anyway, 4ByteStruct configurations are there in case we ever decide to
use them.

* Photoshop plug-in building on Windows

* Mac fix

Found what appears to be a little bug on Mac while porting to Windows.

* Need to include OCIO if I want the version

* Fix output paths

* Fixed bug getting display transform

* Fix Windows crash

* extra line

* De-Tab
  • Loading branch information
fnordware authored and scoopxyz committed Nov 29, 2017
1 parent 508b3f4 commit 927e81d
Show file tree
Hide file tree
Showing 37 changed files with 11,094 additions and 321 deletions.
5 changes: 5 additions & 0 deletions ext/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Adobe*
yaml-cpp/*
yaml-cpp-0.5.1/*
lcms2-2.1/*
tinyxml/*
111 changes: 69 additions & 42 deletions src/aftereffects/OpenColorIO_AE_Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Path::Path(const Path &path)

std::string Path::full_path() const
{
if( is_relative(_path) && !_dir.empty() )
if( !_path.empty() && is_relative(_path) && !_dir.empty() )
{
std::vector<std::string> path_vec = components( convert_delimiters(_path) );
std::vector<std::string> dir_vec = components(_dir);
Expand Down Expand Up @@ -115,7 +115,7 @@ std::string Path::full_path() const

std::string Path::relative_path(bool force) const
{
if( is_relative(_path) || _dir.empty() || _path.empty() )
if( _dir.empty() || _path.empty() || is_relative(_path) )
{
return _path;
}
Expand Down Expand Up @@ -182,7 +182,7 @@ bool Path::exists() const
}


Path::PathType Path::path_type(std::string path)
Path::PathType Path::path_type(const std::string &path)
{
if( path.empty() )
{
Expand Down Expand Up @@ -228,7 +228,7 @@ Path::PathType Path::path_type(std::string path)
}


bool Path::is_relative(std::string path)
bool Path::is_relative(const std::string &path)
{
Path::PathType type = path_type(path);

Expand All @@ -254,27 +254,29 @@ bool Path::is_relative(std::string path)
}


std::string Path::convert_delimiters(std::string path)
std::string Path::convert_delimiters(const std::string &path)
{
#ifdef WIN_ENV
char search = mac_delimiter;
char replace = win_delimiter;
const char search = mac_delimiter;
const char replace = win_delimiter;
#else
char search = win_delimiter;
char replace = mac_delimiter;
const char search = win_delimiter;
const char replace = mac_delimiter;
#endif

for(int i=0; i < path.size(); i++)
std::string path_copy = path;

for(int i=0; i < path_copy.size(); i++)
{
if(path[i] == search)
path[i] = replace;
if(path_copy[i] == search)
path_copy[i] = replace;
}

return path;
return path_copy;
}


std::vector<std::string> Path::components(std::string path)
std::vector<std::string> Path::components(const std::string &path)
{
std::vector<std::string> vec;

Expand Down Expand Up @@ -354,7 +356,17 @@ OpenColorIO_AE_Context::OpenColorIO_AE_Context(const std::string &path, OCIO_Sou

for(int i=0; i < _config->getNumColorSpaces(); ++i)
{
_inputs.push_back( _config->getColorSpaceNameByIndex(i) );
const char *colorSpaceName = _config->getColorSpaceNameByIndex(i);

OCIO::ConstColorSpaceRcPtr colorSpace = _config->getColorSpace(colorSpaceName);

const char *family = colorSpace->getFamily();

_inputs.push_back(colorSpaceName);

const std::string fullPath = (family == NULL ? colorSpaceName : std::string(family) + "/" + colorSpaceName);

_inputsFullPath.push_back(fullPath);
}


Expand All @@ -363,24 +375,20 @@ OpenColorIO_AE_Context::OpenColorIO_AE_Context(const std::string &path, OCIO_Sou
_devices.push_back( _config->getDisplay(i) );
}

const char * defaultDisplay = _config->getDefaultDisplay();
const char * defaultTransform = _config->getDefaultView(defaultDisplay);

for(int i=0; i < _config->getNumViews(defaultDisplay); ++i)
{
_transforms.push_back( _config->getView(defaultDisplay, i) );
}
OCIO::ConstColorSpaceRcPtr defaultInput = _config->getColorSpace(OCIO::ROLE_DEFAULT);

const char *defaultInputName = (defaultInput ? defaultInput->getName() : OCIO::ROLE_DEFAULT);

OCIO::ConstColorSpaceRcPtr defaultInput = _config->getColorSpace(OCIO::ROLE_SCENE_LINEAR);

const char *defaultInputName = (defaultInput ? defaultInput->getName() : OCIO::ROLE_SCENE_LINEAR);
setupConvert(defaultInputName, defaultInputName);


setupConvert(defaultInputName, defaultInputName);
const char *defaultDisplay = _config->getDefaultDisplay();
const char *defaultTransform = _config->getDefaultView(defaultDisplay);

_transform = defaultTransform;
_device = defaultDisplay;
_transform = defaultTransform;
}
else
{
Expand Down Expand Up @@ -450,7 +458,17 @@ OpenColorIO_AE_Context::OpenColorIO_AE_Context(const ArbitraryData *arb_data, co

for(int i=0; i < _config->getNumColorSpaces(); ++i)
{
_inputs.push_back( _config->getColorSpaceNameByIndex(i) );
const char *colorSpaceName = _config->getColorSpaceNameByIndex(i);

OCIO::ConstColorSpaceRcPtr colorSpace = _config->getColorSpace(colorSpaceName);

const char *family = colorSpace->getFamily();

_inputs.push_back(colorSpaceName);

const std::string fullPath = (family == NULL ? colorSpaceName : std::string(family) + "/" + colorSpaceName);

_inputsFullPath.push_back(fullPath);
}


Expand All @@ -459,25 +477,16 @@ OpenColorIO_AE_Context::OpenColorIO_AE_Context(const ArbitraryData *arb_data, co
_devices.push_back( _config->getDisplay(i) );
}

const char * defaultDisplay = _config->getDefaultDisplay();
const char * defaultTransform = _config->getDefaultView(defaultDisplay);

for(int i=0; i < _config->getNumViews(defaultDisplay); ++i)
{
_transforms.push_back( _config->getView(defaultDisplay, i) );
}


if(arb_data->action == OCIO_ACTION_CONVERT)
{
setupConvert(arb_data->input, arb_data->output);

_transform = arb_data->transform;
_device = arb_data->device;
_transform = arb_data->transform;
}
else
{
setupDisplay(arb_data->input, arb_data->transform, arb_data->device);
setupDisplay(arb_data->input, arb_data->device, arb_data->transform);

_output = arb_data->output;
}
Expand Down Expand Up @@ -572,11 +581,11 @@ bool OpenColorIO_AE_Context::Verify(const ArbitraryData *arb_data, const std::st
else if(arb_data->action == OCIO_ACTION_DISPLAY)
{
if(_input != arb_data->input ||
_transform != arb_data->transform ||
_device != arb_data->device ||
_transform != arb_data->transform ||
force_reset)
{
setupDisplay(arb_data->input, arb_data->transform, arb_data->device);
setupDisplay(arb_data->input, arb_data->device, arb_data->transform);
}
}
else
Expand Down Expand Up @@ -606,17 +615,35 @@ void OpenColorIO_AE_Context::setupConvert(const char *input, const char *output)
}


void OpenColorIO_AE_Context::setupDisplay(const char *input, const char *xform, const char *device)
void OpenColorIO_AE_Context::setupDisplay(const char *input, const char *device, const char *xform)
{
_transforms.clear();

bool xformValid = false;

for(int i=0; i < _config->getNumViews(device); i++)
{
const std::string transformName = _config->getView(device, i);

if(transformName == xform)
xformValid = true;

_transforms.push_back(transformName);
}

if(!xformValid)
xform = _config->getDefaultView(device);


OCIO::DisplayTransformRcPtr transform = OCIO::DisplayTransform::Create();

transform->setInputColorSpaceName(input);
transform->setView(xform);
transform->setDisplay(device);
transform->setView(xform);

_input = input;
_transform = xform;
_device = device;
_transform = xform;


_processor = _config->getProcessor(transform);
Expand Down
24 changes: 13 additions & 11 deletions src/aftereffects/OpenColorIO_AE_Context.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ class Path
TYPE_WIN
} PathType;

static PathType path_type(std::string path);
static bool is_relative(std::string path);
static std::string convert_delimiters(std::string path);
static std::vector<std::string> components(std::string path);
static PathType path_type(const std::string &path);
static bool is_relative(const std::string &path);
static std::string convert_delimiters(const std::string &path);
static std::vector<std::string> components(const std::string &path);
};


Expand All @@ -81,21 +81,22 @@ class OpenColorIO_AE_Context
bool Verify(const ArbitraryData *arb_data, const std::string &dir);

void setupConvert(const char *input, const char *output);
void setupDisplay(const char *input, const char *transform, const char *device);
void setupDisplay(const char *input, const char *device, const char *transform);
void setupLUT(bool invert, OCIO_Interp interpolation);

typedef std::vector<std::string> SpaceVec;

OCIO_Action getAction() const { return _action; }
const std::string & getInput() const { return _input; }
const std::string & getOutput() const { return _output; }
const std::string & getTransform() const { return _transform; }
const std::string & getDevice() const { return _device; }
const SpaceVec & getInputs() const { return _inputs; }
const SpaceVec & getTransforms() const { return _transforms; }
const std::string & getTransform() const { return _transform; }
const SpaceVec & getInputs(bool fullPath=false) const { return fullPath ? _inputsFullPath : _inputs; }
const SpaceVec & getDevices() const { return _devices; }
const SpaceVec & getTransforms() const { return _transforms; }

const OCIO::ConstProcessorRcPtr & processor() const { return _processor; }
OCIO::ConstConfigRcPtr config() const { return _config; }
OCIO::ConstProcessorRcPtr processor() const { return _processor; }

bool ExportLUT(const std::string &path, const std::string &display_icc_path);

Expand All @@ -110,11 +111,12 @@ class OpenColorIO_AE_Context

std::string _input;
std::string _output;
std::string _transform;
std::string _device;
std::string _transform;
SpaceVec _inputs;
SpaceVec _transforms;
SpaceVec _inputsFullPath;
SpaceVec _devices;
SpaceVec _transforms;

bool _invert;
OCIO_Interp _interpolation;
Expand Down
10 changes: 10 additions & 0 deletions src/aftereffects/OpenColorIO_AE_Dialogs.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <map>
#include <vector>

#include <OpenColorIO/OpenColorIO.h>
namespace OCIO = OCIO_NAMESPACE;


typedef std::map<std::string, std::string> ExtensionMap; // map[ ext ] = format

bool OpenFile(char *path, int buf_len, const ExtensionMap &extensions, const void *hwnd);
Expand All @@ -54,7 +58,13 @@ typedef std::vector<std::string> MenuVec;
int PopUpMenu(const MenuVec &menu_items, int selected_index, const void *hwnd);


bool ColorSpacePopUpMenu(OCIO::ConstConfigRcPtr config, std::string &colorSpace, bool selectRoles, const void *hwnd);


void ErrorMessage(const char *message, const void *hwnd);

#ifdef SUPPLY_HINSTANCE
void SetHInstance(void *hInstance);
#endif

#endif // _OPENCOLORIC_AE_DIALOG_H_
Loading

0 comments on commit 927e81d

Please sign in to comment.