Skip to content

Commit

Permalink
Tile generation did not work with TJXFORM_HFLIP, because the underlyi…
Browse files Browse the repository at this point in the history
…ng 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: https://libjpeg-turbo.svn.sourceforge.net/svnroot/libjpeg-turbo/trunk@495 3789f03b-4d11-0410-bbf8-ca57d06f2519
  • Loading branch information
dcommander committed Mar 4, 2011
1 parent 26ca2cb commit 7ce6dbe
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions jpegtran.c
Expand Up @@ -142,6 +142,7 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
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 */
Expand Down
4 changes: 2 additions & 2 deletions transupp.c
Expand Up @@ -1022,7 +1022,7 @@ jtransform_request_workspace (j_decompress_ptr srcinfo,
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;
Expand Down Expand Up @@ -1448,7 +1448,7 @@ jtransform_execute_transform (j_decompress_ptr srcinfo,
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
Expand Down
7 changes: 7 additions & 0 deletions transupp.h
Expand Up @@ -128,6 +128,13 @@ typedef struct {
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().
Expand Down
2 changes: 2 additions & 0 deletions turbojpegl.c
Expand Up @@ -751,6 +751,8 @@ DLLEXPORT int DLLCALL tjTransform(tjhandle hnd,
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)
{
Expand Down

0 comments on commit 7ce6dbe

Please sign in to comment.