Blame gtkmm-osx/jpeg-6b/transupp.h

Carlos Lopez a09598
/*
Carlos Lopez a09598
 * transupp.h
Carlos Lopez a09598
 *
Carlos Lopez a09598
 * Copyright (C) 1997, Thomas G. Lane.
Carlos Lopez a09598
 * This file is part of the Independent JPEG Group's software.
Carlos Lopez a09598
 * For conditions of distribution and use, see the accompanying README file.
Carlos Lopez a09598
 *
Carlos Lopez a09598
 * This file contains declarations for image transformation routines and
Carlos Lopez a09598
 * other utility code used by the jpegtran sample application.  These are
Carlos Lopez a09598
 * NOT part of the core JPEG library.  But we keep these routines separate
Carlos Lopez a09598
 * from jpegtran.c to ease the task of maintaining jpegtran-like programs
Carlos Lopez a09598
 * that have other user interfaces.
Carlos Lopez a09598
 *
Carlos Lopez a09598
 * NOTE: all the routines declared here have very specific requirements
Carlos Lopez a09598
 * about when they are to be executed during the reading and writing of the
Carlos Lopez a09598
 * source and destination files.  See the comments in transupp.c, or see
Carlos Lopez a09598
 * jpegtran.c for an example of correct usage.
Carlos Lopez a09598
 */
Carlos Lopez a09598
Carlos Lopez a09598
/* If you happen not to want the image transform support, disable it here */
Carlos Lopez a09598
#ifndef TRANSFORMS_SUPPORTED
Carlos Lopez a09598
#define TRANSFORMS_SUPPORTED 1		/* 0 disables transform code */
Carlos Lopez a09598
#endif
Carlos Lopez a09598
Carlos Lopez a09598
/* Short forms of external names for systems with brain-damaged linkers. */
Carlos Lopez a09598
Carlos Lopez a09598
#ifdef NEED_SHORT_EXTERNAL_NAMES
Carlos Lopez a09598
#define jtransform_request_workspace		jTrRequest
Carlos Lopez a09598
#define jtransform_adjust_parameters		jTrAdjust
Carlos Lopez a09598
#define jtransform_execute_transformation	jTrExec
Carlos Lopez a09598
#define jcopy_markers_setup			jCMrkSetup
Carlos Lopez a09598
#define jcopy_markers_execute			jCMrkExec
Carlos Lopez a09598
#endif /* NEED_SHORT_EXTERNAL_NAMES */
Carlos Lopez a09598
Carlos Lopez a09598
Carlos Lopez a09598
/*
Carlos Lopez a09598
 * Codes for supported types of image transformations.
Carlos Lopez a09598
 */
Carlos Lopez a09598
Carlos Lopez a09598
typedef enum {
Carlos Lopez a09598
	JXFORM_NONE,		/* no transformation */
Carlos Lopez a09598
	JXFORM_FLIP_H,		/* horizontal flip */
Carlos Lopez a09598
	JXFORM_FLIP_V,		/* vertical flip */
Carlos Lopez a09598
	JXFORM_TRANSPOSE,	/* transpose across UL-to-LR axis */
Carlos Lopez a09598
	JXFORM_TRANSVERSE,	/* transpose across UR-to-LL axis */
Carlos Lopez a09598
	JXFORM_ROT_90,		/* 90-degree clockwise rotation */
Carlos Lopez a09598
	JXFORM_ROT_180,		/* 180-degree rotation */
Carlos Lopez a09598
	JXFORM_ROT_270		/* 270-degree clockwise (or 90 ccw) */
Carlos Lopez a09598
} JXFORM_CODE;
Carlos Lopez a09598
Carlos Lopez a09598
/*
Carlos Lopez a09598
 * Although rotating and flipping data expressed as DCT coefficients is not
Carlos Lopez a09598
 * hard, there is an asymmetry in the JPEG format specification for images
Carlos Lopez a09598
 * whose dimensions aren't multiples of the iMCU size.  The right and bottom
Carlos Lopez a09598
 * image edges are padded out to the next iMCU boundary with junk data; but
Carlos Lopez a09598
 * no padding is possible at the top and left edges.  If we were to flip
Carlos Lopez a09598
 * the whole image including the pad data, then pad garbage would become
Carlos Lopez a09598
 * visible at the top and/or left, and real pixels would disappear into the
Carlos Lopez a09598
 * pad margins --- perhaps permanently, since encoders & decoders may not
Carlos Lopez a09598
 * bother to preserve DCT blocks that appear to be completely outside the
Carlos Lopez a09598
 * nominal image area.  So, we have to exclude any partial iMCUs from the
Carlos Lopez a09598
 * basic transformation.
Carlos Lopez a09598
 *
Carlos Lopez a09598
 * Transpose is the only transformation that can handle partial iMCUs at the
Carlos Lopez a09598
 * right and bottom edges completely cleanly.  flip_h can flip partial iMCUs
Carlos Lopez a09598
 * at the bottom, but leaves any partial iMCUs at the right edge untouched.
Carlos Lopez a09598
 * Similarly flip_v leaves any partial iMCUs at the bottom edge untouched.
Carlos Lopez a09598
 * The other transforms are defined as combinations of these basic transforms
Carlos Lopez a09598
 * and process edge blocks in a way that preserves the equivalence.
Carlos Lopez a09598
 *
Carlos Lopez a09598
 * The "trim" option causes untransformable partial iMCUs to be dropped;
Carlos Lopez a09598
 * this is not strictly lossless, but it usually gives the best-looking
Carlos Lopez a09598
 * result for odd-size images.  Note that when this option is active,
Carlos Lopez a09598
 * the expected mathematical equivalences between the transforms may not hold.
Carlos Lopez a09598
 * (For example, -rot 270 -trim trims only the bottom edge, but -rot 90 -trim
Carlos Lopez a09598
 * followed by -rot 180 -trim trims both edges.)
Carlos Lopez a09598
 *
Carlos Lopez a09598
 * We also offer a "force to grayscale" option, which simply discards the
Carlos Lopez a09598
 * chrominance channels of a YCbCr image.  This is lossless in the sense that
Carlos Lopez a09598
 * the luminance channel is preserved exactly.  It's not the same kind of
Carlos Lopez a09598
 * thing as the rotate/flip transformations, but it's convenient to handle it
Carlos Lopez a09598
 * as part of this package, mainly because the transformation routines have to
Carlos Lopez a09598
 * be aware of the option to know how many components to work on.
Carlos Lopez a09598
 */
