diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-07-11 16:52:18 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-07-11 18:07:59 +0300 |
commit | 2410797ab15d08e5138b8cf10d8f8246513935af (patch) | |
tree | 7b256ebb075babe33fc307c8b536c48b24bbd4ee | |
parent | 03d8907ca7564c88c9f5357be93a74adbc638665 (diff) |
ImBuf: cleanup, use const for memory passed in
-rw-r--r-- | source/blender/imbuf/intern/IMB_filetype.h | 51 | ||||
-rw-r--r-- | source/blender/imbuf/intern/bmp.c | 9 | ||||
-rw-r--r-- | source/blender/imbuf/intern/cineon/cineon_dpx.c | 13 | ||||
-rw-r--r-- | source/blender/imbuf/intern/dds/dds_api.cpp | 6 | ||||
-rw-r--r-- | source/blender/imbuf/intern/dds/dds_api.h | 4 | ||||
-rw-r--r-- | source/blender/imbuf/intern/iris.c | 28 | ||||
-rw-r--r-- | source/blender/imbuf/intern/jp2.c | 11 | ||||
-rw-r--r-- | source/blender/imbuf/intern/jpeg.c | 10 | ||||
-rw-r--r-- | source/blender/imbuf/intern/openexr/openexr_api.cpp | 6 | ||||
-rw-r--r-- | source/blender/imbuf/intern/openexr/openexr_api.h | 4 | ||||
-rw-r--r-- | source/blender/imbuf/intern/png.c | 6 | ||||
-rw-r--r-- | source/blender/imbuf/intern/radiance_hdr.c | 10 | ||||
-rw-r--r-- | source/blender/imbuf/intern/targa.c | 14 | ||||
-rw-r--r-- | source/blender/imbuf/intern/tiff.c | 14 |
14 files changed, 93 insertions, 93 deletions
diff --git a/source/blender/imbuf/intern/IMB_filetype.h b/source/blender/imbuf/intern/IMB_filetype.h index 332878b6067..2bd7cbcf6eb 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 298e2da965f..6c082e8828c 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 56ce46bf92e..5c0af9e9816 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 45d9fa2ac59..cad76ffcee1 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 2316fefce69..d911a163098 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 --git a/source/blender/imbuf/intern/iris.c b/source/blender/imbuf/intern/iris.c index ea5acf27e99..369942f93ce 100644 --- a/source/blender/imbuf/intern/iris.c +++ b/source/blender/imbuf/intern/iris.c @@ -110,10 +110,10 @@ static int putlong(FILE *outf, unsigned int val); static int writetab(FILE *outf, unsigned int *tab, int len); static void readtab(FILE *inf, unsigned int *tab, int len); -static void expandrow(unsigned char *optr, unsigned char *iptr, int z); -static void expandrow2(float *optr, unsigned char *iptr, int z); -static void interleaverow(unsigned char *lptr, unsigned char *cptr, int z, int n); -static void interleaverow2(float *lptr, unsigned char *cptr, int z, int n); +static void expandrow(unsigned char *optr, const unsigned char *iptr, int z); +static void expandrow2(float *optr, const unsigned char *iptr, int z); +static void interleaverow(unsigned char *lptr, const unsigned char *cptr, int z, int n); +static void interleaverow2(float *lptr, const unsigned char *cptr, int z, int n); static int compressrow(unsigned char *lbuf, unsigned char *rlebuf, int z, int cnt); static void lumrow(unsigned char *rgbptr, unsigned char *lumptr, int n); @@ -122,12 +122,12 @@ static void lumrow(unsigned char *rgbptr, unsigned char *lumptr, int n); * */ -static uchar *file_data; +static const uchar *file_data; static int file_offset; static unsigned short getshort(FILE *inf) { - unsigned char *buf; + const unsigned char *buf; (void)inf; /* unused */ buf = file_data + file_offset; @@ -138,7 +138,7 @@ static unsigned short getshort(FILE *inf) static unsigned int getlong(FILE *inf) { - unsigned char *buf; + const unsigned char *buf; (void)inf; /* unused */ buf = file_data + file_offset; @@ -238,7 +238,7 @@ static void test_endian_zbuf(struct ImBuf *ibuf) /* this one is only def-ed once, strangely... */ #define GSS(x) (((uchar *)(x))[1] << 8 | ((uchar *)(x))[0]) -int imb_is_a_iris(unsigned char *mem) +int imb_is_a_iris(const unsigned char *mem) { return ((GS(mem) == IMAGIC) || (GSS(mem) == IMAGIC)); } @@ -250,12 +250,12 @@ 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]) +struct ImBuf *imb_loadiris(const unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]) { unsigned int *base, *lptr = NULL; float *fbase, *fptr = NULL; unsigned int *zbase, *zptr; - unsigned char *rledat; + const unsigned char *rledat; unsigned int *starttab, *lengthtab; FILE *inf = NULL; IMAGE image; @@ -541,7 +541,7 @@ struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags, char colo /* static utility functions for longimagedata */ -static void interleaverow(unsigned char *lptr, unsigned char *cptr, int z, int n) +static void interleaverow(unsigned char *lptr, const unsigned char *cptr, int z, int n) { lptr += z; while (n--) { @@ -550,7 +550,7 @@ static void interleaverow(unsigned char *lptr, unsigned char *cptr, int z, int n } } -static void interleaverow2(float *lptr, unsigned char *cptr, int z, int n) +static void interleaverow2(float *lptr, const unsigned char *cptr, int z, int n) { lptr += z; while (n--) { @@ -560,7 +560,7 @@ static void interleaverow2(float *lptr, unsigned char *cptr, int z, int n) } } -static void expandrow2(float *optr, unsigned char *iptr, int z) +static void expandrow2(float *optr, const unsigned char *iptr, int z) { unsigned short pixel, count; float pixel_f; @@ -616,7 +616,7 @@ static void expandrow2(float *optr, unsigned char *iptr, int z) } } -static void expandrow(unsigned char *optr, unsigned char *iptr, int z) +static void expandrow(unsigned char *optr, const unsigned char *iptr, int z) { unsigned char pixel, count; diff --git a/source/blender/imbuf/intern/jp2.c b/source/blender/imbuf/intern/jp2.c index 8750b825fb6..82b015b92c8 100644 --- a/source/blender/imbuf/intern/jp2.c +++ b/source/blender/imbuf/intern/jp2.c @@ -58,17 +58,17 @@ typedef struct img_folder { float *rates; } img_fol_t; -static int check_jp2(unsigned char *mem) /* J2K_CFMT */ +static int check_jp2(const unsigned char *mem) /* J2K_CFMT */ { return memcmp(JP2_HEAD, mem, sizeof(JP2_HEAD)) ? 0 : 1; } -static int check_j2k(unsigned char *mem) /* J2K_CFMT */ +static int check_j2k(const unsigned char *mem) /* J2K_CFMT */ { return memcmp(J2K_HEAD, mem, sizeof(J2K_HEAD)) ? 0 : 1; } -int imb_is_a_jp2(unsigned char *buf) +int imb_is_a_jp2(const unsigned char *buf) { return check_jp2(buf); } @@ -116,7 +116,7 @@ static void info_callback(const char *msg, void *client_data) } \ } (void)0 \ -struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]) +struct ImBuf *imb_jp2_decode(const unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]) { struct ImBuf *ibuf = NULL; bool use_float = false; /* for precision higher then 8 use float */ @@ -170,7 +170,8 @@ struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags, char co opj_setup_decoder(dinfo, ¶meters); /* open a byte stream */ - cio = opj_cio_open((opj_common_ptr)dinfo, mem, size); + /* note, we can't avoid removing 'const' cast here */ + cio = opj_cio_open((opj_common_ptr)dinfo, (unsigned char *)mem, size); /* decode the stream and fill the image structure */ image = opj_decode(dinfo, cio); diff --git a/source/blender/imbuf/intern/jpeg.c b/source/blender/imbuf/intern/jpeg.c index 310e517e38d..17952c40068 100644 --- a/source/blender/imbuf/intern/jpeg.c +++ b/source/blender/imbuf/intern/jpeg.c @@ -66,7 +66,7 @@ static void init_source(j_decompress_ptr cinfo); static boolean fill_input_buffer(j_decompress_ptr cinfo); static void skip_input_data(j_decompress_ptr cinfo, long num_bytes); static void term_source(j_decompress_ptr cinfo); -static void memory_source(j_decompress_ptr cinfo, unsigned char *buffer, size_t size); +static void memory_source(j_decompress_ptr cinfo, const unsigned char *buffer, size_t size); static boolean handle_app1(j_decompress_ptr cinfo); static ImBuf *ibJpegImageFromCinfo(struct jpeg_decompress_struct *cinfo, int flags); @@ -87,7 +87,7 @@ static ImBuf *ibJpegImageFromCinfo(struct jpeg_decompress_struct *cinfo, int fla static int jpeg_default_quality; static int ibuf_ftype; -int imb_is_a_jpeg(unsigned char *mem) +int imb_is_a_jpeg(const unsigned char *mem) { if ((mem[0] == 0xFF) && (mem[1] == 0xD8)) return 1; return 0; @@ -133,7 +133,7 @@ typedef struct { typedef struct { struct jpeg_source_mgr pub; /* public fields */ - unsigned char *buffer; + const unsigned char *buffer; int size; JOCTET terminal[2]; } my_source_mgr; @@ -182,7 +182,7 @@ static void term_source(j_decompress_ptr cinfo) (void)cinfo; /* unused */ } -static void memory_source(j_decompress_ptr cinfo, unsigned char *buffer, size_t size) +static void memory_source(j_decompress_ptr cinfo, const unsigned char *buffer, size_t size) { my_src_ptr src; @@ -443,7 +443,7 @@ next_stamp_marker: return(ibuf); } -ImBuf *imb_load_jpeg(unsigned char *buffer, size_t size, int flags, char colorspace[IM_MAX_SPACE]) +ImBuf *imb_load_jpeg(const unsigned char *buffer, size_t size, int flags, char colorspace[IM_MAX_SPACE]) { struct jpeg_decompress_struct _cinfo, *cinfo = &_cinfo; struct my_error_mgr jerr; diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index 6bb1f0cd0d3..36742cb91eb 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -302,7 +302,7 @@ extern "C" * Test presence of OpenEXR file. * \param mem pointer to loaded OpenEXR bitstream */ -int imb_is_a_openexr(unsigned char *mem) +int imb_is_a_openexr(const unsigned char *mem) { return Imf::isImfMagic((const char *)mem); } @@ -1900,7 +1900,7 @@ static bool imb_exr_is_multi(MultiPartInputFile& file) return false; } -struct ImBuf *imb_load_openexr(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]) +struct ImBuf *imb_load_openexr(const unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]) { struct ImBuf *ibuf = NULL; Mem_IStream *membuf = NULL; @@ -1914,7 +1914,7 @@ struct ImBuf *imb_load_openexr(unsigned char *mem, size_t size, int flags, char { bool is_multi; - membuf = new Mem_IStream(mem, size); + membuf = new Mem_IStream((unsigned char *)mem, size); file = new MultiPartInputFile(*membuf); Box2i dw = file->header(0).dataWindow(); diff --git a/source/blender/imbuf/intern/openexr/openexr_api.h b/source/blender/imbuf/intern/openexr/openexr_api.h index bc21d8cea7b..ec4ae94795d 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.h +++ b/source/blender/imbuf/intern/openexr/openexr_api.h @@ -41,11 +41,11 @@ extern "C" { void imb_initopenexr (void); -int imb_is_a_openexr (unsigned char *mem); +int imb_is_a_openexr (const unsigned char *mem); int imb_save_openexr (struct ImBuf *ibuf, const char *name, int flags); -struct ImBuf *imb_load_openexr (unsigned char *mem, size_t size, int flags, char *colorspace); +struct ImBuf *imb_load_openexr (const unsigned char *mem, size_t size, int flags, char *colorspace); #ifdef __cplusplus } diff --git a/source/blender/imbuf/intern/png.c b/source/blender/imbuf/intern/png.c index b0e4af29ae6..b96424dd319 100644 --- a/source/blender/imbuf/intern/png.c +++ b/source/blender/imbuf/intern/png.c @@ -53,7 +53,7 @@ #include "IMB_colormanagement_intern.h" typedef struct PNGReadStruct { - unsigned char *data; + const unsigned char *data; unsigned int size; unsigned int seek; } PNGReadStruct; @@ -67,7 +67,7 @@ BLI_INLINE unsigned short UPSAMPLE_8_TO_16(const unsigned char _val) return (_val << 8) + _val; } -int imb_is_a_png(unsigned char *mem) +int imb_is_a_png(const unsigned char *mem) { int ret_val = 0; @@ -504,7 +504,7 @@ static void imb_png_error(png_structp UNUSED(png_ptr), png_const_charp message) fprintf(stderr, "libpng error: %s\n", message); } -ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]) +ImBuf *imb_loadpng(const unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]) { struct ImBuf *ibuf = NULL; png_structp png_ptr; diff --git a/source/blender/imbuf/intern/radiance_hdr.c b/source/blender/imbuf/intern/radiance_hdr.c index 318bb7e96e3..32293e9de78 100644 --- a/source/blender/imbuf/intern/radiance_hdr.c +++ b/source/blender/imbuf/intern/radiance_hdr.c @@ -72,7 +72,7 @@ typedef float fCOLOR[3]; #define COPY_RGBE(c1, c2) (c2[RED] = c1[RED], c2[GRN] = c1[GRN], c2[BLU] = c1[BLU], c2[EXP] = c1[EXP]) /* read routines */ -static unsigned char *oldreadcolrs(RGBE *scan, unsigned char *mem, int xmax, unsigned char *mem_eof) +static const unsigned char *oldreadcolrs(RGBE *scan, const unsigned char *mem, int xmax, const unsigned char *mem_eof) { int i, rshift = 0, len = xmax; while (len > 0) { @@ -100,7 +100,7 @@ static unsigned char *oldreadcolrs(RGBE *scan, unsigned char *mem, int xmax, uns return mem; } -static unsigned char *freadcolrs(RGBE *scan, unsigned char *mem, int xmax, unsigned char *mem_eof) +static const unsigned char *freadcolrs(RGBE *scan, const unsigned char *mem, int xmax, const unsigned char *mem_eof) { int i, j, code, val; @@ -194,7 +194,7 @@ static void FLOAT2RGBE(fCOLOR fcol, RGBE rgbe) /* ImBuf read */ -int imb_is_a_hdr(unsigned char *buf) +int imb_is_a_hdr(const unsigned char *buf) { /* For recognition, Blender only loads first 32 bytes, so use #?RADIANCE id instead */ /* update: actually, the 'RADIANCE' part is just an optional program name, the magic word is really only the '#?' part */ @@ -204,7 +204,7 @@ int imb_is_a_hdr(unsigned char *buf) return 0; } -struct ImBuf *imb_loadhdr(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]) +struct ImBuf *imb_loadhdr(const unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]) { struct ImBuf *ibuf; RGBE *sline; @@ -213,7 +213,7 @@ struct ImBuf *imb_loadhdr(unsigned char *mem, size_t size, int flags, char color int found = 0; int width = 0, height = 0; int x, y; - unsigned char *ptr, *mem_eof = mem + size; + const unsigned char *ptr, *mem_eof = mem + size; char oriY[80], oriX[80]; if (imb_is_a_hdr((void *)mem)) { diff --git a/source/blender/imbuf/intern/targa.c b/source/blender/imbuf/intern/targa.c index 40dcdc9d24a..617fdab0618 100644 --- a/source/blender/imbuf/intern/targa.c +++ b/source/blender/imbuf/intern/targa.c @@ -314,7 +314,7 @@ int imb_savetarga(struct ImBuf *ibuf, const char *name, int flags) } -static int checktarga(TARGA *tga, unsigned char *mem) +static int checktarga(TARGA *tga, const unsigned char *mem) { tga->numid = mem[0]; tga->maptyp = mem[1]; @@ -350,7 +350,7 @@ static int checktarga(TARGA *tga, unsigned char *mem) return 1; } -int imb_is_a_targa(unsigned char *buf) +int imb_is_a_targa(const unsigned char *buf) { TARGA tga; @@ -372,9 +372,9 @@ static void complete_partial_load(struct ImBuf *ibuf, unsigned int *rect) } } -static void decodetarga(struct ImBuf *ibuf, unsigned char *mem, size_t mem_size, int psize) +static void decodetarga(struct ImBuf *ibuf, const unsigned char *mem, size_t mem_size, int psize) { - unsigned char *mem_end = mem + mem_size; + const unsigned char *mem_end = mem + mem_size; int count, col, size; unsigned int *rect; uchar *cp = (uchar *) &col; @@ -490,9 +490,9 @@ partial_load: complete_partial_load(ibuf, rect); } -static void ldtarga(struct ImBuf *ibuf, unsigned char *mem, size_t mem_size, int psize) +static void ldtarga(struct ImBuf *ibuf, const unsigned char *mem, size_t mem_size, int psize) { - unsigned char *mem_end = mem + mem_size; + const unsigned char *mem_end = mem + mem_size; int col, size; unsigned int *rect; uchar *cp = (uchar *) &col; @@ -550,7 +550,7 @@ partial_load: } -ImBuf *imb_loadtarga(unsigned char *mem, size_t mem_size, int flags, char colorspace[IM_MAX_SPACE]) +ImBuf *imb_loadtarga(const unsigned char *mem, size_t mem_size, int flags, char colorspace[IM_MAX_SPACE]) { TARGA tga; struct ImBuf *ibuf; diff --git a/source/blender/imbuf/intern/tiff.c b/source/blender/imbuf/intern/tiff.c index 62097635296..6a25f057cc0 100644 --- a/source/blender/imbuf/intern/tiff.c +++ b/source/blender/imbuf/intern/tiff.c @@ -79,9 +79,9 @@ static void imb_tiff_DummyUnmapProc(thandle_t fd, tdata_t base, toff_t size); /* Structure for in-memory TIFF file. */ typedef struct ImbTIFFMemFile { - unsigned char *mem; /* Location of first byte of TIFF file. */ - toff_t offset; /* Current offset within the file. */ - tsize_t size; /* Size of the TIFF file. */ + const unsigned char *mem; /* Location of first byte of TIFF file. */ + toff_t offset; /* Current offset within the file. */ + tsize_t size; /* Size of the TIFF file. */ } ImbTIFFMemFile; #define IMB_TIFF_GET_MEMFILE(x) ((ImbTIFFMemFile *)(x)) @@ -274,7 +274,7 @@ static toff_t imb_tiff_SizeProc(thandle_t handle) return (toff_t)(mfile->size); } -static TIFF *imb_tiff_client_open(ImbTIFFMemFile *memFile, unsigned char *mem, size_t size) +static TIFF *imb_tiff_client_open(ImbTIFFMemFile *memFile, const unsigned char *mem, size_t size) { /* open the TIFF client layer interface to the in-memory file */ memFile->mem = mem; @@ -304,7 +304,7 @@ static TIFF *imb_tiff_client_open(ImbTIFFMemFile *memFile, unsigned char *mem, s * hence my manual comparison. - Jonathan Merritt (lancelet) 4th Sept 2005. */ #define IMB_TIFF_NCB 4 /* number of comparison bytes used */ -int imb_is_a_tiff(unsigned char *mem) +int imb_is_a_tiff(const unsigned char *mem) { char big_endian[IMB_TIFF_NCB] = { 0x4d, 0x4d, 0x00, 0x2a }; char lil_endian[IMB_TIFF_NCB] = { 0x49, 0x49, 0x2a, 0x00 }; @@ -520,7 +520,7 @@ void imb_inittiff(void) * * \return: A newly allocated ImBuf structure if successful, otherwise NULL. */ -ImBuf *imb_loadtiff(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]) +ImBuf *imb_loadtiff(const unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]) { TIFF *image = NULL; ImBuf *ibuf = NULL, *hbuf; @@ -643,7 +643,7 @@ ImBuf *imb_loadtiff(unsigned char *mem, size_t size, int flags, char colorspace[ return ibuf; } -void imb_loadtiletiff(ImBuf *ibuf, unsigned char *mem, size_t size, int tx, int ty, unsigned int *rect) +void imb_loadtiletiff(ImBuf *ibuf, const unsigned char *mem, size_t size, int tx, int ty, unsigned int *rect) { TIFF *image = NULL; uint32 width, height; |