170a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine/*
270a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine * jpegint.h
370a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine *
470a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine * Copyright (C) 1991-1997, Thomas G. Lane.
570a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine * This file is part of the Independent JPEG Group's software.
670a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine * For conditions of distribution and use, see the accompanying README file.
770a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine *
870a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine * This file provides common declarations for the various JPEG modules.
970a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine * These declarations are considered internal to the JPEG library; most
1070a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine * applications using the library shouldn't need to include this file.
1170a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine */
1270a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
1370a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
1470a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine/* Declarations for both compression & decompression */
1570a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
1670a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkinetypedef enum {			/* Operating modes for buffer controllers */
1770a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine	JBUF_PASS_THRU,		/* Plain stripwise operation */
1870a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine	/* Remaining modes require a full-image buffer to have been created */
1970a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine	JBUF_SAVE_SOURCE,	/* Run source subobject only, save output */
2070a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine	JBUF_CRANK_DEST,	/* Run dest subobject only, using saved data */
2170a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine	JBUF_SAVE_AND_PASS	/* Run both subobjects, save output */
2270a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine} J_BUF_MODE;
2370a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
2470a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine/* Values of global_state field (jdapi.c has some dependencies on ordering!) */
2570a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define CSTATE_START	100	/* after create_compress */
2670a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define CSTATE_SCANNING	101	/* start_compress done, write_scanlines OK */
2770a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define CSTATE_RAW_OK	102	/* start_compress done, write_raw_data OK */
2870a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define CSTATE_WRCOEFS	103	/* jpeg_write_coefficients done */
2970a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define DSTATE_START	200	/* after create_decompress */
3070a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define DSTATE_INHEADER	201	/* reading header markers, no SOS yet */
3170a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define DSTATE_READY	202	/* found SOS, ready for start_decompress */
3270a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define DSTATE_PRELOAD	203	/* reading multiscan file in start_decompress*/
3370a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define DSTATE_PRESCAN	204	/* performing dummy pass for 2-pass quant */
3470a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define DSTATE_SCANNING	205	/* start_decompress done, read_scanlines OK */
3570a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define DSTATE_RAW_OK	206	/* start_decompress done, read_raw_data OK */
3670a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define DSTATE_BUFIMAGE	207	/* expecting jpeg_start_output */
3770a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define DSTATE_BUFPOST	208	/* looking for SOS/EOI in jpeg_finish_output */
3870a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define DSTATE_RDCOEFS	209	/* reading file in jpeg_read_coefficients */
3970a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define DSTATE_STOPPING	210	/* looking for EOI in jpeg_finish_decompress */
4070a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
4170a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
4270a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine/* Declarations for compression modules */
4370a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
4470a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine/* Master control module */
4570a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkinestruct jpeg_comp_master {
4670a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(void, prepare_for_pass, (j_compress_ptr cinfo));
4770a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(void, pass_startup, (j_compress_ptr cinfo));
4870a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(void, finish_pass, (j_compress_ptr cinfo));
4970a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
5070a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  /* State variables made visible to other modules */
5170a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  boolean call_pass_startup;	/* True if pass_startup must be called */
5270a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  boolean is_last_pass;		/* True during last pass */
5370a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine};
5470a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
5570a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine/* Main buffer control (downsampled-data buffer) */
5670a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkinestruct jpeg_c_main_controller {
5770a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode));
5870a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(void, process_data, (j_compress_ptr cinfo,
5970a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine			       JSAMPARRAY input_buf, JDIMENSION *in_row_ctr,
6070a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine			       JDIMENSION in_rows_avail));
6170a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine};
6270a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
6370a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine/* Compression preprocessing (downsampling input buffer control) */
6470a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkinestruct jpeg_c_prep_controller {
6570a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode));
6670a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(void, pre_process_data, (j_compress_ptr cinfo,
6770a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine				   JSAMPARRAY input_buf,
6870a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine				   JDIMENSION *in_row_ctr,
6970a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine				   JDIMENSION in_rows_avail,
7070a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine				   JSAMPIMAGE output_buf,
7170a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine				   JDIMENSION *out_row_group_ctr,
7270a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine				   JDIMENSION out_row_groups_avail));
7370a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine};
7470a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
7570a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine/* Coefficient buffer control */
7670a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkinestruct jpeg_c_coef_controller {
7770a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode));
7870a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(boolean, compress_data, (j_compress_ptr cinfo,
7970a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine				   JSAMPIMAGE input_buf));
8070a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine};
8170a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
8270a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine/* Colorspace conversion */
8370a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkinestruct jpeg_color_converter {
8470a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(void, start_pass, (j_compress_ptr cinfo));
8570a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(void, color_convert, (j_compress_ptr cinfo,
8670a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine				JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
8770a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine				JDIMENSION output_row, int num_rows));
8870a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine};
8970a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
9070a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine/* Downsampling */
9170a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkinestruct jpeg_downsampler {
9270a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(void, start_pass, (j_compress_ptr cinfo));
9370a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(void, downsample, (j_compress_ptr cinfo,
9470a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine			     JSAMPIMAGE input_buf, JDIMENSION in_row_index,
9570a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine			     JSAMPIMAGE output_buf,
9670a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine			     JDIMENSION out_row_group_index));
9770a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
9870a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  boolean need_context_rows;	/* TRUE if need rows above & below */
9970a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine};
10070a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
10170a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine/* Forward DCT (also controls coefficient quantization) */
10270a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkinestruct jpeg_forward_dct {
10370a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(void, start_pass, (j_compress_ptr cinfo));
10470a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  /* perhaps this should be an array??? */
10570a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(void, forward_DCT, (j_compress_ptr cinfo,
10670a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine			      jpeg_component_info * compptr,
10770a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine			      JSAMPARRAY sample_data, JBLOCKROW coef_blocks,
10870a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine			      JDIMENSION start_row, JDIMENSION start_col,
10970a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine			      JDIMENSION num_blocks));
11070a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine};
11170a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
11270a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine/* Entropy encoding */
11370a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkinestruct jpeg_entropy_encoder {
11470a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(void, start_pass, (j_compress_ptr cinfo, boolean gather_statistics));
11570a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(boolean, encode_mcu, (j_compress_ptr cinfo, JBLOCKROW *MCU_data));
11670a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(void, finish_pass, (j_compress_ptr cinfo));
11770a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine};
11870a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
11970a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine/* Marker writing */
12070a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkinestruct jpeg_marker_writer {
12170a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(void, write_file_header, (j_compress_ptr cinfo));
12270a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(void, write_frame_header, (j_compress_ptr cinfo));
12370a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(void, write_scan_header, (j_compress_ptr cinfo));
12470a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(void, write_file_trailer, (j_compress_ptr cinfo));
12570a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(void, write_tables_only, (j_compress_ptr cinfo));
12670a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  /* These routines are exported to allow insertion of extra markers */
12770a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  /* Probably only COM and APPn markers should be written this way */
12870a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(void, write_marker_header, (j_compress_ptr cinfo, int marker,
12970a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine				      unsigned int datalen));
13070a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(void, write_marker_byte, (j_compress_ptr cinfo, int val));
13170a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine};
13270a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
13370a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
13470a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine/* Declarations for decompression modules */
13570a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
13670a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine/* Master control module */
13770a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkinestruct jpeg_decomp_master {
13870a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(void, prepare_for_output_pass, (j_decompress_ptr cinfo));
13970a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(void, finish_output_pass, (j_decompress_ptr cinfo));
14070a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
14170a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  /* State variables made visible to other modules */
14270a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  boolean is_dummy_pass;	/* True during 1st pass for 2-pass quant */
14370a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine};
14470a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
14570a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine/* Input control module */
14670a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkinestruct jpeg_input_controller {
14770a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(int, consume_input, (j_decompress_ptr cinfo));
14870a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(int, consume_input_build_huffman_index, (j_decompress_ptr cinfo,
14970a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine                    huffman_index *index, int scan_count));
15070a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(int, consume_markers, (j_decompress_ptr cinfo,
15170a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine                    huffman_index *index, int scan_count));
15270a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(void, reset_input_controller, (j_decompress_ptr cinfo));
15370a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(void, start_input_pass, (j_decompress_ptr cinfo));
15470a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(void, finish_input_pass, (j_decompress_ptr cinfo));
15570a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
15670a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  /* State variables made visible to other modules */
15770a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  boolean has_multiple_scans;	/* True if file has multiple scans */
15870a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  boolean eoi_reached;		/* True when EOI has been consumed */
15970a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine};
16070a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
16170a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine/* Main buffer control (downsampled-data buffer) */
16270a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkinestruct jpeg_d_main_controller {
16370a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(void, start_pass, (j_decompress_ptr cinfo, J_BUF_MODE pass_mode));
16470a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(void, process_data, (j_decompress_ptr cinfo,
16570a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine			       JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
16670a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine			       JDIMENSION out_rows_avail));
16770a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine};
16870a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
16970a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine/* Coefficient buffer control */
17070a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkinestruct jpeg_d_coef_controller {
17170a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(void, start_input_pass, (j_decompress_ptr cinfo));
17270a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(int, consume_data, (j_decompress_ptr cinfo));
17370a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(int, consume_data_build_huffman_index, (j_decompress_ptr cinfo,
17470a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine                    huffman_index* index, int scan_count));
17570a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(void, start_output_pass, (j_decompress_ptr cinfo));
17670a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(int, decompress_data, (j_decompress_ptr cinfo,
17770a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine				 JSAMPIMAGE output_buf));
17870a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  /* Pointer to array of coefficient virtual arrays, or NULL if none */
17970a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  jvirt_barray_ptr *coef_arrays;
18070a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
18170a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  /* column number of the first and last tile, respectively */
18270a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  int column_left_boundary;
18370a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  int column_right_boundary;
18470a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
18570a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  /* column number of the first and last MCU, respectively */
18670a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  int MCU_column_left_boundary;
18770a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  int MCU_column_right_boundary;
18870a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
18970a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  /* the number of MCU columns to skip from the indexed MCU, iM,
19070a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine   * to the requested MCU boundary, rM, where iM is the MCU that we sample
19170a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine   * into our index and is the nearest one to the left of rM.
19270a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine   */
19370a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  int MCU_columns_to_skip;
19470a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine};
19570a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
19670a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine/* Decompression postprocessing (color quantization buffer control) */
19770a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkinestruct jpeg_d_post_controller {
19870a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(void, start_pass, (j_decompress_ptr cinfo, J_BUF_MODE pass_mode));
19970a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(void, post_process_data, (j_decompress_ptr cinfo,
20070a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine				    JSAMPIMAGE input_buf,
20170a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine				    JDIMENSION *in_row_group_ctr,
20270a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine				    JDIMENSION in_row_groups_avail,
20370a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine				    JSAMPARRAY output_buf,
20470a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine				    JDIMENSION *out_row_ctr,
20570a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine				    JDIMENSION out_rows_avail));
20670a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine};
20770a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
20870a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine/* Marker reading & parsing */
20970a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkinestruct jpeg_marker_reader {
21070a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(void, reset_marker_reader, (j_decompress_ptr cinfo));
21170a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  /* Read markers until SOS or EOI.
21270a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine   * Returns same codes as are defined for jpeg_consume_input:
21370a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine   * JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI.
21470a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine   */
21570a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(int, read_markers, (j_decompress_ptr cinfo));
21670a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(void, get_sos_marker_position, (j_decompress_ptr cinfo,
21770a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine                    huffman_index *index));
21870a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  /* Read a restart marker --- exported for use by entropy decoder only */
21970a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  jpeg_marker_parser_method read_restart_marker;
22070a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
22170a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  /* State of marker reader --- nominally internal, but applications
22270a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine   * supplying COM or APPn handlers might like to know the state.
22370a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine   */
22470a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  boolean saw_SOI;		/* found SOI? */
22570a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  boolean saw_SOF;		/* found SOF? */
22670a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  int next_restart_num;		/* next restart number expected (0-7) */
22770a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  int current_sos_marker_position;
22870a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  unsigned int discarded_bytes;	/* # of bytes skipped looking for a marker */
22970a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine};
23070a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
23170a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine/* Entropy decoding */
23270a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkinestruct jpeg_entropy_decoder {
23370a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(void, start_pass, (j_decompress_ptr cinfo));
23470a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(boolean, decode_mcu, (j_decompress_ptr cinfo,
23570a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine				JBLOCKROW *MCU_data));
23670a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(boolean, decode_mcu_discard_coef, (j_decompress_ptr cinfo));
23770a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(void, configure_huffman_decoder, (j_decompress_ptr cinfo,
23870a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine                    huffman_offset_data offset));
23970a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(void, get_huffman_decoder_configuration, (j_decompress_ptr cinfo,
24070a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine                    huffman_offset_data *offset));
24170a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
24270a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  /* This is here to share code between baseline and progressive decoders; */
24370a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  /* other modules probably should not use it */
24470a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  boolean insufficient_data;	/* set TRUE after emitting warning */
24570a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
24670a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  huffman_index *index;
24770a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine};
24870a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
24970a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine/* Inverse DCT (also performs dequantization) */
25070a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkinetypedef JMETHOD(void, inverse_DCT_method_ptr,
25170a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine		(j_decompress_ptr cinfo, jpeg_component_info * compptr,
25270a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine		 JCOEFPTR coef_block,
25370a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine		 JSAMPARRAY output_buf, JDIMENSION output_col));
25470a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
25570a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkinestruct jpeg_inverse_dct {
25670a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(void, start_pass, (j_decompress_ptr cinfo));
25770a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  /* It is useful to allow each component to have a separate IDCT method. */
25870a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  inverse_DCT_method_ptr inverse_DCT[MAX_COMPONENTS];
25970a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine};
26070a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
26170a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine/* Upsampling (note that upsampler must also call color converter) */
26270a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkinestruct jpeg_upsampler {
26370a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(void, start_pass, (j_decompress_ptr cinfo));
26470a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(void, upsample, (j_decompress_ptr cinfo,
26570a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine			   JSAMPIMAGE input_buf,
26670a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine			   JDIMENSION *in_row_group_ctr,
26770a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine			   JDIMENSION in_row_groups_avail,
26870a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine			   JSAMPARRAY output_buf,
26970a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine			   JDIMENSION *out_row_ctr,
27070a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine			   JDIMENSION out_rows_avail));
27170a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
27270a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  boolean need_context_rows;	/* TRUE if need rows above & below */
27370a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine};
27470a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
27570a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine/* Colorspace conversion */
27670a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkinestruct jpeg_color_deconverter {
27770a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(void, start_pass, (j_decompress_ptr cinfo));
27870a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(void, color_convert, (j_decompress_ptr cinfo,
27970a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine				JSAMPIMAGE input_buf, JDIMENSION input_row,
28070a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine				JSAMPARRAY output_buf, int num_rows));
28170a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine};
28270a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
28370a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine/* Color quantization or color precision reduction */
28470a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkinestruct jpeg_color_quantizer {
28570a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(void, start_pass, (j_decompress_ptr cinfo, boolean is_pre_scan));
28670a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(void, color_quantize, (j_decompress_ptr cinfo,
28770a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine				 JSAMPARRAY input_buf, JSAMPARRAY output_buf,
28870a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine				 int num_rows));
28970a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(void, finish_pass, (j_decompress_ptr cinfo));
29070a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine  JMETHOD(void, new_color_map, (j_decompress_ptr cinfo));
29170a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine};
29270a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
29370a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
29470a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine/* Miscellaneous useful macros */
29570a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
29670a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#undef MAX
29770a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define MAX(a,b)	((a) > (b) ? (a) : (b))
29870a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#undef MIN
29970a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define MIN(a,b)	((a) < (b) ? (a) : (b))
30070a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
30170a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
30270a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine/* We assume that right shift corresponds to signed division by 2 with
30370a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine * rounding towards minus infinity.  This is correct for typical "arithmetic
30470a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine * shift" instructions that shift in copies of the sign bit.  But some
30570a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine * C compilers implement >> with an unsigned shift.  For these machines you
30670a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine * must define RIGHT_SHIFT_IS_UNSIGNED.
30770a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine * RIGHT_SHIFT provides a proper signed right shift of an INT32 quantity.
30870a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine * It is only applied with constant shift counts.  SHIFT_TEMPS must be
30970a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine * included in the variables of any routine using RIGHT_SHIFT.
31070a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine */
31170a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
31270a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#ifdef RIGHT_SHIFT_IS_UNSIGNED
31370a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define SHIFT_TEMPS	INT32 shift_temp;
31470a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define RIGHT_SHIFT(x,shft)  \
31570a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine	((shift_temp = (x)) < 0 ? \
31670a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine	 (shift_temp >> (shft)) | ((~((INT32) 0)) << (32-(shft))) : \
31770a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine	 (shift_temp >> (shft)))
31870a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#else
31970a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define SHIFT_TEMPS
32070a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define RIGHT_SHIFT(x,shft)	((x) >> (shft))
32170a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#endif
32270a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
32370a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
32470a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine/* Short forms of external names for systems with brain-damaged linkers. */
32570a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
32670a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#ifdef NEED_SHORT_EXTERNAL_NAMES
32770a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define jinit_compress_master	jICompress
32870a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define jinit_c_master_control	jICMaster
32970a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define jinit_c_main_controller	jICMainC
33070a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define jinit_c_prep_controller	jICPrepC
33170a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define jinit_c_coef_controller	jICCoefC
33270a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define jinit_color_converter	jICColor
33370a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define jinit_downsampler	jIDownsampler
33470a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define jinit_forward_dct	jIFDCT
33570a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define jinit_huff_encoder	jIHEncoder
33670a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define jinit_phuff_encoder	jIPHEncoder
33770a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define jinit_marker_writer	jIMWriter
33870a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define jinit_master_decompress	jIDMaster
33970a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define jinit_d_main_controller	jIDMainC
34070a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define jinit_d_coef_controller	jIDCoefC
34170a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define jinit_d_post_controller	jIDPostC
34270a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define jinit_input_controller	jIInCtlr
34370a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define jinit_marker_reader	jIMReader
34470a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define jinit_huff_decoder	jIHDecoder
34570a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define jinit_phuff_decoder	jIPHDecoder
34670a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define jinit_inverse_dct	jIIDCT
34770a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define jinit_upsampler		jIUpsampler
34870a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define jinit_color_deconverter	jIDColor
34970a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define jinit_1pass_quantizer	jI1Quant
35070a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define jinit_2pass_quantizer	jI2Quant
35170a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define jinit_merged_upsampler	jIMUpsampler
35270a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define jinit_memory_mgr	jIMemMgr
35370a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define jdiv_round_up		jDivRound
35470a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define jround_up		jRound
35570a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define jcopy_sample_rows	jCopySamples
35670a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define jcopy_block_row		jCopyBlocks
35770a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define jzero_far		jZeroFar
35870a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define jpeg_zigzag_order	jZIGTable
35970a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#define jpeg_natural_order	jZAGTable
36070a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#endif /* NEED_SHORT_EXTERNAL_NAMES */
36170a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
36270a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
36370a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine/* Compression module initialization routines */
36470a18cd874a22452aca9e39e22275ed4538ed20bVladimir ChtchetkineEXTERN(void) jinit_compress_master JPP((j_compress_ptr cinfo));
36570a18cd874a22452aca9e39e22275ed4538ed20bVladimir ChtchetkineEXTERN(void) jinit_c_master_control JPP((j_compress_ptr cinfo,
36670a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine					 boolean transcode_only));
36770a18cd874a22452aca9e39e22275ed4538ed20bVladimir ChtchetkineEXTERN(void) jinit_c_main_controller JPP((j_compress_ptr cinfo,
36870a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine					  boolean need_full_buffer));
36970a18cd874a22452aca9e39e22275ed4538ed20bVladimir ChtchetkineEXTERN(void) jinit_c_prep_controller JPP((j_compress_ptr cinfo,
37070a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine					  boolean need_full_buffer));
37170a18cd874a22452aca9e39e22275ed4538ed20bVladimir ChtchetkineEXTERN(void) jinit_c_coef_controller JPP((j_compress_ptr cinfo,
37270a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine					  boolean need_full_buffer));
37370a18cd874a22452aca9e39e22275ed4538ed20bVladimir ChtchetkineEXTERN(void) jinit_color_converter JPP((j_compress_ptr cinfo));
37470a18cd874a22452aca9e39e22275ed4538ed20bVladimir ChtchetkineEXTERN(void) jinit_downsampler JPP((j_compress_ptr cinfo));
37570a18cd874a22452aca9e39e22275ed4538ed20bVladimir ChtchetkineEXTERN(void) jinit_forward_dct JPP((j_compress_ptr cinfo));
37670a18cd874a22452aca9e39e22275ed4538ed20bVladimir ChtchetkineEXTERN(void) jinit_huff_encoder JPP((j_compress_ptr cinfo));
37770a18cd874a22452aca9e39e22275ed4538ed20bVladimir ChtchetkineEXTERN(void) jinit_phuff_encoder JPP((j_compress_ptr cinfo));
37870a18cd874a22452aca9e39e22275ed4538ed20bVladimir ChtchetkineEXTERN(void) jinit_marker_writer JPP((j_compress_ptr cinfo));
37970a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine/* Decompression module initialization routines */
38070a18cd874a22452aca9e39e22275ed4538ed20bVladimir ChtchetkineEXTERN(void) jinit_master_decompress JPP((j_decompress_ptr cinfo));
38170a18cd874a22452aca9e39e22275ed4538ed20bVladimir ChtchetkineEXTERN(void) jinit_d_main_controller JPP((j_decompress_ptr cinfo,
38270a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine					  boolean need_full_buffer));
38370a18cd874a22452aca9e39e22275ed4538ed20bVladimir ChtchetkineEXTERN(void) jinit_d_coef_controller JPP((j_decompress_ptr cinfo,
38470a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine					  boolean need_full_buffer));
38570a18cd874a22452aca9e39e22275ed4538ed20bVladimir ChtchetkineEXTERN(void) jinit_d_post_controller JPP((j_decompress_ptr cinfo,
38670a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine					  boolean need_full_buffer));
38770a18cd874a22452aca9e39e22275ed4538ed20bVladimir ChtchetkineEXTERN(void) jinit_input_controller JPP((j_decompress_ptr cinfo));
38870a18cd874a22452aca9e39e22275ed4538ed20bVladimir ChtchetkineEXTERN(void) jinit_marker_reader JPP((j_decompress_ptr cinfo));
38970a18cd874a22452aca9e39e22275ed4538ed20bVladimir ChtchetkineEXTERN(void) jinit_huff_decoder JPP((j_decompress_ptr cinfo));
39070a18cd874a22452aca9e39e22275ed4538ed20bVladimir ChtchetkineEXTERN(void) jinit_huff_decoder_no_data JPP((j_decompress_ptr cinfo));
39170a18cd874a22452aca9e39e22275ed4538ed20bVladimir ChtchetkineEXTERN(void) jinit_phuff_decoder JPP((j_decompress_ptr cinfo));
39270a18cd874a22452aca9e39e22275ed4538ed20bVladimir ChtchetkineEXTERN(void) jinit_inverse_dct JPP((j_decompress_ptr cinfo));
39370a18cd874a22452aca9e39e22275ed4538ed20bVladimir ChtchetkineEXTERN(void) jinit_upsampler JPP((j_decompress_ptr cinfo));
39470a18cd874a22452aca9e39e22275ed4538ed20bVladimir ChtchetkineEXTERN(void) jinit_color_deconverter JPP((j_decompress_ptr cinfo));
39570a18cd874a22452aca9e39e22275ed4538ed20bVladimir ChtchetkineEXTERN(void) jinit_1pass_quantizer JPP((j_decompress_ptr cinfo));
39670a18cd874a22452aca9e39e22275ed4538ed20bVladimir ChtchetkineEXTERN(void) jinit_2pass_quantizer JPP((j_decompress_ptr cinfo));
39770a18cd874a22452aca9e39e22275ed4538ed20bVladimir ChtchetkineEXTERN(void) jinit_merged_upsampler JPP((j_decompress_ptr cinfo));
39870a18cd874a22452aca9e39e22275ed4538ed20bVladimir ChtchetkineEXTERN(void) jpeg_decompress_per_scan_setup (j_decompress_ptr cinfo);
39970a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine/* Memory manager initialization */
40070a18cd874a22452aca9e39e22275ed4538ed20bVladimir ChtchetkineEXTERN(void) jinit_memory_mgr JPP((j_common_ptr cinfo));
40170a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
40270a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine/* Utility routines in jutils.c */
40370a18cd874a22452aca9e39e22275ed4538ed20bVladimir ChtchetkineEXTERN(long) jdiv_round_up JPP((long a, long b));
40470a18cd874a22452aca9e39e22275ed4538ed20bVladimir ChtchetkineEXTERN(long) jround_up JPP((long a, long b));
40570a18cd874a22452aca9e39e22275ed4538ed20bVladimir ChtchetkineEXTERN(long) jmin JPP((long a, long b));
40670a18cd874a22452aca9e39e22275ed4538ed20bVladimir ChtchetkineEXTERN(void) jcopy_sample_rows JPP((JSAMPARRAY input_array, int source_row,
40770a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine				    JSAMPARRAY output_array, int dest_row,
40870a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine				    int num_rows, JDIMENSION num_cols));
40970a18cd874a22452aca9e39e22275ed4538ed20bVladimir ChtchetkineEXTERN(void) jcopy_block_row JPP((JBLOCKROW input_row, JBLOCKROW output_row,
41070a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine				  JDIMENSION num_blocks));
41170a18cd874a22452aca9e39e22275ed4538ed20bVladimir ChtchetkineEXTERN(void) jzero_far JPP((void FAR * target, size_t bytestozero));
41270a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
41370a18cd874a22452aca9e39e22275ed4538ed20bVladimir ChtchetkineEXTERN(void) jset_input_stream_position JPP((j_decompress_ptr cinfo,
41470a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine                    int offset));
41570a18cd874a22452aca9e39e22275ed4538ed20bVladimir ChtchetkineEXTERN(void) jset_input_stream_position_bit JPP((j_decompress_ptr cinfo,
41670a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine                    int byte_offset, int bit_left, INT32 buf));
41770a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
41870a18cd874a22452aca9e39e22275ed4538ed20bVladimir ChtchetkineEXTERN(int) jget_input_stream_position JPP((j_decompress_ptr cinfo));
41970a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine/* Constant tables in jutils.c */
42070a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#if 0				/* This table is not actually needed in v6a */
42170a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkineextern const int jpeg_zigzag_order[]; /* natural coef order to zigzag order */
42270a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#endif
42370a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkineextern const int jpeg_natural_order[]; /* zigzag coef order to natural order */
42470a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
42570a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine/* Suppress undefined-structure complaints if necessary. */
42670a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine
42770a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#ifdef INCOMPLETE_TYPES_BROKEN
42870a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#ifndef AM_MEMORY_MANAGER	/* only jmemmgr.c defines these */
42970a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkinestruct jvirt_sarray_control { long dummy; };
43070a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkinestruct jvirt_barray_control { long dummy; };
43170a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#endif
43270a18cd874a22452aca9e39e22275ed4538ed20bVladimir Chtchetkine#endif /* INCOMPLETE_TYPES_BROKEN */
433