summaryrefslogtreecommitdiff
path: root/turbojpeg.c
diff options
context:
space:
mode:
authorhbono@chromium.org <hbono@chromium.org@4ff67af0-8c30-449e-8e8b-ad334ec8d88c>2012-07-19 06:04:44 +0000
committerhbono@chromium.org <hbono@chromium.org@4ff67af0-8c30-449e-8e8b-ad334ec8d88c>2012-07-19 06:04:44 +0000
commit11e6ee95ca9a40fe6b86a1cd23a9fbfd7d19c2bd (patch)
tree2eec0543260b716b3862c8c05100bcd7ab6f833c /turbojpeg.c
parentcd3e30f64064274b17a99bb93e20a7dad2703bf0 (diff)
Update libjpeg-turbo to r856.
BUG=132952 TEST=none Review URL: https://chromiumcodereview.appspot.com/10700197 git-svn-id: http://src.chromium.org/svn/trunk/deps/third_party/libjpeg_turbo@147403 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
Diffstat (limited to 'turbojpeg.c')
-rw-r--r--turbojpeg.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/turbojpeg.c b/turbojpeg.c
index c875fd9..21599c8 100644
--- a/turbojpeg.c
+++ b/turbojpeg.c
@@ -145,7 +145,7 @@ static int getPixelFormat(int pixelSize, int flags)
}
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 @@ static int setCompDefaults(struct jpeg_compress_struct *cinfo,
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 setCompDefaults(struct jpeg_compress_struct *cinfo,
}
static int setDecompDefaults(struct jpeg_decompress_struct *dinfo,
- int pixelFormat)
+ int pixelFormat, int flags)
{
int retval=0;
@@ -258,6 +258,8 @@ static int setDecompDefaults(struct jpeg_decompress_struct *dinfo,
_throw("Unsupported pixel format");
}
+ if(flags&TJFLAG_FASTDCT) dinfo->dct_method=JDCT_FASTEST;
+
bailout:
return retval;
}
@@ -618,7 +620,7 @@ DLLEXPORT int DLLCALL tjCompress2(tjhandle handle, unsigned char *srcBuf,
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 @@ DLLEXPORT int DLLCALL tjEncodeYUV2(tjhandle handle, unsigned char *srcBuf,
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 @@ DLLEXPORT int DLLCALL tjDecompress2(tjhandle handle, unsigned char *jpegBuf,
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 @@ DLLEXPORT int DLLCALL tjDecompressToYUV(tjhandle handle,
}
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);