From 9234f29e673632d15f6a19cf5eda675cde392e44 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 15 Sep 2010 06:43:36 +0000 Subject: bugfix [#23405] PNG Images bigger then 2gig wont load with blender. all image formats should be able to load files bigger then 2gig (when its supported) --- extern/libopenjpeg/CMakeLists.txt | 6 ++--- source/blender/blenkernel/intern/effect.c | 1 + source/blender/blenkernel/intern/exotic.c | 4 +++- source/blender/blenkernel/intern/fluidsim.c | 1 + source/blender/blenkernel/intern/particle_system.c | 1 + source/blender/blenlib/BLI_storage.h | 5 ++-- source/blender/blenlib/intern/bpath.c | 2 +- source/blender/blenlib/intern/storage.c | 6 ++--- source/blender/blenloader/intern/readblenentry.c | 1 + source/blender/imbuf/IMB_imbuf.h | 2 +- source/blender/imbuf/intern/IMB_filetype.h | 28 +++++++++++----------- source/blender/imbuf/intern/allocimbuf.c | 2 ++ source/blender/imbuf/intern/bmp.c | 2 +- source/blender/imbuf/intern/filetype.c | 1 + source/blender/imbuf/intern/iris.c | 2 +- source/blender/imbuf/intern/jp2.c | 2 +- source/blender/imbuf/intern/jpeg.c | 6 ++--- source/blender/imbuf/intern/module.c | 1 + source/blender/imbuf/intern/png.c | 4 ++-- source/blender/imbuf/intern/radiance_hdr.c | 2 +- source/blender/imbuf/intern/readimage.c | 6 ++--- source/blender/imbuf/intern/targa.c | 6 ++--- source/blender/imbuf/intern/tiff.c | 6 ++--- .../blender/readblenfile/intern/BLO_readblenfile.c | 3 ++- 24 files changed, 55 insertions(+), 45 deletions(-) diff --git a/extern/libopenjpeg/CMakeLists.txt b/extern/libopenjpeg/CMakeLists.txt index d7b25ed1412..8cdd804dfba 100644 --- a/extern/libopenjpeg/CMakeLists.txt +++ b/extern/libopenjpeg/CMakeLists.txt @@ -24,9 +24,7 @@ # # ***** END GPL LICENSE BLOCK ***** -SET(INC . src) +SET(INC .) -FILE(GLOB SRC *.c except t1_generate_luts.c) -ADD_DEFINITIONS(-DWITH_OPENJPEG) +FILE(GLOB SRC *.c) BLENDERLIB(extern_openjpeg "${SRC}" "${INC}") -#, libtype=['international','player'], priority=[5, 210]) diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 05fcabd371f..0da5e0da2c4 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -29,6 +29,7 @@ * ***** END GPL LICENSE BLOCK ***** */ +#include #include "BLI_storage.h" /* _LARGEFILE_SOURCE */ #include diff --git a/source/blender/blenkernel/intern/exotic.c b/source/blender/blenkernel/intern/exotic.c index bd001649bf5..973c18531c4 100644 --- a/source/blender/blenkernel/intern/exotic.c +++ b/source/blender/blenkernel/intern/exotic.c @@ -29,12 +29,14 @@ * * ***** END GPL LICENSE BLOCK *****/ +#include #include "BLI_storage.h" +#include #include /* isdigit, isspace */ #include #include -#include + #include #include #include diff --git a/source/blender/blenkernel/intern/fluidsim.c b/source/blender/blenkernel/intern/fluidsim.c index 04ce6c39694..ef89d39864a 100644 --- a/source/blender/blenkernel/intern/fluidsim.c +++ b/source/blender/blenkernel/intern/fluidsim.c @@ -28,6 +28,7 @@ * ***** END GPL LICENSE BLOCK ***** */ +#include #include "BLI_storage.h" /* _LARGEFILE_SOURCE */ #include "MEM_guardedalloc.h" diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 0d14c3cb9f6..598dd3c03fe 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -29,6 +29,7 @@ * ***** END GPL LICENSE BLOCK ***** */ +#include #include "BLI_storage.h" /* _LARGEFILE_SOURCE */ #include diff --git a/source/blender/blenlib/BLI_storage.h b/source/blender/blenlib/BLI_storage.h index 0d9db40fc97..83537e4f3c4 100644 --- a/source/blender/blenlib/BLI_storage.h +++ b/source/blender/blenlib/BLI_storage.h @@ -42,12 +42,13 @@ struct direntry; + void BLI_adddirstrings(void); void BLI_builddir(char *dirname, char *relname); int BLI_compare(struct direntry *entry1, struct direntry *entry2); -int BLI_filesize(int file); -int BLI_filepathsize(const char *path); +size_t BLI_filesize(int file); +size_t BLI_filepathsize(const char *path); double BLI_diskfree(char *dir); char *BLI_getwdN(char *dir); diff --git a/source/blender/blenlib/intern/bpath.c b/source/blender/blenlib/intern/bpath.c index d1a8de14181..cf7eb873409 100644 --- a/source/blender/blenlib/intern/bpath.c +++ b/source/blender/blenlib/intern/bpath.c @@ -633,7 +633,7 @@ static int findFileRecursive(char *filename_new, const char *dirname, const char if (S_ISREG(status.st_mode)) { /* is file */ if (strncmp(filename, de->d_name, FILE_MAX)==0) { /* name matches */ /* open the file to read its size */ - size = BLI_filepathsize(path); + size = status.st_size; if ((size > 0) && (size > *filesize)) { /* find the biggest file */ *filesize = size; BLI_strncpy(filename_new, path, FILE_MAX); diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c index 80310b1ef8a..9c31557619b 100644 --- a/source/blender/blenlib/intern/storage.c +++ b/source/blender/blenlib/intern/storage.c @@ -421,7 +421,7 @@ unsigned int BLI_getdir(char *dirname, struct direntry **filelist) } -int BLI_filesize(int file) +size_t BLI_filesize(int file) { struct stat buf; @@ -430,11 +430,11 @@ int BLI_filesize(int file) return (buf.st_size); } -int BLI_filepathsize(const char *path) +size_t BLI_filepathsize(const char *path) { int size, file = open(path, O_BINARY|O_RDONLY); - if (file < 0) + if (file == -1) return -1; size = BLI_filesize(file); diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c index da441214b37..b637d538b91 100644 --- a/source/blender/blenloader/intern/readblenentry.c +++ b/source/blender/blenloader/intern/readblenentry.c @@ -28,6 +28,7 @@ * .blend file reading entry point */ +#include #include "BLI_storage.h" /* _LARGEFILE_SOURCE */ #include diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h index 07b99dddfa5..c39c5d31f80 100644 --- a/source/blender/imbuf/IMB_imbuf.h +++ b/source/blender/imbuf/IMB_imbuf.h @@ -93,7 +93,7 @@ void IMB_exit(void); * * @attention Defined in readimage.c */ -struct ImBuf *IMB_ibImageFromMemory(unsigned char *mem, int size, int flags); +struct ImBuf *IMB_ibImageFromMemory(unsigned char *mem, size_t size, int flags); /** * diff --git a/source/blender/imbuf/intern/IMB_filetype.h b/source/blender/imbuf/intern/IMB_filetype.h index 9fd4108bee9..8529c72c7ae 100644 --- a/source/blender/imbuf/intern/IMB_filetype.h +++ b/source/blender/imbuf/intern/IMB_filetype.h @@ -37,9 +37,9 @@ typedef struct ImFileType { int (*is_a)(unsigned char *buf); int (*ftype)(struct ImFileType *type, struct ImBuf *ibuf); - struct ImBuf *(*load)(unsigned char *mem, int size, int flags); + struct ImBuf *(*load)(unsigned char *mem, size_t size, int flags); int (*save)(struct ImBuf *ibuf, char *name, int flags); - void (*load_tile)(struct ImBuf *ibuf, unsigned char *mem, int size, int tx, int ty, unsigned int *rect); + void (*load_tile)(struct ImBuf *ibuf, unsigned char *mem, size_t size, int tx, int ty, unsigned int *rect); int flag; int filetype; @@ -60,59 +60,59 @@ void imb_tile_cache_tile_free(struct ImBuf *ibuf, int tx, int ty); /* png */ int imb_is_a_png(unsigned char *buf); -struct ImBuf *imb_loadpng(unsigned char *mem, int size, int flags); +struct ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags); int imb_savepng(struct ImBuf *ibuf, char *name, int flags); /* targa */ int imb_is_a_targa(unsigned char *buf); -struct ImBuf *imb_loadtarga(unsigned char *mem, int size, int flags); +struct ImBuf *imb_loadtarga(unsigned char *mem, size_t size, int flags); int imb_savetarga(struct ImBuf * ibuf, char *name, int flags); /* iris */ int imb_is_a_iris(unsigned char *mem); -struct ImBuf *imb_loadiris(unsigned char *mem, int size, int flags); +struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags); int imb_saveiris(struct ImBuf * ibuf, char *name, int flags); /* jp2 */ int imb_is_a_jp2(unsigned char *buf); -struct ImBuf *imb_jp2_decode(unsigned char *mem, int size, int flags); +struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags); int imb_savejp2(struct ImBuf *ibuf, char *name, int flags); /* jpeg */ int imb_is_a_jpeg(unsigned char *mem); int imb_savejpeg(struct ImBuf * ibuf, char * name, int flags); struct ImBuf * imb_ibJpegImageFromFilename (const char * filename, int flags); -struct ImBuf * imb_load_jpeg (unsigned char * buffer, int size, int flags); +struct ImBuf * imb_load_jpeg (unsigned char * buffer, size_t size, int flags); /* bmp */ int imb_is_a_bmp(unsigned char *buf); -struct ImBuf *imb_bmp_decode(unsigned char *mem, int size, int flags); +struct ImBuf *imb_bmp_decode(unsigned char *mem, size_t size, int flags); int imb_savebmp(struct ImBuf *ibuf, char *name, int flags); /* cocoa */ -struct ImBuf *imb_cocoaLoadImage(unsigned char *mem, int size, int flags); +struct ImBuf *imb_cocoaLoadImage(unsigned char *mem, size_t size, int flags); short imb_cocoaSaveImage(struct ImBuf *ibuf, char *name, int flags); /* cineon */ int imb_savecineon(struct ImBuf *buf, char *myfil, int flags); -struct ImBuf *imb_loadcineon(unsigned char *mem, int size, int flags); +struct ImBuf *imb_loadcineon(unsigned char *mem, size_t size, int flags); int imb_is_cineon(unsigned char *buf); /* dpx */ int imb_save_dpx(struct ImBuf *buf, char *myfile, int flags); -struct ImBuf *imb_loaddpx(unsigned char *mem, int size, int flags); +struct ImBuf *imb_loaddpx(unsigned char *mem, size_t size, int flags); int imb_is_dpx(unsigned char *buf); /* hdr */ int imb_is_a_hdr(unsigned char *buf); -struct ImBuf *imb_loadhdr(unsigned char *mem, int size, int flags); +struct ImBuf *imb_loadhdr(unsigned char *mem, size_t size, int flags); int imb_savehdr(struct ImBuf * ibuf, char *name, int flags); /* tiff */ void imb_inittiff(void); int imb_is_a_tiff(unsigned char *buf); -struct ImBuf *imb_loadtiff(unsigned char *mem, int size, int flags); -void imb_loadtiletiff(struct ImBuf *ibuf, unsigned char *mem, int size, +struct ImBuf *imb_loadtiff(unsigned char *mem, size_t size, int flags); +void imb_loadtiletiff(struct ImBuf *ibuf, unsigned char *mem, size_t size, int tx, int ty, unsigned int *rect); int imb_savetiff(struct ImBuf *ibuf, char *name, int flags); void *libtiff_findsymbol(char *name); diff --git a/source/blender/imbuf/intern/allocimbuf.c b/source/blender/imbuf/intern/allocimbuf.c index 3f440c0bf6f..02fc98f2d63 100644 --- a/source/blender/imbuf/intern/allocimbuf.c +++ b/source/blender/imbuf/intern/allocimbuf.c @@ -32,6 +32,8 @@ /* It's become a bit messy... Basically, only the IMB_ prefixed files * should remain. */ +#include + #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" diff --git a/source/blender/imbuf/intern/bmp.c b/source/blender/imbuf/intern/bmp.c index bdcf60090c3..450b09c923b 100644 --- a/source/blender/imbuf/intern/bmp.c +++ b/source/blender/imbuf/intern/bmp.c @@ -101,7 +101,7 @@ int imb_is_a_bmp(unsigned char *buf) { return checkbmp(buf); } -struct ImBuf *imb_bmp_decode(unsigned char *mem, int size, int flags) +struct ImBuf *imb_bmp_decode(unsigned char *mem, size_t size, int flags) { struct ImBuf *ibuf = 0; BMPINFOHEADER bmi; diff --git a/source/blender/imbuf/intern/filetype.c b/source/blender/imbuf/intern/filetype.c index db2eef759dc..fb5d2f2e4d7 100644 --- a/source/blender/imbuf/intern/filetype.c +++ b/source/blender/imbuf/intern/filetype.c @@ -22,6 +22,7 @@ * ***** END GPL LICENSE BLOCK ***** */ +#include #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" #include "IMB_filetype.h" diff --git a/source/blender/imbuf/intern/iris.c b/source/blender/imbuf/intern/iris.c index c676c401ccd..883de823745 100644 --- a/source/blender/imbuf/intern/iris.c +++ b/source/blender/imbuf/intern/iris.c @@ -244,7 +244,7 @@ int imb_is_a_iris(unsigned char *mem) * */ -struct ImBuf *imb_loadiris(unsigned char *mem, int size, int flags) +struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags) { unsigned int *base, *lptr = NULL; float *fbase, *fptr = NULL; diff --git a/source/blender/imbuf/intern/jp2.c b/source/blender/imbuf/intern/jp2.c index 558eaedf8b2..a70c154014a 100644 --- a/source/blender/imbuf/intern/jp2.c +++ b/source/blender/imbuf/intern/jp2.c @@ -90,7 +90,7 @@ void info_callback(const char *msg, void *client_data) { -struct ImBuf *imb_jp2_decode(unsigned char *mem, int size, int flags) +struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags) { struct ImBuf *ibuf = 0; int use_float = 0; /* for precision higher then 8 use float */ diff --git a/source/blender/imbuf/intern/jpeg.c b/source/blender/imbuf/intern/jpeg.c index 2bae7228220..855c0bf3433 100644 --- a/source/blender/imbuf/intern/jpeg.c +++ b/source/blender/imbuf/intern/jpeg.c @@ -58,7 +58,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, int size); +static void memory_source(j_decompress_ptr cinfo, unsigned char *buffer, size_t size); static boolean handle_app1 (j_decompress_ptr cinfo); static ImBuf * ibJpegImageFromCinfo(struct jpeg_decompress_struct * cinfo, int flags); @@ -167,7 +167,7 @@ static void term_source(j_decompress_ptr cinfo) { } -static void memory_source(j_decompress_ptr cinfo, unsigned char *buffer, int size) +static void memory_source(j_decompress_ptr cinfo, unsigned char *buffer, size_t size) { my_src_ptr src; @@ -459,7 +459,7 @@ ImBuf * imb_ibJpegImageFromFilename (const char * filename, int flags) return(ibuf); } -ImBuf * imb_load_jpeg (unsigned char * buffer, int size, int flags) +ImBuf * imb_load_jpeg (unsigned char * buffer, size_t size, int flags) { struct jpeg_decompress_struct _cinfo, *cinfo = &_cinfo; struct my_error_mgr jerr; diff --git a/source/blender/imbuf/intern/module.c b/source/blender/imbuf/intern/module.c index 5438066d164..f291c0de776 100644 --- a/source/blender/imbuf/intern/module.c +++ b/source/blender/imbuf/intern/module.c @@ -22,6 +22,7 @@ * ***** END GPL LICENSE BLOCK ***** */ +#include #include "IMB_imbuf.h" #include "IMB_filetype.h" diff --git a/source/blender/imbuf/intern/png.c b/source/blender/imbuf/intern/png.c index 6344b227174..6b21f20b3fb 100644 --- a/source/blender/imbuf/intern/png.c +++ b/source/blender/imbuf/intern/png.c @@ -286,7 +286,7 @@ int imb_savepng(struct ImBuf *ibuf, char *name, int flags) return(1); } -struct ImBuf *imb_loadpng(unsigned char *mem, int size, int flags) +struct ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags) { struct ImBuf *ibuf = 0; png_structp png_ptr; @@ -317,7 +317,7 @@ struct ImBuf *imb_loadpng(unsigned char *mem, int size, int flags) return 0; } - ps.size = size; + ps.size = size; /* XXX, 4gig limit! */ ps.data = mem; ps.seek = 0; diff --git a/source/blender/imbuf/intern/radiance_hdr.c b/source/blender/imbuf/intern/radiance_hdr.c index c5122ebe46c..4064246c866 100644 --- a/source/blender/imbuf/intern/radiance_hdr.c +++ b/source/blender/imbuf/intern/radiance_hdr.c @@ -173,7 +173,7 @@ int imb_is_a_hdr(unsigned char *buf) return 0; } -struct ImBuf *imb_loadhdr(unsigned char *mem, int size, int flags) +struct ImBuf *imb_loadhdr(unsigned char *mem, size_t size, int flags) { struct ImBuf* ibuf; RGBE* sline; diff --git a/source/blender/imbuf/intern/readimage.c b/source/blender/imbuf/intern/readimage.c index 3f4e177c78b..a56007f15f0 100644 --- a/source/blender/imbuf/intern/readimage.c +++ b/source/blender/imbuf/intern/readimage.c @@ -46,7 +46,7 @@ #include "IMB_imbuf.h" #include "IMB_filetype.h" -ImBuf *IMB_ibImageFromMemory(unsigned char *mem, int size, int flags) +ImBuf *IMB_ibImageFromMemory(unsigned char *mem, size_t size, int flags) { ImBuf *ibuf; ImFileType *type; @@ -79,7 +79,7 @@ ImBuf *IMB_loadifffile(int file, int flags) { ImBuf *ibuf; unsigned char *mem; - int size; + size_t size; if(file == -1) return 0; @@ -166,7 +166,7 @@ static void imb_loadtilefile(ImBuf *ibuf, int file, int tx, int ty, unsigned int { ImFileType *type; unsigned char *mem; - int size; + size_t size; if(file == -1) return; diff --git a/source/blender/imbuf/intern/targa.c b/source/blender/imbuf/intern/targa.c index b5434b85b5a..ada1f448bfc 100644 --- a/source/blender/imbuf/intern/targa.c +++ b/source/blender/imbuf/intern/targa.c @@ -359,7 +359,7 @@ static void complete_partial_load(struct ImBuf *ibuf, unsigned int *rect) } } -static void decodetarga(struct ImBuf *ibuf, unsigned char *mem, int mem_size, int psize) +static void decodetarga(struct ImBuf *ibuf, unsigned char *mem, size_t mem_size, int psize) { unsigned char *mem_end = mem+mem_size; int count, col, size; @@ -470,7 +470,7 @@ partial_load: complete_partial_load(ibuf, rect); } -static void ldtarga(struct ImBuf * ibuf,unsigned char * mem, int mem_size, int psize) +static void ldtarga(struct ImBuf * ibuf,unsigned char * mem, size_t mem_size, int psize) { unsigned char *mem_end = mem+mem_size; int col,size; @@ -527,7 +527,7 @@ partial_load: } -struct ImBuf *imb_loadtarga(unsigned char *mem, int mem_size, int flags) +struct ImBuf *imb_loadtarga(unsigned char *mem, size_t mem_size, int flags) { TARGA tga; struct ImBuf * ibuf; diff --git a/source/blender/imbuf/intern/tiff.c b/source/blender/imbuf/intern/tiff.c index 6b94583f17d..5b77c6c7c36 100644 --- a/source/blender/imbuf/intern/tiff.c +++ b/source/blender/imbuf/intern/tiff.c @@ -262,7 +262,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, int size) +static TIFF *imb_tiff_client_open(ImbTIFFMemFile *memFile, unsigned char *mem, size_t size) { /* open the TIFF client layer interface to the in-memory file */ memFile->mem = mem; @@ -464,7 +464,7 @@ void imb_inittiff(void) * * @return: A newly allocated ImBuf structure if successful, otherwise NULL. */ -ImBuf *imb_loadtiff(unsigned char *mem, int size, int flags) +ImBuf *imb_loadtiff(unsigned char *mem, size_t size, int flags) { TIFF *image = NULL; ImBuf *ibuf = NULL, *hbuf; @@ -573,7 +573,7 @@ ImBuf *imb_loadtiff(unsigned char *mem, int size, int flags) return ibuf; } -void imb_loadtiletiff(ImBuf *ibuf, unsigned char *mem, int size, int tx, int ty, unsigned int *rect) +void imb_loadtiletiff(ImBuf *ibuf, unsigned char *mem, size_t size, int tx, int ty, unsigned int *rect) { TIFF *image = NULL; uint32 width, height; diff --git a/source/blender/readblenfile/intern/BLO_readblenfile.c b/source/blender/readblenfile/intern/BLO_readblenfile.c index 7c876c96a86..dfcdaf756f7 100644 --- a/source/blender/readblenfile/intern/BLO_readblenfile.c +++ b/source/blender/readblenfile/intern/BLO_readblenfile.c @@ -132,7 +132,8 @@ blo_read_runtime( ReportList *reports) { BlendFileData *bfd= NULL; - int fd, actualsize, datastart; + size_t actualsize; + int fd, datastart; char buf[8]; fd= open(path, O_BINARY|O_RDONLY, 0); -- cgit v1.2.3