/*
 * jdct.h
 *
 * Copyright (C) 1994, Thomas G. Lane.
 * This file is part of the Independent JPEG Group's software.
 * For conditions of distribution and use, see the accompanying README file.
 *
 * This include file contains common declarations for the forward and
 * inverse DCT modules.  These declarations are private to the DCT managers
 * (jcdctmgr.c, jddctmgr.c) and the individual DCT algorithms.
 * The individual DCT algorithms are kept in separate files to ease 
 * machine-dependent tuning (e.g., assembly coding).
 */


/*
 * A forward DCT routine is given a pointer to a work area of type int[];
 * the DCT is to be performed in-place in that buffer.  (May want to change
 * this??)
 * The DCT inputs are expected to be signed (range +-CENTERJSAMPLE).
 * For now, quantization of the output coefficients is done by jcdctmgr.c.
 */

typedef JMETHOD(void, forward_dct_method_ptr, (int * data));

/*
 * An inverse DCT routine is given a pointer to the input JBLOCK and a pointer
 * to an output sample array.  The output data is to be placed into the
 * sample array starting at a specified column.  (Any row offset needed will
 * be applied to the array pointer before it is passed to the IDCT code.)
 * Note that the number of samples emitted by the IDCT routine is
 * DCT_scaled_size * DCT_scaled_size.
 */

/* typedef inverse_DCT_method_ptr is declared in jpegint.h */


/*
 * Each IDCT routine is responsible for range-limiting its results and
 * converting them to unsigned form (0..MAXJSAMPLE).  The raw outputs could
 * be quite far out of range if the input data is corrupt, so a bulletproof
 * range-limiting step is required.  We use a mask-and-table-lookup method
 * to do the combined operations quickly.  See the comments with
 * prepare_range_limit_table (in jdmaster.c) for more info.
 */

#define IDCT_range_limit(cinfo)  ((cinfo)->sample_range_limit + CENTERJSAMPLE)

#define RANGE_MASK  (MAXJSAMPLE * 4 + 3) /* 2 bits wider than legal samples */


/* Short forms of external names for systems with brain-damaged linkers. */

#ifdef NEED_SHORT_EXTERNAL_NAMES
#define jpeg_fdct_llm		jFDllm
#define jpeg_idct_llm		jRDllm
#define jpeg_idct_4x4		jRD4x4
#define jpeg_idct_2x2		jRD2x2
#define jpeg_idct_1x1		jRD1x1
#endif /* NEED_SHORT_EXTERNAL_NAMES */

/* Extern declarations for the forward and inverse DCT routines. */

EXTERN void jpeg_fdct_llm JPP((int * data));

EXTERN void jpeg_idct_llm JPP((j_decompress_ptr cinfo, JCOEFPTR coef_block,
			       JSAMPARRAY output_buf, JDIMENSION output_col));
EXTERN void jpeg_idct_4x4 JPP((j_decompress_ptr cinfo, JCOEFPTR coef_block,
			       JSAMPARRAY output_buf, JDIMENSION output_col));
EXTERN void jpeg_idct_2x2 JPP((j_decompress_ptr cinfo, JCOEFPTR coef_block,
			       JSAMPARRAY output_buf, JDIMENSION output_col));
EXTERN void jpeg_idct_1x1 JPP((j_decompress_ptr cinfo, JCOEFPTR coef_block,
			       JSAMPARRAY output_buf, JDIMENSION output_col));
