Port the width/height force feature from jpegtran v8d.
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@881 632fc199-4ca6-4c93-a231-07263d6284db
This commit is contained in:
@@ -33,6 +33,13 @@ the performance of the TurboJPEG Java API. It can be run with
|
|||||||
[8] cjpeg can now be used to generate JPEG files with the RGB colorspace
|
[8] cjpeg can now be used to generate JPEG files with the RGB colorspace
|
||||||
(feature ported from jpeg-8d.)
|
(feature ported from jpeg-8d.)
|
||||||
|
|
||||||
|
[9] The width and height in the -crop argument passed to jpegtran can now be
|
||||||
|
suffixed with "f" to indicate that, when the upper left corner of the cropping
|
||||||
|
region is automatically moved to the nearest iMCU boundary, the bottom right
|
||||||
|
corner should be moved by the same amount. In other words, this feature causes
|
||||||
|
jpegtran to strictly honor the specified width/height rather than the specified
|
||||||
|
bottom right corner (feature ported from jpeg-8d.)
|
||||||
|
|
||||||
|
|
||||||
1.2.1
|
1.2.1
|
||||||
=====
|
=====
|
||||||
|
|||||||
@@ -12,6 +12,9 @@ Using this switch suppresses the conversion from RGB
|
|||||||
colorspace input to the default YCbCr JPEG colorspace.
|
colorspace input to the default YCbCr JPEG colorspace.
|
||||||
Thank to Michael Koch for the initial suggestion.
|
Thank to Michael Koch for the initial suggestion.
|
||||||
|
|
||||||
|
Add option to disable the region adjustment in the transupp crop code.
|
||||||
|
Thank to Jeffrey Friedl for the suggestion.
|
||||||
|
|
||||||
|
|
||||||
Version 8b 16-May-2010
|
Version 8b 16-May-2010
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|||||||
18
transupp.c
18
transupp.c
@@ -2,7 +2,7 @@
|
|||||||
* transupp.c
|
* transupp.c
|
||||||
*
|
*
|
||||||
* This file was part of the Independent JPEG Group's software:
|
* This file was part of the Independent JPEG Group's software:
|
||||||
* Copyright (C) 1997-2009, Thomas G. Lane, Guido Vollbeding.
|
* Copyright (C) 1997-2011, Thomas G. Lane, Guido Vollbeding.
|
||||||
* Modifications:
|
* Modifications:
|
||||||
* Copyright (C) 2010, D. R. Commander.
|
* Copyright (C) 2010, D. R. Commander.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
@@ -783,7 +783,7 @@ jt_read_integer (const char ** strptr, JDIMENSION * result)
|
|||||||
* The routine returns TRUE if the spec string is valid, FALSE if not.
|
* The routine returns TRUE if the spec string is valid, FALSE if not.
|
||||||
*
|
*
|
||||||
* The crop spec string should have the format
|
* The crop spec string should have the format
|
||||||
* <width>x<height>{+-}<xoffset>{+-}<yoffset>
|
* <width>[f]x<height>[f]{+-}<xoffset>{+-}<yoffset>
|
||||||
* where width, height, xoffset, and yoffset are unsigned integers.
|
* where width, height, xoffset, and yoffset are unsigned integers.
|
||||||
* Each of the elements can be omitted to indicate a default value.
|
* Each of the elements can be omitted to indicate a default value.
|
||||||
* (A weakness of this style is that it is not possible to omit xoffset
|
* (A weakness of this style is that it is not possible to omit xoffset
|
||||||
@@ -805,6 +805,10 @@ jtransform_parse_crop_spec (jpeg_transform_info *info, const char *spec)
|
|||||||
/* fetch width */
|
/* fetch width */
|
||||||
if (! jt_read_integer(&spec, &info->crop_width))
|
if (! jt_read_integer(&spec, &info->crop_width))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
if (*spec == 'f' || *spec == 'F') {
|
||||||
|
spec++;
|
||||||
|
info->crop_width_set = JCROP_FORCE;
|
||||||
|
} else
|
||||||
info->crop_width_set = JCROP_POS;
|
info->crop_width_set = JCROP_POS;
|
||||||
}
|
}
|
||||||
if (*spec == 'x' || *spec == 'X') {
|
if (*spec == 'x' || *spec == 'X') {
|
||||||
@@ -812,6 +816,10 @@ jtransform_parse_crop_spec (jpeg_transform_info *info, const char *spec)
|
|||||||
spec++;
|
spec++;
|
||||||
if (! jt_read_integer(&spec, &info->crop_height))
|
if (! jt_read_integer(&spec, &info->crop_height))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
if (*spec == 'f' || *spec == 'F') {
|
||||||
|
spec++;
|
||||||
|
info->crop_height_set = JCROP_FORCE;
|
||||||
|
} else
|
||||||
info->crop_height_set = JCROP_POS;
|
info->crop_height_set = JCROP_POS;
|
||||||
}
|
}
|
||||||
if (*spec == '+' || *spec == '-') {
|
if (*spec == '+' || *spec == '-') {
|
||||||
@@ -997,8 +1005,14 @@ jtransform_request_workspace (j_decompress_ptr srcinfo,
|
|||||||
else
|
else
|
||||||
yoffset = info->crop_yoffset;
|
yoffset = info->crop_yoffset;
|
||||||
/* Now adjust so that upper left corner falls at an iMCU boundary */
|
/* Now adjust so that upper left corner falls at an iMCU boundary */
|
||||||
|
if (info->crop_width_set == JCROP_FORCE)
|
||||||
|
info->output_width = info->crop_width;
|
||||||
|
else
|
||||||
info->output_width =
|
info->output_width =
|
||||||
info->crop_width + (xoffset % info->iMCU_sample_width);
|
info->crop_width + (xoffset % info->iMCU_sample_width);
|
||||||
|
if (info->crop_height_set == JCROP_FORCE)
|
||||||
|
info->output_height = info->crop_height;
|
||||||
|
else
|
||||||
info->output_height =
|
info->output_height =
|
||||||
info->crop_height + (yoffset % info->iMCU_sample_height);
|
info->crop_height + (yoffset % info->iMCU_sample_height);
|
||||||
/* Save x/y offsets measured in iMCUs */
|
/* Save x/y offsets measured in iMCUs */
|
||||||
|
|||||||
13
transupp.h
13
transupp.h
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* transupp.h
|
* transupp.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 1997-2009, Thomas G. Lane, Guido Vollbeding.
|
* Copyright (C) 1997-2011, Thomas G. Lane, Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@@ -57,6 +57,7 @@
|
|||||||
* corner up and/or left to make it so, simultaneously increasing the region
|
* corner up and/or left to make it so, simultaneously increasing the region
|
||||||
* dimensions to keep the lower right crop corner unchanged. (Thus, the
|
* dimensions to keep the lower right crop corner unchanged. (Thus, the
|
||||||
* output image covers at least the requested region, but may cover more.)
|
* output image covers at least the requested region, but may cover more.)
|
||||||
|
* The adjustment of the region dimensions may be optionally disabled.
|
||||||
*
|
*
|
||||||
* We also provide a lossless-resize option, which is kind of a lossless-crop
|
* We also provide a lossless-resize option, which is kind of a lossless-crop
|
||||||
* operation in the DCT coefficient block domain - it discards higher-order
|
* operation in the DCT coefficient block domain - it discards higher-order
|
||||||
@@ -106,13 +107,15 @@ typedef enum {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Codes for crop parameters, which can individually be unspecified,
|
* Codes for crop parameters, which can individually be unspecified,
|
||||||
* positive, or negative. (Negative width or height makes no sense, though.)
|
* positive or negative for xoffset or yoffset,
|
||||||
|
* positive or forced for width or height.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
JCROP_UNSET,
|
JCROP_UNSET,
|
||||||
JCROP_POS,
|
JCROP_POS,
|
||||||
JCROP_NEG
|
JCROP_NEG,
|
||||||
|
JCROP_FORCE
|
||||||
} JCROP_CODE;
|
} JCROP_CODE;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -140,9 +143,9 @@ typedef struct {
|
|||||||
* These can be filled in by jtransform_parse_crop_spec().
|
* These can be filled in by jtransform_parse_crop_spec().
|
||||||
*/
|
*/
|
||||||
JDIMENSION crop_width; /* Width of selected region */
|
JDIMENSION crop_width; /* Width of selected region */
|
||||||
JCROP_CODE crop_width_set;
|
JCROP_CODE crop_width_set; /* (forced disables adjustment) */
|
||||||
JDIMENSION crop_height; /* Height of selected region */
|
JDIMENSION crop_height; /* Height of selected region */
|
||||||
JCROP_CODE crop_height_set;
|
JCROP_CODE crop_height_set; /* (forced disables adjustment) */
|
||||||
JDIMENSION crop_xoffset; /* X offset of selected region */
|
JDIMENSION crop_xoffset; /* X offset of selected region */
|
||||||
JCROP_CODE crop_xoffset_set; /* (negative measures from right edge) */
|
JCROP_CODE crop_xoffset_set; /* (negative measures from right edge) */
|
||||||
JDIMENSION crop_yoffset; /* Y offset of selected region */
|
JDIMENSION crop_yoffset; /* Y offset of selected region */
|
||||||
|
|||||||
Reference in New Issue
Block a user