Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/imbuf/intern/jpeg.c')
-rw-r--r--source/blender/imbuf/intern/jpeg.c69
1 files changed, 22 insertions, 47 deletions
diff --git a/source/blender/imbuf/intern/jpeg.c b/source/blender/imbuf/intern/jpeg.c
index 2bae7228220..d23223e4c11 100644
--- a/source/blender/imbuf/intern/jpeg.c
+++ b/source/blender/imbuf/intern/jpeg.c
@@ -1,4 +1,4 @@
-/**
+/*
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
@@ -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);
@@ -132,6 +132,7 @@ typedef my_source_mgr * my_src_ptr;
static void init_source(j_decompress_ptr cinfo)
{
+ (void)cinfo; /* unused */
}
@@ -165,9 +166,10 @@ static void skip_input_data(j_decompress_ptr cinfo, long num_bytes)
static void term_source(j_decompress_ptr cinfo)
{
+ (void)cinfo; /* unused */
}
-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;
@@ -297,10 +299,12 @@ static ImBuf * ibJpegImageFromCinfo(struct jpeg_decompress_struct * cinfo, int f
if (flags & IB_test) {
jpeg_abort_decompress(cinfo);
- ibuf = IMB_allocImBuf(x, y, 8 * depth, 0, 0);
- } else {
- ibuf = IMB_allocImBuf(x, y, 8 * depth, IB_rect, 0);
-
+ ibuf = IMB_allocImBuf(x, y, 8 * depth, 0);
+ }
+ else if ((ibuf = IMB_allocImBuf(x, y, 8 * depth, IB_rect)) == NULL) {
+ jpeg_abort_decompress(cinfo);
+ }
+ else {
row_stride = cinfo->output_width * depth;
row_pointer = (*cinfo->mem->alloc_sarray) ((j_common_ptr) cinfo, JPOOL_IMAGE, row_stride, 1);
@@ -421,45 +425,16 @@ next_stamp_marker:
}
jpeg_destroy((j_common_ptr) cinfo);
- ibuf->ftype = ibuf_ftype;
- ibuf->profile = IB_PROFILE_SRGB;
- }
-
- return(ibuf);
-}
-
-ImBuf * imb_ibJpegImageFromFilename (const char * filename, int flags)
-{
- struct jpeg_decompress_struct _cinfo, *cinfo = &_cinfo;
- struct my_error_mgr jerr;
- FILE * infile;
- ImBuf * ibuf;
-
- if ((infile = fopen(filename, "rb")) == NULL) return 0;
-
- cinfo->err = jpeg_std_error(&jerr.pub);
- jerr.pub.error_exit = jpeg_error;
-
- /* Establish the setjmp return context for my_error_exit to use. */
- if (setjmp(jerr.setjmp_buffer)) {
- /* If we get here, the JPEG code has signaled an error.
- * We need to clean up the JPEG object, close the input file, and return.
- */
- jpeg_destroy_decompress(cinfo);
- fclose(infile);
- return NULL;
+ if(ibuf) {
+ ibuf->ftype = ibuf_ftype;
+ ibuf->profile = IB_PROFILE_SRGB;
+ }
}
- jpeg_create_decompress(cinfo);
- jpeg_stdio_src(cinfo, infile);
-
- ibuf = ibJpegImageFromCinfo(cinfo, flags);
-
- fclose(infile);
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;
@@ -616,7 +591,7 @@ static int init_jpeg(FILE * outfile, struct jpeg_compress_struct * cinfo, struct
}
-static int save_stdjpeg(char * name, struct ImBuf * ibuf)
+static int save_stdjpeg(const char *name, struct ImBuf *ibuf)
{
FILE * outfile;
struct jpeg_compress_struct _cinfo, *cinfo = &_cinfo;
@@ -650,7 +625,7 @@ static int save_stdjpeg(char * name, struct ImBuf * ibuf)
}
-static int save_vidjpeg(char * name, struct ImBuf * ibuf)
+static int save_vidjpeg(const char *name, struct ImBuf *ibuf)
{
FILE * outfile;
struct jpeg_compress_struct _cinfo, *cinfo = &_cinfo;
@@ -689,13 +664,13 @@ static int save_vidjpeg(char * name, struct ImBuf * ibuf)
return 1;
}
-static int save_jstjpeg(char * name, struct ImBuf * ibuf)
+static int save_jstjpeg(const char *name, struct ImBuf *ibuf)
{
char fieldname[1024];
struct ImBuf * tbuf;
int oldy, returnval;
- tbuf = IMB_allocImBuf(ibuf->x, ibuf->y / 2, 24, IB_rect, 0);
+ tbuf = IMB_allocImBuf(ibuf->x, ibuf->y / 2, 24, IB_rect);
tbuf->ftype = ibuf->ftype;
tbuf->flags = ibuf->flags;
@@ -720,7 +695,7 @@ static int save_jstjpeg(char * name, struct ImBuf * ibuf)
return returnval;
}
-static int save_maxjpeg(char * name, struct ImBuf * ibuf)
+static int save_maxjpeg(const char *name, struct ImBuf *ibuf)
{
FILE * outfile;
struct jpeg_compress_struct _cinfo, *cinfo = &_cinfo;
@@ -759,7 +734,7 @@ static int save_maxjpeg(char * name, struct ImBuf * ibuf)
return 1;
}
-int imb_savejpeg(struct ImBuf * ibuf, char * name, int flags)
+int imb_savejpeg(struct ImBuf *ibuf, const char *name, int flags)
{
ibuf->flags = flags;