Carlos Lopez a09598
Carlos Lopez a09598
typedef struct {
Carlos Lopez a09598
  /* Options: set by caller */
Carlos Lopez a09598
  JXFORM_CODE transform;	/* image transform operator */
Carlos Lopez a09598
  boolean trim;			/* if TRUE, trim partial MCUs as needed */
Carlos Lopez a09598
  boolean force_grayscale;	/* if TRUE, convert color image to grayscale */
Carlos Lopez a09598
Carlos Lopez a09598
  /* Internal workspace: caller should not touch these */
Carlos Lopez a09598
  int num_components;		/* # of components in workspace */
Carlos Lopez a09598
  jvirt_barray_ptr * workspace_coef_arrays; /* workspace for transformations */
Carlos Lopez a09598
} jpeg_transform_info;
Carlos Lopez a09598
Carlos Lopez a09598
Carlos Lopez a09598
#if TRANSFORMS_SUPPORTED
Carlos Lopez a09598
Carlos Lopez a09598
/* Request any required workspace */
Carlos Lopez a09598
EXTERN(void) jtransform_request_workspace
Carlos Lopez a09598
	JPP((j_decompress_ptr srcinfo, jpeg_transform_info *info));
Carlos Lopez a09598
/* Adjust output image parameters */
Carlos Lopez a09598
EXTERN(jvirt_barray_ptr *) jtransform_adjust_parameters
Carlos Lopez a09598
	JPP((j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
Carlos Lopez a09598
	     jvirt_barray_ptr *src_coef_arrays,
Carlos Lopez a09598
	     jpeg_transform_info *info));
Carlos Lopez a09598
/* Execute the actual transformation, if any */
Carlos Lopez a09598
EXTERN(void) jtransform_execute_transformation
Carlos Lopez a09598
	JPP((j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
Carlos Lopez a09598
	     jvirt_barray_ptr *src_coef_arrays,
Carlos Lopez a09598
	     jpeg_transform_info *info));
Carlos Lopez a09598
Carlos Lopez a09598
#endif /* TRANSFORMS_SUPPORTED */
Carlos Lopez a09598
Carlos Lopez a09598
Carlos Lopez a09598
/*
Carlos Lopez a09598
 * Support for copying optional markers from source to destination file.
Carlos Lopez a09598
 */
Carlos Lopez a09598
Carlos Lopez a09598
typedef enum {
Carlos Lopez a09598
	JCOPYOPT_NONE,		/* copy no optional markers */
Carlos Lopez a09598
	JCOPYOPT_COMMENTS,	/* copy only comment (COM) markers */
Carlos Lopez a09598
	JCOPYOPT_ALL		/* copy all optional markers */
Carlos Lopez a09598
} JCOPY_OPTION;
Carlos Lopez a09598
Carlos Lopez a09598
#define JCOPYOPT_DEFAULT  JCOPYOPT_COMMENTS	/* recommended default */
Carlos Lopez a09598
Carlos Lopez a09598
/* Setup decompression object to save desired markers in memory */
Carlos Lopez a09598
EXTERN(void) jcopy_markers_setup
Carlos Lopez a09598
	JPP((j_decompress_ptr srcinfo, JCOPY_OPTION option));
Carlos Lopez a09598
/* Copy markers saved in the given source object to the destination object */
Carlos Lopez a09598
EXTERN(void) jcopy_markers_execute
Carlos Lopez a09598
	JPP((j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
Carlos Lopez a09598
	     JCOPY_OPTION option));