| Index: turbojpeg.c
|
| ===================================================================
|
| --- turbojpeg.c (revision 144411)
|
| +++ turbojpeg.c (working copy)
|
| @@ -145,7 +145,7 @@
|
| }
|
|
|
| static int setCompDefaults(struct jpeg_compress_struct *cinfo,
|
| - int pixelFormat, int subsamp, int jpegQual)
|
| + int pixelFormat, int subsamp, int jpegQual, int flags)
|
| {
|
| int retval=0;
|
|
|
| @@ -191,7 +191,7 @@
|
| if(jpegQual>=0)
|
| {
|
| jpeg_set_quality(cinfo, jpegQual, TRUE);
|
| - if(jpegQual>=96) cinfo->dct_method=JDCT_ISLOW;
|
| + if(jpegQual>=96 || flags&TJFLAG_ACCURATEDCT) cinfo->dct_method=JDCT_ISLOW;
|
| else cinfo->dct_method=JDCT_FASTEST;
|
| }
|
| if(subsamp==TJSAMP_GRAY)
|
| @@ -210,7 +210,7 @@
|
| }
|
|
|
| static int setDecompDefaults(struct jpeg_decompress_struct *dinfo,
|
| - int pixelFormat)
|
| + int pixelFormat, int flags)
|
| {
|
| int retval=0;
|
|
|
| @@ -258,6 +258,8 @@
|
| _throw("Unsupported pixel format");
|
| }
|
|
|
| + if(flags&TJFLAG_FASTDCT) dinfo->dct_method=JDCT_FASTEST;
|
| +
|
| bailout:
|
| return retval;
|
| }
|
| @@ -618,7 +620,7 @@
|
| alloc=0; *jpegSize=tjBufSize(width, height, jpegSubsamp);
|
| }
|
| jpeg_mem_dest_tj(cinfo, jpegBuf, jpegSize, alloc);
|
| - if(setCompDefaults(cinfo, pixelFormat, jpegSubsamp, jpegQual)==-1)
|
| + if(setCompDefaults(cinfo, pixelFormat, jpegSubsamp, jpegQual, flags)==-1)
|
| return -1;
|
|
|
| jpeg_start_compress(cinfo, TRUE);
|
| @@ -726,7 +728,7 @@
|
|
|
| yuvsize=tjBufSizeYUV(width, height, subsamp);
|
| jpeg_mem_dest_tj(cinfo, &dstBuf, &yuvsize, 0);
|
| - if(setCompDefaults(cinfo, pixelFormat, subsamp, -1)==-1) return -1;
|
| + if(setCompDefaults(cinfo, pixelFormat, subsamp, -1, flags)==-1) return -1;
|
|
|
| jpeg_start_compress(cinfo, TRUE);
|
| pw=PAD(width, cinfo->max_h_samp_factor);
|
| @@ -955,7 +957,7 @@
|
|
|
| jpeg_mem_src_tj(dinfo, jpegBuf, jpegSize);
|
| jpeg_read_header(dinfo, TRUE);
|
| - if(setDecompDefaults(dinfo, pixelFormat)==-1)
|
| + if(setDecompDefaults(dinfo, pixelFormat, flags)==-1)
|
| {
|
| retval=-1; goto bailout;
|
| }
|
| @@ -1110,6 +1112,7 @@
|
| }
|
|
|
| if(flags&TJFLAG_FASTUPSAMPLE) dinfo->do_fancy_upsampling=FALSE;
|
| + if(flags&TJFLAG_FASTDCT) dinfo->dct_method=JDCT_FASTEST;
|
| dinfo->raw_data_out=TRUE;
|
|
|
| jpeg_start_decompress(dinfo);
|
|
|