Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DNG SDK Support in LibRaw Fork #22

Open
SkyeHoefling opened this issue Aug 13, 2021 · 1 comment
Open

Add DNG SDK Support in LibRaw Fork #22

SkyeHoefling opened this issue Aug 13, 2021 · 1 comment

Comments

@SkyeHoefling
Copy link
Contributor

Description

Some DNG files are not opening correctly in our compilation instructions for LibRaw. This is because we need to add full support for compiling with DNG SDK 1.4 and XMPCore.

Solution

Update LibRaw fork and builds to properly compile LibRaw using DNG SDK flags. This is not a simple compiler flag as these tools need to be installed on the build box and/or local development machine requiring different versions of Visual Studio. For example to compile XMPCore with their latest July 2021 release, you still need VS2017.

cc: @manoj252 @mitchelsellers

@SkyeHoefling
Copy link
Contributor Author

I did some research on this and have some updates.

Building With DNG 1.4

The LibRaw project is compatible with the DNG SDK v1.4 which is compatible with older versions of Visual Studio. I was able to get the SDK compiling for both x86 and x64 windows binaries using Visual Studio 2013 inside of a virtual machine. I needed to make the following changes to the build script

In the fileonq fork of LibRaw I updated both Makefile_x64.msvc and Makefile_x86.msvc to fix DNG SDK Flags. I also needed to update paths, but that is too be expected.

# Compile with DNG SDK support
CFLAGS_DNG=/USE_DNGSDK /I "..\\external\\dng_sdk\\source"
LDFLAGS_DNG=..\\external\\dng_sdk\\release\\libdng_x64.lib ..\\external\\dng_sdk\\release\\XMPCore.lib
# you may also need to specify zlib.lib and jpeg.lib in the line above

DNG SDK Location

The DNG SDK comes pre-loaded with the necessary code to compile as well as the necessary lib files for XMPCore. To ensure everything was in the right place I created a release folder as documented in the Makefile, then copied the following lib files

  • The generated DNG SDK lib file, which I renamed to libdng.lib
  • The pre compiled XMPCoreStaticRelease.lib file which I renamed to XMPCore.lib

You will need to ensure you are using the correct x64 vs x86 lib files for everything to compile correctly.

Code Changes

If we want to leverage this correctly, we will need to add new C-API methods for creating and deleting the dng_host object. Evaluating the dcraw_emu code provides usage for DNG SDK.

void* dnghost = new dng_host;
libraw_set_dng_host(dnghost);

// Perform standard LibRaw interactions

// ensure DNG Host is deleted from memory
delete dnghost;

As far as I can tell there is no API for creating the dng_host. This means we will need to add new C-APIs for creating the host, setting the host and deleting it. In my rapid prototyping I was able to fork LibRaw and add a new api to create the host, which emulates the behavior found in dcraw_emu.cpp. This appeared to work without issues, but I don't have proper test data.

Build Agent

To properly add DNG SDK to the build agent we will need to configure Visual Studio 2013 which will help us generate the correct binaries of the DNG library. Right now I was able to set this up in a Virtual Machine to isolate moving parts.

If we are to add proper support for this, the GitHub Actions Build Agent will need to install VS2013. I am not 100% sure how to automate this and it is an unknown if we proceed.

Test Data

At the moment our test data does not have any dng files that require the full Adobe DNG SDK. It is difficult to evaluate if this is working how it is supposed to. I am planning to get more data points so we can evaluate it, but if anyone has dngs that don't work with the library that would be helpful to add to out test suite.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant