OpenEXR 2.2 add support for Dreamworks DWAA / DWAB compression

This patch makes it possible for the user to select all supported compression types in OpenEXR 2.2

Discussion points:
 - B44 is only defined for half's it compresses to a fixed representation of 44% of the halfs. We do currently not reflect in the UI that in the case of float32's it will be equal to compression = NONE
 - ZIPS is single scanline zip and is supposed to be useful in cases where importing in Nuke happens.
 - The new Dreamworks formats, are the worth exposing etc etc

Reviewers: campbellbarton, sergey

Reviewed By: sergey

Projects: #bf_blender

Differential Revision: https://developer.blender.org/D1050
This commit is contained in:
Martijn Berger 2015-03-12 14:02:33 +01:00
parent 2814039ee3
commit ae45496812
4 changed files with 65 additions and 6 deletions

View File

@ -202,7 +202,7 @@ typedef struct ImBuf {
#define OPENEXR (1 << 22)
#define OPENEXR_HALF (1 << 8 )
#define OPENEXR_COMPRESS (7)
#define OPENEXR_COMPRESS (15)
#ifdef WITH_CINEON
#define CINEON (1 << 21)

View File

@ -38,6 +38,8 @@
#include <errno.h>
#include <algorithm>
#include "DNA_scene_types.h" /* For OpenEXR compression constants */
#include <openexr_api.h>
#if defined (WIN32) && !defined(FREE_WINDOWS)
@ -284,21 +286,38 @@ int imb_is_a_openexr(unsigned char *mem)
static void openexr_header_compression(Header *header, int compression)
{
switch (compression) {
case 0:
case R_IMF_EXR_CODEC_NONE:
header->compression() = NO_COMPRESSION;
break;
case 1:
case R_IMF_EXR_CODEC_PXR24:
header->compression() = PXR24_COMPRESSION;
break;
case 2:
case R_IMF_EXR_CODEC_ZIP:
header->compression() = ZIP_COMPRESSION;
break;
case 3:
case R_IMF_EXR_CODEC_PIZ:
header->compression() = PIZ_COMPRESSION;
break;
case 4:
case R_IMF_EXR_CODEC_RLE:
header->compression() = RLE_COMPRESSION;
break;
case R_IMF_EXR_CODEC_ZIPS:
header->compression() = ZIPS_COMPRESSION;
break;
case R_IMF_EXR_CODEC_B44:
header->compression() = B44_COMPRESSION;
break;
case R_IMF_EXR_CODEC_B44A:
header->compression() = B44A_COMPRESSION;
break;
#if OPENEXR_VERSION_MAJOR >= 2 && OPENEXR_VERSION_MINOR >= 2
case R_IMF_EXR_CODEC_DWAA:
header->compression() = DWAA_COMPRESSION;
break;
case R_IMF_EXR_CODEC_DWAB:
header->compression() = DWAB_COMPRESSION;
break;
#endif
default:
header->compression() = ZIP_COMPRESSION;
break;

View File

@ -350,6 +350,12 @@ typedef struct ImageFormatData {
#define R_IMF_EXR_CODEC_ZIP 2
#define R_IMF_EXR_CODEC_PIZ 3
#define R_IMF_EXR_CODEC_RLE 4
#define R_IMF_EXR_CODEC_ZIPS 5
#define R_IMF_EXR_CODEC_B44 6
#define R_IMF_EXR_CODEC_B44A 7
#define R_IMF_EXR_CODEC_DWAA 8
#define R_IMF_EXR_CODEC_DWAB 9
#define R_IMF_EXR_CODEC_MAX 10
/* ImageFormatData.jp2_flag */
#define R_IMF_JP2_FLAG_YCC (1<<0) /* when disabled use RGB */ /* was R_JPEG2K_YCC */

View File

@ -82,6 +82,11 @@ EnumPropertyItem exr_codec_items[] = {
{R_IMF_EXR_CODEC_ZIP, "ZIP", 0, "ZIP (lossless)", ""},
{R_IMF_EXR_CODEC_PIZ, "PIZ", 0, "PIZ (lossless)", ""},
{R_IMF_EXR_CODEC_RLE, "RLE", 0, "RLE (lossless)", ""},
{R_IMF_EXR_CODEC_ZIPS, "ZIPS", 0, "ZIPS (lossless)", ""},
{R_IMF_EXR_CODEC_B44, "B44", 0, "B44 (lossy)", ""},
{R_IMF_EXR_CODEC_B44A, "B44A", 0, "B44A (lossy)", ""},
{R_IMF_EXR_CODEC_DWAA, "DWAA", 0, "DWAA (lossy)", ""},
{R_IMF_EXR_CODEC_DWAB, "DWAB", 0, "DWAB (lossy)", ""},
{0, NULL, 0, NULL, NULL}
};
#endif
@ -938,6 +943,34 @@ static EnumPropertyItem *rna_ImageFormatSettings_color_depth_itemf(bContext *UNU
}
}
#ifdef WITH_OPENEXR
/* OpenEXR */
static EnumPropertyItem *rna_ImageFormatSettings_exr_codec_itemf(bContext *UNUSED(C), PointerRNA *ptr,
PropertyRNA *UNUSED(prop), bool *r_free)
{
ImageFormatData *imf = (ImageFormatData *)ptr->data;
EnumPropertyItem *item = NULL;
int i = 1, totitem = 0;
if(imf->depth == 16)
return exr_codec_items; /* All compression types are defined for halfs */
for (i = 0; i < R_IMF_EXR_CODEC_MAX; i++) {
if((i == R_IMF_EXR_CODEC_B44 || i == R_IMF_EXR_CODEC_B44A))
continue; /* B44 and B44A are not defined for 32 bit floats */
RNA_enum_item_add(&item, &totitem, &exr_codec_items[i]);
}
RNA_enum_item_end(&item, &totitem);
*r_free = true;
return item;
}
#endif
static int rna_SceneRender_file_ext_length(PointerRNA *ptr)
{
RenderData *rd = (RenderData *)ptr->data;
@ -4101,6 +4134,7 @@ static void rna_def_scene_image_format_data(BlenderRNA *brna)
prop = RNA_def_property(srna, "exr_codec", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "exr_codec");
RNA_def_property_enum_items(prop, exr_codec_items);
RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_ImageFormatSettings_exr_codec_itemf");
RNA_def_property_ui_text(prop, "Codec", "Codec settings for OpenEXR");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);