diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2015-07-13 14:58:17 +0300 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2015-07-13 14:58:17 +0300 |
commit | e142ae77cadf04103fbc643f21cf60891862f6a8 (patch) | |
tree | 142e25fccd5ba3e748a1652706e7e4f1220ca289 /source/blender/imbuf/intern | |
parent | 107bbee4c763c95ea5d07a3b2f08bfe3b6adb24c (diff) |
Imbuf types refactor.
ImBuf types were getting stored as bitflags in a 32bit integer which had
already run out of space. Solved the problem by separating file type to
an ftype enum, and file specific options to foptions.
Reviewed by Campbell, thanks a lot!
Diffstat (limited to 'source/blender/imbuf/intern')
-rw-r--r-- | source/blender/imbuf/intern/allocimbuf.c | 3 | ||||
-rw-r--r-- | source/blender/imbuf/intern/bmp.c | 2 | ||||
-rw-r--r-- | source/blender/imbuf/intern/cineon/cineon_dpx.c | 10 | ||||
-rw-r--r-- | source/blender/imbuf/intern/colormanagement.c | 2 | ||||
-rw-r--r-- | source/blender/imbuf/intern/dds/dds_api.cpp | 2 | ||||
-rw-r--r-- | source/blender/imbuf/intern/filetype.c | 30 | ||||
-rw-r--r-- | source/blender/imbuf/intern/iris.c | 8 | ||||
-rw-r--r-- | source/blender/imbuf/intern/jp2.c | 22 | ||||
-rw-r--r-- | source/blender/imbuf/intern/jpeg.c | 34 | ||||
-rw-r--r-- | source/blender/imbuf/intern/oiio/openimageio_api.cpp | 2 | ||||
-rw-r--r-- | source/blender/imbuf/intern/openexr/openexr_api.cpp | 10 | ||||
-rw-r--r-- | source/blender/imbuf/intern/png.c | 8 | ||||
-rw-r--r-- | source/blender/imbuf/intern/radiance_hdr.c | 2 | ||||
-rw-r--r-- | source/blender/imbuf/intern/targa.c | 8 | ||||
-rw-r--r-- | source/blender/imbuf/intern/thumbs.c | 2 | ||||
-rw-r--r-- | source/blender/imbuf/intern/tiff.c | 4 | ||||
-rw-r--r-- | source/blender/imbuf/intern/util.c | 2 |
17 files changed, 79 insertions, 72 deletions
diff --git a/source/blender/imbuf/intern/allocimbuf.c b/source/blender/imbuf/intern/allocimbuf.c index 79f869968d3..03fc2c0fa5d 100644 --- a/source/blender/imbuf/intern/allocimbuf.c +++ b/source/blender/imbuf/intern/allocimbuf.c @@ -409,7 +409,8 @@ ImBuf *IMB_allocImBuf(unsigned int x, unsigned int y, uchar planes, unsigned int ibuf->x = x; ibuf->y = y; ibuf->planes = planes; - ibuf->ftype = PNG | 15; /* the 15 means, set compression to low ratio but not time consuming */ + ibuf->ftype = IMB_FTYPE_PNG; + ibuf->foptions.quality = 15; /* the 15 means, set compression to low ratio but not time consuming */ ibuf->channels = 4; /* float option, is set to other values when buffers get assigned */ ibuf->ppm[0] = ibuf->ppm[1] = IMB_DPI_DEFAULT / 0.0254f; /* IMB_DPI_DEFAULT -> pixels-per-meter */ diff --git a/source/blender/imbuf/intern/bmp.c b/source/blender/imbuf/intern/bmp.c index 6c082e8828c..c5694148127 100644 --- a/source/blender/imbuf/intern/bmp.c +++ b/source/blender/imbuf/intern/bmp.c @@ -271,7 +271,7 @@ struct ImBuf *imb_bmp_decode(const unsigned char *mem, size_t size, int flags, c if (ibuf) { ibuf->ppm[0] = xppm; ibuf->ppm[1] = yppm; - ibuf->ftype = BMP; + ibuf->ftype = IMB_FTYPE_BMP; } return(ibuf); diff --git a/source/blender/imbuf/intern/cineon/cineon_dpx.c b/source/blender/imbuf/intern/cineon/cineon_dpx.c index 5c0af9e9816..3e2206dc013 100644 --- a/source/blender/imbuf/intern/cineon/cineon_dpx.c +++ b/source/blender/imbuf/intern/cineon/cineon_dpx.c @@ -86,7 +86,7 @@ static struct ImBuf *imb_load_dpx_cineon( } logImageClose(image); - ibuf->ftype = use_cineon ? CINEON : DPX; + ibuf->ftype = use_cineon ? IMB_FTYPE_CINEON : IMB_FTYPE_DPX; if (flags & IB_alphamode_detect) ibuf->flags |= IB_alphamode_premul; @@ -115,17 +115,17 @@ static int imb_save_dpx_cineon(ImBuf *ibuf, const char *filename, int use_cineon return 0; } - if (ibuf->ftype & CINEON_10BIT) + if (ibuf->foptions.flag & CINEON_10BIT) bitspersample = 10; - else if (ibuf->ftype & CINEON_12BIT) + else if (ibuf->foptions.flag & CINEON_12BIT) bitspersample = 12; - else if (ibuf->ftype & CINEON_16BIT) + else if (ibuf->foptions.flag & CINEON_16BIT) bitspersample = 16; else bitspersample = 8; logImage = logImageCreate(filename, use_cineon, ibuf->x, ibuf->y, bitspersample, (depth == 4), - (ibuf->ftype & CINEON_LOG), -1, -1, -1, "Blender"); + (ibuf->foptions.flag & CINEON_LOG), -1, -1, -1, "Blender"); if (logImage == NULL) { printf("DPX/Cineon: error creating file.\n"); diff --git a/source/blender/imbuf/intern/colormanagement.c b/source/blender/imbuf/intern/colormanagement.c index a61204ea850..5a3d9b4c653 100644 --- a/source/blender/imbuf/intern/colormanagement.c +++ b/source/blender/imbuf/intern/colormanagement.c @@ -1958,7 +1958,7 @@ ImBuf *IMB_colormanagement_imbuf_for_write(ImBuf *ibuf, bool save_as_render, boo * should be pretty safe since this image buffer is supposed to be used for * saving only and ftype would be overwritten a bit later by BKE_imbuf_write */ - colormanaged_ibuf->ftype = BKE_image_imtype_to_ftype(image_format_data->imtype); + colormanaged_ibuf->ftype = BKE_image_imtype_to_ftype(image_format_data->imtype, &colormanaged_ibuf->foptions); /* if file format isn't able to handle float buffer itself, * we need to allocate byte buffer and store color managed diff --git a/source/blender/imbuf/intern/dds/dds_api.cpp b/source/blender/imbuf/intern/dds/dds_api.cpp index cad76ffcee1..c963609b321 100644 --- a/source/blender/imbuf/intern/dds/dds_api.cpp +++ b/source/blender/imbuf/intern/dds/dds_api.cpp @@ -142,7 +142,7 @@ struct ImBuf *imb_load_dds(const unsigned char *mem, size_t size, int flags, cha ibuf = IMB_allocImBuf(dds.width(), dds.height(), bits_per_pixel, 0); if (ibuf == 0) return(0); /* memory allocation failed */ - ibuf->ftype = DDS; + ibuf->ftype = IMB_FTYPE_DDS; ibuf->dds_data.fourcc = dds.fourCC(); ibuf->dds_data.nummipmaps = dds.mipmapCount(); diff --git a/source/blender/imbuf/intern/filetype.c b/source/blender/imbuf/intern/filetype.c index e58cda07ecf..3d3e8a0646a 100644 --- a/source/blender/imbuf/intern/filetype.c +++ b/source/blender/imbuf/intern/filetype.c @@ -53,41 +53,41 @@ static int imb_ftype_default(const ImFileType *type, ImBuf *ibuf) { - return (ibuf->ftype & type->filetype); + return (ibuf->ftype == type->filetype); } static int imb_ftype_iris(const ImFileType *type, ImBuf *ibuf) { (void)type; - return (ibuf->ftype == IMAGIC); + return (ibuf->ftype == IMB_FTYPE_IMAGIC); } const ImFileType IMB_FILE_TYPES[] = { - {NULL, NULL, imb_is_a_jpeg, NULL, imb_ftype_default, imb_load_jpeg, NULL, imb_savejpeg, NULL, 0, JPG, COLOR_ROLE_DEFAULT_BYTE}, - {NULL, NULL, imb_is_a_png, NULL, imb_ftype_default, imb_loadpng, NULL, imb_savepng, NULL, 0, PNG, COLOR_ROLE_DEFAULT_BYTE}, - {NULL, NULL, imb_is_a_bmp, NULL, imb_ftype_default, imb_bmp_decode, NULL, imb_savebmp, NULL, 0, BMP, COLOR_ROLE_DEFAULT_BYTE}, - {NULL, NULL, imb_is_a_targa, NULL, imb_ftype_default, imb_loadtarga, NULL, imb_savetarga, NULL, 0, TGA, COLOR_ROLE_DEFAULT_BYTE}, - {NULL, NULL, imb_is_a_iris, NULL, imb_ftype_iris, imb_loadiris, NULL, imb_saveiris, NULL, 0, IMAGIC, COLOR_ROLE_DEFAULT_BYTE}, + {NULL, NULL, imb_is_a_jpeg, NULL, imb_ftype_default, imb_load_jpeg, NULL, imb_savejpeg, NULL, 0, IMB_FTYPE_JPG, COLOR_ROLE_DEFAULT_BYTE}, + {NULL, NULL, imb_is_a_png, NULL, imb_ftype_default, imb_loadpng, NULL, imb_savepng, NULL, 0, IMB_FTYPE_PNG, COLOR_ROLE_DEFAULT_BYTE}, + {NULL, NULL, imb_is_a_bmp, NULL, imb_ftype_default, imb_bmp_decode, NULL, imb_savebmp, NULL, 0, IMB_FTYPE_BMP, COLOR_ROLE_DEFAULT_BYTE}, + {NULL, NULL, imb_is_a_targa, NULL, imb_ftype_default, imb_loadtarga, NULL, imb_savetarga, NULL, 0, IMB_FTYPE_TGA, COLOR_ROLE_DEFAULT_BYTE}, + {NULL, NULL, imb_is_a_iris, NULL, imb_ftype_iris, imb_loadiris, NULL, imb_saveiris, NULL, 0, IMB_FTYPE_IMAGIC, COLOR_ROLE_DEFAULT_BYTE}, #ifdef WITH_CINEON - {NULL, NULL, imb_is_dpx, NULL, imb_ftype_default, imb_load_dpx, NULL, imb_save_dpx, NULL, IM_FTYPE_FLOAT, DPX, COLOR_ROLE_DEFAULT_FLOAT}, - {NULL, NULL, imb_is_cineon, NULL, imb_ftype_default, imb_load_cineon, NULL, imb_save_cineon, NULL, IM_FTYPE_FLOAT, CINEON, COLOR_ROLE_DEFAULT_FLOAT}, + {NULL, NULL, imb_is_dpx, NULL, imb_ftype_default, imb_load_dpx, NULL, imb_save_dpx, NULL, IM_FTYPE_FLOAT, IMB_FTYPE_DPX, COLOR_ROLE_DEFAULT_FLOAT}, + {NULL, NULL, imb_is_cineon, NULL, imb_ftype_default, imb_load_cineon, NULL, imb_save_cineon, NULL, IM_FTYPE_FLOAT, IMB_FTYPE_CINEON, COLOR_ROLE_DEFAULT_FLOAT}, #endif #ifdef WITH_TIFF - {imb_inittiff, NULL, imb_is_a_tiff, NULL, imb_ftype_default, imb_loadtiff, NULL, imb_savetiff, imb_loadtiletiff, 0, TIF, COLOR_ROLE_DEFAULT_BYTE}, + {imb_inittiff, NULL, imb_is_a_tiff, NULL, imb_ftype_default, imb_loadtiff, NULL, imb_savetiff, imb_loadtiletiff, 0, IMB_FTYPE_TIF, COLOR_ROLE_DEFAULT_BYTE}, #endif #ifdef WITH_HDR - {NULL, NULL, imb_is_a_hdr, NULL, imb_ftype_default, imb_loadhdr, NULL, imb_savehdr, NULL, IM_FTYPE_FLOAT, RADHDR, COLOR_ROLE_DEFAULT_FLOAT}, + {NULL, NULL, imb_is_a_hdr, NULL, imb_ftype_default, imb_loadhdr, NULL, imb_savehdr, NULL, IM_FTYPE_FLOAT, IMB_FTYPE_RADHDR, COLOR_ROLE_DEFAULT_FLOAT}, #endif #ifdef WITH_OPENEXR - {imb_initopenexr, NULL, imb_is_a_openexr, NULL, imb_ftype_default, imb_load_openexr, NULL, imb_save_openexr, NULL, IM_FTYPE_FLOAT, OPENEXR, COLOR_ROLE_DEFAULT_FLOAT}, + {imb_initopenexr, NULL, imb_is_a_openexr, NULL, imb_ftype_default, imb_load_openexr, NULL, imb_save_openexr, NULL, IM_FTYPE_FLOAT, IMB_FTYPE_OPENEXR, COLOR_ROLE_DEFAULT_FLOAT}, #endif #ifdef WITH_OPENJPEG - {NULL, NULL, imb_is_a_jp2, NULL, imb_ftype_default, imb_jp2_decode, NULL, imb_savejp2, NULL, IM_FTYPE_FLOAT, JP2, COLOR_ROLE_DEFAULT_BYTE}, + {NULL, NULL, imb_is_a_jp2, NULL, imb_ftype_default, imb_jp2_decode, NULL, imb_savejp2, NULL, IM_FTYPE_FLOAT, IMB_FTYPE_JP2, COLOR_ROLE_DEFAULT_BYTE}, #endif #ifdef WITH_DDS - {NULL, NULL, imb_is_a_dds, NULL, imb_ftype_default, imb_load_dds, NULL, NULL, NULL, 0, DDS, COLOR_ROLE_DEFAULT_BYTE}, + {NULL, NULL, imb_is_a_dds, NULL, imb_ftype_default, imb_load_dds, NULL, NULL, NULL, 0, IMB_FTYPE_DDS, COLOR_ROLE_DEFAULT_BYTE}, #endif #ifdef WITH_OPENIMAGEIO - {NULL, NULL, NULL, imb_is_a_photoshop, imb_ftype_default, NULL, imb_load_photoshop, NULL, NULL, IM_FTYPE_FLOAT, PSD, COLOR_ROLE_DEFAULT_FLOAT}, + {NULL, NULL, NULL, imb_is_a_photoshop, imb_ftype_default, NULL, imb_load_photoshop, NULL, NULL, IM_FTYPE_FLOAT, IMB_FTYPE_PSD, COLOR_ROLE_DEFAULT_FLOAT}, #endif {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0} }; diff --git a/source/blender/imbuf/intern/iris.c b/source/blender/imbuf/intern/iris.c index d2e3f7bff41..7a9fa2b9768 100644 --- a/source/blender/imbuf/intern/iris.c +++ b/source/blender/imbuf/intern/iris.c @@ -45,6 +45,8 @@ #include "IMB_colormanagement.h" #include "IMB_colormanagement_intern.h" +#define IMAGIC 0732 + typedef struct { unsigned short imagic; /* stuff saved on disk . . */ unsigned short type; @@ -299,7 +301,7 @@ struct ImBuf *imb_loadiris(const unsigned char *mem, size_t size, int flags, cha if (flags & IB_test) { ibuf = IMB_allocImBuf(image.xsize, image.ysize, 8 * image.zsize, 0); - if (ibuf) ibuf->ftype = IMAGIC; + if (ibuf) ibuf->ftype = IMB_FTYPE_IMAGIC; return(ibuf); } @@ -526,7 +528,7 @@ struct ImBuf *imb_loadiris(const unsigned char *mem, size_t size, int flags, cha } - ibuf->ftype = IMAGIC; + ibuf->ftype = IMB_FTYPE_IMAGIC; test_endian_zbuf(ibuf); @@ -701,7 +703,7 @@ static int output_iris(unsigned int *lptr, int xsize, int ysize, int zsize, cons lumbuf = (unsigned int *)MEM_mallocN(xsize * sizeof(int), "iris lumbuf"); memset(image, 0, sizeof(IMAGE)); - image->imagic = IMAGIC; + image->imagic = IMB_FTYPE_IMAGIC; image->type = RLE(1); if (zsize > 1) image->dim = 3; diff --git a/source/blender/imbuf/intern/jp2.c b/source/blender/imbuf/intern/jp2.c index 11733222e2f..7cb7636573b 100644 --- a/source/blender/imbuf/intern/jp2.c +++ b/source/blender/imbuf/intern/jp2.c @@ -232,11 +232,11 @@ struct ImBuf *imb_jp2_decode(const unsigned char *mem, size_t size, int flags, c return NULL; } - ibuf->ftype = JP2; + ibuf->ftype = IMB_FTYPE_JP2; if (is_jp2) - ibuf->ftype |= JP2_JP2; + ibuf->foptions.flag |= JP2_JP2; else - ibuf->ftype |= JP2_J2K; + ibuf->foptions.flag |= JP2_J2K; if (use_float) { float *rect_float = ibuf->rect_float; @@ -587,12 +587,12 @@ static opj_image_t *ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters) chanel_colormanage_cb = linearrgb_to_srgb; } - if (ibuf->ftype & JP2_CINE) { + if (ibuf->foptions.flag & JP2_CINE) { if (ibuf->x == 4096 || ibuf->y == 2160) parameters->cp_cinema = CINEMA4K_24; else { - if (ibuf->ftype & JP2_CINE_48FPS) { + if (ibuf->foptions.flag & JP2_CINE_48FPS) { parameters->cp_cinema = CINEMA2K_48; } else { @@ -613,10 +613,10 @@ static opj_image_t *ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters) } else { /* Get settings from the imbuf */ - color_space = (ibuf->ftype & JP2_YCC) ? CLRSPC_SYCC : CLRSPC_SRGB; + color_space = (ibuf->foptions.flag & JP2_YCC) ? CLRSPC_SYCC : CLRSPC_SRGB; - if (ibuf->ftype & JP2_16BIT) prec = 16; - else if (ibuf->ftype & JP2_12BIT) prec = 12; + if (ibuf->foptions.flag & JP2_16BIT) prec = 16; + else if (ibuf->foptions.flag & JP2_12BIT) prec = 12; else prec = 8; /* 32bit images == alpha channel */ @@ -952,7 +952,7 @@ static opj_image_t *ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters) /* Found write info at http://users.ece.gatech.edu/~slabaugh/personal/c/bitmapUnix.c */ int imb_savejp2(struct ImBuf *ibuf, const char *name, int flags) { - int quality = ibuf->ftype & 0xff; + int quality = ibuf->foptions.quality; int bSuccess; opj_cparameters_t parameters; /* compression parameters */ @@ -992,9 +992,9 @@ int imb_savejp2(struct ImBuf *ibuf, const char *name, int flags) opj_cinfo_t *cinfo = NULL; /* get a JP2 compressor handle */ - if (ibuf->ftype & JP2_JP2) + if (ibuf->foptions.flag & JP2_JP2) cinfo = opj_create_compress(CODEC_JP2); - else if (ibuf->ftype & JP2_J2K) + else if (ibuf->foptions.flag & JP2_J2K) cinfo = opj_create_compress(CODEC_J2K); else BLI_assert(!"Unsupported codec was specified in save settings"); diff --git a/source/blender/imbuf/intern/jpeg.c b/source/blender/imbuf/intern/jpeg.c index 8ddfd44649c..ff2a9767386 100644 --- a/source/blender/imbuf/intern/jpeg.c +++ b/source/blender/imbuf/intern/jpeg.c @@ -55,10 +55,10 @@ #include "IMB_colormanagement_intern.h" // #define IS_jpg(x) (x->ftype & JPG) // UNUSED -#define IS_stdjpg(x) ((x->ftype & JPG_MSK) == JPG_STD) -// #define IS_vidjpg(x) ((x->ftype & JPG_MSK) == JPG_VID) // UNUSED -#define IS_jstjpg(x) ((x->ftype & JPG_MSK) == JPG_JST) -#define IS_maxjpg(x) ((x->ftype & JPG_MSK) == JPG_MAX) +#define IS_stdjpg(x) ((x->foptions.flag & JPG_MSK) == JPG_STD) +// #define IS_vidjpg(x) ((x->foptions & JPG_MSK) == JPG_VID) // UNUSED +#define IS_jstjpg(x) ((x->foptions.flag & JPG_MSK) == JPG_JST) +#define IS_maxjpg(x) ((x->foptions.flag & JPG_MSK) == JPG_MAX) /* the types are from the jpeg lib */ static void jpeg_error(j_common_ptr cinfo) ATTR_NORETURN; @@ -85,7 +85,7 @@ static ImBuf *ibJpegImageFromCinfo(struct jpeg_decompress_struct *cinfo, int fla */ static int jpeg_default_quality; -static int ibuf_ftype; +static int ibuf_foptions; int imb_is_a_jpeg(const unsigned char *mem) { @@ -269,8 +269,8 @@ static boolean handle_app1(j_decompress_ptr cinfo) if (length < 16) { for (i = 0; i < length; i++) INPUT_BYTE(cinfo, neogeo[i], return false); length = 0; - if (STREQLEN(neogeo, "NeoGeo", 6)) memcpy(&ibuf_ftype, neogeo + 6, 4); - ibuf_ftype = BIG_LONG(ibuf_ftype); + if (STREQLEN(neogeo, "NeoGeo", 6)) memcpy(&ibuf_foptions, neogeo + 6, 4); + ibuf_foptions = BIG_LONG(ibuf_foptions); } INPUT_SYNC(cinfo); /* do before skip_input_data */ if (length > 0) (*cinfo->src->skip_input_data)(cinfo, length); @@ -290,7 +290,7 @@ static ImBuf *ibJpegImageFromCinfo(struct jpeg_decompress_struct *cinfo, int fla char *str, *key, *value; /* install own app1 handler */ - ibuf_ftype = 0; + ibuf_foptions = 0; jpeg_set_marker_processor(cinfo, 0xe1, handle_app1); cinfo->dct_method = JDCT_FLOAT; jpeg_save_markers(cinfo, JPEG_COM, 0xffff); @@ -304,11 +304,11 @@ static ImBuf *ibJpegImageFromCinfo(struct jpeg_decompress_struct *cinfo, int fla jpeg_start_decompress(cinfo); - if (ibuf_ftype == 0) { - ibuf_ftype = JPG_STD; + if (ibuf_foptions == 0) { + ibuf_foptions = JPG_STD; if (cinfo->max_v_samp_factor == 1) { - if (cinfo->max_h_samp_factor == 1) ibuf_ftype = JPG_MAX; - else ibuf_ftype = JPG_VID; + if (cinfo->max_h_samp_factor == 1) ibuf_foptions = JPG_MAX; + else ibuf_foptions = JPG_VID; } } @@ -435,7 +435,8 @@ next_stamp_marker: jpeg_destroy((j_common_ptr) cinfo); if (ibuf) { - ibuf->ftype = ibuf_ftype; + ibuf->ftype = IMB_FTYPE_JPG; + ibuf->foptions.flag = ibuf_foptions; } } @@ -485,9 +486,9 @@ static void write_jpeg(struct jpeg_compress_struct *cinfo, struct ImBuf *ibuf) jpeg_start_compress(cinfo, true); strcpy(neogeo, "NeoGeo"); - ibuf_ftype = BIG_LONG(ibuf->ftype); + ibuf_foptions = BIG_LONG((((int)ibuf->foptions.flag) << 8) | (int)ibuf->foptions.quality); - memcpy(neogeo + 6, &ibuf_ftype, 4); + memcpy(neogeo + 6, &ibuf_foptions, 4); jpeg_write_marker(cinfo, 0xe1, (JOCTET *) neogeo, 10); if (ibuf->metadata) { @@ -562,7 +563,7 @@ static int init_jpeg(FILE *outfile, struct jpeg_compress_struct *cinfo, struct I { int quality; - quality = ibuf->ftype & 0xff; + quality = ibuf->foptions.quality; if (quality <= 0) quality = jpeg_default_quality; if (quality > 100) quality = 100; @@ -687,6 +688,7 @@ static int save_jstjpeg(const char *name, struct ImBuf *ibuf) tbuf = IMB_allocImBuf(ibuf->x, ibuf->y / 2, 24, IB_rect); tbuf->ftype = ibuf->ftype; + tbuf->foptions = ibuf->foptions; tbuf->flags = ibuf->flags; oldy = ibuf->y; diff --git a/source/blender/imbuf/intern/oiio/openimageio_api.cpp b/source/blender/imbuf/intern/oiio/openimageio_api.cpp index 7728183d3b6..0a2e8742ba8 100644 --- a/source/blender/imbuf/intern/oiio/openimageio_api.cpp +++ b/source/blender/imbuf/intern/oiio/openimageio_api.cpp @@ -268,7 +268,7 @@ struct ImBuf *imb_load_photoshop(const char *filename, int flags, char colorspac return NULL; /* ImBuf always needs 4 channels */ - ibuf->ftype = PSD; + ibuf->ftype = IMB_FTYPE_PSD; ibuf->channels = 4; ibuf->planes = (3 + (is_alpha ? 1 : 0)) * 4 << basesize; diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index ff6f55a777b..cd9701cf7e7 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -391,7 +391,7 @@ static bool imb_save_openexr_half(ImBuf *ibuf, const char *name, const int flags { Header header(width, height); - openexr_header_compression(&header, ibuf->ftype & OPENEXR_COMPRESS); + openexr_header_compression(&header, ibuf->foptions.flag & OPENEXR_COMPRESS); openexr_header_metadata(&header, ibuf); /* create views when possible */ @@ -508,7 +508,7 @@ static bool imb_save_openexr_float(ImBuf *ibuf, const char *name, const int flag { Header header(width, height); - openexr_header_compression(&header, ibuf->ftype & OPENEXR_COMPRESS); + openexr_header_compression(&header, ibuf->foptions.flag & OPENEXR_COMPRESS); openexr_header_metadata(&header, ibuf); /* create views when possible */ @@ -580,7 +580,7 @@ int imb_save_openexr(struct ImBuf *ibuf, const char *name, int flags) return(0); } - if (ibuf->ftype & OPENEXR_HALF) + if (ibuf->foptions.flag & OPENEXR_HALF) return (int) imb_save_openexr_half(ibuf, name, flags, 1, NULL, NULL); else { /* when no float rect, we save as half (16 bits is sufficient) */ @@ -602,7 +602,7 @@ static bool imb_save_openexr_multiview(ImBuf *ibuf, const char *name, const int return false; } - if (ibuf->ftype & OPENEXR_HALF) + if (ibuf->foptions.flag & OPENEXR_HALF) return imb_save_openexr_half(ibuf, name, flags, totviews, getview, getbuffer); else { /* when no float rect, we save as half (16 bits is sufficient) */ @@ -1944,7 +1944,7 @@ struct ImBuf *imb_load_openexr(const unsigned char *mem, size_t size, int flags, ibuf->ppm[1] = ibuf->ppm[0] * (double)file->header(0).pixelAspectRatio(); } - ibuf->ftype = OPENEXR; + ibuf->ftype = IMB_FTYPE_OPENEXR; if (!(flags & IB_test)) { diff --git a/source/blender/imbuf/intern/png.c b/source/blender/imbuf/intern/png.c index 77a0f1dc1db..744a05c7091 100644 --- a/source/blender/imbuf/intern/png.c +++ b/source/blender/imbuf/intern/png.c @@ -140,7 +140,7 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags) int i, bytesperpixel, color_type = PNG_COLOR_TYPE_GRAY; FILE *fp = NULL; - bool is_16bit = (ibuf->ftype & PNG_16BIT) != 0; + bool is_16bit = (ibuf->foptions.flag & PNG_16BIT) != 0; bool has_float = (ibuf->rect_float != NULL); int channels_in_float = ibuf->channels ? ibuf->channels : 4; @@ -149,7 +149,7 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags) /* use the jpeg quality setting for compression */ int compression; - compression = (int)(((float)(ibuf->ftype & 0xff) / 11.1111f)); + compression = (int)(((float)(ibuf->foptions.quality) / 11.1111f)); compression = compression < 0 ? 0 : (compression > 9 ? 9 : compression); if (ibuf->float_colorspace) { @@ -606,9 +606,9 @@ ImBuf *imb_loadpng(const unsigned char *mem, size_t size, int flags, char colors ibuf = IMB_allocImBuf(width, height, 8 * bytesperpixel, 0); if (ibuf) { - ibuf->ftype = PNG; + ibuf->ftype = IMB_FTYPE_PNG; if (bit_depth == 16) - ibuf->ftype |= PNG_16BIT; + ibuf->foptions.flag |= PNG_16BIT; if (png_get_valid(png_ptr, info_ptr, PNG_INFO_pHYs)) { int unit_type; diff --git a/source/blender/imbuf/intern/radiance_hdr.c b/source/blender/imbuf/intern/radiance_hdr.c index 32293e9de78..f97860cc66c 100644 --- a/source/blender/imbuf/intern/radiance_hdr.c +++ b/source/blender/imbuf/intern/radiance_hdr.c @@ -241,7 +241,7 @@ struct ImBuf *imb_loadhdr(const unsigned char *mem, size_t size, int flags, char else ibuf = IMB_allocImBuf(width, height, 32, (flags & IB_rect) | IB_rectfloat); if (ibuf == NULL) return NULL; - ibuf->ftype = RADHDR; + ibuf->ftype = IMB_FTYPE_RADHDR; if (flags & IB_alphamode_detect) ibuf->flags |= IB_alphamode_premul; diff --git a/source/blender/imbuf/intern/targa.c b/source/blender/imbuf/intern/targa.c index 617fdab0618..7073d34e2bc 100644 --- a/source/blender/imbuf/intern/targa.c +++ b/source/blender/imbuf/intern/targa.c @@ -264,7 +264,7 @@ int imb_savetarga(struct ImBuf *ibuf, const char *name, int flags) buf[2] = 11; } - if (ibuf->ftype == RAWTGA) buf[2] &= ~8; + if (ibuf->foptions.flag & RAWTGA) buf[2] &= ~8; buf[8] = 0; buf[9] = 0; @@ -289,7 +289,7 @@ int imb_savetarga(struct ImBuf *ibuf, const char *name, int flags) return 0; } - if (ibuf->ftype == RAWTGA) { + if (ibuf->foptions.flag & RAWTGA) { ok = dumptarga(ibuf, fildes); } else { @@ -568,7 +568,9 @@ ImBuf *imb_loadtarga(const unsigned char *mem, size_t mem_size, int flags, char else ibuf = IMB_allocImBuf(tga.xsize, tga.ysize, (tga.pixsize + 0x7) & ~0x7, IB_rect); if (ibuf == NULL) return NULL; - ibuf->ftype = (tga.imgtyp < 4) ? RAWTGA : TGA; + ibuf->ftype = IMB_FTYPE_TGA; + if (tga.imgtyp < 4) + ibuf->foptions.flag |= RAWTGA; mem = mem + 18 + tga.numid; cp[0] = 0xff; diff --git a/source/blender/imbuf/intern/thumbs.c b/source/blender/imbuf/intern/thumbs.c index 4889026dbff..bd7495734d1 100644 --- a/source/blender/imbuf/intern/thumbs.c +++ b/source/blender/imbuf/intern/thumbs.c @@ -439,7 +439,7 @@ static ImBuf *thumb_create_ex( IMB_metadata_change_field(img, "Thumb::Image::Width", cwidth); IMB_metadata_change_field(img, "Thumb::Image::Height", cheight); } - img->ftype = PNG; + img->ftype = IMB_FTYPE_PNG; img->planes = 32; if (IMB_saveiff(img, temp, IB_rect | IB_metadata)) { diff --git a/source/blender/imbuf/intern/tiff.c b/source/blender/imbuf/intern/tiff.c index 6a25f057cc0..1c501f8f592 100644 --- a/source/blender/imbuf/intern/tiff.c +++ b/source/blender/imbuf/intern/tiff.c @@ -559,7 +559,7 @@ ImBuf *imb_loadtiff(const unsigned char *mem, size_t size, int flags, char color ibuf = IMB_allocImBuf(width, height, ib_depth, 0); if (ibuf) { - ibuf->ftype = TIF; + ibuf->ftype = IMB_FTYPE_TIF; } else { fprintf(stderr, @@ -720,7 +720,7 @@ int imb_savetiff(ImBuf *ibuf, const char *name, int flags) return (0); } - if ((ibuf->ftype & TIF_16BIT) && ibuf->rect_float) + if ((ibuf->foptions.flag & TIF_16BIT) && ibuf->rect_float) bitspersample = 16; else bitspersample = 8; diff --git a/source/blender/imbuf/intern/util.c b/source/blender/imbuf/intern/util.c index 8b16e03aed2..ca793d04d9b 100644 --- a/source/blender/imbuf/intern/util.c +++ b/source/blender/imbuf/intern/util.c @@ -212,7 +212,7 @@ int IMB_ispic_type(const char *name) /* XXX move this exception */ if ((BIG_LONG(((int *)buf)[0]) & 0xfffffff0) == 0xffd8ffe0) - return JPG; + return IMB_FTYPE_JPG; for (type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++) { if (type->is_a) { |