/* This program is part of the TACLeBench benchmark suite. Version V 2.0 Name: jpeglib Author: Thomas G. Lane Function: This file defines the application interface for the JPEG library. Most applications using the library need only include this file, and perhaps jerror.h if they want to know the exact error codes. Source: MediaBench II http://euler.slu.edu/~fritts/mediabench (mirror) Original name: cjpeg Changes: No major functional changes. License: See the accompanying README file. */ #ifndef JPEGLIB_H #define JPEGLIB_H /* Various constants determining the sizes of things. All of these are specified by the JPEG standard, so don't change them if you want to be compatible. */ /* The basic DCT block is 8x8 samples */ #define DCTSIZE 8 /* DCTSIZE squared; # of elements in a block */ #define DCTSIZE2 64 /* Data structures for images (arrays of samples and of DCT coefficients). On 80x86 machines, the image arrays are too big for near pointers, but the pointer arrays can fit in near memory. */ /* ptr to one image row of pixel samples. */ typedef unsigned char *JSAMPROW; /* ptr to some rows (a 2-D sample array) */ typedef JSAMPROW *JSAMPARRAY; /* one block of coefficients */ typedef signed char JBLOCK[DCTSIZE2]; /* pointer to one row of coefficient blocks */ typedef JBLOCK *JBLOCKROW; /* a 2-D array of coefficient blocks */ typedef JBLOCKROW *JBLOCKARRAY; /* useful in a couple of places */ typedef signed char *JCOEFPTR; /* DCT coefficient quantization tables. */ typedef struct { /* quantization step for each coefficient */ /* This array gives the coefficient quantizers in natural array order (not the zigzag order in which they are stored in a JPEG DQT marker). CAUTION: IJG versions prior to v6a kept this array in zigzag order. */ unsigned short quantval[ DCTSIZE2 ]; /* 1 when table has been output */ /* This field is used only during compression. It's initialized 0 when the table is created, and set 1 when it's been output to the file. You could suppress output of a table by setting this to 1. (See jpeg_suppress_tables for an example.) */ int sent_table; } JQUANT_TBL; /* Huffman coding tables. */ typedef struct { /* These two fields directly represent the contents of a JPEG DHT marker */ /* bits[k] = # of symbols with codes of */ /* length k bits; bits[0] is unused */ unsigned char bits[ 17 ]; /* The symbols, in order of incr code length */ /* This field is used only during compression. It's initialized 0 when the table is created, and set 1 when it's been output to the file. You could suppress output of a table by setting this to 1. (See jpeg_suppress_tables for an example.) */ unsigned char huffval[ 256 ]; /* 1 when table has been output */ int sent_table; } JHUFF_TBL; /* Basic info about one component (color channel). */ typedef struct { /* These values are fixed over the whole image. For compression, they must be supplied by parameter setup; for decompression, they are read from the SOF marker. */ /* identifier for this component (0..255) */ int component_id; /* its index in SOF or cinfo->comp_info[] */ int component_index; /* horizontal sampling factor (1..4) */ int h_samp_factor; /* vertical sampling factor (1..4) */ int v_samp_factor; /* quantization table selector (0..3) */ int quant_tbl_no; /* These values may vary between scans. For compression, they must be supplied by parameter setup; for decompression, they are read from the SOS marker. The decompressor output side may not use these variables. */ /* DC entropy table selector (0..3) */ int dc_tbl_no; /* AC entropy table selector (0..3) */ int ac_tbl_no; /* Remaining fields should be treated as private by applications. */ /* These values are computed during compression or decompression startup: Component's size in DCT blocks. Any dummy blocks added to complete an MCU are not counted; therefore these values do not depend on whether a scan is interleaved or not. */ unsigned int width_in_blocks; unsigned int height_in_blocks; /* Size of a DCT block in samples. Always DCTSIZE for compression. For decompression this is the size of the output from one DCT block, reflecting any scaling we choose to apply during the IDCT step. Values of 1,2,4,8 are likely to be supported. Note that different components may receive different IDCT scalings. */ int DCT_scaled_size; /* The downsampled dimensions are the component's actual, unpadded number of samples at the main buffer (preprocessing/compression interface), thus downsampled_width = ceil(image_width * Hi/Hmax) and similarly for height. For decompression, IDCT scaling is included, so downsampled_width = ceil(image_width * Hi/Hmax * DCT_scaled_size/DCTSIZE) */ /* actual width in samples */ unsigned int downsampled_width; /* actual height in samples */ unsigned int downsampled_height; /* This flag is used only for decompression. In cases where some of the components will be ignored (eg grayscale output from YCbCr image), we can skip most computations for the unused components. */ /* do we need the value of this component? */ int component_needed; /* These values are computed before starting a scan of the component. The decompressor output side may not use these variables. */ /* number of blocks per MCU, horizontally */ int MCU_width; /* number of blocks per MCU, vertically */ int MCU_height; /* MCU_width * MCU_height */ int MCU_blocks; /* MCU width in samples, MCU_width*DCT_scaled_size */ int MCU_sample_width; /* # of non-dummy blocks across in last MCU */ int last_col_width; /* # of non-dummy blocks down in last MCU */ int last_row_height; /* Saved quantization table for component; (void*)0 if none yet saved. See jdinput.c comments about the need for this information. This field is currently used only for decompression. */ JQUANT_TBL *quant_table; /* Private per-component storage for DCT or IDCT subsystem. */ void *dct_table; } jpeg_component_info; /* The script for encoding a multiple-scan file is an array of these: */ typedef struct { /* number of components encoded in this scan */ int comps_in_scan; /* their SOF/comp_info[] indexes */ int component_index[ 4 ]; /* progressive JPEG spectral selection parms */ int Ss, Se; /* progressive JPEG successive approx. parms */ int Ah, Al; } jpeg_scan_info; /* Known color spaces. */ typedef enum { /* error/unspecified */ JCS_UNKNOWN, /* monochrome */ JCS_GRAYSCALE, /* red/green/blue */ JCS_RGB, /* Y/Cb/Cr (also known as YUV) */ JCS_YCbCr, /* C/M/Y/K */ JCS_CMYK, /* Y/Cb/Cr/K */ JCS_YCCK } J_COLOR_SPACE; /* DCT/IDCT algorithm options. */ typedef enum { /* slow but accurate integer algorithm */ JDCT_ISLOW,