summaryrefslogtreecommitdiff
path: root/src/jpegint.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/jpegint.h')
-rw-r--r--src/jpegint.h114
1 files changed, 72 insertions, 42 deletions
diff --git a/src/jpegint.h b/src/jpegint.h
index e55a2be..eb6ec8b 100644
--- a/src/jpegint.h
+++ b/src/jpegint.h
@@ -2,6 +2,7 @@
* jpegint.h
*
* Copyright (C) 1991-1997, Thomas G. Lane.
+ * Modified 1997-2009 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
@@ -10,6 +11,7 @@
* applications using the library shouldn't need to include this file.
*/
+
/* Declarations for both compression & decompression */
typedef enum { /* Operating modes for buffer controllers */
@@ -37,6 +39,7 @@ typedef enum { /* Operating modes for buffer controllers */
#define DSTATE_RDCOEFS 209 /* reading file in jpeg_read_coefficients */
#define DSTATE_STOPPING 210 /* looking for EOI in jpeg_finish_decompress */
+
/* Declarations for compression modules */
/* Master control module */
@@ -53,17 +56,19 @@ struct jpeg_comp_master {
/* Main buffer control (downsampled-data buffer) */
struct jpeg_c_main_controller {
JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode));
- JMETHOD(void, process_data,
- (j_compress_ptr cinfo, JSAMPARRAY input_buf, JDIMENSION * in_row_ctr, JDIMENSION in_rows_avail));
+ JMETHOD(void, process_data, (j_compress_ptr cinfo,
+ JSAMPARRAY input_buf, JDIMENSION * in_row_ctr, JDIMENSION in_rows_avail));
};
/* Compression preprocessing (downsampling input buffer control) */
struct jpeg_c_prep_controller {
JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode));
- JMETHOD(void, pre_process_data,
- (j_compress_ptr cinfo, JSAMPARRAY input_buf,
- JDIMENSION * in_row_ctr, JDIMENSION in_rows_avail,
- JSAMPIMAGE output_buf, JDIMENSION * out_row_group_ctr, JDIMENSION out_row_groups_avail));
+ JMETHOD(void, pre_process_data, (j_compress_ptr cinfo,
+ JSAMPARRAY input_buf,
+ JDIMENSION * in_row_ctr,
+ JDIMENSION in_rows_avail,
+ JSAMPIMAGE output_buf,
+ JDIMENSION * out_row_group_ctr, JDIMENSION out_row_groups_avail));
};
/* Coefficient buffer control */
@@ -76,29 +81,30 @@ struct jpeg_c_coef_controller {
struct jpeg_color_converter {
JMETHOD(void, start_pass, (j_compress_ptr cinfo));
JMETHOD(void, color_convert, (j_compress_ptr cinfo,
- JSAMPARRAY input_buf,
- JSAMPIMAGE output_buf, JDIMENSION output_row, int num_rows));
+ JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
+ JDIMENSION output_row, int num_rows));
};
/* Downsampling */
struct jpeg_downsampler {
JMETHOD(void, start_pass, (j_compress_ptr cinfo));
JMETHOD(void, downsample, (j_compress_ptr cinfo,
- JSAMPIMAGE input_buf,
- JDIMENSION in_row_index, JSAMPIMAGE output_buf, JDIMENSION out_row_group_index));
+ JSAMPIMAGE input_buf, JDIMENSION in_row_index,
+ JSAMPIMAGE output_buf, JDIMENSION out_row_group_index));
boolean need_context_rows; /* TRUE if need rows above & below */
};
/* Forward DCT (also controls coefficient quantization) */
+typedef JMETHOD(void, forward_DCT_ptr,
+ (j_compress_ptr cinfo, jpeg_component_info * compptr,
+ JSAMPARRAY sample_data, JBLOCKROW coef_blocks,
+ JDIMENSION start_row, JDIMENSION start_col, JDIMENSION num_blocks));
+
struct jpeg_forward_dct {
JMETHOD(void, start_pass, (j_compress_ptr cinfo));
- /* perhaps this should be an array??? */
- JMETHOD(void, forward_DCT, (j_compress_ptr cinfo,
- jpeg_component_info * compptr,
- JSAMPARRAY sample_data,
- JBLOCKROW coef_blocks,
- JDIMENSION start_row, JDIMENSION start_col, JDIMENSION num_blocks));
+ /* It is useful to allow each component to have a separate FDCT method. */
+ forward_DCT_ptr forward_DCT[MAX_COMPONENTS];
};
/* Entropy encoding */
@@ -121,6 +127,7 @@ struct jpeg_marker_writer {
JMETHOD(void, write_marker_byte, (j_compress_ptr cinfo, int val));
};
+
/* Declarations for decompression modules */
/* Master control module */
@@ -147,8 +154,8 @@ struct jpeg_input_controller {
/* Main buffer control (downsampled-data buffer) */
struct jpeg_d_main_controller {
JMETHOD(void, start_pass, (j_decompress_ptr cinfo, J_BUF_MODE pass_mode));
- JMETHOD(void, process_data,
- (j_decompress_ptr cinfo, JSAMPARRAY output_buf, JDIMENSION * out_row_ctr, JDIMENSION out_rows_avail));
+ JMETHOD(void, process_data, (j_decompress_ptr cinfo,
+ JSAMPARRAY output_buf, JDIMENSION * out_row_ctr, JDIMENSION out_rows_avail));
};
/* Coefficient buffer control */
@@ -164,11 +171,11 @@ struct jpeg_d_coef_controller {
/* Decompression postprocessing (color quantization buffer control) */
struct jpeg_d_post_controller {
JMETHOD(void, start_pass, (j_decompress_ptr cinfo, J_BUF_MODE pass_mode));
- JMETHOD(void, post_process_data,
- (j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION * in_row_group_ctr,
- JDIMENSION in_row_groups_avail, JSAMPARRAY output_buf,
- JDIMENSION * out_row_ctr, JDIMENSION out_rows_avail));
+ JMETHOD(void, post_process_data, (j_decompress_ptr cinfo,
+ JSAMPIMAGE input_buf,
+ JDIMENSION * in_row_group_ctr,
+ JDIMENSION in_row_groups_avail,
+ JSAMPARRAY output_buf, JDIMENSION * out_row_ctr, JDIMENSION out_rows_avail));
};
/* Marker reading & parsing */
@@ -195,10 +202,6 @@ struct jpeg_marker_reader {
struct jpeg_entropy_decoder {
JMETHOD(void, start_pass, (j_decompress_ptr cinfo));
JMETHOD(boolean, decode_mcu, (j_decompress_ptr cinfo, JBLOCKROW * MCU_data));
-
- /* This is here to share code between baseline and progressive decoders; */
- /* other modules probably should not use it */
- boolean insufficient_data; /* set TRUE after emitting warning */
};
/* Inverse DCT (also performs dequantization) */
@@ -228,19 +231,20 @@ struct jpeg_upsampler {
struct jpeg_color_deconverter {
JMETHOD(void, start_pass, (j_decompress_ptr cinfo));
JMETHOD(void, color_convert, (j_decompress_ptr cinfo,
- JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows));
+ JSAMPIMAGE input_buf, JDIMENSION input_row,
+ JSAMPARRAY output_buf, int num_rows));
};
/* Color quantization or color precision reduction */
struct jpeg_color_quantizer {
JMETHOD(void, start_pass, (j_decompress_ptr cinfo, boolean is_pre_scan));
- JMETHOD(void, color_quantize,
- (j_decompress_ptr cinfo, JSAMPARRAY input_buf, JSAMPARRAY output_buf, int num_rows));
+ JMETHOD(void, color_quantize, (j_decompress_ptr cinfo,
+ JSAMPARRAY input_buf, JSAMPARRAY output_buf, int num_rows));
JMETHOD(void, finish_pass, (j_decompress_ptr cinfo));
JMETHOD(void, new_color_map, (j_decompress_ptr cinfo));
};
+
/* Miscellaneous useful macros */
#undef MAX
@@ -248,6 +252,7 @@ struct jpeg_color_quantizer {
#undef MIN
#define MIN(a,b) ((a) < (b) ? (a) : (b))
+
/* We assume that right shift corresponds to signed division by 2 with
* rounding towards minus infinity. This is correct for typical "arithmetic
* shift" instructions that shift in copies of the sign bit. But some
@@ -269,6 +274,7 @@ struct jpeg_color_quantizer {
#define RIGHT_SHIFT(x,shft) ((x) >> (shft))
#endif
+
/* Short forms of external names for systems with brain-damaged linkers. */
#ifdef NEED_SHORT_EXTERNAL_NAMES
@@ -281,7 +287,7 @@ struct jpeg_color_quantizer {
#define jinit_downsampler jIDownsampler
#define jinit_forward_dct jIFDCT
#define jinit_huff_encoder jIHEncoder
-#define jinit_phuff_encoder jIPHEncoder
+#define jinit_arith_encoder jIAEncoder
#define jinit_marker_writer jIMWriter
#define jinit_master_decompress jIDMaster
#define jinit_d_main_controller jIDMainC
@@ -290,7 +296,7 @@ struct jpeg_color_quantizer {
#define jinit_input_controller jIInCtlr
#define jinit_marker_reader jIMReader
#define jinit_huff_decoder jIHDecoder
-#define jinit_phuff_decoder jIPHDecoder
+#define jinit_arith_decoder jIADecoder
#define jinit_inverse_dct jIIDCT
#define jinit_upsampler jIUpsampler
#define jinit_color_deconverter jIDColor
@@ -305,16 +311,27 @@ struct jpeg_color_quantizer {
#define jzero_far jZeroFar
#define jpeg_zigzag_order jZIGTable
#define jpeg_natural_order jZAGTable
+#define jpeg_natural_order7 jZAGTable7
+#define jpeg_natural_order6 jZAGTable6
+#define jpeg_natural_order5 jZAGTable5
+#define jpeg_natural_order4 jZAGTable4
+#define jpeg_natural_order3 jZAGTable3
+#define jpeg_natural_order2 jZAGTable2
+#define jpeg_aritab jAriTab
#endif /* NEED_SHORT_EXTERNAL_NAMES */
+
/* Compression module initialization routines */
EXTERN(void)
jinit_compress_master JPP((j_compress_ptr cinfo));
EXTERN(void)
jinit_c_master_control JPP((j_compress_ptr cinfo, boolean transcode_only));
-EXTERN(void) jinit_c_main_controller JPP((j_compress_ptr cinfo, boolean need_full_buffer));
-EXTERN(void) jinit_c_prep_controller JPP((j_compress_ptr cinfo, boolean need_full_buffer));
-EXTERN(void) jinit_c_coef_controller JPP((j_compress_ptr cinfo, boolean need_full_buffer));
+EXTERN(void)
+jinit_c_main_controller JPP((j_compress_ptr cinfo, boolean need_full_buffer));
+EXTERN(void)
+jinit_c_prep_controller JPP((j_compress_ptr cinfo, boolean need_full_buffer));
+EXTERN(void)
+jinit_c_coef_controller JPP((j_compress_ptr cinfo, boolean need_full_buffer));
EXTERN(void)
jinit_color_converter JPP((j_compress_ptr cinfo));
EXTERN(void)
@@ -324,15 +341,18 @@ jinit_forward_dct JPP((j_compress_ptr cinfo));
EXTERN(void)
jinit_huff_encoder JPP((j_compress_ptr cinfo));
EXTERN(void)
-jinit_phuff_encoder JPP((j_compress_ptr cinfo));
+jinit_arith_encoder JPP((j_compress_ptr cinfo));
EXTERN(void)
jinit_marker_writer JPP((j_compress_ptr cinfo));
/* Decompression module initialization routines */
EXTERN(void)
jinit_master_decompress JPP((j_decompress_ptr cinfo));
-EXTERN(void) jinit_d_main_controller JPP((j_decompress_ptr cinfo, boolean need_full_buffer));
-EXTERN(void) jinit_d_coef_controller JPP((j_decompress_ptr cinfo, boolean need_full_buffer));
-EXTERN(void) jinit_d_post_controller JPP((j_decompress_ptr cinfo, boolean need_full_buffer));
+EXTERN(void)
+jinit_d_main_controller JPP((j_decompress_ptr cinfo, boolean need_full_buffer));
+EXTERN(void)
+jinit_d_coef_controller JPP((j_decompress_ptr cinfo, boolean need_full_buffer));
+EXTERN(void)
+jinit_d_post_controller JPP((j_decompress_ptr cinfo, boolean need_full_buffer));
EXTERN(void)
jinit_input_controller JPP((j_decompress_ptr cinfo));
EXTERN(void)
@@ -340,7 +360,7 @@ jinit_marker_reader JPP((j_decompress_ptr cinfo));
EXTERN(void)
jinit_huff_decoder JPP((j_decompress_ptr cinfo));
EXTERN(void)
-jinit_phuff_decoder JPP((j_decompress_ptr cinfo));
+jinit_arith_decoder JPP((j_decompress_ptr cinfo));
EXTERN(void)
jinit_inverse_dct JPP((j_decompress_ptr cinfo));
EXTERN(void)
@@ -365,7 +385,8 @@ jround_up JPP((long a, long b));
EXTERN(void)
jcopy_sample_rows JPP((JSAMPARRAY input_array, int source_row,
JSAMPARRAY output_array, int dest_row, int num_rows, JDIMENSION num_cols));
-EXTERN(void) jcopy_block_row JPP((JBLOCKROW input_row, JBLOCKROW output_row, JDIMENSION num_blocks));
+EXTERN(void)
+jcopy_block_row JPP((JBLOCKROW input_row, JBLOCKROW output_row, JDIMENSION num_blocks));
EXTERN(void)
jzero_far JPP((void FAR * target, size_t bytestozero));
/* Constant tables in jutils.c */
@@ -373,6 +394,15 @@ jzero_far JPP((void FAR * target, size_t bytestozero));
extern const int jpeg_zigzag_order[]; /* natural coef order to zigzag order */
#endif
extern const int jpeg_natural_order[]; /* zigzag coef order to natural order */
+extern const int jpeg_natural_order7[]; /* zz to natural order for 7x7 block */
+extern const int jpeg_natural_order6[]; /* zz to natural order for 6x6 block */
+extern const int jpeg_natural_order5[]; /* zz to natural order for 5x5 block */
+extern const int jpeg_natural_order4[]; /* zz to natural order for 4x4 block */
+extern const int jpeg_natural_order3[]; /* zz to natural order for 3x3 block */
+extern const int jpeg_natural_order2[]; /* zz to natural order for 2x2 block */
+
+/* Arithmetic coding probability estimation tables in jaricom.c */
+extern const INT32 jpeg_aritab[];
/* Suppress undefined-structure complaints if necessary. */