OpenImageIO/oiio — pull request #435 by lgritz (2012-09-20 22:25:55+00:00)
Title: OpenEXR 2.x support: part 1 -- multi-part EXR

This set of changes works toward fully supporting OpenEXR 2.0. There are two new features in OpenEXR 2.0: (1) multi-part EXR (a limited implementation of multiple images in one file), and (2) deep data (arbitrary numbers of data samples per pixel, and varying numbers of them with each pixel). This first review corresponds to (1).

Unfortunately, OpenEXR's library requires that the multi-part files declare the headers for all the parts upon opening the file. This is in contradiction to the way TIFF works, and therefore the way I had organized OIIO's APIs, to allow additional subimages to simply be appended one by one. So to accommodate this, I had to add a new API call to ImageOutput:

bool open (const std::string &name, int subimages, const ImageSpec *specs);

This lets you open with full information about the number and specification of subimages that you will be writing. A new supports("appendsubimage"), which returns true for TIFF, is used to indicate a format that can be output with the old appending method instead of requiring pre-declaration of the subimages.

I also changed oiiotool to use this new call in the appropriate way, and verified that all this stuff is working by adding a test that uses oiiotool to copy all the subimages of one of the new OpenEXR 2.0 test images. In the process, I changed the convention of the exr test images being stored in ../openexr-images-1.5.0 (which seems like a bad idea to have a specific version) to ../openexr-images. So beware that you may need to make a link on your end to ensure that the testsuite runs properly.

It was a much bigger pain to modify 'iconvert' to write multi-part OpenEXR files (or, more properly, to restructure it to use the new pre-declare flavor of the API), so I didn't do that at this time. That means that for now, please use oiiotool rather than iconvert if you anticipate needing to write multi-part OpenEXRs. I'm not sure if that's a serious limitation, if it is I can try to fix it, otherwise I'll get to it when I have a chance.

With this patch, OIIO will build with both OpenEXR 2.x as well as 1.x. Of course, if only 1.x is found at build time, the multi-part support won't be enabled. Also I've added top-level-Makefile OPENEXR_HOME=... and ILMBASE_HOME=... variables that let you override the location of those libraries.

I have one more set of changes coming after this one is approved and merged, which will add support for "deep" images, which I hope will be the last public API change before issuing a 1.2 release.