[Bf-blender-cvs] [2410797] master: ImBuf: cleanup, use const for memory passed in
Campbell Barton
noreply at git.blender.org
Sat Jul 11 17:19:13 CEST 2015
Commit: 2410797ab15d08e5138b8cf10d8f8246513935af
Author: Campbell Barton
Date: Sat Jul 11 23:52:18 2015 +1000
Branches: master
https://developer.blender.org/rB2410797ab15d08e5138b8cf10d8f8246513935af
ImBuf: cleanup, use const for memory passed in
===================================================================
M source/blender/imbuf/intern/IMB_filetype.h
M source/blender/imbuf/intern/bmp.c
M source/blender/imbuf/intern/cineon/cineon_dpx.c
M source/blender/imbuf/intern/dds/dds_api.cpp
M source/blender/imbuf/intern/dds/dds_api.h
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/openexr/openexr_api.cpp
M source/blender/imbuf/intern/openexr/openexr_api.h
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/tiff.c
===================================================================
diff --git a/source/blender/imbuf/intern/IMB_filetype.h b/source/blender/imbuf/intern/IMB_filetype.h
index 332878b..2bd7cbc 100644
--- a/source/blender/imbuf/intern/IMB_filetype.h
+++ b/source/blender/imbuf/intern/IMB_filetype.h
@@ -38,13 +38,13 @@ typedef struct ImFileType {
void (*init)(void);
void (*exit)(void);
- int (*is_a)(unsigned char *buf);
+ int (*is_a)(const unsigned char *buf);
int (*is_a_filepath)(const char *name);
int (*ftype)(const struct ImFileType *type, struct ImBuf *ibuf);
- struct ImBuf *(*load)(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]);
+ struct ImBuf *(*load)(const unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]);
struct ImBuf *(*load_filepath)(const char *name, int flags, char colorspace[IM_MAX_SPACE]);
int (*save)(struct ImBuf *ibuf, const char *name, int flags);
- void (*load_tile)(struct ImBuf *ibuf, unsigned char *mem, size_t size, int tx, int ty, unsigned int *rect);
+ void (*load_tile)(struct ImBuf *ibuf, const unsigned char *mem, size_t size, int tx, int ty, unsigned int *rect);
int flag;
int filetype;
@@ -66,58 +66,55 @@ void imb_tile_cache_tile_free(struct ImBuf *ibuf, int tx, int ty);
/* Type Specific Functions */
/* png */
-int imb_is_a_png(unsigned char *buf);
-struct ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]);
+int imb_is_a_png(const unsigned char *buf);
+struct ImBuf *imb_loadpng(const unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]);
int imb_savepng(struct ImBuf *ibuf, const char *name, int flags);
/* targa */
-int imb_is_a_targa(unsigned char *buf);
-struct ImBuf *imb_loadtarga(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]);
+int imb_is_a_targa(const unsigned char *buf);
+struct ImBuf *imb_loadtarga(const unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]);
int imb_savetarga(struct ImBuf *ibuf, const char *name, int flags);
/* iris */
-int imb_is_a_iris(unsigned char *mem);
-struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]);
+int imb_is_a_iris(const unsigned char *mem);
+struct ImBuf *imb_loadiris(const unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]);
int imb_saveiris(struct ImBuf *ibuf, const char *name, int flags);
/* jp2 */
-int imb_is_a_jp2(unsigned char *buf);
-struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]);
+int imb_is_a_jp2(const unsigned char *buf);
+struct ImBuf *imb_jp2_decode(const unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]);
int imb_savejp2(struct ImBuf *ibuf, const char *name, int flags);
/* jpeg */
-int imb_is_a_jpeg(unsigned char *mem);
+int imb_is_a_jpeg(const unsigned char *mem);
int imb_savejpeg(struct ImBuf *ibuf, const char *name, int flags);
-struct ImBuf *imb_load_jpeg(unsigned char *buffer, size_t size, int flags, char colorspace[IM_MAX_SPACE]);
+struct ImBuf *imb_load_jpeg(const unsigned char *buffer, size_t size, int flags, char colorspace[IM_MAX_SPACE]);
/* bmp */
-int imb_is_a_bmp(unsigned char *buf);
-struct ImBuf *imb_bmp_decode(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]);
+int imb_is_a_bmp(const unsigned char *buf);
+struct ImBuf *imb_bmp_decode(const unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]);
int imb_savebmp(struct ImBuf *ibuf, const char *name, int flags);
-/* cocoa */
-struct ImBuf *imb_cocoaLoadImage(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]);
-
/* cineon */
+int imb_is_cineon(const unsigned char *buf);
int imb_save_cineon(struct ImBuf *buf, const char *name, int flags);
-struct ImBuf *imb_load_cineon(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]);
-int imb_is_cineon(unsigned char *buf);
+struct ImBuf *imb_load_cineon(const unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]);
/* dpx */
+int imb_is_dpx(const unsigned char *buf);
int imb_save_dpx(struct ImBuf *buf, const char *name, int flags);
-struct ImBuf *imb_load_dpx(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]);
-int imb_is_dpx(unsigned char *buf);
+struct ImBuf *imb_load_dpx(const unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]);
/* hdr */
-int imb_is_a_hdr(unsigned char *buf);
-struct ImBuf *imb_loadhdr(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]);
+int imb_is_a_hdr(const unsigned char *buf);
+struct ImBuf *imb_loadhdr(const unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]);
int imb_savehdr(struct ImBuf *ibuf, const char *name, int flags);
/* tiff */
void imb_inittiff(void);
-int imb_is_a_tiff(unsigned char *buf);
-struct ImBuf *imb_loadtiff(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]);
-void imb_loadtiletiff(struct ImBuf *ibuf, unsigned char *mem, size_t size,
+int imb_is_a_tiff(const unsigned char *buf);
+struct ImBuf *imb_loadtiff(const unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]);
+void imb_loadtiletiff(struct ImBuf *ibuf, const unsigned char *mem, size_t size,
int tx, int ty, unsigned int *rect);
int imb_savetiff(struct ImBuf *ibuf, const char *name, int flags);
diff --git a/source/blender/imbuf/intern/bmp.c b/source/blender/imbuf/intern/bmp.c
index 298e2da..6c082e8 100644
--- a/source/blender/imbuf/intern/bmp.c
+++ b/source/blender/imbuf/intern/bmp.c
@@ -81,7 +81,7 @@ typedef struct BMPHEADER {
CHECK_HEADER_FIELD(_mem, "IC") || \
CHECK_HEADER_FIELD(_mem, "PT"))
-static int checkbmp(unsigned char *mem)
+static int checkbmp(const unsigned char *mem)
{
int ret_val = 0;
@@ -115,17 +115,18 @@ static int checkbmp(unsigned char *mem)
return(ret_val);
}
-int imb_is_a_bmp(unsigned char *buf)
+int imb_is_a_bmp(const unsigned char *buf)
{
return checkbmp(buf);
}
-struct ImBuf *imb_bmp_decode(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE])
+struct ImBuf *imb_bmp_decode(const unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE])
{
struct ImBuf *ibuf = NULL;
BMPINFOHEADER bmi;
int x, y, depth, ibuf_depth, skip, i, j;
- unsigned char *bmp, *rect;
+ const unsigned char *bmp;
+ unsigned char *rect;
unsigned short col;
double xppm, yppm;
bool top_to_bottom = false;
diff --git a/source/blender/imbuf/intern/cineon/cineon_dpx.c b/source/blender/imbuf/intern/cineon/cineon_dpx.c
index 56ce46b..5c0af9e 100644
--- a/source/blender/imbuf/intern/cineon/cineon_dpx.c
+++ b/source/blender/imbuf/intern/cineon/cineon_dpx.c
@@ -49,8 +49,9 @@
#include "MEM_guardedalloc.h"
-static struct ImBuf *imb_load_dpx_cineon(unsigned char *mem, size_t size, int use_cineon, int flags,
- char colorspace[IM_MAX_SPACE])
+static struct ImBuf *imb_load_dpx_cineon(
+ const unsigned char *mem, size_t size, int use_cineon, int flags,
+ char colorspace[IM_MAX_SPACE])
{
ImBuf *ibuf;
LogImageFile *image;
@@ -181,12 +182,12 @@ int imb_save_cineon(struct ImBuf *buf, const char *myfile, int flags)
return imb_save_dpx_cineon(buf, myfile, 1, flags);
}
-int imb_is_cineon(unsigned char *buf)
+int imb_is_cineon(const unsigned char *buf)
{
return logImageIsCineon(buf);
}
-ImBuf *imb_load_cineon(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE])
+ImBuf *imb_load_cineon(const unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE])
{
if (imb_is_cineon(mem))
return imb_load_dpx_cineon(mem, size, 1, flags, colorspace);
@@ -198,12 +199,12 @@ int imb_save_dpx(struct ImBuf *buf, const char *myfile, int flags)
return imb_save_dpx_cineon(buf, myfile, 0, flags);
}
-int imb_is_dpx(unsigned char *buf)
+int imb_is_dpx(const unsigned char *buf)
{
return logImageIsDpx(buf);
}
-ImBuf *imb_load_dpx(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE])
+ImBuf *imb_load_dpx(const unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE])
{
if (imb_is_dpx(mem))
return imb_load_dpx_cineon(mem, size, 0, flags, colorspace);
diff --git a/source/blender/imbuf/intern/dds/dds_api.cpp b/source/blender/imbuf/intern/dds/dds_api.cpp
index 45d9fa2..cad76ff 100644
--- a/source/blender/imbuf/intern/dds/dds_api.cpp
+++ b/source/blender/imbuf/intern/dds/dds_api.cpp
@@ -73,7 +73,7 @@ int imb_save_dds(struct ImBuf *ibuf, const char *name, int /*flags*/)
return(1);
}
-int imb_is_a_dds(unsigned char *mem) // note: use at most first 32 bytes
+int imb_is_a_dds(const unsigned char *mem) // note: use at most first 32 bytes
{
/* heuristic check to see if mem contains a DDS file */
/* header.fourcc == FOURCC_DDS */
@@ -83,10 +83,10 @@ int imb_is_a_dds(unsigned char *mem) // note: use at most first 32 bytes
return(1);
}
-struct ImBuf *imb_load_dds(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE])
+struct ImBuf *imb_load_dds(const unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE])
{
struct ImBuf *ibuf = NULL;
- DirectDrawSurface dds(mem, size); /* reads header */
+ DirectDrawSurface dds((unsigned char *)mem, size); /* reads header */
unsigned char bits_per_pixel;
unsigned int *rect;
Image img;
diff --git a/source/blender/imbuf/intern/dds/dds_api.h b/source/blender/imbuf/intern/dds/dds_api.h
index 2316fef..d911a16 100644
--- a/source/blender/imbuf/intern/dds/dds_api.h
+++ b/source/blender/imbuf/intern/dds/dds_api.h
@@ -34,9 +34,9 @@ extern "C" {
#include "../../IMB_imbuf.h"
+int imb_is_a_dds(const unsigned char *mem); /* use only first 32 bytes of mem */
int imb_save_dds(struct ImBuf *ibuf, const char *name, int flags);
-int imb_is_a_dds(unsigned char *mem); /* use only first 32 bytes of mem */
-struct ImBuf *imb_load_dds(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]);
+struct ImBuf *imb_load_dds(const unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]);
#ifdef __cplusplus
}
diff --gi
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list