jpegint.h
Go to the documentation of this file.
00001 /*
00002  * jpegint.h
00003  *
00004  * Copyright (C) 1991-1997, Thomas G. Lane.
00005  * This file is part of the Independent JPEG Group's software.
00006  * For conditions of distribution and use, see the accompanying README file.
00007  *
00008  * This file provides common declarations for the various JPEG modules.
00009  * These declarations are considered internal to the JPEG library; most
00010  * applications using the library shouldn't need to include this file.
00011  */
00012 
00013 
00014 /* Declarations for both compression & decompression */
00015 
00016 typedef enum {                  /* Operating modes for buffer controllers */
00017         JBUF_PASS_THRU,         /* Plain stripwise operation */
00018         /* Remaining modes require a full-image buffer to have been created */
00019         JBUF_SAVE_SOURCE,       /* Run source subobject only, save output */
00020         JBUF_CRANK_DEST,        /* Run dest subobject only, using saved data */
00021         JBUF_SAVE_AND_PASS      /* Run both subobjects, save output */
00022 } J_BUF_MODE;
00023 
00024 /* Values of global_state field (jdapi.c has some dependencies on ordering!) */
00025 #define CSTATE_START    100     /* after create_compress */
00026 #define CSTATE_SCANNING 101     /* start_compress done, write_scanlines OK */
00027 #define CSTATE_RAW_OK   102     /* start_compress done, write_raw_data OK */
00028 #define CSTATE_WRCOEFS  103     /* jpeg_write_coefficients done */
00029 #define DSTATE_START    200     /* after create_decompress */
00030 #define DSTATE_INHEADER 201     /* reading header markers, no SOS yet */
00031 #define DSTATE_READY    202     /* found SOS, ready for start_decompress */
00032 #define DSTATE_PRELOAD  203     /* reading multiscan file in start_decompress*/
00033 #define DSTATE_PRESCAN  204     /* performing dummy pass for 2-pass quant */
00034 #define DSTATE_SCANNING 205     /* start_decompress done, read_scanlines OK */
00035 #define DSTATE_RAW_OK   206     /* start_decompress done, read_raw_data OK */
00036 #define DSTATE_BUFIMAGE 207     /* expecting jpeg_start_output */
00037 #define DSTATE_BUFPOST  208     /* looking for SOS/EOI in jpeg_finish_output */
00038 #define DSTATE_RDCOEFS  209     /* reading file in jpeg_read_coefficients */
00039 #define DSTATE_STOPPING 210     /* looking for EOI in jpeg_finish_decompress */
00040 
00041 
00042 /* Declarations for compression modules */
00043 
00044 /* Master control module */
00045 struct jpeg_comp_master {
00046   JMETHOD(void, prepare_for_pass, (j_compress_ptr cinfo));
00047   JMETHOD(void, pass_startup, (j_compress_ptr cinfo));
00048   JMETHOD(void, finish_pass, (j_compress_ptr cinfo));
00049 
00050   /* State variables made visible to other modules */
00051   boolean call_pass_startup;    /* True if pass_startup must be called */
00052   boolean is_last_pass;         /* True during last pass */
00053 };
00054 
00055 /* Main buffer control (downsampled-data buffer) */
00056 struct jpeg_c_main_controller {
00057   JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode));
00058   JMETHOD(void, process_data, (j_compress_ptr cinfo,
00059                                JSAMPARRAY input_buf, JDIMENSION *in_row_ctr,
00060                                JDIMENSION in_rows_avail));
00061 };
00062 
00063 /* Compression preprocessing (downsampling input buffer control) */
00064 struct jpeg_c_prep_controller {
00065   JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode));
00066   JMETHOD(void, pre_process_data, (j_compress_ptr cinfo,
00067                                    JSAMPARRAY input_buf,
00068                                    JDIMENSION *in_row_ctr,
00069                                    JDIMENSION in_rows_avail,
00070                                    JSAMPIMAGE output_buf,
00071                                    JDIMENSION *out_row_group_ctr,
00072                                    JDIMENSION out_row_groups_avail));
00073 };
00074 
00075 /* Coefficient buffer control */
00076 struct jpeg_c_coef_controller {
00077   JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode));
00078   JMETHOD(boolean, compress_data, (j_compress_ptr cinfo,
00079                                    JSAMPIMAGE input_buf));
00080 };
00081 
00082 /* Colorspace conversion */
00083 struct jpeg_color_converter {
00084   JMETHOD(void, start_pass, (j_compress_ptr cinfo));
00085   JMETHOD(void, color_convert, (j_compress_ptr cinfo,
00086                                 JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
00087                                 JDIMENSION output_row, int num_rows));
00088 };
00089 
00090 /* Downsampling */
00091 struct jpeg_downsampler {
00092   JMETHOD(void, start_pass, (j_compress_ptr cinfo));
00093   JMETHOD(void, downsample, (j_compress_ptr cinfo,
00094                              JSAMPIMAGE input_buf, JDIMENSION in_row_index,
00095                              JSAMPIMAGE output_buf,
00096                              JDIMENSION out_row_group_index));
00097 
00098   boolean need_context_rows;    /* TRUE if need rows above & below */
00099 };
00100 
00101 /* Forward DCT (also controls coefficient quantization) */
00102 struct jpeg_forward_dct {
00103   JMETHOD(void, start_pass, (j_compress_ptr cinfo));
00104   /* perhaps this should be an array??? */
00105   JMETHOD(void, forward_DCT, (j_compress_ptr cinfo,
00106                               jpeg_component_info * compptr,
00107                               JSAMPARRAY sample_data, JBLOCKROW coef_blocks,
00108                               JDIMENSION start_row, JDIMENSION start_col,
00109                               JDIMENSION num_blocks));
00110 };
00111 
00112 /* Entropy encoding */
00113 struct jpeg_entropy_encoder {
00114   JMETHOD(void, start_pass, (j_compress_ptr cinfo, boolean gather_statistics));
00115   JMETHOD(boolean, encode_mcu, (j_compress_ptr cinfo, JBLOCKROW *MCU_data));
00116   JMETHOD(void, finish_pass, (j_compress_ptr cinfo));
00117 };
00118 
00119 /* Marker writing */
00120 struct jpeg_marker_writer {
00121   JMETHOD(void, write_file_header, (j_compress_ptr cinfo));
00122   JMETHOD(void, write_frame_header, (j_compress_ptr cinfo));
00123   JMETHOD(void, write_scan_header, (j_compress_ptr cinfo));
00124   JMETHOD(void, write_file_trailer, (j_compress_ptr cinfo));
00125   JMETHOD(void, write_tables_only, (j_compress_ptr cinfo));
00126   /* These routines are exported to allow insertion of extra markers */
00127   /* Probably only COM and APPn markers should be written this way */
00128   JMETHOD(void, write_marker_header, (j_compress_ptr cinfo, int marker,
00129                                       unsigned int datalen));
00130   JMETHOD(void, write_marker_byte, (j_compress_ptr cinfo, int val));
00131 };
00132 
00133 
00134 /* Declarations for decompression modules */
00135 
00136 /* Master control module */
00137 struct jpeg_decomp_master {
00138   JMETHOD(void, prepare_for_output_pass, (j_decompress_ptr cinfo));
00139   JMETHOD(void, finish_output_pass, (j_decompress_ptr cinfo));
00140 
00141   /* State variables made visible to other modules */
00142   boolean is_dummy_pass;        /* True during 1st pass for 2-pass quant */
00143 };
00144 
00145 /* Input control module */
00146 struct jpeg_input_controller {
00147   JMETHOD(int, consume_input, (j_decompress_ptr cinfo));
00148   JMETHOD(void, reset_input_controller, (j_decompress_ptr cinfo));
00149   JMETHOD(void, start_input_pass, (j_decompress_ptr cinfo));
00150   JMETHOD(void, finish_input_pass, (j_decompress_ptr cinfo));
00151 
00152   /* State variables made visible to other modules */
00153   boolean has_multiple_scans;   /* True if file has multiple scans */
00154   boolean eoi_reached;          /* True when EOI has been consumed */
00155 };
00156 
00157 /* Main buffer control (downsampled-data buffer) */
00158 struct jpeg_d_main_controller {
00159   JMETHOD(void, start_pass, (j_decompress_ptr cinfo, J_BUF_MODE pass_mode));
00160   JMETHOD(void, process_data, (j_decompress_ptr cinfo,
00161                                JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
00162                                JDIMENSION out_rows_avail));
00163 };
00164 
00165 /* Coefficient buffer control */
00166 struct jpeg_d_coef_controller {
00167   JMETHOD(void, start_input_pass, (j_decompress_ptr cinfo));
00168   JMETHOD(int, consume_data, (j_decompress_ptr cinfo));
00169   JMETHOD(void, start_output_pass, (j_decompress_ptr cinfo));
00170   JMETHOD(int, decompress_data, (j_decompress_ptr cinfo,
00171                                  JSAMPIMAGE output_buf));
00172   /* Pointer to array of coefficient virtual arrays, or NULL if none */
00173   jvirt_barray_ptr *coef_arrays;
00174 };
00175 
00176 /* Decompression postprocessing (color quantization buffer control) */
00177 struct jpeg_d_post_controller {
00178   JMETHOD(void, start_pass, (j_decompress_ptr cinfo, J_BUF_MODE pass_mode));
00179   JMETHOD(void, post_process_data, (j_decompress_ptr cinfo,
00180                                     JSAMPIMAGE input_buf,
00181                                     JDIMENSION *in_row_group_ctr,
00182                                     JDIMENSION in_row_groups_avail,
00183                                     JSAMPARRAY output_buf,
00184                                     JDIMENSION *out_row_ctr,
00185                                     JDIMENSION out_rows_avail));
00186 };
00187 
00188 /* Marker reading & parsing */
00189 struct jpeg_marker_reader {
00190   JMETHOD(void, reset_marker_reader, (j_decompress_ptr cinfo));
00191   /* Read markers until SOS or EOI.
00192    * Returns same codes as are defined for jpeg_consume_input:
00193    * JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI.
00194    */
00195   JMETHOD(int, read_markers, (j_decompress_ptr cinfo));
00196   /* Read a restart marker --- exported for use by entropy decoder only */
00197   jpeg_marker_parser_method read_restart_marker;
00198 
00199   /* State of marker reader --- nominally internal, but applications
00200    * supplying COM or APPn handlers might like to know the state.
00201    */
00202   boolean saw_SOI;              /* found SOI? */
00203   boolean saw_SOF;              /* found SOF? */
00204   int next_restart_num;         /* next restart number expected (0-7) */
00205   unsigned int discarded_bytes; /* # of bytes skipped looking for a marker */
00206 };
00207 
00208 /* Entropy decoding */
00209 struct jpeg_entropy_decoder {
00210   JMETHOD(void, start_pass, (j_decompress_ptr cinfo));
00211   JMETHOD(boolean, decode_mcu, (j_decompress_ptr cinfo,
00212                                 JBLOCKROW *MCU_data));
00213 
00214   /* This is here to share code between baseline and progressive decoders; */
00215   /* other modules probably should not use it */
00216   boolean insufficient_data;    /* set TRUE after emitting warning */
00217 };
00218 
00219 /* Inverse DCT (also performs dequantization) */
00220 typedef JMETHOD(void, inverse_DCT_method_ptr,
00221                 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
00222                  JCOEFPTR coef_block,
00223                  JSAMPARRAY output_buf, JDIMENSION output_col));
00224 
00225 struct jpeg_inverse_dct {
00226   JMETHOD(void, start_pass, (j_decompress_ptr cinfo));
00227   /* It is useful to allow each component to have a separate IDCT method. */
00228   inverse_DCT_method_ptr inverse_DCT[MAX_COMPONENTS];
00229 };
00230 
00231 /* Upsampling (note that upsampler must also call color converter) */
00232 struct jpeg_upsampler {
00233   JMETHOD(void, start_pass, (j_decompress_ptr cinfo));
00234   JMETHOD(void, upsample, (j_decompress_ptr cinfo,
00235                            JSAMPIMAGE input_buf,
00236                            JDIMENSION *in_row_group_ctr,
00237                            JDIMENSION in_row_groups_avail,
00238                            JSAMPARRAY output_buf,
00239                            JDIMENSION *out_row_ctr,
00240                            JDIMENSION out_rows_avail));
00241 
00242   boolean need_context_rows;    /* TRUE if need rows above & below */
00243 };
00244 
00245 /* Colorspace conversion */
00246 struct jpeg_color_deconverter {
00247   JMETHOD(void, start_pass, (j_decompress_ptr cinfo));
00248   JMETHOD(void, color_convert, (j_decompress_ptr cinfo,
00249                                 JSAMPIMAGE input_buf, JDIMENSION input_row,
00250                                 JSAMPARRAY output_buf, int num_rows));
00251 };
00252 
00253 /* Color quantization or color precision reduction */
00254 struct jpeg_color_quantizer {
00255   JMETHOD(void, start_pass, (j_decompress_ptr cinfo, boolean is_pre_scan));
00256   JMETHOD(void, color_quantize, (j_decompress_ptr cinfo,
00257                                  JSAMPARRAY input_buf, JSAMPARRAY output_buf,
00258                                  int num_rows));
00259   JMETHOD(void, finish_pass, (j_decompress_ptr cinfo));
00260   JMETHOD(void, new_color_map, (j_decompress_ptr cinfo));
00261 };
00262 
00263 
00264 /* Miscellaneous useful macros */
00265 
00266 #undef MAX
00267 #define MAX(a,b)        ((a) > (b) ? (a) : (b))
00268 #undef MIN
00269 #define MIN(a,b)        ((a) < (b) ? (a) : (b))
00270 
00271 
00272 /* We assume that right shift corresponds to signed division by 2 with
00273  * rounding towards minus infinity.  This is correct for typical "arithmetic
00274  * shift" instructions that shift in copies of the sign bit.  But some
00275  * C compilers implement >> with an unsigned shift.  For these machines you
00276  * must define RIGHT_SHIFT_IS_UNSIGNED.
00277  * RIGHT_SHIFT provides a proper signed right shift of an INT32 quantity.
00278  * It is only applied with constant shift counts.  SHIFT_TEMPS must be
00279  * included in the variables of any routine using RIGHT_SHIFT.
00280  */
00281 
00282 #ifdef RIGHT_SHIFT_IS_UNSIGNED
00283 #define SHIFT_TEMPS     INT32 shift_temp;
00284 #define RIGHT_SHIFT(x,shft)  \
00285         ((shift_temp = (x)) < 0 ? \
00286          (shift_temp >> (shft)) | ((~((INT32) 0)) << (32-(shft))) : \
00287          (shift_temp >> (shft)))
00288 #else
00289 #define SHIFT_TEMPS
00290 #define RIGHT_SHIFT(x,shft)     ((x) >> (shft))
00291 #endif
00292 
00293 
00294 /* Short forms of external names for systems with brain-damaged linkers. */
00295 
00296 #ifdef NEED_SHORT_EXTERNAL_NAMES
00297 #define jinit_compress_master   jICompress
00298 #define jinit_c_master_control  jICMaster
00299 #define jinit_c_main_controller jICMainC
00300 #define jinit_c_prep_controller jICPrepC
00301 #define jinit_c_coef_controller jICCoefC
00302 #define jinit_color_converter   jICColor
00303 #define jinit_downsampler       jIDownsampler
00304 #define jinit_forward_dct       jIFDCT
00305 #define jinit_huff_encoder      jIHEncoder
00306 #define jinit_phuff_encoder     jIPHEncoder
00307 #define jinit_marker_writer     jIMWriter
00308 #define jinit_master_decompress jIDMaster
00309 #define jinit_d_main_controller jIDMainC
00310 #define jinit_d_coef_controller jIDCoefC
00311 #define jinit_d_post_controller jIDPostC
00312 #define jinit_input_controller  jIInCtlr
00313 #define jinit_marker_reader     jIMReader
00314 #define jinit_huff_decoder      jIHDecoder
00315 #define jinit_phuff_decoder     jIPHDecoder
00316 #define jinit_inverse_dct       jIIDCT
00317 #define jinit_upsampler         jIUpsampler
00318 #define jinit_color_deconverter jIDColor
00319 #define jinit_1pass_quantizer   jI1Quant
00320 #define jinit_2pass_quantizer   jI2Quant
00321 #define jinit_merged_upsampler  jIMUpsampler
00322 #define jinit_memory_mgr        jIMemMgr
00323 #define jdiv_round_up           jDivRound
00324 #define jround_up               jRound
00325 #define jcopy_sample_rows       jCopySamples
00326 #define jcopy_block_row         jCopyBlocks
00327 #define jzero_far               jZeroFar
00328 #define jpeg_zigzag_order       jZIGTable
00329 #define jpeg_natural_order      jZAGTable
00330 #endif /* NEED_SHORT_EXTERNAL_NAMES */
00331 
00332 
00333 /* Compression module initialization routines */
00334 EXTERN(void) jinit_compress_master JPP((j_compress_ptr cinfo));
00335 EXTERN(void) jinit_c_master_control JPP((j_compress_ptr cinfo,
00336                                          boolean transcode_only));
00337 EXTERN(void) jinit_c_main_controller JPP((j_compress_ptr cinfo,
00338                                           boolean need_full_buffer));
00339 EXTERN(void) jinit_c_prep_controller JPP((j_compress_ptr cinfo,
00340                                           boolean need_full_buffer));
00341 EXTERN(void) jinit_c_coef_controller JPP((j_compress_ptr cinfo,
00342                                           boolean need_full_buffer));
00343 EXTERN(void) jinit_color_converter JPP((j_compress_ptr cinfo));
00344 EXTERN(void) jinit_downsampler JPP((j_compress_ptr cinfo));
00345 EXTERN(void) jinit_forward_dct JPP((j_compress_ptr cinfo));
00346 EXTERN(void) jinit_huff_encoder JPP((j_compress_ptr cinfo));
00347 EXTERN(void) jinit_phuff_encoder JPP((j_compress_ptr cinfo));
00348 EXTERN(void) jinit_marker_writer JPP((j_compress_ptr cinfo));
00349 /* Decompression module initialization routines */
00350 EXTERN(void) jinit_master_decompress JPP((j_decompress_ptr cinfo));
00351 EXTERN(void) jinit_d_main_controller JPP((j_decompress_ptr cinfo,
00352                                           boolean need_full_buffer));
00353 EXTERN(void) jinit_d_coef_controller JPP((j_decompress_ptr cinfo,
00354                                           boolean need_full_buffer));
00355 EXTERN(void) jinit_d_post_controller JPP((j_decompress_ptr cinfo,
00356                                           boolean need_full_buffer));
00357 EXTERN(void) jinit_input_controller JPP((j_decompress_ptr cinfo));
00358 EXTERN(void) jinit_marker_reader JPP((j_decompress_ptr cinfo));
00359 EXTERN(void) jinit_huff_decoder JPP((j_decompress_ptr cinfo));
00360 EXTERN(void) jinit_phuff_decoder JPP((j_decompress_ptr cinfo));
00361 EXTERN(void) jinit_inverse_dct JPP((j_decompress_ptr cinfo));
00362 EXTERN(void) jinit_upsampler JPP((j_decompress_ptr cinfo));
00363 EXTERN(void) jinit_color_deconverter JPP((j_decompress_ptr cinfo));
00364 EXTERN(void) jinit_1pass_quantizer JPP((j_decompress_ptr cinfo));
00365 EXTERN(void) jinit_2pass_quantizer JPP((j_decompress_ptr cinfo));
00366 EXTERN(void) jinit_merged_upsampler JPP((j_decompress_ptr cinfo));
00367 /* Memory manager initialization */
00368 EXTERN(void) jinit_memory_mgr JPP((j_common_ptr cinfo));
00369 
00370 /* Utility routines in jutils.c */
00371 EXTERN(long) jdiv_round_up JPP((long a, long b));
00372 EXTERN(long) jround_up JPP((long a, long b));
00373 EXTERN(void) jcopy_sample_rows JPP((JSAMPARRAY input_array, int source_row,
00374                                     JSAMPARRAY output_array, int dest_row,
00375                                     int num_rows, JDIMENSION num_cols));
00376 EXTERN(void) jcopy_block_row JPP((JBLOCKROW input_row, JBLOCKROW output_row,
00377                                   JDIMENSION num_blocks));
00378 EXTERN(void) jzero_far JPP((void FAR * target, size_t bytestozero));
00379 /* Constant tables in jutils.c */
00380 #if 0                           /* This table is not actually needed in v6a */
00381 extern const int jpeg_zigzag_order[]; /* natural coef order to zigzag order */
00382 #endif
00383 extern const int jpeg_natural_order[]; /* zigzag coef order to natural order */
00384 
00385 /* Suppress undefined-structure complaints if necessary. */
00386 
00387 #ifdef INCOMPLETE_TYPES_BROKEN
00388 #ifndef AM_MEMORY_MANAGER       /* only jmemmgr.c defines these */
00389 struct jvirt_sarray_control { long dummy; };
00390 struct jvirt_barray_control { long dummy; };
00391 #endif
00392 #endif /* INCOMPLETE_TYPES_BROKEN */


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Sun Apr 2 2017 03:43:55