Group: Unstable (example)
Before going any further, this patch is not intended to be submitted as is, but is just a base for discussion.
DPX format is very flexible, and can store images in different color spaces (sRGB, Linear RGB, Cineon Log, other Log color spaces...). The main drawback of this flexibility is that a lot of software are not really compliant and output DPX with wrong header. Due to this, loading and converting DPX files automatically is difficult and error prone as you have a lot of chances to do something just wrong (eg. do a sRGB -> linear conversion whereas the file was actually in log color space).
The only way to prevent that is to let the user have the possibility to adjust the color conversion used, assuming he knows what he's doing and what color space is being used in the DPX file. Now that Blender includes and uses ocio, I think it's a good way to enhance the DPX files support.
This patch removes all the color space conversion code from the DPX code. Now, when a DPX file is loaded, color space is dynamically selected according to the file header information. If image is flagged as Cineon Log or Log, Cineon color space is selected, otherwise it just defaults to sRGB (same behavior than Nuke). The user can then adjust the setting if the result is not correct.
This also adds the possibility for users who know what they're doing to add color spaces in their ocio config file, and use them with their DPX files (something that is currently not possible if another color space conversion occurs internally in the DPX loading code).
To achieve that, I've added a function in the color management code, "colorspace_set_named", which selects a color space according to its name (or return FALSE if the color space does not exist).
Note also that YCbCr conversion are still done internally and are not planned to be removed.
When saving a DPX file, the image is flagged according to the color space selected in the color management settings :
- flagged as Cineon if Cineon Log color space is used
- flagged as Linear if Linear or sRGB color spaces used, or if the "Save As Render" option is turned off
- and flagged as "User Defined" for any other color spaces.
Then, the "Log" option is not needed anymore and has been removed from the file saving dialog.
Everything seems to work fine, but it definitely needs some more testing from users and a careful review from devs.
I'm open to any suggestions and remarks.