Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- Do not use config proxy for absolute paths while computing file hash or loading LUT data.
- Added the unit test provided in the ticket.

Signed-off-by: cuneyt.ozdas <[email protected]>
  • Loading branch information
cozdas committed Jan 9, 2025
1 parent 6fa40a4 commit 7eb3d4f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/OpenColorIO/PathUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,20 +88,20 @@ std::string GetFastFileHash(const std::string & filename, const Context & contex
fileHashResultPtr->ready = true;

std::string h = "";
if (!context.getConfigIOProxy())
if (!pystring::os::path::isabs(filename) && context.getConfigIOProxy())
{
// Default case.
h = g_hashFunction(filename);
// Case for when ConfigIOProxy is used (callbacks mechanism).
h = context.getConfigIOProxy()->getFastLutFileHash(filename.c_str());
}
else
{
// Case for when ConfigIOProxy is used (callbacks mechanism).
h = context.getConfigIOProxy()->getFastLutFileHash(filename.c_str());
// Default case
h = g_hashFunction(filename);
}

fileHashResultPtr->hash = h;
}

hash = fileHashResultPtr->hash;
}

Expand Down
2 changes: 1 addition & 1 deletion src/OpenColorIO/transforms/FileTransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ std::unique_ptr<std::istream> getLutData(
const std::string & filepath,
std::ios_base::openmode mode)
{
if (config.getConfigIOProxy())
if (!pystring::os::path::isabs(filepath) && config.getConfigIOProxy())
{
std::vector<uint8_t> buffer = config.getConfigIOProxy()->getLutData(filepath.c_str());
std::stringstream ss;
Expand Down
12 changes: 12 additions & 0 deletions tests/cpu/OCIOZArchive_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,18 @@ OCIO_ADD_TEST(OCIOZArchive, context_test_for_search_paths_and_filetransform_sour

auto testPaths = [&mat](const OCIO::ConfigRcPtr & cfg, const OCIO::ContextRcPtr ctx)
{
{
const std::string filePath = OCIO::GetTestFilesDir() + "/matrix_example4x4.ctf";
OCIO::FileTransformRcPtr transform = OCIO::FileTransform::Create();
transform->setSrc(filePath.c_str());
OCIO::ConstProcessorRcPtr processor = cfg->getProcessor(transform);
OCIO::ConstTransformRcPtr tr = processor->createGroupTransform()->getTransform(0);
auto mtx = OCIO::DynamicPtrCast<const OCIO::MatrixTransform>(tr);
OCIO_REQUIRE_ASSERT(mtx);
mtx->getMatrix(mat);
OCIO_CHECK_EQUAL(mat[0], 3.24);
}

{
// This is independent of the context.
OCIO::ConstProcessorRcPtr processor = cfg->getProcessor(ctx, "shot1_lut1_cs", "reference");
Expand Down

0 comments on commit 7eb3d4f

Please sign in to comment.