[Bf-blender-cvs] [e142ae7] master: Imbuf types refactor.
Antony Riakiotakis
noreply at git.blender.org
Mon Jul 13 13:59:42 CEST 2015
Commit: e142ae77cadf04103fbc643f21cf60891862f6a8
Author: Antony Riakiotakis
Date: Mon Jul 13 13:58:17 2015 +0200
Branches: master
https://developer.blender.org/rBe142ae77cadf04103fbc643f21cf60891862f6a8
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!
===================================================================
M source/blender/blenkernel/BKE_image.h
M source/blender/blenkernel/intern/dynamicpaint.c
M source/blender/blenkernel/intern/image.c
M source/blender/blenkernel/intern/movieclip.c
M source/blender/blenkernel/intern/sequencer.c
M source/blender/editors/space_image/image_buttons.c
M source/blender/editors/space_image/image_ops.c
M source/blender/freestyle/intern/stroke/Canvas.cpp
M source/blender/freestyle/intern/view_map/SteerableViewMap.cpp
M source/blender/gpu/intern/gpu_draw.c
M source/blender/imbuf/IMB_imbuf_types.h
M source/blender/imbuf/intern/allocimbuf.c
M source/blender/imbuf/intern/bmp.c
M source/blender/imbuf/intern/cineon/cineon_dpx.c
M source/blender/imbuf/intern/colormanagement.c
M source/blender/imbuf/intern/dds/dds_api.cpp
M source/blender/imbuf/intern/filetype.c
M source/blender/imbuf/intern/iris.c
M source/blender/imbuf/intern/jp2.c
M source/blender/imbuf/intern/jpeg.c
M source/blender/imbuf/intern/oiio/openimageio_api.cpp
M source/blender/imbuf/intern/openexr/openexr_api.cpp
M source/blender/imbuf/intern/png.c
M source/blender/imbuf/intern/radiance_hdr.c
M source/blender/imbuf/intern/targa.c
M source/blender/imbuf/intern/thumbs.c
M source/blender/imbuf/intern/tiff.c
M source/blender/imbuf/intern/util.c
M source/blender/makesrna/intern/rna_image.c
M source/gameengine/Ketsji/BL_Texture.cpp
===================================================================
diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h
index 29b073f..94afc8a 100644
--- a/source/blender/blenkernel/BKE_image.h
+++ b/source/blender/blenkernel/BKE_image.h
@@ -39,6 +39,7 @@ extern "C" {
struct Image;
struct ImBuf;
+struct ImbFormatOptions;
struct anim;
struct Scene;
struct Object;
@@ -80,8 +81,8 @@ void BKE_image_path_from_imtype(
const char imtype, const bool use_ext, const bool use_frames, const char *suffix);
int BKE_image_path_ensure_ext_from_imformat(char *string, const struct ImageFormatData *im_format);
int BKE_image_path_ensure_ext_from_imtype(char *string, const char imtype);
-char BKE_image_ftype_to_imtype(const int ftype);
-int BKE_image_imtype_to_ftype(const char imtype);
+char BKE_image_ftype_to_imtype(const int ftype, const struct ImbFormatOptions *options);
+int BKE_image_imtype_to_ftype(const char imtype, struct ImbFormatOptions *r_options);
bool BKE_imtype_is_movie(const char imtype);
int BKE_imtype_supports_zbuf(const char imtype);
@@ -270,7 +271,7 @@ bool BKE_image_has_anim(struct Image *image);
bool BKE_image_has_packedfile(struct Image *image);
bool BKE_image_is_animated(struct Image *image);
bool BKE_image_is_dirty(struct Image *image);
-void BKE_image_file_format_set(struct Image *image, int ftype);
+void BKE_image_file_format_set(struct Image *image, int ftype, const struct ImbFormatOptions *options);
bool BKE_image_has_loaded_ibuf(struct Image *image);
struct ImBuf *BKE_image_get_ibuf_with_name(struct Image *image, const char *name);
struct ImBuf *BKE_image_get_first_ibuf(struct Image *image);
diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c
index 8dac578..c6a04c7 100644
--- a/source/blender/blenkernel/intern/dynamicpaint.c
+++ b/source/blender/blenkernel/intern/dynamicpaint.c
@@ -2785,10 +2785,13 @@ void dynamicPaint_outputSurfaceImage(DynamicPaintSurface *surface, char *filenam
}
/* Set output format, png in case exr isn't supported */
- ibuf->ftype = PNG | 95;
+ ibuf->ftype = IMB_FTYPE_PNG;
+ ibuf->foptions.quality = 15;
+
#ifdef WITH_OPENEXR
if (format == R_IMF_IMTYPE_OPENEXR) { /* OpenEXR 32-bit float */
- ibuf->ftype = OPENEXR | OPENEXR_COMPRESS;
+ ibuf->ftype = IMB_FTYPE_OPENEXR;
+ ibuf->foptions.flag |= OPENEXR_COMPRESS;
}
#endif
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 9921c50..a906a6d 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -916,7 +916,7 @@ static void image_memorypack_multiview(Image *ima)
for (i = 0, iv = ima->views.first; iv; iv = iv->next, i++) {
ImBuf *ibuf = image_get_cached_ibuf_for_index_frame(ima, i, 0);
- ibuf->ftype = PNG;
+ ibuf->ftype = IMB_FTYPE_PNG;
ibuf->planes = R_IMF_PLANES_RGBA;
/* if the image was a R_IMF_VIEWS_STEREO_3D we force _L, _R suffices */
@@ -976,7 +976,7 @@ void BKE_image_memorypack(Image *ima)
image_free_packedfiles(ima);
- ibuf->ftype = PNG;
+ ibuf->ftype = IMB_FTYPE_PNG;
ibuf->planes = R_IMF_PLANES_RGBA;
IMB_saveiff(ibuf, ibuf->name, IB_rect | IB_mem);
@@ -1208,82 +1208,92 @@ void BKE_image_all_free_anim_ibufs(int cfra)
/* *********** READ AND WRITE ************** */
-int BKE_image_imtype_to_ftype(const char imtype)
+int BKE_image_imtype_to_ftype(const char imtype, ImbFormatOptions *r_options)
{
+ memset(r_options, 0, sizeof(*r_options));
+
if (imtype == R_IMF_IMTYPE_TARGA)
- return TGA;
- else if (imtype == R_IMF_IMTYPE_RAWTGA)
- return RAWTGA;
+ return IMB_FTYPE_TGA;
+ else if (imtype == R_IMF_IMTYPE_RAWTGA) {
+ r_options->flag = RAWTGA;
+ return IMB_FTYPE_TGA;
+ }
else if (imtype == R_IMF_IMTYPE_IRIS)
- return IMAGIC;
+ return IMB_FTYPE_IMAGIC;
#ifdef WITH_HDR
else if (imtype == R_IMF_IMTYPE_RADHDR)
- return RADHDR;
+ return IMB_FTYPE_RADHDR;
#endif
- else if (imtype == R_IMF_IMTYPE_PNG)
- return PNG | 15;
+ else if (imtype == R_IMF_IMTYPE_PNG) {
+ r_options->quality = 15;
+ return IMB_FTYPE_PNG;
+ }
#ifdef WITH_DDS
else if (imtype == R_IMF_IMTYPE_DDS)
- return DDS;
+ return IMB_FTYPE_DDS;
#endif
else if (imtype == R_IMF_IMTYPE_BMP)
- return BMP;
+ return IMB_FTYPE_BMP;
#ifdef WITH_TIFF
else if (imtype == R_IMF_IMTYPE_TIFF)
- return TIF;
+ return IMB_FTYPE_TIF;
#endif
else if (imtype == R_IMF_IMTYPE_OPENEXR || imtype == R_IMF_IMTYPE_MULTILAYER)
- return OPENEXR;
+ return IMB_FTYPE_OPENEXR;
#ifdef WITH_CINEON
else if (imtype == R_IMF_IMTYPE_CINEON)
- return CINEON;
+ return IMB_FTYPE_CINEON;
else if (imtype == R_IMF_IMTYPE_DPX)
- return DPX;
+ return IMB_FTYPE_DPX;
#endif
#ifdef WITH_OPENJPEG
else if (imtype == R_IMF_IMTYPE_JP2)
- return JP2;
+ return IMB_FTYPE_JP2;
#endif
- else
- return JPG | 90;
+ else {
+ r_options->quality = 90;
+ return IMB_FTYPE_JPG;
+ }
}
-char BKE_image_ftype_to_imtype(const int ftype)
+char BKE_image_ftype_to_imtype(const int ftype, const ImbFormatOptions *options)
{
if (ftype == 0)
return R_IMF_IMTYPE_TARGA;
- else if (ftype == IMAGIC)
+ else if (ftype == IMB_FTYPE_IMAGIC)
return R_IMF_IMTYPE_IRIS;
#ifdef WITH_HDR
- else if (ftype & RADHDR)
+ else if (ftype == IMB_FTYPE_RADHDR)
return R_IMF_IMTYPE_RADHDR;
#endif
- else if (ftype & PNG)
+ else if (ftype == IMB_FTYPE_PNG)
return R_IMF_IMTYPE_PNG;
#ifdef WITH_DDS
- else if (ftype & DDS)
+ else if (ftype == IMB_FTYPE_DDS)
return R_IMF_IMTYPE_DDS;
#endif
- else if (ftype & BMP)
+ else if (ftype == IMB_FTYPE_BMP)
return R_IMF_IMTYPE_BMP;
#ifdef WITH_TIFF
- else if (ftype & TIF)
+ else if (ftype == IMB_FTYPE_TIF)
return R_IMF_IMTYPE_TIFF;
#endif
- else if (ftype & OPENEXR)
+ else if (ftype == IMB_FTYPE_OPENEXR)
return R_IMF_IMTYPE_OPENEXR;
#ifdef WITH_CINEON
- else if (ftype & CINEON)
+ else if (ftype == IMB_FTYPE_CINEON)
return R_IMF_IMTYPE_CINEON;
- else if (ftype & DPX)
+ else if (ftype == IMB_FTYPE_DPX)
return R_IMF_IMTYPE_DPX;
#endif
- else if (ftype & TGA)
- return R_IMF_IMTYPE_TARGA;
- else if (ftype & RAWTGA)
- return R_IMF_IMTYPE_RAWTGA;
+ else if (ftype == IMB_FTYPE_TGA) {
+ if (options && (options->flag & RAWTGA))
+ return R_IMF_IMTYPE_RAWTGA;
+ else
+ return R_IMF_IMTYPE_TARGA;
+ }
#ifdef WITH_OPENJPEG
- else if (ftype & JP2)
+ else if (ftype == IMB_FTYPE_JP2)
return R_IMF_IMTYPE_JP2;
#endif
else
@@ -1590,38 +1600,41 @@ void BKE_imformat_defaults(ImageFormatData *im_format)
void BKE_imbuf_to_image_format(struct ImageFormatData *im_format, const ImBuf *imbuf)
{
- int ftype = imbuf->ftype & ~IB_CUSTOM_FLAGS_MASK;
- int custom_flags = imbuf->ftype & IB_CUSTOM_FLAGS_MASK;
+ int ftype = imbuf->ftype;
+ int custom_flags = imbuf->foptions.flag;
+ char quality = imbuf->foptions.quality;
BKE_imformat_defaults(im_format);
/* file type */
- if (ftype == IMAGIC)
+ if (ftype == IMB_FTYPE_IMAGIC)
im_format->imtype = R_IMF_IMTYPE_IRIS;
#ifdef WITH_HDR
- else if (ftype == RADHDR)
+ else if (ftype == IMB_FTYPE_RADHDR)
im_format->imtype = R_IMF_IMTYPE_RADHDR;
#endif
- else if (ftype == PNG) {
+ else if (ftype == IMB_FTYPE_PNG) {
im_format->imtype = R_IMF_IMTYPE_PNG;
if (custom_flags & PNG_16BIT)
im_format->depth = R_IMF_CHAN_DEPTH_16;
+
+ im_format->compress = quality;
}
#ifdef WITH_DDS
- else if (ftype == DDS)
+ else if (ftype == IMB_FTYPE_DDS)
im_format->imtype = R_IMF_IMTYPE_DDS;
#endif
- else if (ftype == BMP)
+ else if (ftype == IMB_FTYPE_BMP)
im_format->imtype = R_IMF_IMTYPE_BMP;
#ifdef WITH_TIFF
- else if (ftype == TIF) {
+ else if (ftype == IMB_FTYPE_TIF) {
im_format->imtype = R_IMF_IMTYPE_TIFF;
if (custom_flags & TIF_16BIT)
im_format->depth = R_IMF_CHAN_DEPTH_16;
@@ -1629,7 +1642,7 @@ void BKE_imbuf_to_image_format(struct ImageFormatData *im_format, const ImBuf *i
#endif
#ifdef WITH_OPENEXR
- else if (ftype == OPENEXR) {
+ else if (ftype == IMB_FTYPE_OPENEXR) {
im_format->imtype = R_IMF_IMTYPE_OPENEXR;
if (custom_flags & OPENEXR_HALF)
im_format->depth = R_IMF_CHAN_DEPTH_16;
@@ -1641,41 +1654,40 @@ void BKE_imbuf_to_image_format(struct ImageFormatData *im_format, const ImBuf *i
#endif
#ifdef WITH_CINEON
- else if (ftype == CINEON)
+ else if (ftype == IMB_FTYPE_CINEON)
im_format->imtype = R_IMF_IMTYPE_CINEON;
- else if (ftype == DPX)
+ else if (ftype == IMB_FTYPE_DPX)
im_format->imtype = R_IMF_IMTYPE_DPX;
#endif
- else if (ftype == TGA) {
- im_format->imtype = R_IMF_IMTYPE_TARGA;
- }
- else if (ftype == RAWTGA) {
- im_format->imtype = R_IMF_IMTYPE_RAWTGA;
+ else if (ftype == IMB_FTYPE_TGA) {
+ if (custom_flags & RAWTGA)
+ im_format->imtype = R_IMF_IMTYPE_RAWTGA;
+ else
+ im_format->imtype = R_IMF_IMTYPE_TARGA;
}
-
#ifdef WITH_OPENJPEG
- else if (ftype & JP2) {
+ else if (ftype == IMB_FTYPE_JP2) {
im_format->imtype = R_IMF_IMTYPE_JP2;
- im_format->quality = custom_flags & ~JPG_MSK;
+ im_format->quality = quality;
- if (ftype & JP2_16BIT)
+ if (custom_flags & JP2_16BIT)
im_format->depth = R_IMF_CHAN_DEPTH_16;
- else if (ftype & JP2_12BIT)
+ else if (custom_flags & JP2_12BIT)
im_format->depth = R_IMF_CHAN_DEPTH_12;
- if (ftype & JP2_YCC)
+ if (custom_flags & JP2_YCC)
im_format->jp2_flag |= R_IMF_JP2_FLAG_YCC;
- if (ftype & JP2_CINE) {
+ if (custom_flags & JP2_CINE) {
im_format->jp2_flag |= R_IMF_JP2_FLAG_CINE_PRESET;
- if (ftype & JP2_CINE_48FPS)
+ if (custom_flags & JP2_CINE_48FPS)
im_format->jp2_flag |= R_IMF_JP2_FLAG_CINE_48;
}
- if (ftype & JP2_JP2)
+ if (custom_flags & JP2_JP2)
im_format->jp2_codec = R_IMF_JP2_CODEC_JP2;
- else if (ftype & JP2_J2K)
+ else if (custom_flags & JP2_J2K)
im_format->jp2_codec = R_IMF_JP2_CODEC_J2K;
else
BLI_assert(!"Unsupported jp2 codec was specified in file type");
@@ -1684,7 +1696,7 @@ void BKE_imbuf_to_image_format(struct ImageFormatData *im_format, const ImBuf *i
else {
im_format->imtype = R_IMF_IMTYPE_JPEG90;
- im_format->quality = custom_flags & ~JPG_MSK;
+ im_format->quality = quality;
}
/* planes */
@@ -2162,46 +2174,46 @@ void BKE_imbuf_write_prepare(ImBuf *ibuf, ImageFormatData *imf)
char qualit
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list