Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/thirdparty/libjpeg-turbo/src/cdjpeg.h
9904 views
1
/*
2
* cdjpeg.h
3
*
4
* This file was part of the Independent JPEG Group's software:
5
* Copyright (C) 1994-1997, Thomas G. Lane.
6
* Modified 2019 by Guido Vollbeding.
7
* libjpeg-turbo Modifications:
8
* Copyright (C) 2017, 2019, 2021-2022, D. R. Commander.
9
* For conditions of distribution and use, see the accompanying README.ijg
10
* file.
11
*
12
* This file contains common declarations for the sample applications
13
* cjpeg and djpeg. It is NOT used by the core JPEG library.
14
*/
15
16
#define JPEG_CJPEG_DJPEG /* define proper options in jconfig.h */
17
#define JPEG_INTERNAL_OPTIONS /* cjpeg.c,djpeg.c need to see xxx_SUPPORTED */
18
#include "jinclude.h"
19
#include "jpeglib.h"
20
#include "jerror.h" /* get library error codes too */
21
#include "cderror.h" /* get application-specific error codes */
22
23
24
/*
25
* Object interface for cjpeg's source file decoding modules
26
*/
27
28
typedef struct cjpeg_source_struct *cjpeg_source_ptr;
29
30
struct cjpeg_source_struct {
31
void (*start_input) (j_compress_ptr cinfo, cjpeg_source_ptr sinfo);
32
JDIMENSION (*get_pixel_rows) (j_compress_ptr cinfo, cjpeg_source_ptr sinfo);
33
void (*finish_input) (j_compress_ptr cinfo, cjpeg_source_ptr sinfo);
34
35
FILE *input_file;
36
37
JSAMPARRAY buffer;
38
J12SAMPARRAY buffer12;
39
#ifdef C_LOSSLESS_SUPPORTED
40
J16SAMPARRAY buffer16;
41
#endif
42
JDIMENSION buffer_height;
43
JDIMENSION max_pixels;
44
};
45
46
47
/*
48
* Object interface for djpeg's output file encoding modules
49
*/
50
51
typedef struct djpeg_dest_struct *djpeg_dest_ptr;
52
53
struct djpeg_dest_struct {
54
/* start_output is called after jpeg_start_decompress finishes.
55
* The color map will be ready at this time, if one is needed.
56
*/
57
void (*start_output) (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo);
58
/* Emit the specified number of pixel rows from the buffer. */
59
void (*put_pixel_rows) (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
60
JDIMENSION rows_supplied);
61
/* Finish up at the end of the image. */
62
void (*finish_output) (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo);
63
/* Re-calculate buffer dimensions based on output dimensions (for use with
64
partial image decompression.) If this is NULL, then the output format
65
does not support partial image decompression (BMP, in particular, cannot
66
support partial decompression because it uses an inversion buffer to write
67
the image in bottom-up order.) */
68
void (*calc_buffer_dimensions) (j_decompress_ptr cinfo,
69
djpeg_dest_ptr dinfo);
70
71
72
/* Target file spec; filled in by djpeg.c after object is created. */
73
FILE *output_file;
74
75
/* Output pixel-row buffer. Created by module init or start_output.
76
* Width is cinfo->output_width * cinfo->output_components;
77
* height is buffer_height.
78
*/
79
JSAMPARRAY buffer;
80
J12SAMPARRAY buffer12;
81
#ifdef D_LOSSLESS_SUPPORTED
82
J16SAMPARRAY buffer16;
83
#endif
84
JDIMENSION buffer_height;
85
};
86
87
88
/*
89
* cjpeg/djpeg may need to perform extra passes to convert to or from
90
* the source/destination file format. The JPEG library does not know
91
* about these passes, but we'd like them to be counted by the progress
92
* monitor. We use an expanded progress monitor object to hold the
93
* additional pass count.
94
*/
95
96
struct cdjpeg_progress_mgr {
97
struct jpeg_progress_mgr pub; /* fields known to JPEG library */
98
int completed_extra_passes; /* extra passes completed */
99
int total_extra_passes; /* total extra */
100
JDIMENSION max_scans; /* abort if the number of scans exceeds this
101
value and the value is non-zero */
102
boolean report; /* whether or not to report progress */
103
/* last printed percentage stored here to avoid multiple printouts */
104
int percent_done;
105
};
106
107
typedef struct cdjpeg_progress_mgr *cd_progress_ptr;
108
109
110
/* Module selection routines for I/O modules. */
111
112
EXTERN(cjpeg_source_ptr) jinit_read_bmp(j_compress_ptr cinfo,
113
boolean use_inversion_array);
114
EXTERN(djpeg_dest_ptr) jinit_write_bmp(j_decompress_ptr cinfo, boolean is_os2,
115
boolean use_inversion_array);
116
EXTERN(cjpeg_source_ptr) jinit_read_gif(j_compress_ptr cinfo);
117
EXTERN(djpeg_dest_ptr) jinit_write_gif(j_decompress_ptr cinfo, boolean is_lzw);
118
EXTERN(djpeg_dest_ptr) j12init_write_gif(j_decompress_ptr cinfo,
119
boolean is_lzw);
120
EXTERN(cjpeg_source_ptr) jinit_read_ppm(j_compress_ptr cinfo);
121
EXTERN(cjpeg_source_ptr) j12init_read_ppm(j_compress_ptr cinfo);
122
#ifdef C_LOSSLESS_SUPPORTED
123
EXTERN(cjpeg_source_ptr) j16init_read_ppm(j_compress_ptr cinfo);
124
#endif
125
EXTERN(djpeg_dest_ptr) jinit_write_ppm(j_decompress_ptr cinfo);
126
EXTERN(djpeg_dest_ptr) j12init_write_ppm(j_decompress_ptr cinfo);
127
#ifdef D_LOSSLESS_SUPPORTED
128
EXTERN(djpeg_dest_ptr) j16init_write_ppm(j_decompress_ptr cinfo);
129
#endif
130
EXTERN(cjpeg_source_ptr) jinit_read_targa(j_compress_ptr cinfo);
131
EXTERN(djpeg_dest_ptr) jinit_write_targa(j_decompress_ptr cinfo);
132
133
/* cjpeg support routines (in rdswitch.c) */
134
135
EXTERN(boolean) read_quant_tables(j_compress_ptr cinfo, char *filename,
136
boolean force_baseline);
137
EXTERN(boolean) read_scan_script(j_compress_ptr cinfo, char *filename);
138
EXTERN(boolean) set_quality_ratings(j_compress_ptr cinfo, char *arg,
139
boolean force_baseline);
140
EXTERN(boolean) set_quant_slots(j_compress_ptr cinfo, char *arg);
141
EXTERN(boolean) set_sample_factors(j_compress_ptr cinfo, char *arg);
142
143
/* djpeg support routines (in rdcolmap.c) */
144
145
EXTERN(void) read_color_map(j_decompress_ptr cinfo, FILE *infile);
146
EXTERN(void) read_color_map_12(j_decompress_ptr cinfo, FILE *infile);
147
148
/* common support routines (in cdjpeg.c) */
149
150
EXTERN(void) start_progress_monitor(j_common_ptr cinfo,
151
cd_progress_ptr progress);
152
EXTERN(void) end_progress_monitor(j_common_ptr cinfo);
153
EXTERN(boolean) keymatch(char *arg, const char *keyword, int minchars);
154
EXTERN(FILE *) read_stdin(void);
155
EXTERN(FILE *) write_stdout(void);
156
157
/* miscellaneous useful macros */
158
159
#ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */
160
#define READ_BINARY "r"
161
#define WRITE_BINARY "w"
162
#else
163
#define READ_BINARY "rb"
164
#define WRITE_BINARY "wb"
165
#endif
166
167
#ifndef EXIT_FAILURE /* define exit() codes if not provided */
168
#define EXIT_FAILURE 1
169
#endif
170
#ifndef EXIT_SUCCESS
171
#define EXIT_SUCCESS 0
172
#endif
173
#ifndef EXIT_WARNING
174
#define EXIT_WARNING 2
175
#endif
176
177