blob: cc0d60016a470229b813ac210c2c6a2ef9844118 [file] [log] [blame]
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +00001/*
2 * cdjpeg.h
3 *
Thomas G. Lane489583f1996-02-07 00:00:00 +00004 * Copyright (C) 1994-1996, Thomas G. Lane.
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +00005 * This file is part of the Independent JPEG Group's software.
6 * For conditions of distribution and use, see the accompanying README file.
7 *
8 * This file contains common declarations for the sample applications
9 * cjpeg and djpeg. It is NOT used by the core JPEG library.
10 */
11
12#define JPEG_CJPEG_DJPEG /* define proper options in jconfig.h */
13#define JPEG_INTERNAL_OPTIONS /* cjpeg.c,djpeg.c need to see xxx_SUPPORTED */
14#include "jinclude.h"
15#include "jpeglib.h"
16#include "jerror.h" /* get library error codes too */
17#include "cderror.h" /* get application-specific error codes */
18
19
20/*
21 * Object interface for cjpeg's source file decoding modules
22 */
23
24typedef struct cjpeg_source_struct * cjpeg_source_ptr;
25
26struct cjpeg_source_struct {
27 JMETHOD(void, start_input, (j_compress_ptr cinfo,
28 cjpeg_source_ptr sinfo));
29 JMETHOD(JDIMENSION, get_pixel_rows, (j_compress_ptr cinfo,
30 cjpeg_source_ptr sinfo));
31 JMETHOD(void, finish_input, (j_compress_ptr cinfo,
32 cjpeg_source_ptr sinfo));
33
34 FILE *input_file;
35
36 JSAMPARRAY buffer;
37 JDIMENSION buffer_height;
38};
39
40
41/*
42 * Object interface for djpeg's output file encoding modules
43 */
44
45typedef struct djpeg_dest_struct * djpeg_dest_ptr;
46
47struct djpeg_dest_struct {
48 /* start_output is called after jpeg_start_decompress finishes.
49 * The color map will be ready at this time, if one is needed.
50 */
51 JMETHOD(void, start_output, (j_decompress_ptr cinfo,
52 djpeg_dest_ptr dinfo));
53 /* Emit the specified number of pixel rows from the buffer. */
54 JMETHOD(void, put_pixel_rows, (j_decompress_ptr cinfo,
55 djpeg_dest_ptr dinfo,
56 JDIMENSION rows_supplied));
57 /* Finish up at the end of the image. */
58 JMETHOD(void, finish_output, (j_decompress_ptr cinfo,
59 djpeg_dest_ptr dinfo));
60
61 /* Target file spec; filled in by djpeg.c after object is created. */
62 FILE * output_file;
63
64 /* Output pixel-row buffer. Created by module init or start_output.
65 * Width is cinfo->output_width * cinfo->output_components;
66 * height is buffer_height.
67 */
68 JSAMPARRAY buffer;
69 JDIMENSION buffer_height;
70};
71
72
73/*
74 * cjpeg/djpeg may need to perform extra passes to convert to or from
75 * the source/destination file format. The JPEG library does not know
76 * about these passes, but we'd like them to be counted by the progress
77 * monitor. We use an expanded progress monitor object to hold the
78 * additional pass count.
79 */
80
81struct cdjpeg_progress_mgr {
82 struct jpeg_progress_mgr pub; /* fields known to JPEG library */
83 int completed_extra_passes; /* extra passes completed */
84 int total_extra_passes; /* total extra */
85 /* last printed percentage stored here to avoid multiple printouts */
86 int percent_done;
87};
88
89typedef struct cdjpeg_progress_mgr * cd_progress_ptr;
90
91
92/* Short forms of external names for systems with brain-damaged linkers. */
93
94#ifdef NEED_SHORT_EXTERNAL_NAMES
95#define jinit_read_bmp jIRdBMP
96#define jinit_write_bmp jIWrBMP
97#define jinit_read_gif jIRdGIF
98#define jinit_write_gif jIWrGIF
99#define jinit_read_ppm jIRdPPM
100#define jinit_write_ppm jIWrPPM
101#define jinit_read_rle jIRdRLE
102#define jinit_write_rle jIWrRLE
103#define jinit_read_targa jIRdTarga
104#define jinit_write_targa jIWrTarga
Thomas G. Lanebc79e061995-08-02 00:00:00 +0000105#define read_quant_tables RdQTables
106#define read_scan_script RdScnScript
107#define set_quant_slots SetQSlots
108#define set_sample_factors SetSFacts
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +0000109#define read_color_map RdCMap
Thomas G. Lanebc79e061995-08-02 00:00:00 +0000110#define enable_signal_catcher EnSigCatcher
111#define start_progress_monitor StProgMon
112#define end_progress_monitor EnProgMon
113#define read_stdin RdStdin
114#define write_stdout WrStdout
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +0000115#endif /* NEED_SHORT_EXTERNAL_NAMES */
116
117/* Module selection routines for I/O modules. */
118
Thomas G. Lane489583f1996-02-07 00:00:00 +0000119EXTERN(cjpeg_source_ptr) jinit_read_bmp JPP((j_compress_ptr cinfo));
120EXTERN(djpeg_dest_ptr) jinit_write_bmp JPP((j_decompress_ptr cinfo,
121 boolean is_os2));
122EXTERN(cjpeg_source_ptr) jinit_read_gif JPP((j_compress_ptr cinfo));
123EXTERN(djpeg_dest_ptr) jinit_write_gif JPP((j_decompress_ptr cinfo));
124EXTERN(cjpeg_source_ptr) jinit_read_ppm JPP((j_compress_ptr cinfo));
125EXTERN(djpeg_dest_ptr) jinit_write_ppm JPP((j_decompress_ptr cinfo));
126EXTERN(cjpeg_source_ptr) jinit_read_rle JPP((j_compress_ptr cinfo));
127EXTERN(djpeg_dest_ptr) jinit_write_rle JPP((j_decompress_ptr cinfo));
128EXTERN(cjpeg_source_ptr) jinit_read_targa JPP((j_compress_ptr cinfo));
129EXTERN(djpeg_dest_ptr) jinit_write_targa JPP((j_decompress_ptr cinfo));
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +0000130
Thomas G. Lanebc79e061995-08-02 00:00:00 +0000131/* cjpeg support routines (in rdswitch.c) */
132
Thomas G. Lane489583f1996-02-07 00:00:00 +0000133EXTERN(boolean) read_quant_tables JPP((j_compress_ptr cinfo, char * filename,
134 int scale_factor, boolean force_baseline));
135EXTERN(boolean) read_scan_script JPP((j_compress_ptr cinfo, char * filename));
136EXTERN(boolean) set_quant_slots JPP((j_compress_ptr cinfo, char *arg));
137EXTERN(boolean) set_sample_factors JPP((j_compress_ptr cinfo, char *arg));
Thomas G. Lanebc79e061995-08-02 00:00:00 +0000138
139/* djpeg support routines (in rdcolmap.c) */
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +0000140
Thomas G. Lane489583f1996-02-07 00:00:00 +0000141EXTERN(void) read_color_map JPP((j_decompress_ptr cinfo, FILE * infile));
Thomas G. Lanebc79e061995-08-02 00:00:00 +0000142
143/* common support routines (in cdjpeg.c) */
144
Thomas G. Lane489583f1996-02-07 00:00:00 +0000145EXTERN(void) enable_signal_catcher JPP((j_common_ptr cinfo));
146EXTERN(void) start_progress_monitor JPP((j_common_ptr cinfo,
147 cd_progress_ptr progress));
148EXTERN(void) end_progress_monitor JPP((j_common_ptr cinfo));
149EXTERN(boolean) keymatch JPP((char * arg, const char * keyword, int minchars));
150EXTERN(FILE *) read_stdin JPP((void));
151EXTERN(FILE *) write_stdout JPP((void));
Thomas G. Lanebc79e061995-08-02 00:00:00 +0000152
153/* miscellaneous useful macros */
154
155#ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */
156#define READ_BINARY "r"
157#define WRITE_BINARY "w"
158#else
159#define READ_BINARY "rb"
160#define WRITE_BINARY "wb"
161#endif
162
163#ifndef EXIT_FAILURE /* define exit() codes if not provided */
164#define EXIT_FAILURE 1
165#endif
166#ifndef EXIT_SUCCESS
167#ifdef VMS
168#define EXIT_SUCCESS 1 /* VMS is very nonstandard */
169#else
170#define EXIT_SUCCESS 0
171#endif
172#endif
173#ifndef EXIT_WARNING
174#ifdef VMS
175#define EXIT_WARNING 1 /* VMS is very nonstandard */
176#else
177#define EXIT_WARNING 2
178#endif
179#endif