| OLD | NEW |
| 1 /* | 1 /* |
| 2 * transupp.h | 2 * transupp.h |
| 3 * | 3 * |
| 4 * This file was part of the Independent JPEG Group's software: |
| 4 * Copyright (C) 1997-2011, Thomas G. Lane, Guido Vollbeding. | 5 * Copyright (C) 1997-2011, Thomas G. Lane, Guido Vollbeding. |
| 5 * This file is part of the Independent JPEG Group's software. | 6 * It was modified by The libjpeg-turbo Project to include only code relevant |
| 6 * For conditions of distribution and use, see the accompanying README file. | 7 * to libjpeg-turbo. |
| 8 * For conditions of distribution and use, see the accompanying README.ijg |
| 9 * file. |
| 7 * | 10 * |
| 8 * This file contains declarations for image transformation routines and | 11 * This file contains declarations for image transformation routines and |
| 9 * other utility code used by the jpegtran sample application. These are | 12 * other utility code used by the jpegtran sample application. These are |
| 10 * NOT part of the core JPEG library. But we keep these routines separate | 13 * NOT part of the core JPEG library. But we keep these routines separate |
| 11 * from jpegtran.c to ease the task of maintaining jpegtran-like programs | 14 * from jpegtran.c to ease the task of maintaining jpegtran-like programs |
| 12 * that have other user interfaces. | 15 * that have other user interfaces. |
| 13 * | 16 * |
| 14 * NOTE: all the routines declared here have very specific requirements | 17 * NOTE: all the routines declared here have very specific requirements |
| 15 * about when they are to be executed during the reading and writing of the | 18 * about when they are to be executed during the reading and writing of the |
| 16 * source and destination files. See the comments in transupp.c, or see | 19 * source and destination files. See the comments in transupp.c, or see |
| 17 * jpegtran.c for an example of correct usage. | 20 * jpegtran.c for an example of correct usage. |
| 18 */ | 21 */ |
| 19 | 22 |
| 20 /* If you happen not to want the image transform support, disable it here */ | 23 /* If you happen not to want the image transform support, disable it here */ |
| 21 #ifndef TRANSFORMS_SUPPORTED | 24 #ifndef TRANSFORMS_SUPPORTED |
| 22 #define TRANSFORMS_SUPPORTED 1» » /* 0 disables transform code */ | 25 #define TRANSFORMS_SUPPORTED 1 /* 0 disables transform code */ |
| 23 #endif | 26 #endif |
| 24 | 27 |
| 25 /* | 28 /* |
| 26 * Although rotating and flipping data expressed as DCT coefficients is not | 29 * Although rotating and flipping data expressed as DCT coefficients is not |
| 27 * hard, there is an asymmetry in the JPEG format specification for images | 30 * hard, there is an asymmetry in the JPEG format specification for images |
| 28 * whose dimensions aren't multiples of the iMCU size. The right and bottom | 31 * whose dimensions aren't multiples of the iMCU size. The right and bottom |
| 29 * image edges are padded out to the next iMCU boundary with junk data; but | 32 * image edges are padded out to the next iMCU boundary with junk data; but |
| 30 * no padding is possible at the top and left edges. If we were to flip | 33 * no padding is possible at the top and left edges. If we were to flip |
| 31 * the whole image including the pad data, then pad garbage would become | 34 * the whole image including the pad data, then pad garbage would become |
| 32 * visible at the top and/or left, and real pixels would disappear into the | 35 * visible at the top and/or left, and real pixels would disappear into the |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 * | 73 * |
| 71 * We also offer a "force to grayscale" option, which simply discards the | 74 * We also offer a "force to grayscale" option, which simply discards the |
| 72 * chrominance channels of a YCbCr image. This is lossless in the sense that | 75 * chrominance channels of a YCbCr image. This is lossless in the sense that |
| 73 * the luminance channel is preserved exactly. It's not the same kind of | 76 * the luminance channel is preserved exactly. It's not the same kind of |
| 74 * thing as the rotate/flip transformations, but it's convenient to handle it | 77 * thing as the rotate/flip transformations, but it's convenient to handle it |
| 75 * as part of this package, mainly because the transformation routines have to | 78 * as part of this package, mainly because the transformation routines have to |
| 76 * be aware of the option to know how many components to work on. | 79 * be aware of the option to know how many components to work on. |
| 77 */ | 80 */ |
| 78 | 81 |
| 79 | 82 |
| 80 /* Short forms of external names for systems with brain-damaged linkers. */ | |
| 81 | |
| 82 #ifdef NEED_SHORT_EXTERNAL_NAMES | |
| 83 #define jtransform_parse_crop_spec jTrParCrop | |
| 84 #define jtransform_request_workspace jTrRequest | |
| 85 #define jtransform_adjust_parameters jTrAdjust | |
| 86 #define jtransform_execute_transform jTrExec | |
| 87 #define jtransform_perfect_transform jTrPerfect | |
| 88 #define jcopy_markers_setup jCMrkSetup | |
| 89 #define jcopy_markers_execute jCMrkExec | |
| 90 #endif /* NEED_SHORT_EXTERNAL_NAMES */ | |
| 91 | |
| 92 | |
| 93 /* | 83 /* |
| 94 * Codes for supported types of image transformations. | 84 * Codes for supported types of image transformations. |
| 95 */ | 85 */ |
| 96 | 86 |
| 97 typedef enum { | 87 typedef enum { |
| 98 » JXFORM_NONE,» » /* no transformation */ | 88 JXFORM_NONE, /* no transformation */ |
| 99 » JXFORM_FLIP_H,» » /* horizontal flip */ | 89 JXFORM_FLIP_H, /* horizontal flip */ |
| 100 » JXFORM_FLIP_V,» » /* vertical flip */ | 90 JXFORM_FLIP_V, /* vertical flip */ |
| 101 » JXFORM_TRANSPOSE,» /* transpose across UL-to-LR axis */ | 91 JXFORM_TRANSPOSE, /* transpose across UL-to-LR axis */ |
| 102 » JXFORM_TRANSVERSE,» /* transpose across UR-to-LL axis */ | 92 JXFORM_TRANSVERSE, /* transpose across UR-to-LL axis */ |
| 103 » JXFORM_ROT_90,» » /* 90-degree clockwise rotation */ | 93 JXFORM_ROT_90, /* 90-degree clockwise rotation */ |
| 104 » JXFORM_ROT_180,»» /* 180-degree rotation */ | 94 JXFORM_ROT_180, /* 180-degree rotation */ |
| 105 » JXFORM_ROT_270» » /* 270-degree clockwise (or 90 ccw) */ | 95 JXFORM_ROT_270 /* 270-degree clockwise (or 90 ccw) */ |
| 106 } JXFORM_CODE; | 96 } JXFORM_CODE; |
| 107 | 97 |
| 108 /* | 98 /* |
| 109 * Codes for crop parameters, which can individually be unspecified, | 99 * Codes for crop parameters, which can individually be unspecified, |
| 110 * positive or negative for xoffset or yoffset, | 100 * positive or negative for xoffset or yoffset, |
| 111 * positive or forced for width or height. | 101 * positive or forced for width or height. |
| 112 */ | 102 */ |
| 113 | 103 |
| 114 typedef enum { | 104 typedef enum { |
| 115 JCROP_UNSET, | 105 JCROP_UNSET, |
| 116 JCROP_POS, | 106 JCROP_POS, |
| 117 JCROP_NEG, | 107 JCROP_NEG, |
| 118 JCROP_FORCE | 108 JCROP_FORCE |
| 119 } JCROP_CODE; | 109 } JCROP_CODE; |
| 120 | 110 |
| 121 /* | 111 /* |
| 122 * Transform parameters struct. | 112 * Transform parameters struct. |
| 123 * NB: application must not change any elements of this struct after | 113 * NB: application must not change any elements of this struct after |
| 124 * calling jtransform_request_workspace. | 114 * calling jtransform_request_workspace. |
| 125 */ | 115 */ |
| 126 | 116 |
| 127 typedef struct { | 117 typedef struct { |
| 128 /* Options: set by caller */ | 118 /* Options: set by caller */ |
| 129 JXFORM_CODE transform;» /* image transform operator */ | 119 JXFORM_CODE transform; /* image transform operator */ |
| 130 boolean perfect;» » /* if TRUE, fail if partial MCUs are requested *
/ | 120 boolean perfect; /* if TRUE, fail if partial MCUs are requested *
/ |
| 131 boolean trim;»» » /* if TRUE, trim partial MCUs as needed */ | 121 boolean trim; /* if TRUE, trim partial MCUs as needed */ |
| 132 boolean force_grayscale;» /* if TRUE, convert color image to grayscale */ | 122 boolean force_grayscale; /* if TRUE, convert color image to grayscale */ |
| 133 boolean crop;»» » /* if TRUE, crop source image */ | 123 boolean crop; /* if TRUE, crop source image */ |
| 134 boolean slow_hflip; /* For best performance, the JXFORM_FLIP_H transform | 124 boolean slow_hflip; /* For best performance, the JXFORM_FLIP_H transform |
| 135 normally modifies the source coefficients in place. | 125 normally modifies the source coefficients in place. |
| 136 Setting this to TRUE will instead use a slower, | 126 Setting this to TRUE will instead use a slower, |
| 137 double-buffered algorithm, which leaves the source | 127 double-buffered algorithm, which leaves the source |
| 138 coefficients in tact (necessary if other transformed | 128 coefficients in tact (necessary if other transformed |
| 139 images must be generated from the same set of | 129 images must be generated from the same set of |
| 140 coefficients. */ | 130 coefficients. */ |
| 141 | 131 |
| 142 /* Crop parameters: application need not set these unless crop is TRUE. | 132 /* Crop parameters: application need not set these unless crop is TRUE. |
| 143 * These can be filled in by jtransform_parse_crop_spec(). | 133 * These can be filled in by jtransform_parse_crop_spec(). |
| 144 */ | 134 */ |
| 145 JDIMENSION crop_width;» /* Width of selected region */ | 135 JDIMENSION crop_width; /* Width of selected region */ |
| 146 JCROP_CODE crop_width_set;» /* (forced disables adjustment) */ | 136 JCROP_CODE crop_width_set; /* (forced disables adjustment) */ |
| 147 JDIMENSION crop_height;» /* Height of selected region */ | 137 JDIMENSION crop_height; /* Height of selected region */ |
| 148 JCROP_CODE crop_height_set;» /* (forced disables adjustment) */ | 138 JCROP_CODE crop_height_set; /* (forced disables adjustment) */ |
| 149 JDIMENSION crop_xoffset;» /* X offset of selected region */ | 139 JDIMENSION crop_xoffset; /* X offset of selected region */ |
| 150 JCROP_CODE crop_xoffset_set;» /* (negative measures from right edge) */ | 140 JCROP_CODE crop_xoffset_set; /* (negative measures from right edge) */ |
| 151 JDIMENSION crop_yoffset;» /* Y offset of selected region */ | 141 JDIMENSION crop_yoffset; /* Y offset of selected region */ |
| 152 JCROP_CODE crop_yoffset_set;» /* (negative measures from bottom edge) */ | 142 JCROP_CODE crop_yoffset_set; /* (negative measures from bottom edge) */ |
| 153 | 143 |
| 154 /* Internal workspace: caller should not touch these */ | 144 /* Internal workspace: caller should not touch these */ |
| 155 int num_components;» » /* # of components in workspace */ | 145 int num_components; /* # of components in workspace */ |
| 156 jvirt_barray_ptr * workspace_coef_arrays; /* workspace for transformations */ | 146 jvirt_barray_ptr *workspace_coef_arrays; /* workspace for transformations */ |
| 157 JDIMENSION output_width;» /* cropped destination dimensions */ | 147 JDIMENSION output_width; /* cropped destination dimensions */ |
| 158 JDIMENSION output_height; | 148 JDIMENSION output_height; |
| 159 JDIMENSION x_crop_offset;» /* destination crop offsets measured in iMCUs */ | 149 JDIMENSION x_crop_offset; /* destination crop offsets measured in iMCUs */ |
| 160 JDIMENSION y_crop_offset; | 150 JDIMENSION y_crop_offset; |
| 161 int iMCU_sample_width;» /* destination iMCU size */ | 151 int iMCU_sample_width; /* destination iMCU size */ |
| 162 int iMCU_sample_height; | 152 int iMCU_sample_height; |
| 163 } jpeg_transform_info; | 153 } jpeg_transform_info; |
| 164 | 154 |
| 165 | 155 |
| 166 #if TRANSFORMS_SUPPORTED | 156 #if TRANSFORMS_SUPPORTED |
| 167 | 157 |
| 168 /* Parse a crop specification (written in X11 geometry style) */ | 158 /* Parse a crop specification (written in X11 geometry style) */ |
| 169 EXTERN(boolean) jtransform_parse_crop_spec | 159 EXTERN(boolean) jtransform_parse_crop_spec |
| 170 » JPP((jpeg_transform_info *info, const char *spec)); | 160 (jpeg_transform_info *info, const char *spec); |
| 171 /* Request any required workspace */ | 161 /* Request any required workspace */ |
| 172 EXTERN(boolean) jtransform_request_workspace | 162 EXTERN(boolean) jtransform_request_workspace |
| 173 » JPP((j_decompress_ptr srcinfo, jpeg_transform_info *info)); | 163 (j_decompress_ptr srcinfo, jpeg_transform_info *info); |
| 174 /* Adjust output image parameters */ | 164 /* Adjust output image parameters */ |
| 175 EXTERN(jvirt_barray_ptr *) jtransform_adjust_parameters | 165 EXTERN(jvirt_barray_ptr *) jtransform_adjust_parameters |
| 176 » JPP((j_decompress_ptr srcinfo, j_compress_ptr dstinfo, | 166 (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, |
| 177 » jvirt_barray_ptr *src_coef_arrays, | 167 jvirt_barray_ptr *src_coef_arrays, jpeg_transform_info *info); |
| 178 » jpeg_transform_info *info)); | |
| 179 /* Execute the actual transformation, if any */ | 168 /* Execute the actual transformation, if any */ |
| 180 EXTERN(void) jtransform_execute_transform | 169 EXTERN(void) jtransform_execute_transform |
| 181 » JPP((j_decompress_ptr srcinfo, j_compress_ptr dstinfo, | 170 (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, |
| 182 » jvirt_barray_ptr *src_coef_arrays, | 171 jvirt_barray_ptr *src_coef_arrays, jpeg_transform_info *info); |
| 183 » jpeg_transform_info *info)); | |
| 184 /* Determine whether lossless transformation is perfectly | 172 /* Determine whether lossless transformation is perfectly |
| 185 * possible for a specified image and transformation. | 173 * possible for a specified image and transformation. |
| 186 */ | 174 */ |
| 187 EXTERN(boolean) jtransform_perfect_transform | 175 EXTERN(boolean) jtransform_perfect_transform |
| 188 » JPP((JDIMENSION image_width, JDIMENSION image_height, | 176 (JDIMENSION image_width, JDIMENSION image_height, int MCU_width, |
| 189 » int MCU_width, int MCU_height, | 177 int MCU_height, JXFORM_CODE transform); |
| 190 » JXFORM_CODE transform)); | |
| 191 | 178 |
| 192 /* jtransform_execute_transform used to be called | 179 /* jtransform_execute_transform used to be called |
| 193 * jtransform_execute_transformation, but some compilers complain about | 180 * jtransform_execute_transformation, but some compilers complain about |
| 194 * routine names that long. This macro is here to avoid breaking any | 181 * routine names that long. This macro is here to avoid breaking any |
| 195 * old source code that uses the original name... | 182 * old source code that uses the original name... |
| 196 */ | 183 */ |
| 197 #define jtransform_execute_transformation» jtransform_execute_transform | 184 #define jtransform_execute_transformation jtransform_execute_transform |
| 198 | 185 |
| 199 #endif /* TRANSFORMS_SUPPORTED */ | 186 #endif /* TRANSFORMS_SUPPORTED */ |
| 200 | 187 |
| 201 | 188 |
| 202 /* | 189 /* |
| 203 * Support for copying optional markers from source to destination file. | 190 * Support for copying optional markers from source to destination file. |
| 204 */ | 191 */ |
| 205 | 192 |
| 206 typedef enum { | 193 typedef enum { |
| 207 » JCOPYOPT_NONE,» » /* copy no optional markers */ | 194 JCOPYOPT_NONE, /* copy no optional markers */ |
| 208 » JCOPYOPT_COMMENTS,» /* copy only comment (COM) markers */ | 195 JCOPYOPT_COMMENTS, /* copy only comment (COM) markers */ |
| 209 » JCOPYOPT_ALL» » /* copy all optional markers */ | 196 JCOPYOPT_ALL /* copy all optional markers */ |
| 210 } JCOPY_OPTION; | 197 } JCOPY_OPTION; |
| 211 | 198 |
| 212 #define JCOPYOPT_DEFAULT JCOPYOPT_COMMENTS» /* recommended default */ | 199 #define JCOPYOPT_DEFAULT JCOPYOPT_COMMENTS /* recommended default */ |
| 213 | 200 |
| 214 /* Setup decompression object to save desired markers in memory */ | 201 /* Setup decompression object to save desired markers in memory */ |
| 215 EXTERN(void) jcopy_markers_setup | 202 EXTERN(void) jcopy_markers_setup |
| 216 » JPP((j_decompress_ptr srcinfo, JCOPY_OPTION option)); | 203 (j_decompress_ptr srcinfo, JCOPY_OPTION option); |
| 217 /* Copy markers saved in the given source object to the destination object */ | 204 /* Copy markers saved in the given source object to the destination object */ |
| 218 EXTERN(void) jcopy_markers_execute | 205 EXTERN(void) jcopy_markers_execute |
| 219 » JPP((j_decompress_ptr srcinfo, j_compress_ptr dstinfo, | 206 (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, |
| 220 » JCOPY_OPTION option)); | 207 JCOPY_OPTION option); |
| OLD | NEW |