[ Beneath the Waves ]

DaVinci's Shadow

article by Ben Lincoln, software by numerous developers

 

DaVinci's Shadow is an experimental fork I created of DaVinci, a command-line data-processing tool written by Arizona State University for NASA's Jet Propulsion Laboratory. The changes I made are minor, but very necessary for some of the core functionality I wanted to use in The Mirror's Surface Breaks.

If you just want to process images with TMSB, you can ignore everything on this page. You don't need any of it. The main reason this page is here is to explain why I needed to fork DaVinci to do what I wanted to do with TMSB, and to comply with the GPL by providing full source that will allow someone who wants to to build it themselves.

Alterations From The Mainline Version

DaVinci's Shadow 2.9.2 is based on version 2.09 of DaVinci (as of version 1.3 of The Mirror's Surface Breaks - prior releases were based on version 2.05 of DaVinci), and has had these modifications performed:

Known Issues

Building DaVinci's Shadow on Linux

This is an easy process. See DaVinci's Shadow Build Process - Linux.

Building DaVinci's Shadow on Windows®

Prior to version 1.3 of TMSB, I built the Windows® version of DaVinci's Shadow on a Windows® XP VM running MinGW and MSYS. This is a laborious environment to set up, but see DaVinci's Shadow Build Process - Windows for the instructions if you would like to attempt it. You may encounter unexpected issues attempting to use that process for versions 2.9.2 and later of DaVinci's Shadow. Windows® users don't need to do this unless they want to compile the software themselves for some reason - TMSB includes pre-built executables for 32-bit and 64-bit Windows®.

Cross-Compiling DaVinci's Shadow on Linux for Windows®

This is the method I've begun to use more recently for generating the Windows® version of DaVinci's Shadow. It still involves a lot more work to get the build environment up and running than the regular Linux compile, but is much less problematic than the MinGW/MSYS combination under Windows®. See DaVinci's Shadow Build Process - Cross-Compiling For Windows on Linux for the instructions. Windows® users don't need to do this unless they want to compile the software themselves for some reason - TMSB includes pre-built executables for 32-bit and 64-bit Windows®.

Building DaVinci's Shadow on BSD

This is a bit of a headache, but I'm sure BSD users are used to those by now. See DaVinci's Shadow Build Process - BSD.

Building DaVinci's Shadow on MacOS

I don't have access to a Mac, so I can't guarantee this will work. You may be able to use a similar process to the one described in DaVinci's Shadow Build Process - BSD, although you'll probably also need to install most/all of the packages listed in the DaVinci's Shadow Build Process - Linux article (most of them were installed by default in the BSD distribution I used). You should be able to get them from The MacPorts Project. If you are successful (or not), please let me know. If someone wants to donate a PowerBook or other MacOS laptop (it doesn't have to be high-end or brand new, but it does need to have an Intel processor, unless you want me to try to make it work on the older Power-based hardware), I'll see what I can do. I don't have room for a MacOS desktop, even if it's free.

Download Options

There are three downloads available at the bottom of this page: the precompiled Windows® version, the full source code, and the source files that I changed from the stock DaVinci versions. If you really don't trust me, you can download the 2.09 version of the source code from ASU's website, then apply the files in the last archive to it. If you really don't trust me, you can paste in the specific changes from those files into the files of the same names in the stock code. Everything I added or changed is generally contained in comment blocks that look like this:

/* DaVinci's Shadow customization - custom colourspace conversions - part 1 of 2 - Begin */

...code...

/* DaVinci's Shadow customization - custom colourspace conversions - part 1 of 2 - End */

Note: the build_utils directory in the "diff" file is mostly original content from ASU, but it's not included with their normal source package.

Update History

Changes in version 2.9.2

16-Bit-Per-Channel Image I/O - Detailed Discussion

When I first started monkeying around with DaVinci back in early 2010, one of the first things I noticed is that it had some issues with 16-bit-per-channel ("48-bit") images. It could read 16-bit-per-channel TIFFs just fine, but writing them to disk resulted in a corrupted image. A similar issue plagued the PNG support, but in addition, reading PNGs also resulted in corrupt data being loaded into the tool (although the original file on disk was unaffected).

It turned out that the issue with writing to disk was related to how DaVinci loaded that type of image. A 16-bit-per-channel PNG or TIFF has its data represented as "unsigned integers". That is, each value is between 0 and 65535. DaVinci uses a "signed integer" format for 16-bit numbers, where each value is between -32768 and 32767. There was a step in the file-loading code to convert the unsigned integers in the file into signed integers, but there was no corresponding step during the file-writing code.

The issue with PNGs was related to another exciting aspect of cross-platform development called "endian-ness": each 16-bit value is actually stored as two 8-bit bytes, and those bytes were being handled in the wrong order.

This is a lot easier to understand by looking at the test images I made:

Image I/O Test Images
[ Greyscale ]
Greyscale
[ RGB ]
RGB
[ ARGB ]
ARGB
   

This is the way they should look...

 

...and then seeing the results when the unmodified code is used:

Bad Results
[ 16BPC - TIFF ]
16BPC - TIFF
[ 16BPC - PNG ]
16BPC - PNG
[ 16BPC - TIFF ]
16BPC - TIFF
[ 16BPC - PNG ]
16BPC - PNG
[ 16BPC - TIFF ]
16BPC - TIFF

...this is the sort of result that will crop up with the unmodified DaVinci code when 16-bit-per-channel TIFF or PNG output is used.

 

If you'd like to try this for yourself, you can download dshadow_iotest-1.0.tar.bz2 from the bottom of this page. It isn't a comprehensive test, but it is fairly thorough - it actually caught some subtle issues in my code right before I was about to release TMSB 1.3, which is why DaVinci's Shadow is up to version 2.9.2 instead of just 2.9 or 2.9.1.

The DaVinci developers came up with a different approach, which is to upconvert 16-bit-per-channel images to 32-bit integer values. I am not a big fan of this, for two main reasons:

I don't blame the DaVinci developers for this, though. DaVinci is mostly intended for scientific use, and I doubt most of its main users use PNGs or TIFFs at all. But I still backed out the change in DaVinci's Shadow 2.9.2.

 
Download
File Size Version Release Date Author
DaVinci's Shadow (Source Code) 41 MiB 2.9.2 2012-01-15 Numerous
This is the complete source code package for DaVinci's Shadow 2.9.2. If you are compiling DaVinci's Shadow, this is probably the file you want.
 
Download
File Size Version Release Date Author
DaVinci's Shadow (Source Code - Differences Only) 997 KiB 2.9.2 2012-01-15 Numerous
This is all of the files that are changed in DaVinci's Shadow 2.9.2 compared to the stock DaVinci 2.09, in case you want to make the task of examining the differences faster.
 
Download
File Size Version Release Date Author
DaVinci's Shadow Image I/O Test Script 8 MiB 1.0 2012-01-15 Numerous
A script to test various PNG/TIFF input/output combinations to make sure the data is uncorrupted.
 
Download
File Size Version Release Date Author
DaVinci's Shadow (Source Code) 55 MiB 2.05 2011-02-20 Numerous
 
 
Download
File Size Version Release Date Author
DaVinci's Shadow (Source Code) - Differences Only 123 KiB 2.05 2011-02-20 Numerous
The files containing content I added or changed from the stock DaVinci. You will need the 2.05 sourcecode from ASU's website to make effective use of this file.
 
[ Page Icon ]