|
shun-iwasawa |
82a8f5 |
/*
|
|
shun-iwasawa |
82a8f5 |
* jpegint.h
|
|
shun-iwasawa |
82a8f5 |
*
|
|
shun-iwasawa |
82a8f5 |
* This file was part of the Independent JPEG Group's software:
|
|
shun-iwasawa |
82a8f5 |
* Copyright (C) 1991-1997, Thomas G. Lane.
|
|
shun-iwasawa |
82a8f5 |
* Modified 1997-2009 by Guido Vollbeding.
|
|
shun-iwasawa |
82a8f5 |
* libjpeg-turbo Modifications:
|
|
shun-iwasawa |
82a8f5 |
* Copyright (C) 2015-2016, D. R. Commander.
|
|
shun-iwasawa |
82a8f5 |
* Copyright (C) 2015, Google, Inc.
|
|
shun-iwasawa |
82a8f5 |
* For conditions of distribution and use, see the accompanying README.ijg
|
|
shun-iwasawa |
82a8f5 |
* file.
|
|
shun-iwasawa |
82a8f5 |
*
|
|
shun-iwasawa |
82a8f5 |
* This file provides common declarations for the various JPEG modules.
|
|
shun-iwasawa |
82a8f5 |
* These declarations are considered internal to the JPEG library; most
|
|
shun-iwasawa |
82a8f5 |
* applications using the library shouldn't need to include this file.
|
|
shun-iwasawa |
82a8f5 |
*/
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
/* Declarations for both compression & decompression */
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
typedef enum { /* Operating modes for buffer controllers */
|
|
shun-iwasawa |
82a8f5 |
JBUF_PASS_THRU, /* Plain stripwise operation */
|
|
shun-iwasawa |
82a8f5 |
/* Remaining modes require a full-image buffer to have been created */
|
|
shun-iwasawa |
82a8f5 |
JBUF_SAVE_SOURCE, /* Run source subobject only, save output */
|
|
shun-iwasawa |
82a8f5 |
JBUF_CRANK_DEST, /* Run dest subobject only, using saved data */
|
|
shun-iwasawa |
82a8f5 |
JBUF_SAVE_AND_PASS /* Run both subobjects, save output */
|
|
shun-iwasawa |
82a8f5 |
} J_BUF_MODE;
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
/* Values of global_state field (jdapi.c has some dependencies on ordering!) */
|
|
shun-iwasawa |
82a8f5 |
#define CSTATE_START 100 /* after create_compress */
|
|
shun-iwasawa |
82a8f5 |
#define CSTATE_SCANNING 101 /* start_compress done, write_scanlines OK */
|
|
shun-iwasawa |
82a8f5 |
#define CSTATE_RAW_OK 102 /* start_compress done, write_raw_data OK */
|
|
shun-iwasawa |
82a8f5 |
#define CSTATE_WRCOEFS 103 /* jpeg_write_coefficients done */
|
|
shun-iwasawa |
82a8f5 |
#define DSTATE_START 200 /* after create_decompress */
|
|
shun-iwasawa |
82a8f5 |
#define DSTATE_INHEADER 201 /* reading header markers, no SOS yet */
|
|
shun-iwasawa |
82a8f5 |
#define DSTATE_READY 202 /* found SOS, ready for start_decompress */
|
|
shun-iwasawa |
82a8f5 |
#define DSTATE_PRELOAD 203 /* reading multiscan file in start_decompress*/
|
|
shun-iwasawa |
82a8f5 |
#define DSTATE_PRESCAN 204 /* performing dummy pass for 2-pass quant */
|
|
shun-iwasawa |
82a8f5 |
#define DSTATE_SCANNING 205 /* start_decompress done, read_scanlines OK */
|
|
shun-iwasawa |
82a8f5 |
#define DSTATE_RAW_OK 206 /* start_decompress done, read_raw_data OK */
|
|
shun-iwasawa |
82a8f5 |
#define DSTATE_BUFIMAGE 207 /* expecting jpeg_start_output */
|
|
shun-iwasawa |
82a8f5 |
#define DSTATE_BUFPOST 208 /* looking for SOS/EOI in jpeg_finish_output */
|
|
shun-iwasawa |
82a8f5 |
#define DSTATE_RDCOEFS 209 /* reading file in jpeg_read_coefficients */
|
|
shun-iwasawa |
82a8f5 |
#define DSTATE_STOPPING 210 /* looking for EOI in jpeg_finish_decompress */
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
/* JLONG must hold at least signed 32-bit values. */
|
|
shun-iwasawa |
82a8f5 |
typedef long JLONG;
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
/*
|
|
shun-iwasawa |
82a8f5 |
* Left shift macro that handles a negative operand without causing any
|
|
shun-iwasawa |
82a8f5 |
* sanitizer warnings
|
|
shun-iwasawa |
82a8f5 |
*/
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
#define LEFT_SHIFT(a, b) ((JLONG)((unsigned long)(a) << (b)))
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
/* Declarations for compression modules */
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
/* Master control module */
|
|
shun-iwasawa |
82a8f5 |
struct jpeg_comp_master {
|
|
shun-iwasawa |
82a8f5 |
void (*prepare_for_pass) (j_compress_ptr cinfo);
|
|
shun-iwasawa |
82a8f5 |
void (*pass_startup) (j_compress_ptr cinfo);
|
|
shun-iwasawa |
82a8f5 |
void (*finish_pass) (j_compress_ptr cinfo);
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
/* State variables made visible to other modules */
|
|
shun-iwasawa |
82a8f5 |
boolean call_pass_startup; /* True if pass_startup must be called */
|
|
shun-iwasawa |
82a8f5 |
boolean is_last_pass; /* True during last pass */
|
|
shun-iwasawa |
82a8f5 |
};
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
/* Main buffer control (downsampled-data buffer) */
|
|
shun-iwasawa |
82a8f5 |
struct jpeg_c_main_controller {
|
|
shun-iwasawa |
82a8f5 |
void (*start_pass) (j_compress_ptr cinfo, J_BUF_MODE pass_mode);
|
|
shun-iwasawa |
82a8f5 |
void (*process_data) (j_compress_ptr cinfo, JSAMPARRAY input_buf,
|
|
shun-iwasawa |
82a8f5 |
JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail);
|
|
shun-iwasawa |
82a8f5 |
};
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
/* Compression preprocessing (downsampling input buffer control) */
|
|
shun-iwasawa |
82a8f5 |
struct jpeg_c_prep_controller {
|
|
shun-iwasawa |
82a8f5 |
void (*start_pass) (j_compress_ptr cinfo, J_BUF_MODE pass_mode);
|
|
shun-iwasawa |
82a8f5 |
void (*pre_process_data) (j_compress_ptr cinfo, JSAMPARRAY input_buf,
|
|
shun-iwasawa |
82a8f5 |
JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail,
|
|
shun-iwasawa |
82a8f5 |
JSAMPIMAGE output_buf,
|
|
shun-iwasawa |
82a8f5 |
JDIMENSION *out_row_group_ctr,
|
|
shun-iwasawa |
82a8f5 |
JDIMENSION out_row_groups_avail);
|
|
shun-iwasawa |
82a8f5 |
};
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
/* Coefficient buffer control */
|
|
shun-iwasawa |
82a8f5 |
struct jpeg_c_coef_controller {
|
|
shun-iwasawa |
82a8f5 |
void (*start_pass) (j_compress_ptr cinfo, J_BUF_MODE pass_mode);
|
|
shun-iwasawa |
82a8f5 |
boolean (*compress_data) (j_compress_ptr cinfo, JSAMPIMAGE input_buf);
|
|
shun-iwasawa |
82a8f5 |
};
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
/* Colorspace conversion */
|
|
shun-iwasawa |
82a8f5 |
struct jpeg_color_converter {
|
|
shun-iwasawa |
82a8f5 |
void (*start_pass) (j_compress_ptr cinfo);
|
|
shun-iwasawa |
82a8f5 |
void (*color_convert) (j_compress_ptr cinfo, JSAMPARRAY input_buf,
|
|
shun-iwasawa |
82a8f5 |
JSAMPIMAGE output_buf, JDIMENSION output_row,
|
|
shun-iwasawa |
82a8f5 |
int num_rows);
|
|
shun-iwasawa |
82a8f5 |
};
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
/* Downsampling */
|
|
shun-iwasawa |
82a8f5 |
struct jpeg_downsampler {
|
|
shun-iwasawa |
82a8f5 |
void (*start_pass) (j_compress_ptr cinfo);
|
|
shun-iwasawa |
82a8f5 |
void (*downsample) (j_compress_ptr cinfo, JSAMPIMAGE input_buf,
|
|
shun-iwasawa |
82a8f5 |
JDIMENSION in_row_index, JSAMPIMAGE output_buf,
|
|
shun-iwasawa |
82a8f5 |
JDIMENSION out_row_group_index);
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
boolean need_context_rows; /* TRUE if need rows above & below */
|
|
shun-iwasawa |
82a8f5 |
};
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
/* Forward DCT (also controls coefficient quantization) */
|
|
shun-iwasawa |
82a8f5 |
struct jpeg_forward_dct {
|
|
shun-iwasawa |
82a8f5 |
void (*start_pass) (j_compress_ptr cinfo);
|
|
shun-iwasawa |
82a8f5 |
/* perhaps this should be an array??? */
|
|
shun-iwasawa |
82a8f5 |
void (*forward_DCT) (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
|
shun-iwasawa |
82a8f5 |
JSAMPARRAY sample_data, JBLOCKROW coef_blocks,
|
|
shun-iwasawa |
82a8f5 |
JDIMENSION start_row, JDIMENSION start_col,
|
|
shun-iwasawa |
82a8f5 |
JDIMENSION num_blocks);
|
|
shun-iwasawa |
82a8f5 |
};
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
/* Entropy encoding */
|
|
shun-iwasawa |
82a8f5 |
struct jpeg_entropy_encoder {
|
|
shun-iwasawa |
82a8f5 |
void (*start_pass) (j_compress_ptr cinfo, boolean gather_statistics);
|
|
shun-iwasawa |
82a8f5 |
boolean (*encode_mcu) (j_compress_ptr cinfo, JBLOCKROW *MCU_data);
|
|
shun-iwasawa |
82a8f5 |
void (*finish_pass) (j_compress_ptr cinfo);
|
|
shun-iwasawa |
82a8f5 |
};
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
/* Marker writing */
|
|
shun-iwasawa |
82a8f5 |
struct jpeg_marker_writer {
|
|
shun-iwasawa |
82a8f5 |
void (*write_file_header) (j_compress_ptr cinfo);
|
|
shun-iwasawa |
82a8f5 |
void (*write_frame_header) (j_compress_ptr cinfo);
|
|
shun-iwasawa |
82a8f5 |
void (*write_scan_header) (j_compress_ptr cinfo);
|
|
shun-iwasawa |
82a8f5 |
void (*write_file_trailer) (j_compress_ptr cinfo);
|
|
shun-iwasawa |
82a8f5 |
void (*write_tables_only) (j_compress_ptr cinfo);
|
|
shun-iwasawa |
82a8f5 |
/* These routines are exported to allow insertion of extra markers */
|
|
shun-iwasawa |
82a8f5 |
/* Probably only COM and APPn markers should be written this way */
|
|
shun-iwasawa |
82a8f5 |
void (*write_marker_header) (j_compress_ptr cinfo, int marker,
|
|
shun-iwasawa |
82a8f5 |
unsigned int datalen);
|
|
shun-iwasawa |
82a8f5 |
void (*write_marker_byte) (j_compress_ptr cinfo, int val);
|
|
shun-iwasawa |
82a8f5 |
};
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
/* Declarations for decompression modules */
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
/* Master control module */
|
|
shun-iwasawa |
82a8f5 |
struct jpeg_decomp_master {
|
|
shun-iwasawa |
82a8f5 |
void (*prepare_for_output_pass) (j_decompress_ptr cinfo);
|
|
shun-iwasawa |
82a8f5 |
void (*finish_output_pass) (j_decompress_ptr cinfo);
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
/* State variables made visible to other modules */
|
|
shun-iwasawa |
82a8f5 |
boolean is_dummy_pass; /* True during 1st pass for 2-pass quant */
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
/* Partial decompression variables */
|
|
shun-iwasawa |
82a8f5 |
JDIMENSION first_iMCU_col;
|
|
shun-iwasawa |
82a8f5 |
JDIMENSION last_iMCU_col;
|
|
shun-iwasawa |
82a8f5 |
JDIMENSION first_MCU_col[MAX_COMPONENTS];
|
|
shun-iwasawa |
82a8f5 |
JDIMENSION last_MCU_col[MAX_COMPONENTS];
|
|
shun-iwasawa |
82a8f5 |
boolean jinit_upsampler_no_alloc;
|
|
shun-iwasawa |
82a8f5 |
};
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
/* Input control module */
|
|
shun-iwasawa |
82a8f5 |
struct jpeg_input_controller {
|
|
shun-iwasawa |
82a8f5 |
int (*consume_input) (j_decompress_ptr cinfo);
|
|
shun-iwasawa |
82a8f5 |
void (*reset_input_controller) (j_decompress_ptr cinfo);
|
|
shun-iwasawa |
82a8f5 |
void (*start_input_pass) (j_decompress_ptr cinfo);
|
|
shun-iwasawa |
82a8f5 |
void (*finish_input_pass) (j_decompress_ptr cinfo);
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
/* State variables made visible to other modules */
|
|
shun-iwasawa |
82a8f5 |
boolean has_multiple_scans; /* True if file has multiple scans */
|
|
shun-iwasawa |
82a8f5 |
boolean eoi_reached; /* True when EOI has been consumed */
|
|
shun-iwasawa |
82a8f5 |
};
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
/* Main buffer control (downsampled-data buffer) */
|
|
shun-iwasawa |
82a8f5 |
struct jpeg_d_main_controller {
|
|
shun-iwasawa |
82a8f5 |
void (*start_pass) (j_decompress_ptr cinfo, J_BUF_MODE pass_mode);
|
|
shun-iwasawa |
82a8f5 |
void (*process_data) (j_decompress_ptr cinfo, JSAMPARRAY output_buf,
|
|
shun-iwasawa |
82a8f5 |
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail);
|
|
shun-iwasawa |
82a8f5 |
};
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
/* Coefficient buffer control */
|
|
shun-iwasawa |
82a8f5 |
struct jpeg_d_coef_controller {
|
|
shun-iwasawa |
82a8f5 |
void (*start_input_pass) (j_decompress_ptr cinfo);
|
|
shun-iwasawa |
82a8f5 |
int (*consume_data) (j_decompress_ptr cinfo);
|
|
shun-iwasawa |
82a8f5 |
void (*start_output_pass) (j_decompress_ptr cinfo);
|
|
shun-iwasawa |
82a8f5 |
int (*decompress_data) (j_decompress_ptr cinfo, JSAMPIMAGE output_buf);
|
|
shun-iwasawa |
82a8f5 |
/* Pointer to array of coefficient virtual arrays, or NULL if none */
|
|
shun-iwasawa |
82a8f5 |
jvirt_barray_ptr *coef_arrays;
|
|
shun-iwasawa |
82a8f5 |
};
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
/* Decompression postprocessing (color quantization buffer control) */
|
|
shun-iwasawa |
82a8f5 |
struct jpeg_d_post_controller {
|
|
shun-iwasawa |
82a8f5 |
void (*start_pass) (j_decompress_ptr cinfo, J_BUF_MODE pass_mode);
|
|
shun-iwasawa |
82a8f5 |
void (*post_process_data) (j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
|
shun-iwasawa |
82a8f5 |
JDIMENSION *in_row_group_ctr,
|
|
shun-iwasawa |
82a8f5 |
JDIMENSION in_row_groups_avail,
|
|
shun-iwasawa |
82a8f5 |
JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
|
|
shun-iwasawa |
82a8f5 |
JDIMENSION out_rows_avail);
|
|
shun-iwasawa |
82a8f5 |
};
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
/* Marker reading & parsing */
|
|
shun-iwasawa |
82a8f5 |
struct jpeg_marker_reader {
|
|
shun-iwasawa |
82a8f5 |
void (*reset_marker_reader) (j_decompress_ptr cinfo);
|
|
shun-iwasawa |
82a8f5 |
/* Read markers until SOS or EOI.
|
|
shun-iwasawa |
82a8f5 |
* Returns same codes as are defined for jpeg_consume_input:
|
|
shun-iwasawa |
82a8f5 |
* JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI.
|
|
shun-iwasawa |
82a8f5 |
*/
|
|
shun-iwasawa |
82a8f5 |
int (*read_markers) (j_decompress_ptr cinfo);
|
|
shun-iwasawa |
82a8f5 |
/* Read a restart marker --- exported for use by entropy decoder only */
|
|
shun-iwasawa |
82a8f5 |
jpeg_marker_parser_method read_restart_marker;
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
/* State of marker reader --- nominally internal, but applications
|
|
shun-iwasawa |
82a8f5 |
* supplying COM or APPn handlers might like to know the state.
|
|
shun-iwasawa |
82a8f5 |
*/
|
|
shun-iwasawa |
82a8f5 |
boolean saw_SOI; /* found SOI? */
|
|
shun-iwasawa |
82a8f5 |
boolean saw_SOF; /* found SOF? */
|
|
shun-iwasawa |
82a8f5 |
int next_restart_num; /* next restart number expected (0-7) */
|
|
shun-iwasawa |
82a8f5 |
unsigned int discarded_bytes; /* # of bytes skipped looking for a marker */
|
|
shun-iwasawa |
82a8f5 |
};
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
/* Entropy decoding */
|
|
shun-iwasawa |
82a8f5 |
struct jpeg_entropy_decoder {
|
|
shun-iwasawa |
82a8f5 |
void (*start_pass) (j_decompress_ptr cinfo);
|
|
shun-iwasawa |
82a8f5 |
boolean (*decode_mcu) (j_decompress_ptr cinfo, JBLOCKROW *MCU_data);
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
/* This is here to share code between baseline and progressive decoders; */
|
|
shun-iwasawa |
82a8f5 |
/* other modules probably should not use it */
|
|
shun-iwasawa |
82a8f5 |
boolean insufficient_data; /* set TRUE after emitting warning */
|
|
shun-iwasawa |
82a8f5 |
};
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
/* Inverse DCT (also performs dequantization) */
|
|
shun-iwasawa |
82a8f5 |
typedef void (*inverse_DCT_method_ptr) (j_decompress_ptr cinfo,
|
|
shun-iwasawa |
82a8f5 |
jpeg_component_info *compptr,
|
|
shun-iwasawa |
82a8f5 |
JCOEFPTR coef_block,
|
|
shun-iwasawa |
82a8f5 |
JSAMPARRAY output_buf,
|
|
shun-iwasawa |
82a8f5 |
JDIMENSION output_col);
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
struct jpeg_inverse_dct {
|
|
shun-iwasawa |
82a8f5 |
void (*start_pass) (j_decompress_ptr cinfo);
|
|
shun-iwasawa |
82a8f5 |
/* It is useful to allow each component to have a separate IDCT method. */
|
|
shun-iwasawa |
82a8f5 |
inverse_DCT_method_ptr inverse_DCT[MAX_COMPONENTS];
|
|
shun-iwasawa |
82a8f5 |
};
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
/* Upsampling (note that upsampler must also call color converter) */
|
|
shun-iwasawa |
82a8f5 |
struct jpeg_upsampler {
|
|
shun-iwasawa |
82a8f5 |
void (*start_pass) (j_decompress_ptr cinfo);
|
|
shun-iwasawa |
82a8f5 |
void (*upsample) (j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
|
shun-iwasawa |
82a8f5 |
JDIMENSION *in_row_group_ctr,
|
|
shun-iwasawa |
82a8f5 |
JDIMENSION in_row_groups_avail, JSAMPARRAY output_buf,
|
|
shun-iwasawa |
82a8f5 |
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail);
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
boolean need_context_rows; /* TRUE if need rows above & below */
|
|
shun-iwasawa |
82a8f5 |
};
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
/* Colorspace conversion */
|
|
shun-iwasawa |
82a8f5 |
struct jpeg_color_deconverter {
|
|
shun-iwasawa |
82a8f5 |
void (*start_pass) (j_decompress_ptr cinfo);
|
|
shun-iwasawa |
82a8f5 |
void (*color_convert) (j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
|
shun-iwasawa |
82a8f5 |
JDIMENSION input_row, JSAMPARRAY output_buf,
|
|
shun-iwasawa |
82a8f5 |
int num_rows);
|
|
shun-iwasawa |
82a8f5 |
};
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
/* Color quantization or color precision reduction */
|
|
shun-iwasawa |
82a8f5 |
struct jpeg_color_quantizer {
|
|
shun-iwasawa |
82a8f5 |
void (*start_pass) (j_decompress_ptr cinfo, boolean is_pre_scan);
|
|
shun-iwasawa |
82a8f5 |
void (*color_quantize) (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
|
shun-iwasawa |
82a8f5 |
JSAMPARRAY output_buf, int num_rows);
|
|
shun-iwasawa |
82a8f5 |
void (*finish_pass) (j_decompress_ptr cinfo);
|
|
shun-iwasawa |
82a8f5 |
void (*new_color_map) (j_decompress_ptr cinfo);
|
|
shun-iwasawa |
82a8f5 |
};
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
/* Miscellaneous useful macros */
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
#undef MAX
|
|
shun-iwasawa |
82a8f5 |
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
|
shun-iwasawa |
82a8f5 |
#undef MIN
|
|
shun-iwasawa |
82a8f5 |
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
/* We assume that right shift corresponds to signed division by 2 with
|
|
shun-iwasawa |
82a8f5 |
* rounding towards minus infinity. This is correct for typical "arithmetic
|
|
shun-iwasawa |
82a8f5 |
* shift" instructions that shift in copies of the sign bit. But some
|
|
shun-iwasawa |
82a8f5 |
* C compilers implement >> with an unsigned shift. For these machines you
|
|
shun-iwasawa |
82a8f5 |
* must define RIGHT_SHIFT_IS_UNSIGNED.
|
|
shun-iwasawa |
82a8f5 |
* RIGHT_SHIFT provides a proper signed right shift of a JLONG quantity.
|
|
shun-iwasawa |
82a8f5 |
* It is only applied with constant shift counts. SHIFT_TEMPS must be
|
|
shun-iwasawa |
82a8f5 |
* included in the variables of any routine using RIGHT_SHIFT.
|
|
shun-iwasawa |
82a8f5 |
*/
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
#ifdef RIGHT_SHIFT_IS_UNSIGNED
|
|
shun-iwasawa |
82a8f5 |
#define SHIFT_TEMPS JLONG shift_temp;
|
|
shun-iwasawa |
82a8f5 |
#define RIGHT_SHIFT(x, shft) \
|
|
shun-iwasawa |
82a8f5 |
((shift_temp = (x)) < 0 ? \
|
|
shun-iwasawa |
82a8f5 |
(shift_temp >> (shft)) | ((~((JLONG)0)) << (32 - (shft))) : \
|
|
shun-iwasawa |
82a8f5 |
(shift_temp >> (shft)))
|
|
shun-iwasawa |
82a8f5 |
#else
|
|
shun-iwasawa |
82a8f5 |
#define SHIFT_TEMPS
|
|
shun-iwasawa |
82a8f5 |
#define RIGHT_SHIFT(x, shft) ((x) >> (shft))
|
|
shun-iwasawa |
82a8f5 |
#endif
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
/* Compression module initialization routines */
|
|
shun-iwasawa |
82a8f5 |
EXTERN(void) jinit_compress_master(j_compress_ptr cinfo);
|
|
shun-iwasawa |
82a8f5 |
EXTERN(void) jinit_c_master_control(j_compress_ptr cinfo,
|
|
shun-iwasawa |
82a8f5 |
boolean transcode_only);
|
|
shun-iwasawa |
82a8f5 |
EXTERN(void) jinit_c_main_controller(j_compress_ptr cinfo,
|
|
shun-iwasawa |
82a8f5 |
boolean need_full_buffer);
|
|
shun-iwasawa |
82a8f5 |
EXTERN(void) jinit_c_prep_controller(j_compress_ptr cinfo,
|
|
shun-iwasawa |
82a8f5 |
boolean need_full_buffer);
|
|
shun-iwasawa |
82a8f5 |
EXTERN(void) jinit_c_coef_controller(j_compress_ptr cinfo,
|
|
shun-iwasawa |
82a8f5 |
boolean need_full_buffer);
|
|
shun-iwasawa |
82a8f5 |
EXTERN(void) jinit_color_converter(j_compress_ptr cinfo);
|
|
shun-iwasawa |
82a8f5 |
EXTERN(void) jinit_downsampler(j_compress_ptr cinfo);
|
|
shun-iwasawa |
82a8f5 |
EXTERN(void) jinit_forward_dct(j_compress_ptr cinfo);
|
|
shun-iwasawa |
82a8f5 |
EXTERN(void) jinit_huff_encoder(j_compress_ptr cinfo);
|
|
shun-iwasawa |
82a8f5 |
EXTERN(void) jinit_phuff_encoder(j_compress_ptr cinfo);
|
|
shun-iwasawa |
82a8f5 |
EXTERN(void) jinit_arith_encoder(j_compress_ptr cinfo);
|
|
shun-iwasawa |
82a8f5 |
EXTERN(void) jinit_marker_writer(j_compress_ptr cinfo);
|
|
shun-iwasawa |
82a8f5 |
/* Decompression module initialization routines */
|
|
shun-iwasawa |
82a8f5 |
EXTERN(void) jinit_master_decompress(j_decompress_ptr cinfo);
|
|
shun-iwasawa |
82a8f5 |
EXTERN(void) jinit_d_main_controller(j_decompress_ptr cinfo,
|
|
shun-iwasawa |
82a8f5 |
boolean need_full_buffer);
|
|
shun-iwasawa |
82a8f5 |
EXTERN(void) jinit_d_coef_controller(j_decompress_ptr cinfo,
|
|
shun-iwasawa |
82a8f5 |
boolean need_full_buffer);
|
|
shun-iwasawa |
82a8f5 |
EXTERN(void) jinit_d_post_controller(j_decompress_ptr cinfo,
|
|
shun-iwasawa |
82a8f5 |
boolean need_full_buffer);
|
|
shun-iwasawa |
82a8f5 |
EXTERN(void) jinit_input_controller(j_decompress_ptr cinfo);
|
|
shun-iwasawa |
82a8f5 |
EXTERN(void) jinit_marker_reader(j_decompress_ptr cinfo);
|
|
shun-iwasawa |
82a8f5 |
EXTERN(void) jinit_huff_decoder(j_decompress_ptr cinfo);
|
|
shun-iwasawa |
82a8f5 |
EXTERN(void) jinit_phuff_decoder(j_decompress_ptr cinfo);
|
|
shun-iwasawa |
82a8f5 |
EXTERN(void) jinit_arith_decoder(j_decompress_ptr cinfo);
|
|
shun-iwasawa |
82a8f5 |
EXTERN(void) jinit_inverse_dct(j_decompress_ptr cinfo);
|
|
shun-iwasawa |
82a8f5 |
EXTERN(void) jinit_upsampler(j_decompress_ptr cinfo);
|
|
shun-iwasawa |
82a8f5 |
EXTERN(void) jinit_color_deconverter(j_decompress_ptr cinfo);
|
|
shun-iwasawa |
82a8f5 |
EXTERN(void) jinit_1pass_quantizer(j_decompress_ptr cinfo);
|
|
shun-iwasawa |
82a8f5 |
EXTERN(void) jinit_2pass_quantizer(j_decompress_ptr cinfo);
|
|
shun-iwasawa |
82a8f5 |
EXTERN(void) jinit_merged_upsampler(j_decompress_ptr cinfo);
|
|
shun-iwasawa |
82a8f5 |
/* Memory manager initialization */
|
|
shun-iwasawa |
82a8f5 |
EXTERN(void) jinit_memory_mgr(j_common_ptr cinfo);
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
/* Utility routines in jutils.c */
|
|
shun-iwasawa |
82a8f5 |
EXTERN(long) jdiv_round_up(long a, long b);
|
|
shun-iwasawa |
82a8f5 |
EXTERN(long) jround_up(long a, long b);
|
|
shun-iwasawa |
82a8f5 |
EXTERN(void) jcopy_sample_rows(JSAMPARRAY input_array, int source_row,
|
|
shun-iwasawa |
82a8f5 |
JSAMPARRAY output_array, int dest_row,
|
|
shun-iwasawa |
82a8f5 |
int num_rows, JDIMENSION num_cols);
|
|
shun-iwasawa |
82a8f5 |
EXTERN(void) jcopy_block_row(JBLOCKROW input_row, JBLOCKROW output_row,
|
|
shun-iwasawa |
82a8f5 |
JDIMENSION num_blocks);
|
|
shun-iwasawa |
82a8f5 |
EXTERN(void) jzero_far(void *target, size_t bytestozero);
|
|
shun-iwasawa |
82a8f5 |
/* Constant tables in jutils.c */
|
|
shun-iwasawa |
82a8f5 |
#if 0 /* This table is not actually needed in v6a */
|
|
shun-iwasawa |
82a8f5 |
extern const int jpeg_zigzag_order[]; /* natural coef order to zigzag order */
|
|
shun-iwasawa |
82a8f5 |
#endif
|
|
shun-iwasawa |
82a8f5 |
extern const int jpeg_natural_order[]; /* zigzag coef order to natural order */
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
/* Arithmetic coding probability estimation tables in jaricom.c */
|
|
shun-iwasawa |
82a8f5 |
extern const JLONG jpeg_aritab[];
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
/* Suppress undefined-structure complaints if necessary. */
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
#ifdef INCOMPLETE_TYPES_BROKEN
|
|
shun-iwasawa |
82a8f5 |
#ifndef AM_MEMORY_MANAGER /* only jmemmgr.c defines these */
|
|
shun-iwasawa |
82a8f5 |
struct jvirt_sarray_control { long dummy; };
|
|
shun-iwasawa |
82a8f5 |
struct jvirt_barray_control { long dummy; };
|
|
shun-iwasawa |
82a8f5 |
#endif
|
|
shun-iwasawa |
82a8f5 |
#endif /* INCOMPLETE_TYPES_BROKEN */
|