0N/A/*
0N/A * reserved comment block
0N/A * DO NOT REMOVE OR ALTER!
0N/A */
0N/A/*
0N/A * jdct.h
0N/A *
0N/A * Copyright (C) 1994-1996, Thomas G. Lane.
0N/A * This file is part of the Independent JPEG Group's software.
0N/A * For conditions of distribution and use, see the accompanying README file.
0N/A *
0N/A * This include file contains common declarations for the forward and
0N/A * inverse DCT modules. These declarations are private to the DCT managers
0N/A * (jcdctmgr.c, jddctmgr.c) and the individual DCT algorithms.
0N/A * The individual DCT algorithms are kept in separate files to ease
0N/A * machine-dependent tuning (e.g., assembly coding).
0N/A */
0N/A
0N/A
0N/A/*
0N/A * A forward DCT routine is given a pointer to a work area of type DCTELEM[];
0N/A * the DCT is to be performed in-place in that buffer. Type DCTELEM is int
0N/A * for 8-bit samples, INT32 for 12-bit samples. (NOTE: Floating-point DCT
0N/A * implementations use an array of type FAST_FLOAT, instead.)
0N/A * The DCT inputs are expected to be signed (range +-CENTERJSAMPLE).
0N/A * The DCT outputs are returned scaled up by a factor of 8; they therefore
0N/A * have a range of +-8K for 8-bit data, +-128K for 12-bit data. This
0N/A * convention improves accuracy in integer implementations and saves some
0N/A * work in floating-point ones.
0N/A * Quantization of the output coefficients is done by jcdctmgr.c.
0N/A */
0N/A
0N/A#if BITS_IN_JSAMPLE == 8
0N/Atypedef int DCTELEM; /* 16 or 32 bits is fine */
0N/A#else
0N/Atypedef INT32 DCTELEM; /* must have 32 bits */
0N/A#endif
0N/A
0N/Atypedef JMETHOD(void, forward_DCT_method_ptr, (DCTELEM * data));
0N/Atypedef JMETHOD(void, float_DCT_method_ptr, (FAST_FLOAT * data));
0N/A
0N/A
0N/A/*
0N/A * An inverse DCT routine is given a pointer to the input JBLOCK and a pointer
0N/A * to an output sample array. The routine must dequantize the input data as
0N/A * well as perform the IDCT; for dequantization, it uses the multiplier table
0N/A * pointed to by compptr->dct_table. The output data is to be placed into the
0N/A * sample array starting at a specified column. (Any row offset needed will
0N/A * be applied to the array pointer before it is passed to the IDCT code.)
0N/A * Note that the number of samples emitted by the IDCT routine is
0N/A * DCT_scaled_size * DCT_scaled_size.
0N/A */
0N/A
0N/A/* typedef inverse_DCT_method_ptr is declared in jpegint.h */
0N/A
0N/A/*
0N/A * Each IDCT routine has its own ideas about the best dct_table element type.
0N/A */
0N/A
0N/Atypedef MULTIPLIER ISLOW_MULT_TYPE; /* short or int, whichever is faster */
0N/A#if BITS_IN_JSAMPLE == 8
0N/Atypedef MULTIPLIER IFAST_MULT_TYPE; /* 16 bits is OK, use short if faster */
0N/A#define IFAST_SCALE_BITS 2 /* fractional bits in scale factors */
0N/A#else
0N/Atypedef INT32 IFAST_MULT_TYPE; /* need 32 bits for scaled quantizers */
0N/A#define IFAST_SCALE_BITS 13 /* fractional bits in scale factors */
0N/A#endif
0N/Atypedef FAST_FLOAT FLOAT_MULT_TYPE; /* preferred floating type */
0N/A
0N/A
0N/A/*
0N/A * Each IDCT routine is responsible for range-limiting its results and
0N/A * converting them to unsigned form (0..MAXJSAMPLE). The raw outputs could
0N/A * be quite far out of range if the input data is corrupt, so a bulletproof
0N/A * range-limiting step is required. We use a mask-and-table-lookup method
0N/A * to do the combined operations quickly. See the comments with
0N/A * prepare_range_limit_table (in jdmaster.c) for more info.
0N/A */
0N/A
0N/A#define IDCT_range_limit(cinfo) ((cinfo)->sample_range_limit + CENTERJSAMPLE)
0N/A
0N/A#define RANGE_MASK (MAXJSAMPLE * 4 + 3) /* 2 bits wider than legal samples */
0N/A
0N/A
0N/A/* Short forms of external names for systems with brain-damaged linkers. */
0N/A
0N/A#ifdef NEED_SHORT_EXTERNAL_NAMES
0N/A#define jpeg_fdct_islow jFDislow
0N/A#define jpeg_fdct_ifast jFDifast
0N/A#define jpeg_fdct_float jFDfloat
0N/A#define jpeg_idct_islow jRDislow
0N/A#define jpeg_idct_ifast jRDifast
0N/A#define jpeg_idct_float jRDfloat
0N/A#define jpeg_idct_4x4 jRD4x4
0N/A#define jpeg_idct_2x2 jRD2x2
0N/A#define jpeg_idct_1x1 jRD1x1
0N/A#endif /* NEED_SHORT_EXTERNAL_NAMES */
0N/A
0N/A/* Extern declarations for the forward and inverse DCT routines. */
0N/A
0N/AEXTERN(void) jpeg_fdct_islow JPP((DCTELEM * data));
0N/AEXTERN(void) jpeg_fdct_ifast JPP((DCTELEM * data));
0N/AEXTERN(void) jpeg_fdct_float JPP((FAST_FLOAT * data));
0N/A
0N/AEXTERN(void) jpeg_idct_islow
0N/A JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
0N/A JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
0N/AEXTERN(void) jpeg_idct_ifast
0N/A JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
0N/A JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
0N/AEXTERN(void) jpeg_idct_float
0N/A JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
0N/A JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
0N/AEXTERN(void) jpeg_idct_4x4
0N/A JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
0N/A JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
0N/AEXTERN(void) jpeg_idct_2x2
0N/A JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
0N/A JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
0N/AEXTERN(void) jpeg_idct_1x1
0N/A JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
0N/A JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
0N/A
0N/A
0N/A/*
0N/A * Macros for handling fixed-point arithmetic; these are used by many
0N/A * but not all of the DCT/IDCT modules.
0N/A *
0N/A * All values are expected to be of type INT32.
0N/A * Fractional constants are scaled left by CONST_BITS bits.
0N/A * CONST_BITS is defined within each module using these macros,
0N/A * and may differ from one module to the next.
0N/A */
0N/A
0N/A#define ONE ((INT32) 1)
0N/A#define CONST_SCALE (ONE << CONST_BITS)
0N/A
0N/A/* Convert a positive real constant to an integer scaled by CONST_SCALE.
0N/A * Caution: some C compilers fail to reduce "FIX(constant)" at compile time,
0N/A * thus causing a lot of useless floating-point operations at run time.
0N/A */
0N/A
0N/A#define FIX(x) ((INT32) ((x) * CONST_SCALE + 0.5))
0N/A
0N/A/* Descale and correctly round an INT32 value that's scaled by N bits.
0N/A * We assume RIGHT_SHIFT rounds towards minus infinity, so adding
0N/A * the fudge factor is correct for either sign of X.
0N/A */
0N/A
0N/A#define DESCALE(x,n) RIGHT_SHIFT((x) + (ONE << ((n)-1)), n)
0N/A
0N/A/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result.
0N/A * This macro is used only when the two inputs will actually be no more than
0N/A * 16 bits wide, so that a 16x16->32 bit multiply can be used instead of a
0N/A * full 32x32 multiply. This provides a useful speedup on many machines.
0N/A * Unfortunately there is no way to specify a 16x16->32 multiply portably
0N/A * in C, but some C compilers will do the right thing if you provide the
0N/A * correct combination of casts.
0N/A */
0N/A
0N/A#ifdef SHORTxSHORT_32 /* may work if 'int' is 32 bits */
0N/A#define MULTIPLY16C16(var,const) (((INT16) (var)) * ((INT16) (const)))
0N/A#endif
0N/A#ifdef SHORTxLCONST_32 /* known to work with Microsoft C 6.0 */
0N/A#define MULTIPLY16C16(var,const) (((INT16) (var)) * ((INT32) (const)))
0N/A#endif
0N/A
0N/A#ifndef MULTIPLY16C16 /* default definition */
0N/A#define MULTIPLY16C16(var,const) ((var) * (const))
0N/A#endif
0N/A
0N/A/* Same except both inputs are variables. */
0N/A
0N/A#ifdef SHORTxSHORT_32 /* may work if 'int' is 32 bits */
0N/A#define MULTIPLY16V16(var1,var2) (((INT16) (var1)) * ((INT16) (var2)))
0N/A#endif
0N/A
0N/A#ifndef MULTIPLY16V16 /* default definition */
0N/A#define MULTIPLY16V16(var1,var2) ((var1) * (var2))
0N/A#endif