transupp.h
Go to the documentation of this file.
00001 /*
00002  * transupp.h
00003  *
00004  * Copyright (C) 1997, Thomas G. Lane.
00005  * This file is part of the Independent JPEG Group's software.
00006  * For conditions of distribution and use, see the accompanying README file.
00007  *
00008  * This file contains declarations for image transformation routines and
00009  * other utility code used by the jpegtran sample application.  These are
00010  * NOT part of the core JPEG library.  But we keep these routines separate
00011  * from jpegtran.c to ease the task of maintaining jpegtran-like programs
00012  * that have other user interfaces.
00013  *
00014  * NOTE: all the routines declared here have very specific requirements
00015  * about when they are to be executed during the reading and writing of the
00016  * source and destination files.  See the comments in transupp.c, or see
00017  * jpegtran.c for an example of correct usage.
00018  */
00019 
00020 /* If you happen not to want the image transform support, disable it here */
00021 #ifndef TRANSFORMS_SUPPORTED
00022 #define TRANSFORMS_SUPPORTED 1          /* 0 disables transform code */
00023 #endif
00024 
00025 /* Short forms of external names for systems with brain-damaged linkers. */
00026 
00027 #ifdef NEED_SHORT_EXTERNAL_NAMES
00028 #define jtransform_request_workspace            jTrRequest
00029 #define jtransform_adjust_parameters            jTrAdjust
00030 #define jtransform_execute_transformation       jTrExec
00031 #define jcopy_markers_setup                     jCMrkSetup
00032 #define jcopy_markers_execute                   jCMrkExec
00033 #endif /* NEED_SHORT_EXTERNAL_NAMES */
00034 
00035 
00036 /*
00037  * Codes for supported types of image transformations.
00038  */
00039 
00040 typedef enum {
00041         JXFORM_NONE,            /* no transformation */
00042         JXFORM_FLIP_H,          /* horizontal flip */
00043         JXFORM_FLIP_V,          /* vertical flip */
00044         JXFORM_TRANSPOSE,       /* transpose across UL-to-LR axis */
00045         JXFORM_TRANSVERSE,      /* transpose across UR-to-LL axis */
00046         JXFORM_ROT_90,          /* 90-degree clockwise rotation */
00047         JXFORM_ROT_180,         /* 180-degree rotation */
00048         JXFORM_ROT_270          /* 270-degree clockwise (or 90 ccw) */
00049 } JXFORM_CODE;
00050 
00051 /*
00052  * Although rotating and flipping data expressed as DCT coefficients is not
00053  * hard, there is an asymmetry in the JPEG format specification for images
00054  * whose dimensions aren't multiples of the iMCU size.  The right and bottom
00055  * image edges are padded out to the next iMCU boundary with junk data; but
00056  * no padding is possible at the top and left edges.  If we were to flip
00057  * the whole image including the pad data, then pad garbage would become
00058  * visible at the top and/or left, and real pixels would disappear into the
00059  * pad margins --- perhaps permanently, since encoders & decoders may not
00060  * bother to preserve DCT blocks that appear to be completely outside the
00061  * nominal image area.  So, we have to exclude any partial iMCUs from the
00062  * basic transformation.
00063  *
00064  * Transpose is the only transformation that can handle partial iMCUs at the
00065  * right and bottom edges completely cleanly.  flip_h can flip partial iMCUs
00066  * at the bottom, but leaves any partial iMCUs at the right edge untouched.
00067  * Similarly flip_v leaves any partial iMCUs at the bottom edge untouched.
00068  * The other transforms are defined as combinations of these basic transforms
00069  * and process edge blocks in a way that preserves the equivalence.
00070  *
00071  * The "trim" option causes untransformable partial iMCUs to be dropped;
00072  * this is not strictly lossless, but it usually gives the best-looking
00073  * result for odd-size images.  Note that when this option is active,
00074  * the expected mathematical equivalences between the transforms may not hold.
00075  * (For example, -rot 270 -trim trims only the bottom edge, but -rot 90 -trim
00076  * followed by -rot 180 -trim trims both edges.)
00077  *
00078  * We also offer a "force to grayscale" option, which simply discards the
00079  * chrominance channels of a YCbCr image.  This is lossless in the sense that
00080  * the luminance channel is preserved exactly.  It's not the same kind of
00081  * thing as the rotate/flip transformations, but it's convenient to handle it
00082  * as part of this package, mainly because the transformation routines have to
00083  * be aware of the option to know how many components to work on.
00084  */
00085 
00086 typedef struct {
00087   /* Options: set by caller */
00088   JXFORM_CODE transform;        /* image transform operator */
00089   boolean trim;                 /* if TRUE, trim partial MCUs as needed */
00090   boolean force_grayscale;      /* if TRUE, convert color image to grayscale */
00091 
00092   /* Internal workspace: caller should not touch these */
00093   int num_components;           /* # of components in workspace */
00094   jvirt_barray_ptr * workspace_coef_arrays; /* workspace for transformations */
00095 } jpeg_transform_info;
00096 
00097 
00098 #if TRANSFORMS_SUPPORTED
00099 
00100 /* Request any required workspace */
00101 EXTERN(void) jtransform_request_workspace
00102         JPP((j_decompress_ptr srcinfo, jpeg_transform_info *info));
00103 /* Adjust output image parameters */
00104 EXTERN(jvirt_barray_ptr *) jtransform_adjust_parameters
00105         JPP((j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
00106              jvirt_barray_ptr *src_coef_arrays,
00107              jpeg_transform_info *info));
00108 /* Execute the actual transformation, if any */
00109 EXTERN(void) jtransform_execute_transformation
00110         JPP((j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
00111              jvirt_barray_ptr *src_coef_arrays,
00112              jpeg_transform_info *info));
00113 
00114 #endif /* TRANSFORMS_SUPPORTED */
00115 
00116 
00117 /*
00118  * Support for copying optional markers from source to destination file.
00119  */
00120 
00121 typedef enum {
00122         JCOPYOPT_NONE,          /* copy no optional markers */
00123         JCOPYOPT_COMMENTS,      /* copy only comment (COM) markers */
00124         JCOPYOPT_ALL            /* copy all optional markers */
00125 } JCOPY_OPTION;
00126 
00127 #define JCOPYOPT_DEFAULT  JCOPYOPT_COMMENTS     /* recommended default */
00128 
00129 /* Setup decompression object to save desired markers in memory */
00130 EXTERN(void) jcopy_markers_setup
00131         JPP((j_decompress_ptr srcinfo, JCOPY_OPTION option));
00132 /* Copy markers saved in the given source object to the destination object */
00133 EXTERN(void) jcopy_markers_execute
00134         JPP((j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
00135              JCOPY_OPTION option));


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Thu Apr 11 2019 03:30:19