Fixed binary search: no more infinite loops when vendor is unknown.
[tangerine.git] / compiler / libjpeg / test / transupp.h
blobd186545d71bf905de28a7a0a5b5bf562a064e30a
1 /*
2 $Id$
3 */
5 /*
6 * transupp.h
8 * Copyright (C) 1997, Thomas G. Lane.
9 * This file is part of the Independent JPEG Group's software.
10 * For conditions of distribution and use, see the accompanying README file.
12 * This file contains declarations for image transformation routines and
13 * other utility code used by the jpegtran sample application. These are
14 * NOT part of the core JPEG library. But we keep these routines separate
15 * from jpegtran.c to ease the task of maintaining jpegtran-like programs
16 * that have other user interfaces.
18 * NOTE: all the routines declared here have very specific requirements
19 * about when they are to be executed during the reading and writing of the
20 * source and destination files. See the comments in transupp.c, or see
21 * jpegtran.c for an example of correct usage.
24 /* If you happen not to want the image transform support, disable it here */
25 #ifndef TRANSFORMS_SUPPORTED
26 #define TRANSFORMS_SUPPORTED 1 /* 0 disables transform code */
27 #endif
29 /* Short forms of external names for systems with brain-damaged linkers. */
31 #ifdef NEED_SHORT_EXTERNAL_NAMES
32 #define jtransform_request_workspace jTrRequest
33 #define jtransform_adjust_parameters jTrAdjust
34 #define jtransform_execute_transformation jTrExec
35 #define jcopy_markers_setup jCMrkSetup
36 #define jcopy_markers_execute jCMrkExec
37 #endif /* NEED_SHORT_EXTERNAL_NAMES */
41 * Codes for supported types of image transformations.
44 typedef enum {
45 JXFORM_NONE, /* no transformation */
46 JXFORM_FLIP_H, /* horizontal flip */
47 JXFORM_FLIP_V, /* vertical flip */
48 JXFORM_TRANSPOSE, /* transpose across UL-to-LR axis */
49 JXFORM_TRANSVERSE, /* transpose across UR-to-LL axis */
50 JXFORM_ROT_90, /* 90-degree clockwise rotation */
51 JXFORM_ROT_180, /* 180-degree rotation */
52 JXFORM_ROT_270 /* 270-degree clockwise (or 90 ccw) */
53 } JXFORM_CODE;
56 * Although rotating and flipping data expressed as DCT coefficients is not
57 * hard, there is an asymmetry in the JPEG format specification for images
58 * whose dimensions aren't multiples of the iMCU size. The right and bottom
59 * image edges are padded out to the next iMCU boundary with junk data; but
60 * no padding is possible at the top and left edges. If we were to flip
61 * the whole image including the pad data, then pad garbage would become
62 * visible at the top and/or left, and real pixels would disappear into the
63 * pad margins --- perhaps permanently, since encoders & decoders may not
64 * bother to preserve DCT blocks that appear to be completely outside the
65 * nominal image area. So, we have to exclude any partial iMCUs from the
66 * basic transformation.
68 * Transpose is the only transformation that can handle partial iMCUs at the
69 * right and bottom edges completely cleanly. flip_h can flip partial iMCUs
70 * at the bottom, but leaves any partial iMCUs at the right edge untouched.
71 * Similarly flip_v leaves any partial iMCUs at the bottom edge untouched.
72 * The other transforms are defined as combinations of these basic transforms
73 * and process edge blocks in a way that preserves the equivalence.
75 * The "trim" option causes untransformable partial iMCUs to be dropped;
76 * this is not strictly lossless, but it usually gives the best-looking
77 * result for odd-size images. Note that when this option is active,
78 * the expected mathematical equivalences between the transforms may not hold.
79 * (For example, -rot 270 -trim trims only the bottom edge, but -rot 90 -trim
80 * followed by -rot 180 -trim trims both edges.)
82 * We also offer a "force to grayscale" option, which simply discards the
83 * chrominance channels of a YCbCr image. This is lossless in the sense that
84 * the luminance channel is preserved exactly. It's not the same kind of
85 * thing as the rotate/flip transformations, but it's convenient to handle it
86 * as part of this package, mainly because the transformation routines have to
87 * be aware of the option to know how many components to work on.
90 typedef struct {
91 /* Options: set by caller */
92 JXFORM_CODE transform; /* image transform operator */
93 boolean trim; /* if TRUE, trim partial MCUs as needed */
94 boolean force_grayscale; /* if TRUE, convert color image to grayscale */
96 /* Internal workspace: caller should not touch these */
97 int num_components; /* # of components in workspace */
98 jvirt_barray_ptr * workspace_coef_arrays; /* workspace for transformations */
99 } jpeg_transform_info;
102 #if TRANSFORMS_SUPPORTED
104 /* Request any required workspace */
105 JEXTERN(void) jtransform_request_workspace
106 JPP((j_decompress_ptr srcinfo, jpeg_transform_info *info));
107 /* Adjust output image parameters */
108 JEXTERN(jvirt_barray_ptr *) jtransform_adjust_parameters
109 JPP((j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
110 jvirt_barray_ptr *src_coef_arrays,
111 jpeg_transform_info *info));
112 /* Execute the actual transformation, if any */
113 JEXTERN(void) jtransform_execute_transformation
114 JPP((j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
115 jvirt_barray_ptr *src_coef_arrays,
116 jpeg_transform_info *info));
118 #endif /* TRANSFORMS_SUPPORTED */
122 * Support for copying optional markers from source to destination file.
125 typedef enum {
126 JCOPYOPT_NONE, /* copy no optional markers */
127 JCOPYOPT_COMMENTS, /* copy only comment (COM) markers */
128 JCOPYOPT_ALL /* copy all optional markers */
129 } JCOPY_OPTION;
131 #define JCOPYOPT_DEFAULT JCOPYOPT_COMMENTS /* recommended default */
133 /* Setup decompression object to save desired markers in memory */
134 JEXTERN(void) jcopy_markers_setup
135 JPP((j_decompress_ptr srcinfo, JCOPY_OPTION option));
136 /* Copy markers saved in the given source object to the destination object */
137 JEXTERN(void) jcopy_markers_execute
138 JPP((j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
139 JCOPY_OPTION option));