Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(304)

Unified Diff: turbojpeg.c

Issue 8720003: Update libjpeg-turbo to r722. (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/libjpeg_turbo/
Patch Set: '' Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « turbojpeg.h ('k') | turbojpeg-jni.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: turbojpeg.c
===================================================================
--- turbojpeg.c (revision 106486)
+++ turbojpeg.c (working copy)
@@ -132,9 +132,11 @@
return -1;
}
-static void setCompDefaults(struct jpeg_compress_struct *cinfo,
+static int setCompDefaults(struct jpeg_compress_struct *cinfo,
int pixelFormat, int subsamp, int jpegQual)
{
+ int retval=0;
+
switch(pixelFormat)
{
case TJPF_GRAY:
@@ -182,11 +184,18 @@
cinfo->comp_info[0].v_samp_factor=tjMCUHeight[subsamp]/8;
cinfo->comp_info[1].v_samp_factor=1;
cinfo->comp_info[2].v_samp_factor=1;
+
+ #if JCS_EXTENSIONS!=1
+ bailout:
+ #endif
+ return retval;
}
-static void setDecompDefaults(struct jpeg_decompress_struct *dinfo,
+static int setDecompDefaults(struct jpeg_decompress_struct *dinfo,
int pixelFormat)
{
+ int retval=0;
+
switch(pixelFormat)
{
case TJPF_GRAY:
@@ -214,6 +223,11 @@
_throw("Unsupported pixel format");
#endif
}
+
+ #if JCS_EXTENSIONS!=1
+ bailout:
+ #endif
+ return retval;
}
@@ -416,7 +430,8 @@
alloc=0; *jpegSize=tjBufSize(width, height, jpegSubsamp);
}
jpeg_mem_dest_tj(cinfo, jpegBuf, jpegSize, alloc);
- setCompDefaults(cinfo, pixelFormat, jpegSubsamp, jpegQual);
+ if(setCompDefaults(cinfo, pixelFormat, jpegSubsamp, jpegQual)==-1)
+ return -1;
jpeg_start_compress(cinfo, TRUE);
if((row_pointer=(JSAMPROW *)malloc(sizeof(JSAMPROW)*height))==NULL)
@@ -507,7 +522,7 @@
yuvsize=tjBufSizeYUV(width, height, subsamp);
jpeg_mem_dest_tj(cinfo, &dstBuf, &yuvsize, 0);
- setCompDefaults(cinfo, pixelFormat, subsamp, -1);
+ if(setCompDefaults(cinfo, pixelFormat, subsamp, -1)==-1) return -1;
jpeg_start_compress(cinfo, TRUE);
pw=PAD(width, cinfo->max_h_samp_factor);
@@ -729,7 +744,7 @@
jpeg_mem_src_tj(dinfo, jpegBuf, jpegSize);
jpeg_read_header(dinfo, TRUE);
- setDecompDefaults(dinfo, pixelFormat);
+ if(setDecompDefaults(dinfo, pixelFormat)==-1) return -1;
if(flags&TJFLAG_FASTUPSAMPLE) dinfo->do_fancy_upsampling=FALSE;
@@ -1023,15 +1038,45 @@
{
alloc=0; dstSizes[i]=tjBufSize(w, h, jpegSubsamp);
}
- jpeg_mem_dest_tj(cinfo, &dstBufs[i], &dstSizes[i], alloc);
+ if(!(t[i].options&TJXOPT_NOOUTPUT))
+ jpeg_mem_dest_tj(cinfo, &dstBufs[i], &dstSizes[i], alloc);
jpeg_copy_critical_parameters(dinfo, cinfo);
dstcoefs=jtransform_adjust_parameters(dinfo, cinfo, srccoefs,
&xinfo[i]);
- jpeg_write_coefficients(cinfo, dstcoefs);
- jcopy_markers_execute(dinfo, cinfo, JCOPYOPT_ALL);
+ if(!(t[i].options&TJXOPT_NOOUTPUT))
+ {
+ jpeg_write_coefficients(cinfo, dstcoefs);
+ jcopy_markers_execute(dinfo, cinfo, JCOPYOPT_ALL);
+ }
+ else jinit_c_master_control(cinfo, TRUE);
jtransform_execute_transformation(dinfo, cinfo, srccoefs,
&xinfo[i]);
- jpeg_finish_compress(cinfo);
+ if(t[i].customFilter)
+ {
+ int ci, by, y;
+ for(ci=0; ci<cinfo->num_components; ci++)
+ {
+ jpeg_component_info *compptr=&cinfo->comp_info[ci];
+ tjregion arrayRegion={0, 0, compptr->width_in_blocks*DCTSIZE,
+ DCTSIZE};
+ tjregion planeRegion={0, 0, compptr->width_in_blocks*DCTSIZE,
+ compptr->height_in_blocks*DCTSIZE};
+ for(by=0; by<compptr->height_in_blocks; by+=compptr->v_samp_factor)
+ {
+ JBLOCKARRAY barray=(dinfo->mem->access_virt_barray)
+ ((j_common_ptr)dinfo, dstcoefs[ci], by, compptr->v_samp_factor,
+ TRUE);
+ for(y=0; y<compptr->v_samp_factor; y++)
+ {
+ if(t[i].customFilter(barray[y][0], arrayRegion, planeRegion,
+ ci, i, &t[i])==-1)
+ _throw("tjTransform(): Error in custom filter");
+ arrayRegion.y+=DCTSIZE;
+ }
+ }
+ }
+ }
+ if(!(t[i].options&TJXOPT_NOOUTPUT)) jpeg_finish_compress(cinfo);
}
jpeg_finish_decompress(dinfo);
« no previous file with comments | « turbojpeg.h ('k') | turbojpeg-jni.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698