Orange: Further cleanup of EXR saving
- F10 scene buttons now has options "half" and "zbuf" for exr saving. Note: when no float buffer is available, it always saves as "half", that's sufficient anyway, since half is 16 bits per channel. - EXR in imbuf now uses compliant ibuf->ftype flags for denoting exr extensions such as 'half' and 'compression'. - Removed ugly blenkernel dependency from exr module
This commit is contained in:
@@ -134,15 +134,9 @@ typedef enum {
|
||||
#define IB_mem (1 << 14)
|
||||
#define IB_rectfloat (1 << 15)
|
||||
|
||||
/**@}*/
|
||||
|
||||
/** \name imbuf_formats Image file formats
|
||||
* \brief These defines are bit flags for the various image file formats.
|
||||
*/
|
||||
/**@{*/
|
||||
/** \brief Identifier for an image file format.
|
||||
*
|
||||
/*
|
||||
* The bit flag is stored in the ImBuf.ftype variable.
|
||||
* Note that the lower 10 bits is used for storing custom flags
|
||||
*/
|
||||
#define AMI (1 << 31)
|
||||
#define PNG (1 << 30)
|
||||
@@ -157,7 +151,10 @@ typedef enum {
|
||||
|
||||
#define RADHDR (1 << 24)
|
||||
#define TIF (1 << 23)
|
||||
|
||||
#define OPENEXR (1 << 22)
|
||||
#define OPENEXR_HALF (1 << 8 )
|
||||
#define OPENEXR_COMPRESS (7)
|
||||
|
||||
#define RAWTGA (TGA | 1)
|
||||
|
||||
|
||||
@@ -39,8 +39,6 @@ extern "C"
|
||||
#include "IMB_imbuf.h"
|
||||
|
||||
#include "IMB_allocimbuf.h"
|
||||
#include "BKE_global.h"
|
||||
#include "DNA_scene_types.h"
|
||||
}
|
||||
|
||||
#include <iostream>
|
||||
@@ -150,27 +148,18 @@ static void openexr_header_compression(Header *header, int compression)
|
||||
}
|
||||
}
|
||||
|
||||
short imb_save_openexr_half(struct ImBuf *ibuf, char *name, int flags)
|
||||
static short imb_save_openexr_half(struct ImBuf *ibuf, char *name, int flags)
|
||||
{
|
||||
|
||||
int width = ibuf->x;
|
||||
int height = ibuf->y;
|
||||
|
||||
if (flags & IB_mem)
|
||||
{
|
||||
printf("OpenEXR-save: Create EXR in memory CURRENTLY NOT SUPPORTED !\n");
|
||||
imb_addencodedbufferImBuf(ibuf);
|
||||
ibuf->encodedsize = 0;
|
||||
return(0);
|
||||
}
|
||||
|
||||
int write_zbuf = (flags & IB_zbuf) && ibuf->zbuf != NULL; // summarize
|
||||
|
||||
try
|
||||
{
|
||||
Header header (width, height);
|
||||
|
||||
openexr_header_compression(&header, G.scene->r.quality);
|
||||
openexr_header_compression(&header, ibuf->ftype & OPENEXR_COMPRESS);
|
||||
|
||||
header.channels().insert ("R", Channel (HALF));
|
||||
header.channels().insert ("G", Channel (HALF));
|
||||
@@ -249,30 +238,18 @@ short imb_save_openexr_half(struct ImBuf *ibuf, char *name, int flags)
|
||||
return (1);
|
||||
}
|
||||
|
||||
short imb_save_openexr_float(struct ImBuf *ibuf, char *name, int flags)
|
||||
static short imb_save_openexr_float(struct ImBuf *ibuf, char *name, int flags)
|
||||
{
|
||||
|
||||
int width = ibuf->x;
|
||||
int height = ibuf->y;
|
||||
|
||||
if (flags & IB_mem)
|
||||
{
|
||||
printf("OpenEXR-save: Create EXR in memory CURRENTLY NOT SUPPORTED !\n");
|
||||
imb_addencodedbufferImBuf(ibuf);
|
||||
ibuf->encodedsize = 0;
|
||||
return(0);
|
||||
}
|
||||
|
||||
if (ibuf->rect_float==NULL)
|
||||
return(0);
|
||||
|
||||
int write_zbuf = (flags & IB_zbuf) && ibuf->zbuf != NULL; // summarize
|
||||
|
||||
try
|
||||
{
|
||||
Header header (width, height);
|
||||
|
||||
openexr_header_compression(&header, G.scene->r.quality);
|
||||
openexr_header_compression(&header, ibuf->ftype & OPENEXR_COMPRESS);
|
||||
|
||||
header.channels().insert ("R", Channel (FLOAT));
|
||||
header.channels().insert ("G", Channel (FLOAT));
|
||||
@@ -313,6 +290,26 @@ short imb_save_openexr_float(struct ImBuf *ibuf, char *name, int flags)
|
||||
}
|
||||
|
||||
|
||||
short imb_save_openexr(struct ImBuf *ibuf, char *name, int flags)
|
||||
{
|
||||
if (flags & IB_mem)
|
||||
{
|
||||
printf("OpenEXR-save: Create EXR in memory CURRENTLY NOT SUPPORTED !\n");
|
||||
imb_addencodedbufferImBuf(ibuf);
|
||||
ibuf->encodedsize = 0;
|
||||
return(0);
|
||||
}
|
||||
|
||||
if (ibuf->ftype & OPENEXR_HALF)
|
||||
return imb_save_openexr_half(ibuf, name, flags);
|
||||
else {
|
||||
/* when no float rect, we save as half (16 bits is sufficient) */
|
||||
if (ibuf->rect_float==NULL)
|
||||
return imb_save_openexr_half(ibuf, name, flags);
|
||||
else
|
||||
return imb_save_openexr_float(ibuf, name, flags);
|
||||
}
|
||||
}
|
||||
|
||||
struct ImBuf *imb_load_openexr(unsigned char *mem, int size, int flags)
|
||||
{
|
||||
@@ -437,5 +434,6 @@ struct ImBuf *imb_load_openexr(unsigned char *mem, int size, int flags)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // export "C"
|
||||
|
||||
@@ -49,8 +49,7 @@ extern "C" {
|
||||
|
||||
int imb_is_a_openexr(unsigned char *mem);
|
||||
|
||||
short imb_save_openexr_half(struct ImBuf *ibuf, char *name, int flags);
|
||||
short imb_save_openexr_float(struct ImBuf *ibuf, char *name, int flags);
|
||||
short imb_save_openexr(struct ImBuf *ibuf, char *name, int flags);
|
||||
|
||||
struct ImBuf *imb_load_openexr(unsigned char *mem, int size, int flags);
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ short IMB_saveiff(struct ImBuf *ibuf, char *name, int flags)
|
||||
}
|
||||
#ifdef WITH_OPENEXR
|
||||
if (IS_openexr(ibuf)) {
|
||||
return imb_save_openexr_half(ibuf, name, flags);
|
||||
return imb_save_openexr(ibuf, name, flags);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -320,7 +320,6 @@ void curvemap_buttons(struct uiBlock *block, struct CurveMapping *cumap, char la
|
||||
|
||||
#define B_SET_EDGE 1643
|
||||
#define B_SET_ZBLUR 1644
|
||||
#define B_SET_OPENEXR 1645
|
||||
|
||||
/* *********************** */
|
||||
#define B_ARMATUREBUTS 1800
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
/**
|
||||
* blenlib/DNA_scene_types.h (mar-2001 nzc)
|
||||
*
|
||||
* Renderrecipe and scene decription. The fact that there is a
|
||||
* hierarchy here is a bit strange, and not desirable.
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
|
||||
@@ -117,7 +112,7 @@ typedef struct RenderData {
|
||||
|
||||
short dimensionspreset; /* for the dimensions presets menu */
|
||||
|
||||
short filtertype, pad; /* filter is box, tent, gauss, mitch, etc */
|
||||
short filtertype; /* filter is box, tent, gauss, mitch, etc */
|
||||
|
||||
|
||||
short size, maximsize; /* size in %, max in Kb */
|
||||
@@ -146,14 +141,14 @@ typedef struct RenderData {
|
||||
* The number of part to use in the y direction
|
||||
*/
|
||||
short yparts;
|
||||
/* should rewrite this I think... */
|
||||
rctf safety, border;
|
||||
|
||||
short winpos, planes, imtype;
|
||||
short winpos, planes, imtype, subimtype;
|
||||
|
||||
/** Mode bits: */
|
||||
/* 0: Enable backbuffering for images */
|
||||
short bufflag;
|
||||
short quality;
|
||||
|
||||
/**
|
||||
* Flags for render settings. Use bit-masking to access the settings.
|
||||
* 0: enable sequence output rendering
|
||||
@@ -210,6 +205,9 @@ typedef struct RenderData {
|
||||
* identical materials with this number.*/
|
||||
short same_mat_redux;
|
||||
|
||||
/* safety and border rect */
|
||||
rctf safety, border;
|
||||
|
||||
/**
|
||||
* The gamma for the normal rendering. Used when doing
|
||||
* oversampling, to correctly blend subpixels to pixels. */
|
||||
@@ -407,6 +405,11 @@ typedef struct Scene {
|
||||
#define R_TIFF 22
|
||||
#define R_OPENEXR 23
|
||||
|
||||
/* subimtype, flag options for imtype */
|
||||
#define R_OPENEXR_HALF 1
|
||||
#define R_OPENEXR_ZBUF 2
|
||||
|
||||
|
||||
/* **************** SCENE ********************* */
|
||||
#define RAD_PHASE_PATCHES 1
|
||||
#define RAD_PHASE_FACES 2
|
||||
|
||||
@@ -1218,12 +1218,13 @@ static void render_panel_format(void)
|
||||
|
||||
#ifdef __sgi
|
||||
yofs = 76;
|
||||
uiDefButS(block, NUM,B_DIFF,"MaxSize:", 892,32,165,20, &G.scene->r.maximsize, 0.0, 500.0, 0, 0, "Maximum size per frame to save in an SGI movie");
|
||||
uiDefButBitI(block, TOG, R_COSMO, 0,"Cosmo", 1059,32,60,20, &G.scene->r.mode, 0, 0, 0, 0, "Attempt to save SGI movies using Cosmo hardware");
|
||||
uiDefButS(block, NUM,B_DIFF,"MaxSize:", 892,32,165,20, &G.scene->r.maximsize, 0.0, 500.0, 0, 0, "Maximum size per frame to save in an SGI movie");
|
||||
uiDefButBitI(block, TOG, R_COSMO, 0,"Cosmo", 1059,32,60,20, &G.scene->r.mode, 0, 0, 0, 0, "Attempt to save SGI movies using Cosmo hardware");
|
||||
#endif
|
||||
|
||||
|
||||
uiDefButS(block, MENU,B_FILETYPEMENU,imagetype_pup(), 892,yofs,174,20, &G.scene->r.imtype, 0, 0, 0, 0, "Images are saved in this file format");
|
||||
uiDefButBitI(block, TOG, R_MOVIECROP, B_DIFF, "Crop", 1068,yofs,51,20, &G.scene->r.mode, 0, 0, 0, 0, "Exclude border rendering from total image");
|
||||
uiDefButBitI(block, TOG, R_MOVIECROP, B_DIFF, "Crop", 1068,yofs,51,20, &G.scene->r.mode, 0, 0, 0, 0, "Exclude border rendering from total image");
|
||||
|
||||
yofs -= 22;
|
||||
|
||||
@@ -1258,12 +1259,21 @@ static void render_panel_format(void)
|
||||
uiDefBut(block, BUT,B_SELECTCODEC, "Set codec", 892,yofs,112,20, 0, 0, 0, 0, 0, "Set codec settings for AVI");
|
||||
}
|
||||
#ifdef WITH_OPENEXR
|
||||
} else if (G.scene->r.imtype == R_OPENEXR ) {
|
||||
}
|
||||
else if (G.scene->r.imtype == R_OPENEXR ) {
|
||||
if (G.scene->r.quality > 5) G.scene->r.quality = 0;
|
||||
uiDefButS(block, MENU,B_SET_OPENEXR, "Codec %t|None %x0|Pxr24 (lossy) %x1|ZIP (lossless) %x2|PIZ (lossless) %x3|RLE (lossless) %x4", 892,yofs,112,20, &G.scene->r.quality, 0, 0, 0, 0, "Set codec settings for OpenEXR");
|
||||
|
||||
uiBlockBeginAlign(block);
|
||||
uiDefButBitS(block, TOG, R_OPENEXR_HALF, B_NOP,"Half", 892,yofs+44,60,20, &G.scene->r.subimtype, 0, 0, 0, 0, "Use 16 bits float 'Half' type");
|
||||
uiDefButBitS(block, TOG, R_OPENEXR_ZBUF, B_NOP,"Zbuf", 952,yofs+44,60,20, &G.scene->r.subimtype, 0, 0, 0, 0, "Save the zbuffer as 32 bits unsigned int");
|
||||
uiBlockEndAlign(block);
|
||||
|
||||
uiDefButS(block, MENU,B_NOP, "Codec %t|None %x0|Pxr24 (lossy) %x1|ZIP (lossless) %x2|PIZ (lossless) %x3|RLE (lossless) %x4",
|
||||
892,yofs,112,20, &G.scene->r.quality, 0, 0, 0, 0, "Set codec settings for OpenEXR");
|
||||
|
||||
#endif
|
||||
} else {
|
||||
if(G.scene->r.quality < 5) G.scene->r.quality = 90; // temp
|
||||
if(G.scene->r.quality < 5) G.scene->r.quality = 90; /* restore from openexr */
|
||||
|
||||
uiDefButS(block, NUM,B_DIFF, "Quality:", 892,yofs,112,20, &G.scene->r.quality, 10.0, 100.0, 0, 0, "Quality setting for JPEG images, AVI Jpeg and SGI movies");
|
||||
}
|
||||
|
||||
@@ -88,7 +88,12 @@ void write_screendump(char *name)
|
||||
else if((G.have_libtiff) &&
|
||||
(G.scene->r.imtype==R_TIFF)) ibuf->ftype= TIF;
|
||||
#ifdef WITH_OPENEXR
|
||||
else if(G.scene->r.imtype==R_OPENEXR) ibuf->ftype= OPENEXR;
|
||||
else if(G.scene->r.imtype==R_OPENEXR) {
|
||||
ibuf->ftype= OPENEXR;
|
||||
if(G.scene->r.subimtype & R_OPENEXR_HALF)
|
||||
ibuf->ftype |= OPENEXR_HALF;
|
||||
ibuf->ftype |= (G.scene->r.quality & OPENEXR_COMPRESS);
|
||||
}
|
||||
#endif
|
||||
else if(G.scene->r.imtype==R_HAMX) ibuf->ftype= AN_hamx;
|
||||
else if(ELEM5(G.scene->r.imtype, R_MOVIE, R_AVICODEC, R_AVIRAW, R_AVIJPEG, R_JPEG90)) {
|
||||
|
||||
@@ -191,9 +191,8 @@ void schrijfplaatje(char *name)
|
||||
else if(R.r.imtype==R_IRIZ) {
|
||||
ibuf->ftype= IMAGIC;
|
||||
if (ibuf->zbuf == 0) {
|
||||
if (R.rectz) {
|
||||
if (R.rectz)
|
||||
ibuf->zbuf = (int *)R.rectz;
|
||||
}
|
||||
else printf("no zbuf\n");
|
||||
}
|
||||
}
|
||||
@@ -211,7 +210,15 @@ void schrijfplaatje(char *name)
|
||||
}
|
||||
#ifdef WITH_OPENEXR
|
||||
else if(R.r.imtype==R_OPENEXR) {
|
||||
/* ibuf stores bitmasks for types */
|
||||
ibuf->ftype= OPENEXR;
|
||||
if(R.r.subimtype & R_OPENEXR_HALF)
|
||||
ibuf->ftype |= OPENEXR_HALF;
|
||||
|
||||
ibuf->ftype |= (R.r.quality & OPENEXR_COMPRESS);
|
||||
|
||||
if(R.rectz && (R.r.subimtype & R_OPENEXR_ZBUF))
|
||||
ibuf->zbuf = (int *)R.rectz;
|
||||
}
|
||||
#endif
|
||||
else if((R.r.imtype==R_TARGA) || (R.r.imtype==R_PNG)) {
|
||||
@@ -533,6 +540,7 @@ void BIF_save_rendered_image(void)
|
||||
}
|
||||
|
||||
R.r.imtype= G.scene->r.imtype;
|
||||
R.r.subimtype= G.scene->r.subimtype;
|
||||
R.r.quality= G.scene->r.quality;
|
||||
R.r.planes= G.scene->r.planes;
|
||||
|
||||
|
||||
@@ -66,6 +66,9 @@ int BIF_write_ibuf(ImBuf *ibuf, char *name)
|
||||
#ifdef WITH_OPENEXR
|
||||
else if (G.scene->r.imtype==R_OPENEXR) {
|
||||
ibuf->ftype= OPENEXR;
|
||||
if(G.scene->r.subimtype & R_OPENEXR_HALF)
|
||||
ibuf->ftype |= OPENEXR_HALF;
|
||||
ibuf->ftype |= (G.scene->r.quality & OPENEXR_COMPRESS);
|
||||
}
|
||||
#endif
|
||||
else if ((G.scene->r.imtype==R_TARGA) || (G.scene->r.imtype==R_PNG)) {
|
||||
|
||||
Reference in New Issue
Block a user