Tile generation did not work with TJXFORM_HFLIP, because the underlying transform code was using an in-place algorithm, which modified the source coefficients after the first tile was generated. Thus, create a new option which allows TurboJPEG to turn off the in-place horizontal flip if there are multiple transforms being performed from the same set of coefficients.
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@495 632fc199-4ca6-4c93-a231-07263d6284db
diff --git a/jpegtran.c b/jpegtran.c
index 73dbe53..f861464 100644
--- a/jpegtran.c
+++ b/jpegtran.c
@@ -142,6 +142,7 @@
transformoption.trim = FALSE;
transformoption.force_grayscale = FALSE;
transformoption.crop = FALSE;
+ transformoption.slow_hflip = FALSE;
cinfo->err->trace_level = 0;
/* Scan command line options, adjust parameters */
diff --git a/transupp.c b/transupp.c
index 5c31416..2513691 100644
--- a/transupp.c
+++ b/transupp.c
@@ -1022,7 +1022,7 @@
case JXFORM_FLIP_H:
if (info->trim)
trim_right_edge(info, srcinfo->output_width);
- if (info->y_crop_offset != 0)
+ if (info->y_crop_offset != 0 || info->slow_hflip)
need_workspace = TRUE;
/* do_flip_h_no_crop doesn't need a workspace array */
break;
@@ -1448,7 +1448,7 @@
src_coef_arrays, dst_coef_arrays);
break;
case JXFORM_FLIP_H:
- if (info->y_crop_offset != 0)
+ if (info->y_crop_offset != 0 || info->slow_hflip)
do_flip_h(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset,
src_coef_arrays, dst_coef_arrays);
else
diff --git a/transupp.h b/transupp.h
index 7c16c19..122d448 100644
--- a/transupp.h
+++ b/transupp.h
@@ -128,6 +128,13 @@
boolean trim; /* if TRUE, trim partial MCUs as needed */
boolean force_grayscale; /* if TRUE, convert color image to grayscale */
boolean crop; /* if TRUE, crop source image */
+ boolean slow_hflip; /* For best performance, the JXFORM_FLIP_H transform
+ normally modifies the source coefficients in place.
+ Setting this to TRUE will instead use a slower,
+ double-buffered algorithm, which leaves the source
+ coefficients in tact (necessary if other transformed
+ images must be generated from the same set of
+ coefficients. */
/* Crop parameters: application need not set these unless crop is TRUE.
* These can be filled in by jtransform_parse_crop_spec().
diff --git a/turbojpegl.c b/turbojpegl.c
index c2ca1fc..bc0ef7f 100644
--- a/turbojpegl.c
+++ b/turbojpegl.c
@@ -751,6 +751,8 @@
xinfo[i].trim=(t[i].options&TJXFORM_TRIM)? 1:0;
xinfo[i].force_grayscale=(t[i].options&TJXFORM_GRAY)? 1:0;
xinfo[i].crop=(t[i].options&TJXFORM_CROP)? 1:0;
+ if(n!=1 && t[i].op==TJXFORM_HFLIP) xinfo[i].slow_hflip=1;
+ else xinfo[i].slow_hflip=0;
if(xinfo[i].crop)
{