dstbuf[bindex]=abs(dstbuf[bindex]-y);
}
}
- }
+ }
else
{
for(row=0; row<h; row++)
}
-void dotestyuv(unsigned char *srcbuf, int w, int h, int subsamp,
+int dotestyuv(unsigned char *srcbuf, int w, int h, int subsamp,
char *filename)
{
char tempstr[1024], tempstr2[80];
if(file) {fclose(file); file=NULL;}
if(dstbuf) {free(dstbuf); dstbuf=NULL;}
if(handle) {tjDestroy(handle); handle=NULL;}
- return;
+ return retval;
}
-void dotest(unsigned char *srcbuf, int w, int h, int subsamp, int jpegqual,
+int dotest(unsigned char *srcbuf, int w, int h, int subsamp, int jpegqual,
char *filename)
{
char tempstr[1024], tempstr2[80];
unsigned long *jpegsize=NULL;
int ps=tjPixelSize[pf], ntilesw=1, ntilesh=1, pitch=w*ps;
- if(yuv==YUVENCODE) {dotestyuv(srcbuf, w, h, subsamp, filename); return;}
+ if(yuv==YUVENCODE) return dotestyuv(srcbuf, w, h, subsamp, filename);
if((tmpbuf=(unsigned char *)malloc(pitch*h)) == NULL)
_throwunix("allocating temporary image buffer");
if(jpegsize) {free(jpegsize); jpegsize=NULL;}
if(tmpbuf) {free(tmpbuf); tmpbuf=NULL;}
if(handle) {tjDestroy(handle); handle=NULL;}
- return;
+ return retval;
}
-void dodecomptest(char *filename)
+int dodecomptest(char *filename)
{
FILE *file=NULL; tjhandle handle=NULL;
unsigned char **jpegbuf=NULL, *srcbuf=NULL;
if(srcbuf) {free(srcbuf); srcbuf=NULL;}
if(t) {free(t); t=NULL;}
if(handle) {tjDestroy(handle); handle=NULL;}
- return;
+ return retval;
}
if(!this) {snprintf(errStr, JMSG_LENGTH_MAX, "Invalid handle"); \
return -1;} \
cinfo=&this->cinfo; dinfo=&this->dinfo;
+#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;
+#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;
static int getPixelFormat(int pixelSize, int flags)
{
unsigned char *rgbBuf=NULL;
#endif
- getinstance(handle)
+ getcinstance(handle)
if((this->init&COMPRESS)==0)
_throw("tjCompress2(): Instance has not been initialized for compression");
unsigned char *rgbBuf=NULL;
#endif
- getinstance(handle);
+ getcinstance(handle);
for(i=0; i<MAX_COMPONENTS; i++)
{
{
int retval=0;
- getinstance(handle);
+ getdinstance(handle);
if((this->init&DECOMPRESS)==0)
_throw("tjDecompressHeader2(): Instance has not been initialized for decompression");
unsigned char *_dstBuf=NULL; int _pitch=0;
#endif
- getinstance(handle);
+ getdinstance(handle);
if((this->init&DECOMPRESS)==0)
_throw("tjDecompress2(): Instance has not been initialized for decompression");
tmpbufsize=0, usetmpbuf=0, th[MAX_COMPONENTS];
JSAMPLE *_tmpbuf=NULL, *ptr=dstBuf; JSAMPROW *tmpbuf[MAX_COMPONENTS];
- getinstance(handle);
+ getdinstance(handle);
for(i=0; i<MAX_COMPONENTS; i++)
{