diff --git a/bmp.c b/bmp.c index 9fcf7bbd5..2b8e80c13 100644 --- a/bmp.c +++ b/bmp.c @@ -108,10 +108,14 @@ static void pixelconvert(unsigned char *srcbuf, int srcpf, int srcbottomup, m=(m-k)/(1.0-k); y=(y-k)/(1.0-k); } - if(c>1.0) c=1.0; if(c<0.) c=0.; - if(m>1.0) m=1.0; if(m<0.) m=0.; - if(y>1.0) y=1.0; if(y<0.) y=0.; - if(k>1.0) k=1.0; if(k<0.) k=0.; + if(c>1.0) c=1.0; + if(c<0.) c=0.; + if(m>1.0) m=1.0; + if(m<0.) m=0.; + if(y>1.0) y=1.0; + if(y<0.) y=0.; + if(k>1.0) k=1.0; + if(k<0.) k=0.; *dstcolptr++=(unsigned char)(255.0-c*255.0+0.5); *dstcolptr++=(unsigned char)(255.0-m*255.0+0.5); *dstcolptr++=(unsigned char)(255.0-y*255.0+0.5); @@ -133,9 +137,12 @@ static void pixelconvert(unsigned char *srcbuf, int srcpf, int srcbottomup, double r=c*k/255.; double g=m*k/255.; double b=y*k/255.; - if(r>255.0) r=255.0; if(r<0.) r=0.; - if(g>255.0) g=255.0; if(g<0.) g=0.; - if(b>255.0) b=255.0; if(b<0.) b=0.; + if(r>255.0) r=255.0; + if(r<0.) r=0.; + if(g>255.0) g=255.0; + if(g<0.) g=0.; + if(b>255.0) b=255.0; + if(b<0.) b=0.; dstcolptr[tjRedOffset[dstpf]]=(unsigned char)(r+0.5); dstcolptr[tjGreenOffset[dstpf]]=(unsigned char)(g+0.5); dstcolptr[tjBlueOffset[dstpf]]=(unsigned char)(b+0.5); diff --git a/tjbench.c b/tjbench.c index 81b36f637..9db1968c1 100644 --- a/tjbench.c +++ b/tjbench.c @@ -248,7 +248,8 @@ int decomp(unsigned char *srcbuf, unsigned char **jpegbuf, int y=(int)((double)srcbuf[rindex]*0.299 + (double)srcbuf[gindex]*0.587 + (double)srcbuf[bindex]*0.114 + 0.5); - if(y>255) y=255; if(y<0) y=0; + if(y>255) y=255; + if(y<0) y=0; dstbuf[rindex]=abs(dstbuf[rindex]-y); dstbuf[gindex]=abs(dstbuf[gindex]-y); dstbuf[bindex]=abs(dstbuf[bindex]-y); @@ -300,7 +301,8 @@ int fullTest(unsigned char *srcbuf, int w, int h, int subsamp, int jpegqual, for(tilew=dotile? 8:w, tileh=dotile? 8:h; ; tilew*=2, tileh*=2) { - if(tilew>w) tilew=w; if(tileh>h) tileh=h; + if(tilew>w) tilew=w; + if(tileh>h) tileh=h; ntilesw=(w+tilew-1)/tilew; ntilesh=(h+tileh-1)/tileh; if((jpegbuf=(unsigned char **)malloc(sizeof(unsigned char *) @@ -447,7 +449,8 @@ int fullTest(unsigned char *srcbuf, int w, int h, int subsamp, int jpegqual, for(i=0; iw) tilew=w; if(tileh>h) tileh=h; + if(tilew>w) tilew=w; + if(tileh>h) tileh=h; ntilesw=(w+tilew-1)/tilew; ntilesh=(h+tileh-1)/tileh; if((jpegbuf=(unsigned char **)malloc(sizeof(unsigned char *) @@ -692,7 +697,8 @@ int decompTest(char *filename) { for(i=0; ijerr.setjmp_buffer)) { /* If we get here, the JPEG code has signaled an error. */ - if(this) free(this); return NULL; + if(this) free(this); + return NULL; } jpeg_create_compress(&this->cinfo); @@ -1231,7 +1232,8 @@ static tjhandle _tjInitDecompress(tjinstance *this) if(setjmp(this->jerr.setjmp_buffer)) { /* If we get here, the JPEG code has signaled an error. */ - if(this) free(this); return NULL; + if(this) free(this); + return NULL; } jpeg_create_decompress(&this->dinfo);