Back to index

lightning-sunbird  0.9+nobinonly
cdjpeg.h
Go to the documentation of this file.
00001 /*
00002  * cdjpeg.h
00003  *
00004  * Copyright (C) 1994-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 contains common declarations for the sample applications
00009  * cjpeg and djpeg.  It is NOT used by the core JPEG library.
00010  */
00011 
00012 #define JPEG_CJPEG_DJPEG    /* define proper options in jconfig.h */
00013 #define JPEG_INTERNAL_OPTIONS      /* cjpeg.c,djpeg.c need to see xxx_SUPPORTED */
00014 #include "jinclude.h"
00015 #include "jpeglib.h"
00016 #include "jerror.h"         /* get library error codes too */
00017 #include "cderror.h"        /* get application-specific error codes */
00018 
00019 
00020 /*
00021  * Object interface for cjpeg's source file decoding modules
00022  */
00023 
00024 typedef struct cjpeg_source_struct * cjpeg_source_ptr;
00025 
00026 struct cjpeg_source_struct {
00027   JMETHOD(void, start_input, (j_compress_ptr cinfo,
00028                            cjpeg_source_ptr sinfo));
00029   JMETHOD(JDIMENSION, get_pixel_rows, (j_compress_ptr cinfo,
00030                                    cjpeg_source_ptr sinfo));
00031   JMETHOD(void, finish_input, (j_compress_ptr cinfo,
00032                             cjpeg_source_ptr sinfo));
00033 
00034   FILE *input_file;
00035 
00036   JSAMPARRAY buffer;
00037   JDIMENSION buffer_height;
00038 };
00039 
00040 
00041 /*
00042  * Object interface for djpeg's output file encoding modules
00043  */
00044 
00045 typedef struct djpeg_dest_struct * djpeg_dest_ptr;
00046 
00047 struct djpeg_dest_struct {
00048   /* start_output is called after jpeg_start_decompress finishes.
00049    * The color map will be ready at this time, if one is needed.
00050    */
00051   JMETHOD(void, start_output, (j_decompress_ptr cinfo,
00052                             djpeg_dest_ptr dinfo));
00053   /* Emit the specified number of pixel rows from the buffer. */
00054   JMETHOD(void, put_pixel_rows, (j_decompress_ptr cinfo,
00055                              djpeg_dest_ptr dinfo,
00056                              JDIMENSION rows_supplied));
00057   /* Finish up at the end of the image. */
00058   JMETHOD(void, finish_output, (j_decompress_ptr cinfo,
00059                             djpeg_dest_ptr dinfo));
00060 
00061   /* Target file spec; filled in by djpeg.c after object is created. */
00062   FILE * output_file;
00063 
00064   /* Output pixel-row buffer.  Created by module init or start_output.
00065    * Width is cinfo->output_width * cinfo->output_components;
00066    * height is buffer_height.
00067    */
00068   JSAMPARRAY buffer;
00069   JDIMENSION buffer_height;
00070 };
00071 
00072 
00073 /*
00074  * cjpeg/djpeg may need to perform extra passes to convert to or from
00075  * the source/destination file format.  The JPEG library does not know
00076  * about these passes, but we'd like them to be counted by the progress
00077  * monitor.  We use an expanded progress monitor object to hold the
00078  * additional pass count.
00079  */
00080 
00081 struct cdjpeg_progress_mgr {
00082   struct jpeg_progress_mgr pub;    /* fields known to JPEG library */
00083   int completed_extra_passes;      /* extra passes completed */
00084   int total_extra_passes;   /* total extra */
00085   /* last printed percentage stored here to avoid multiple printouts */
00086   int percent_done;
00087 };
00088 
00089 typedef struct cdjpeg_progress_mgr * cd_progress_ptr;
00090 
00091 
00092 /* Short forms of external names for systems with brain-damaged linkers. */
00093 
00094 #ifdef NEED_SHORT_EXTERNAL_NAMES
00095 #define jinit_read_bmp             jIRdBMP
00096 #define jinit_write_bmp            jIWrBMP
00097 #define jinit_read_gif             jIRdGIF
00098 #define jinit_write_gif            jIWrGIF
00099 #define jinit_read_ppm             jIRdPPM
00100 #define jinit_write_ppm            jIWrPPM
00101 #define jinit_read_rle             jIRdRLE
00102 #define jinit_write_rle            jIWrRLE
00103 #define jinit_read_targa    jIRdTarga
00104 #define jinit_write_targa   jIWrTarga
00105 #define read_quant_tables   RdQTables
00106 #define read_scan_script    RdScnScript
00107 #define set_quant_slots            SetQSlots
00108 #define set_sample_factors  SetSFacts
00109 #define read_color_map             RdCMap
00110 #define enable_signal_catcher      EnSigCatcher
00111 #define start_progress_monitor     StProgMon
00112 #define end_progress_monitor       EnProgMon
00113 #define read_stdin          RdStdin
00114 #define write_stdout        WrStdout
00115 #endif /* NEED_SHORT_EXTERNAL_NAMES */
00116 
00117 /* Module selection routines for I/O modules. */
00118 
00119 EXTERN(cjpeg_source_ptr) jinit_read_bmp JPP((j_compress_ptr cinfo));
00120 EXTERN(djpeg_dest_ptr) jinit_write_bmp JPP((j_decompress_ptr cinfo,
00121                                        boolean is_os2));
00122 EXTERN(cjpeg_source_ptr) jinit_read_gif JPP((j_compress_ptr cinfo));
00123 EXTERN(djpeg_dest_ptr) jinit_write_gif JPP((j_decompress_ptr cinfo));
00124 EXTERN(cjpeg_source_ptr) jinit_read_ppm JPP((j_compress_ptr cinfo));
00125 EXTERN(djpeg_dest_ptr) jinit_write_ppm JPP((j_decompress_ptr cinfo));
00126 EXTERN(cjpeg_source_ptr) jinit_read_rle JPP((j_compress_ptr cinfo));
00127 EXTERN(djpeg_dest_ptr) jinit_write_rle JPP((j_decompress_ptr cinfo));
00128 EXTERN(cjpeg_source_ptr) jinit_read_targa JPP((j_compress_ptr cinfo));
00129 EXTERN(djpeg_dest_ptr) jinit_write_targa JPP((j_decompress_ptr cinfo));
00130 
00131 /* cjpeg support routines (in rdswitch.c) */
00132 
00133 EXTERN(boolean) read_quant_tables JPP((j_compress_ptr cinfo, char * filename,
00134                                 int scale_factor, boolean force_baseline));
00135 EXTERN(boolean) read_scan_script JPP((j_compress_ptr cinfo, char * filename));
00136 EXTERN(boolean) set_quant_slots JPP((j_compress_ptr cinfo, char *arg));
00137 EXTERN(boolean) set_sample_factors JPP((j_compress_ptr cinfo, char *arg));
00138 
00139 /* djpeg support routines (in rdcolmap.c) */
00140 
00141 EXTERN(void) read_color_map JPP((j_decompress_ptr cinfo, FILE * infile));
00142 
00143 /* common support routines (in cdjpeg.c) */
00144 
00145 EXTERN(void) enable_signal_catcher JPP((j_common_ptr cinfo));
00146 EXTERN(void) start_progress_monitor JPP((j_common_ptr cinfo,
00147                                     cd_progress_ptr progress));
00148 EXTERN(void) end_progress_monitor JPP((j_common_ptr cinfo));
00149 EXTERN(boolean) keymatch JPP((char * arg, const char * keyword, int minchars));
00150 EXTERN(FILE *) read_stdin JPP((void));
00151 EXTERN(FILE *) write_stdout JPP((void));
00152 
00153 /* miscellaneous useful macros */
00154 
00155 #ifdef DONT_USE_B_MODE             /* define mode parameters for fopen() */
00156 #define READ_BINARY  "r"
00157 #define WRITE_BINARY "w"
00158 #else
00159 #ifdef VMS                  /* VMS is very nonstandard */
00160 #define READ_BINARY  "rb", "ctx=stm"
00161 #define WRITE_BINARY "wb", "ctx=stm"
00162 #else                       /* standard ANSI-compliant case */
00163 #define READ_BINARY  "rb"
00164 #define WRITE_BINARY "wb"
00165 #endif
00166 #endif
00167 
00168 #ifndef EXIT_FAILURE        /* define exit() codes if not provided */
00169 #define EXIT_FAILURE  1
00170 #endif
00171 #ifndef EXIT_SUCCESS
00172 #ifdef VMS
00173 #define EXIT_SUCCESS  1            /* VMS is very nonstandard */
00174 #else
00175 #define EXIT_SUCCESS  0
00176 #endif
00177 #endif
00178 #ifndef EXIT_WARNING
00179 #ifdef VMS
00180 #define EXIT_WARNING  1            /* VMS is very nonstandard */
00181 #else
00182 #define EXIT_WARNING  2
00183 #endif
00184 #endif