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.
This commit is contained in:
@@ -142,6 +142,7 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
|
|||||||
transformoption.trim = FALSE;
|
transformoption.trim = FALSE;
|
||||||
transformoption.force_grayscale = FALSE;
|
transformoption.force_grayscale = FALSE;
|
||||||
transformoption.crop = FALSE;
|
transformoption.crop = FALSE;
|
||||||
|
transformoption.slow_hflip = FALSE;
|
||||||
cinfo->err->trace_level = 0;
|
cinfo->err->trace_level = 0;
|
||||||
|
|
||||||
/* Scan command line options, adjust parameters */
|
/* Scan command line options, adjust parameters */
|
||||||
|
|||||||
@@ -1022,7 +1022,7 @@ jtransform_request_workspace (j_decompress_ptr srcinfo,
|
|||||||
case JXFORM_FLIP_H:
|
case JXFORM_FLIP_H:
|
||||||
if (info->trim)
|
if (info->trim)
|
||||||
trim_right_edge(info, srcinfo->output_width);
|
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;
|
need_workspace = TRUE;
|
||||||
/* do_flip_h_no_crop doesn't need a workspace array */
|
/* do_flip_h_no_crop doesn't need a workspace array */
|
||||||
break;
|
break;
|
||||||
@@ -1448,7 +1448,7 @@ jtransform_execute_transform (j_decompress_ptr srcinfo,
|
|||||||
src_coef_arrays, dst_coef_arrays);
|
src_coef_arrays, dst_coef_arrays);
|
||||||
break;
|
break;
|
||||||
case JXFORM_FLIP_H:
|
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,
|
do_flip_h(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset,
|
||||||
src_coef_arrays, dst_coef_arrays);
|
src_coef_arrays, dst_coef_arrays);
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -128,6 +128,13 @@ typedef struct {
|
|||||||
boolean trim; /* if TRUE, trim partial MCUs as needed */
|
boolean trim; /* if TRUE, trim partial MCUs as needed */
|
||||||
boolean force_grayscale; /* if TRUE, convert color image to grayscale */
|
boolean force_grayscale; /* if TRUE, convert color image to grayscale */
|
||||||
boolean crop; /* if TRUE, crop source image */
|
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.
|
/* Crop parameters: application need not set these unless crop is TRUE.
|
||||||
* These can be filled in by jtransform_parse_crop_spec().
|
* These can be filled in by jtransform_parse_crop_spec().
|
||||||
|
|||||||
@@ -751,6 +751,8 @@ DLLEXPORT int DLLCALL tjTransform(tjhandle hnd,
|
|||||||
xinfo[i].trim=(t[i].options&TJXFORM_TRIM)? 1:0;
|
xinfo[i].trim=(t[i].options&TJXFORM_TRIM)? 1:0;
|
||||||
xinfo[i].force_grayscale=(t[i].options&TJXFORM_GRAY)? 1:0;
|
xinfo[i].force_grayscale=(t[i].options&TJXFORM_GRAY)? 1:0;
|
||||||
xinfo[i].crop=(t[i].options&TJXFORM_CROP)? 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)
|
if(xinfo[i].crop)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user