/*
- * Copyright (C)2009-2014 D. R. Commander. All Rights Reserved.
+ * Copyright (C)2009-2015 D. R. Commander. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
{
struct jpeg_error_mgr pub;
jmp_buf setjmp_buffer;
+ void (*emit_message)(j_common_ptr, int);
+ boolean warning;
};
typedef struct my_error_mgr *my_error_ptr;
(*cinfo->err->format_message)(cinfo, errStr);
}
+static void my_emit_message(j_common_ptr cinfo, int msg_level)
+{
+ my_error_ptr myerr=(my_error_ptr)cinfo->err;
+ myerr->emit_message(cinfo, msg_level);
+ if(msg_level<0) myerr->warning=TRUE;
+}
+
/* Global structures, macros, etc. */
j_compress_ptr cinfo=NULL; j_decompress_ptr dinfo=NULL; \
if(!this) {snprintf(errStr, JMSG_LENGTH_MAX, "Invalid handle"); \
return -1;} \
- cinfo=&this->cinfo; dinfo=&this->dinfo;
+ cinfo=&this->cinfo; dinfo=&this->dinfo; \
+ this->jerr.warning=FALSE;
#define getcinstance(handle) tjinstance *this=(tjinstance *)handle; \
j_compress_ptr cinfo=NULL; \
if(!this) {snprintf(errStr, JMSG_LENGTH_MAX, "Invalid handle"); \
return -1;} \
- cinfo=&this->cinfo;
+ cinfo=&this->cinfo; \
+ this->jerr.warning=FALSE;
#define getdinstance(handle) tjinstance *this=(tjinstance *)handle; \
j_decompress_ptr dinfo=NULL; \
if(!this) {snprintf(errStr, JMSG_LENGTH_MAX, "Invalid handle"); \
return -1;} \
- dinfo=&this->dinfo;
+ dinfo=&this->dinfo; \
+ this->jerr.warning=FALSE;
static int getPixelFormat(int pixelSize, int flags)
{
this->cinfo.err=jpeg_std_error(&this->jerr.pub);
this->jerr.pub.error_exit=my_error_exit;
this->jerr.pub.output_message=my_output_message;
+ this->jerr.emit_message=this->jerr.pub.emit_message;
+ this->jerr.pub.emit_message=my_emit_message;
if(setjmp(this->jerr.setjmp_buffer))
{
if(rgbBuf) free(rgbBuf);
#endif
if(row_pointer) free(row_pointer);
+ if(this->jerr.warning) retval=-1;
return retval;
}
if(_tmpbuf2[i]!=NULL) free(_tmpbuf2[i]);
if(outbuf[i]!=NULL) free(outbuf[i]);
}
+ if(this->jerr.warning) retval=-1;
return retval;
}
if(inbuf[i]) free(inbuf[i]);
}
if(_tmpbuf) free(_tmpbuf);
+ if(this->jerr.warning) retval=-1;
return retval;
}
this->dinfo.err=jpeg_std_error(&this->jerr.pub);
this->jerr.pub.error_exit=my_error_exit;
this->jerr.pub.output_message=my_output_message;
+ this->jerr.emit_message=this->jerr.pub.emit_message;
+ this->jerr.pub.emit_message=my_emit_message;
if(setjmp(this->jerr.setjmp_buffer))
{
_throw("tjDecompressHeader3(): Invalid data returned in header");
bailout:
+ if(this->jerr.warning) retval=-1;
return retval;
}
if(rgbBuf) free(rgbBuf);
#endif
if(row_pointer) free(row_pointer);
+ if(this->jerr.warning) retval=-1;
return retval;
}
if(_tmpbuf[i]!=NULL) free(_tmpbuf[i]);
if(inbuf[i]!=NULL) free(inbuf[i]);
}
+ if(this->jerr.warning) retval=-1;
return retval;
}
if(outbuf[i]) free(outbuf[i]);
}
if(_tmpbuf) free(_tmpbuf);
+ if(this->jerr.warning) retval=-1;
return retval;
}
if(cinfo->global_state>CSTATE_START) jpeg_abort_compress(cinfo);
if(dinfo->global_state>DSTATE_START) jpeg_abort_decompress(dinfo);
if(xinfo) free(xinfo);
+ if(this->jerr.warning) retval=-1;
return retval;
}