Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 1 | /* |
| 2 | * cdjpeg.h |
| 3 | * |
DRC | 5033f3e | 2014-05-18 18:33:44 +0000 | [diff] [blame] | 4 | * This file was part of the Independent JPEG Group's software: |
Thomas G. Lane | 5ead57a | 1998-03-27 00:00:00 +0000 | [diff] [blame] | 5 | * Copyright (C) 1994-1997, Thomas G. Lane. |
DRC | 5033f3e | 2014-05-18 18:33:44 +0000 | [diff] [blame] | 6 | * It was modified by The libjpeg-turbo Project to include only code relevant |
| 7 | * to libjpeg-turbo. |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 8 | * For conditions of distribution and use, see the accompanying README file. |
| 9 | * |
| 10 | * This file contains common declarations for the sample applications |
| 11 | * cjpeg and djpeg. It is NOT used by the core JPEG library. |
| 12 | */ |
| 13 | |
DRC | e5eaf37 | 2014-05-09 18:00:32 +0000 | [diff] [blame] | 14 | #define JPEG_CJPEG_DJPEG /* define proper options in jconfig.h */ |
| 15 | #define JPEG_INTERNAL_OPTIONS /* cjpeg.c,djpeg.c need to see xxx_SUPPORTED */ |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 16 | #include "jinclude.h" |
| 17 | #include "jpeglib.h" |
DRC | e5eaf37 | 2014-05-09 18:00:32 +0000 | [diff] [blame] | 18 | #include "jerror.h" /* get library error codes too */ |
| 19 | #include "cderror.h" /* get application-specific error codes */ |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 20 | |
| 21 | |
| 22 | /* |
| 23 | * Object interface for cjpeg's source file decoding modules |
| 24 | */ |
| 25 | |
| 26 | typedef struct cjpeg_source_struct * cjpeg_source_ptr; |
| 27 | |
| 28 | struct cjpeg_source_struct { |
DRC | bc56b75 | 2014-05-16 10:43:44 +0000 | [diff] [blame] | 29 | void (*start_input) (j_compress_ptr cinfo, cjpeg_source_ptr sinfo); |
| 30 | JDIMENSION (*get_pixel_rows) (j_compress_ptr cinfo, cjpeg_source_ptr sinfo); |
| 31 | void (*finish_input) (j_compress_ptr cinfo, cjpeg_source_ptr sinfo); |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 32 | |
| 33 | FILE *input_file; |
| 34 | |
| 35 | JSAMPARRAY buffer; |
| 36 | JDIMENSION buffer_height; |
| 37 | }; |
| 38 | |
| 39 | |
| 40 | /* |
| 41 | * Object interface for djpeg's output file encoding modules |
| 42 | */ |
| 43 | |
| 44 | typedef struct djpeg_dest_struct * djpeg_dest_ptr; |
| 45 | |
| 46 | struct djpeg_dest_struct { |
| 47 | /* start_output is called after jpeg_start_decompress finishes. |
| 48 | * The color map will be ready at this time, if one is needed. |
| 49 | */ |
DRC | bc56b75 | 2014-05-16 10:43:44 +0000 | [diff] [blame] | 50 | void (*start_output) (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo); |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 51 | /* Emit the specified number of pixel rows from the buffer. */ |
DRC | bc56b75 | 2014-05-16 10:43:44 +0000 | [diff] [blame] | 52 | void (*put_pixel_rows) (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, |
| 53 | JDIMENSION rows_supplied); |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 54 | /* Finish up at the end of the image. */ |
DRC | bc56b75 | 2014-05-16 10:43:44 +0000 | [diff] [blame] | 55 | void (*finish_output) (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo); |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 56 | |
| 57 | /* Target file spec; filled in by djpeg.c after object is created. */ |
| 58 | FILE * output_file; |
| 59 | |
| 60 | /* Output pixel-row buffer. Created by module init or start_output. |
| 61 | * Width is cinfo->output_width * cinfo->output_components; |
| 62 | * height is buffer_height. |
| 63 | */ |
| 64 | JSAMPARRAY buffer; |
| 65 | JDIMENSION buffer_height; |
| 66 | }; |
| 67 | |
| 68 | |
| 69 | /* |
| 70 | * cjpeg/djpeg may need to perform extra passes to convert to or from |
| 71 | * the source/destination file format. The JPEG library does not know |
| 72 | * about these passes, but we'd like them to be counted by the progress |
| 73 | * monitor. We use an expanded progress monitor object to hold the |
| 74 | * additional pass count. |
| 75 | */ |
| 76 | |
| 77 | struct cdjpeg_progress_mgr { |
DRC | e5eaf37 | 2014-05-09 18:00:32 +0000 | [diff] [blame] | 78 | struct jpeg_progress_mgr pub; /* fields known to JPEG library */ |
| 79 | int completed_extra_passes; /* extra passes completed */ |
| 80 | int total_extra_passes; /* total extra */ |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 81 | /* last printed percentage stored here to avoid multiple printouts */ |
| 82 | int percent_done; |
| 83 | }; |
| 84 | |
| 85 | typedef struct cdjpeg_progress_mgr * cd_progress_ptr; |
| 86 | |
| 87 | |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 88 | /* Module selection routines for I/O modules. */ |
| 89 | |
DRC | bc56b75 | 2014-05-16 10:43:44 +0000 | [diff] [blame] | 90 | EXTERN(cjpeg_source_ptr) jinit_read_bmp (j_compress_ptr cinfo); |
| 91 | EXTERN(djpeg_dest_ptr) jinit_write_bmp (j_decompress_ptr cinfo, |
| 92 | boolean is_os2); |
| 93 | EXTERN(cjpeg_source_ptr) jinit_read_gif (j_compress_ptr cinfo); |
| 94 | EXTERN(djpeg_dest_ptr) jinit_write_gif (j_decompress_ptr cinfo); |
| 95 | EXTERN(cjpeg_source_ptr) jinit_read_ppm (j_compress_ptr cinfo); |
| 96 | EXTERN(djpeg_dest_ptr) jinit_write_ppm (j_decompress_ptr cinfo); |
| 97 | EXTERN(cjpeg_source_ptr) jinit_read_rle (j_compress_ptr cinfo); |
| 98 | EXTERN(djpeg_dest_ptr) jinit_write_rle (j_decompress_ptr cinfo); |
| 99 | EXTERN(cjpeg_source_ptr) jinit_read_targa (j_compress_ptr cinfo); |
| 100 | EXTERN(djpeg_dest_ptr) jinit_write_targa (j_decompress_ptr cinfo); |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 101 | |
Thomas G. Lane | bc79e06 | 1995-08-02 00:00:00 +0000 | [diff] [blame] | 102 | /* cjpeg support routines (in rdswitch.c) */ |
| 103 | |
DRC | bc56b75 | 2014-05-16 10:43:44 +0000 | [diff] [blame] | 104 | EXTERN(boolean) read_quant_tables (j_compress_ptr cinfo, char * filename, |
| 105 | boolean force_baseline); |
| 106 | EXTERN(boolean) read_scan_script (j_compress_ptr cinfo, char * filename); |
| 107 | EXTERN(boolean) set_quality_ratings (j_compress_ptr cinfo, char *arg, |
| 108 | boolean force_baseline); |
| 109 | EXTERN(boolean) set_quant_slots (j_compress_ptr cinfo, char *arg); |
| 110 | EXTERN(boolean) set_sample_factors (j_compress_ptr cinfo, char *arg); |
Thomas G. Lane | bc79e06 | 1995-08-02 00:00:00 +0000 | [diff] [blame] | 111 | |
| 112 | /* djpeg support routines (in rdcolmap.c) */ |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 113 | |
DRC | bc56b75 | 2014-05-16 10:43:44 +0000 | [diff] [blame] | 114 | EXTERN(void) read_color_map (j_decompress_ptr cinfo, FILE * infile); |
Thomas G. Lane | bc79e06 | 1995-08-02 00:00:00 +0000 | [diff] [blame] | 115 | |
| 116 | /* common support routines (in cdjpeg.c) */ |
| 117 | |
DRC | bc56b75 | 2014-05-16 10:43:44 +0000 | [diff] [blame] | 118 | EXTERN(void) enable_signal_catcher (j_common_ptr cinfo); |
| 119 | EXTERN(void) start_progress_monitor (j_common_ptr cinfo, |
| 120 | cd_progress_ptr progress); |
| 121 | EXTERN(void) end_progress_monitor (j_common_ptr cinfo); |
| 122 | EXTERN(boolean) keymatch (char * arg, const char * keyword, int minchars); |
| 123 | EXTERN(FILE *) read_stdin (void); |
| 124 | EXTERN(FILE *) write_stdout (void); |
Thomas G. Lane | bc79e06 | 1995-08-02 00:00:00 +0000 | [diff] [blame] | 125 | |
| 126 | /* miscellaneous useful macros */ |
| 127 | |
DRC | e5eaf37 | 2014-05-09 18:00:32 +0000 | [diff] [blame] | 128 | #ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */ |
| 129 | #define READ_BINARY "r" |
| 130 | #define WRITE_BINARY "w" |
Thomas G. Lane | bc79e06 | 1995-08-02 00:00:00 +0000 | [diff] [blame] | 131 | #else |
DRC | e5eaf37 | 2014-05-09 18:00:32 +0000 | [diff] [blame] | 132 | #ifdef VMS /* VMS is very nonstandard */ |
| 133 | #define READ_BINARY "rb", "ctx=stm" |
| 134 | #define WRITE_BINARY "wb", "ctx=stm" |
| 135 | #else /* standard ANSI-compliant case */ |
| 136 | #define READ_BINARY "rb" |
| 137 | #define WRITE_BINARY "wb" |
Thomas G. Lane | bc79e06 | 1995-08-02 00:00:00 +0000 | [diff] [blame] | 138 | #endif |
Thomas G. Lane | 5ead57a | 1998-03-27 00:00:00 +0000 | [diff] [blame] | 139 | #endif |
Thomas G. Lane | bc79e06 | 1995-08-02 00:00:00 +0000 | [diff] [blame] | 140 | |
DRC | e5eaf37 | 2014-05-09 18:00:32 +0000 | [diff] [blame] | 141 | #ifndef EXIT_FAILURE /* define exit() codes if not provided */ |
Thomas G. Lane | bc79e06 | 1995-08-02 00:00:00 +0000 | [diff] [blame] | 142 | #define EXIT_FAILURE 1 |
| 143 | #endif |
| 144 | #ifndef EXIT_SUCCESS |
| 145 | #ifdef VMS |
DRC | e5eaf37 | 2014-05-09 18:00:32 +0000 | [diff] [blame] | 146 | #define EXIT_SUCCESS 1 /* VMS is very nonstandard */ |
Thomas G. Lane | bc79e06 | 1995-08-02 00:00:00 +0000 | [diff] [blame] | 147 | #else |
| 148 | #define EXIT_SUCCESS 0 |
| 149 | #endif |
| 150 | #endif |
| 151 | #ifndef EXIT_WARNING |
| 152 | #ifdef VMS |
DRC | e5eaf37 | 2014-05-09 18:00:32 +0000 | [diff] [blame] | 153 | #define EXIT_WARNING 1 /* VMS is very nonstandard */ |
Thomas G. Lane | bc79e06 | 1995-08-02 00:00:00 +0000 | [diff] [blame] | 154 | #else |
| 155 | #define EXIT_WARNING 2 |
| 156 | #endif |
| 157 | #endif |