aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/irrlicht-1.8/source/Irrlicht/jpeglib/jcmarker.c
diff options
context:
space:
mode:
authorDavid Walter Seikel2013-01-13 18:54:10 +1000
committerDavid Walter Seikel2013-01-13 18:54:10 +1000
commit959831f4ef5a3e797f576c3de08cd65032c997ad (patch)
treee7351908be5995f0b325b2ebeaa02d5a34b82583 /libraries/irrlicht-1.8/source/Irrlicht/jpeglib/jcmarker.c
parentAdd info about changes to Irrlicht. (diff)
downloadSledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.zip
SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.gz
SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.bz2
SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.xz
Remove damned ancient DOS line endings from Irrlicht. Hopefully I did not go overboard.
Diffstat (limited to 'libraries/irrlicht-1.8/source/Irrlicht/jpeglib/jcmarker.c')
-rw-r--r--libraries/irrlicht-1.8/source/Irrlicht/jpeglib/jcmarker.c1364
1 files changed, 682 insertions, 682 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/jpeglib/jcmarker.c b/libraries/irrlicht-1.8/source/Irrlicht/jpeglib/jcmarker.c
index 3b91e95..606c19a 100644
--- a/libraries/irrlicht-1.8/source/Irrlicht/jpeglib/jcmarker.c
+++ b/libraries/irrlicht-1.8/source/Irrlicht/jpeglib/jcmarker.c
@@ -1,682 +1,682 @@
1/* 1/*
2 * jcmarker.c 2 * jcmarker.c
3 * 3 *
4 * Copyright (C) 1991-1998, Thomas G. Lane. 4 * Copyright (C) 1991-1998, Thomas G. Lane.
5 * Modified 2003-2010 by Guido Vollbeding. 5 * Modified 2003-2010 by Guido Vollbeding.
6 * This file is part of the Independent JPEG Group's software. 6 * This file is part of the Independent JPEG Group's software.
7 * For conditions of distribution and use, see the accompanying README file. 7 * For conditions of distribution and use, see the accompanying README file.
8 * 8 *
9 * This file contains routines to write JPEG datastream markers. 9 * This file contains routines to write JPEG datastream markers.
10 */ 10 */
11 11
12#define JPEG_INTERNALS 12#define JPEG_INTERNALS
13#include "jinclude.h" 13#include "jinclude.h"
14#include "jpeglib.h" 14#include "jpeglib.h"
15 15
16 16
17typedef enum { /* JPEG marker codes */ 17typedef enum { /* JPEG marker codes */
18 M_SOF0 = 0xc0, 18 M_SOF0 = 0xc0,
19 M_SOF1 = 0xc1, 19 M_SOF1 = 0xc1,
20 M_SOF2 = 0xc2, 20 M_SOF2 = 0xc2,
21 M_SOF3 = 0xc3, 21 M_SOF3 = 0xc3,
22 22
23 M_SOF5 = 0xc5, 23 M_SOF5 = 0xc5,
24 M_SOF6 = 0xc6, 24 M_SOF6 = 0xc6,
25 M_SOF7 = 0xc7, 25 M_SOF7 = 0xc7,
26 26
27 M_JPG = 0xc8, 27 M_JPG = 0xc8,
28 M_SOF9 = 0xc9, 28 M_SOF9 = 0xc9,
29 M_SOF10 = 0xca, 29 M_SOF10 = 0xca,
30 M_SOF11 = 0xcb, 30 M_SOF11 = 0xcb,
31 31
32 M_SOF13 = 0xcd, 32 M_SOF13 = 0xcd,
33 M_SOF14 = 0xce, 33 M_SOF14 = 0xce,
34 M_SOF15 = 0xcf, 34 M_SOF15 = 0xcf,
35 35
36 M_DHT = 0xc4, 36 M_DHT = 0xc4,
37 37
38 M_DAC = 0xcc, 38 M_DAC = 0xcc,
39 39
40 M_RST0 = 0xd0, 40 M_RST0 = 0xd0,
41 M_RST1 = 0xd1, 41 M_RST1 = 0xd1,
42 M_RST2 = 0xd2, 42 M_RST2 = 0xd2,
43 M_RST3 = 0xd3, 43 M_RST3 = 0xd3,
44 M_RST4 = 0xd4, 44 M_RST4 = 0xd4,
45 M_RST5 = 0xd5, 45 M_RST5 = 0xd5,
46 M_RST6 = 0xd6, 46 M_RST6 = 0xd6,
47 M_RST7 = 0xd7, 47 M_RST7 = 0xd7,
48 48
49 M_SOI = 0xd8, 49 M_SOI = 0xd8,
50 M_EOI = 0xd9, 50 M_EOI = 0xd9,
51 M_SOS = 0xda, 51 M_SOS = 0xda,
52 M_DQT = 0xdb, 52 M_DQT = 0xdb,
53 M_DNL = 0xdc, 53 M_DNL = 0xdc,
54 M_DRI = 0xdd, 54 M_DRI = 0xdd,
55 M_DHP = 0xde, 55 M_DHP = 0xde,
56 M_EXP = 0xdf, 56 M_EXP = 0xdf,
57 57
58 M_APP0 = 0xe0, 58 M_APP0 = 0xe0,
59 M_APP1 = 0xe1, 59 M_APP1 = 0xe1,
60 M_APP2 = 0xe2, 60 M_APP2 = 0xe2,
61 M_APP3 = 0xe3, 61 M_APP3 = 0xe3,
62 M_APP4 = 0xe4, 62 M_APP4 = 0xe4,
63 M_APP5 = 0xe5, 63 M_APP5 = 0xe5,
64 M_APP6 = 0xe6, 64 M_APP6 = 0xe6,
65 M_APP7 = 0xe7, 65 M_APP7 = 0xe7,
66 M_APP8 = 0xe8, 66 M_APP8 = 0xe8,
67 M_APP9 = 0xe9, 67 M_APP9 = 0xe9,
68 M_APP10 = 0xea, 68 M_APP10 = 0xea,
69 M_APP11 = 0xeb, 69 M_APP11 = 0xeb,
70 M_APP12 = 0xec, 70 M_APP12 = 0xec,
71 M_APP13 = 0xed, 71 M_APP13 = 0xed,
72 M_APP14 = 0xee, 72 M_APP14 = 0xee,
73 M_APP15 = 0xef, 73 M_APP15 = 0xef,
74 74
75 M_JPG0 = 0xf0, 75 M_JPG0 = 0xf0,
76 M_JPG13 = 0xfd, 76 M_JPG13 = 0xfd,
77 M_COM = 0xfe, 77 M_COM = 0xfe,
78 78
79 M_TEM = 0x01, 79 M_TEM = 0x01,
80 80
81 M_ERROR = 0x100 81 M_ERROR = 0x100
82} JPEG_MARKER; 82} JPEG_MARKER;
83 83
84 84
85/* Private state */ 85/* Private state */
86 86
87typedef struct { 87typedef struct {
88 struct jpeg_marker_writer pub; /* public fields */ 88 struct jpeg_marker_writer pub; /* public fields */
89 89
90 unsigned int last_restart_interval; /* last DRI value emitted; 0 after SOI */ 90 unsigned int last_restart_interval; /* last DRI value emitted; 0 after SOI */
91} my_marker_writer; 91} my_marker_writer;
92 92
93typedef my_marker_writer * my_marker_ptr; 93typedef my_marker_writer * my_marker_ptr;
94 94
95 95
96/* 96/*
97 * Basic output routines. 97 * Basic output routines.
98 * 98 *
99 * Note that we do not support suspension while writing a marker. 99 * Note that we do not support suspension while writing a marker.
100 * Therefore, an application using suspension must ensure that there is 100 * Therefore, an application using suspension must ensure that there is
101 * enough buffer space for the initial markers (typ. 600-700 bytes) before 101 * enough buffer space for the initial markers (typ. 600-700 bytes) before
102 * calling jpeg_start_compress, and enough space to write the trailing EOI 102 * calling jpeg_start_compress, and enough space to write the trailing EOI
103 * (a few bytes) before calling jpeg_finish_compress. Multipass compression 103 * (a few bytes) before calling jpeg_finish_compress. Multipass compression
104 * modes are not supported at all with suspension, so those two are the only 104 * modes are not supported at all with suspension, so those two are the only
105 * points where markers will be written. 105 * points where markers will be written.
106 */ 106 */
107 107
108LOCAL(void) 108LOCAL(void)
109emit_byte (j_compress_ptr cinfo, int val) 109emit_byte (j_compress_ptr cinfo, int val)
110/* Emit a byte */ 110/* Emit a byte */
111{ 111{
112 struct jpeg_destination_mgr * dest = cinfo->dest; 112 struct jpeg_destination_mgr * dest = cinfo->dest;
113 113
114 *(dest->next_output_byte)++ = (JOCTET) val; 114 *(dest->next_output_byte)++ = (JOCTET) val;
115 if (--dest->free_in_buffer == 0) { 115 if (--dest->free_in_buffer == 0) {
116 if (! (*dest->empty_output_buffer) (cinfo)) 116 if (! (*dest->empty_output_buffer) (cinfo))
117 ERREXIT(cinfo, JERR_CANT_SUSPEND); 117 ERREXIT(cinfo, JERR_CANT_SUSPEND);
118 } 118 }
119} 119}
120 120
121 121
122LOCAL(void) 122LOCAL(void)
123emit_marker (j_compress_ptr cinfo, JPEG_MARKER mark) 123emit_marker (j_compress_ptr cinfo, JPEG_MARKER mark)
124/* Emit a marker code */ 124/* Emit a marker code */
125{ 125{
126 emit_byte(cinfo, 0xFF); 126 emit_byte(cinfo, 0xFF);
127 emit_byte(cinfo, (int) mark); 127 emit_byte(cinfo, (int) mark);
128} 128}
129 129
130 130
131LOCAL(void) 131LOCAL(void)
132emit_2bytes (j_compress_ptr cinfo, int value) 132emit_2bytes (j_compress_ptr cinfo, int value)
133/* Emit a 2-byte integer; these are always MSB first in JPEG files */ 133/* Emit a 2-byte integer; these are always MSB first in JPEG files */
134{ 134{
135 emit_byte(cinfo, (value >> 8) & 0xFF); 135 emit_byte(cinfo, (value >> 8) & 0xFF);
136 emit_byte(cinfo, value & 0xFF); 136 emit_byte(cinfo, value & 0xFF);
137} 137}
138 138
139 139
140/* 140/*
141 * Routines to write specific marker types. 141 * Routines to write specific marker types.
142 */ 142 */
143 143
144LOCAL(int) 144LOCAL(int)
145emit_dqt (j_compress_ptr cinfo, int index) 145emit_dqt (j_compress_ptr cinfo, int index)
146/* Emit a DQT marker */ 146/* Emit a DQT marker */
147/* Returns the precision used (0 = 8bits, 1 = 16bits) for baseline checking */ 147/* Returns the precision used (0 = 8bits, 1 = 16bits) for baseline checking */
148{ 148{
149 JQUANT_TBL * qtbl = cinfo->quant_tbl_ptrs[index]; 149 JQUANT_TBL * qtbl = cinfo->quant_tbl_ptrs[index];
150 int prec; 150 int prec;
151 int i; 151 int i;
152 152
153 if (qtbl == NULL) 153 if (qtbl == NULL)
154 ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, index); 154 ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, index);
155 155
156 prec = 0; 156 prec = 0;
157 for (i = 0; i <= cinfo->lim_Se; i++) { 157 for (i = 0; i <= cinfo->lim_Se; i++) {
158 if (qtbl->quantval[cinfo->natural_order[i]] > 255) 158 if (qtbl->quantval[cinfo->natural_order[i]] > 255)
159 prec = 1; 159 prec = 1;
160 } 160 }
161 161
162 if (! qtbl->sent_table) { 162 if (! qtbl->sent_table) {
163 emit_marker(cinfo, M_DQT); 163 emit_marker(cinfo, M_DQT);
164 164
165 emit_2bytes(cinfo, 165 emit_2bytes(cinfo,
166 prec ? cinfo->lim_Se * 2 + 2 + 1 + 2 : cinfo->lim_Se + 1 + 1 + 2); 166 prec ? cinfo->lim_Se * 2 + 2 + 1 + 2 : cinfo->lim_Se + 1 + 1 + 2);
167 167
168 emit_byte(cinfo, index + (prec<<4)); 168 emit_byte(cinfo, index + (prec<<4));
169 169
170 for (i = 0; i <= cinfo->lim_Se; i++) { 170 for (i = 0; i <= cinfo->lim_Se; i++) {
171 /* The table entries must be emitted in zigzag order. */ 171 /* The table entries must be emitted in zigzag order. */
172 unsigned int qval = qtbl->quantval[cinfo->natural_order[i]]; 172 unsigned int qval = qtbl->quantval[cinfo->natural_order[i]];
173 if (prec) 173 if (prec)
174 emit_byte(cinfo, (int) (qval >> 8)); 174 emit_byte(cinfo, (int) (qval >> 8));
175 emit_byte(cinfo, (int) (qval & 0xFF)); 175 emit_byte(cinfo, (int) (qval & 0xFF));
176 } 176 }
177 177
178 qtbl->sent_table = TRUE; 178 qtbl->sent_table = TRUE;
179 } 179 }
180 180
181 return prec; 181 return prec;
182} 182}
183 183
184 184
185LOCAL(void) 185LOCAL(void)
186emit_dht (j_compress_ptr cinfo, int index, boolean is_ac) 186emit_dht (j_compress_ptr cinfo, int index, boolean is_ac)
187/* Emit a DHT marker */ 187/* Emit a DHT marker */
188{ 188{
189 JHUFF_TBL * htbl; 189 JHUFF_TBL * htbl;
190 int length, i; 190 int length, i;
191 191
192 if (is_ac) { 192 if (is_ac) {
193 htbl = cinfo->ac_huff_tbl_ptrs[index]; 193 htbl = cinfo->ac_huff_tbl_ptrs[index];
194 index += 0x10; /* output index has AC bit set */ 194 index += 0x10; /* output index has AC bit set */
195 } else { 195 } else {
196 htbl = cinfo->dc_huff_tbl_ptrs[index]; 196 htbl = cinfo->dc_huff_tbl_ptrs[index];
197 } 197 }
198 198
199 if (htbl == NULL) 199 if (htbl == NULL)
200 ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, index); 200 ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, index);
201 201
202 if (! htbl->sent_table) { 202 if (! htbl->sent_table) {
203 emit_marker(cinfo, M_DHT); 203 emit_marker(cinfo, M_DHT);
204 204
205 length = 0; 205 length = 0;
206 for (i = 1; i <= 16; i++) 206 for (i = 1; i <= 16; i++)
207 length += htbl->bits[i]; 207 length += htbl->bits[i];
208 208
209 emit_2bytes(cinfo, length + 2 + 1 + 16); 209 emit_2bytes(cinfo, length + 2 + 1 + 16);
210 emit_byte(cinfo, index); 210 emit_byte(cinfo, index);
211 211
212 for (i = 1; i <= 16; i++) 212 for (i = 1; i <= 16; i++)
213 emit_byte(cinfo, htbl->bits[i]); 213 emit_byte(cinfo, htbl->bits[i]);
214 214
215 for (i = 0; i < length; i++) 215 for (i = 0; i < length; i++)
216 emit_byte(cinfo, htbl->huffval[i]); 216 emit_byte(cinfo, htbl->huffval[i]);
217 217
218 htbl->sent_table = TRUE; 218 htbl->sent_table = TRUE;
219 } 219 }
220} 220}
221 221
222 222
223LOCAL(void) 223LOCAL(void)
224emit_dac (j_compress_ptr cinfo) 224emit_dac (j_compress_ptr cinfo)
225/* Emit a DAC marker */ 225/* Emit a DAC marker */
226/* Since the useful info is so small, we want to emit all the tables in */ 226/* Since the useful info is so small, we want to emit all the tables in */
227/* one DAC marker. Therefore this routine does its own scan of the table. */ 227/* one DAC marker. Therefore this routine does its own scan of the table. */
228{ 228{
229#ifdef C_ARITH_CODING_SUPPORTED 229#ifdef C_ARITH_CODING_SUPPORTED
230 char dc_in_use[NUM_ARITH_TBLS]; 230 char dc_in_use[NUM_ARITH_TBLS];
231 char ac_in_use[NUM_ARITH_TBLS]; 231 char ac_in_use[NUM_ARITH_TBLS];
232 int length, i; 232 int length, i;
233 jpeg_component_info *compptr; 233 jpeg_component_info *compptr;
234 234
235 for (i = 0; i < NUM_ARITH_TBLS; i++) 235 for (i = 0; i < NUM_ARITH_TBLS; i++)
236 dc_in_use[i] = ac_in_use[i] = 0; 236 dc_in_use[i] = ac_in_use[i] = 0;
237 237
238 for (i = 0; i < cinfo->comps_in_scan; i++) { 238 for (i = 0; i < cinfo->comps_in_scan; i++) {
239 compptr = cinfo->cur_comp_info[i]; 239 compptr = cinfo->cur_comp_info[i];
240 /* DC needs no table for refinement scan */ 240 /* DC needs no table for refinement scan */
241 if (cinfo->Ss == 0 && cinfo->Ah == 0) 241 if (cinfo->Ss == 0 && cinfo->Ah == 0)
242 dc_in_use[compptr->dc_tbl_no] = 1; 242 dc_in_use[compptr->dc_tbl_no] = 1;
243 /* AC needs no table when not present */ 243 /* AC needs no table when not present */
244 if (cinfo->Se) 244 if (cinfo->Se)
245 ac_in_use[compptr->ac_tbl_no] = 1; 245 ac_in_use[compptr->ac_tbl_no] = 1;
246 } 246 }
247 247
248 length = 0; 248 length = 0;
249 for (i = 0; i < NUM_ARITH_TBLS; i++) 249 for (i = 0; i < NUM_ARITH_TBLS; i++)
250 length += dc_in_use[i] + ac_in_use[i]; 250 length += dc_in_use[i] + ac_in_use[i];
251 251
252 if (length) { 252 if (length) {
253 emit_marker(cinfo, M_DAC); 253 emit_marker(cinfo, M_DAC);
254 254
255 emit_2bytes(cinfo, length*2 + 2); 255 emit_2bytes(cinfo, length*2 + 2);
256 256
257 for (i = 0; i < NUM_ARITH_TBLS; i++) { 257 for (i = 0; i < NUM_ARITH_TBLS; i++) {
258 if (dc_in_use[i]) { 258 if (dc_in_use[i]) {
259 emit_byte(cinfo, i); 259 emit_byte(cinfo, i);
260 emit_byte(cinfo, cinfo->arith_dc_L[i] + (cinfo->arith_dc_U[i]<<4)); 260 emit_byte(cinfo, cinfo->arith_dc_L[i] + (cinfo->arith_dc_U[i]<<4));
261 } 261 }
262 if (ac_in_use[i]) { 262 if (ac_in_use[i]) {
263 emit_byte(cinfo, i + 0x10); 263 emit_byte(cinfo, i + 0x10);
264 emit_byte(cinfo, cinfo->arith_ac_K[i]); 264 emit_byte(cinfo, cinfo->arith_ac_K[i]);
265 } 265 }
266 } 266 }
267 } 267 }
268#endif /* C_ARITH_CODING_SUPPORTED */ 268#endif /* C_ARITH_CODING_SUPPORTED */
269} 269}
270 270
271 271
272LOCAL(void) 272LOCAL(void)
273emit_dri (j_compress_ptr cinfo) 273emit_dri (j_compress_ptr cinfo)
274/* Emit a DRI marker */ 274/* Emit a DRI marker */
275{ 275{
276 emit_marker(cinfo, M_DRI); 276 emit_marker(cinfo, M_DRI);
277 277
278 emit_2bytes(cinfo, 4); /* fixed length */ 278 emit_2bytes(cinfo, 4); /* fixed length */
279 279
280 emit_2bytes(cinfo, (int) cinfo->restart_interval); 280 emit_2bytes(cinfo, (int) cinfo->restart_interval);
281} 281}
282 282
283 283
284LOCAL(void) 284LOCAL(void)
285emit_sof (j_compress_ptr cinfo, JPEG_MARKER code) 285emit_sof (j_compress_ptr cinfo, JPEG_MARKER code)
286/* Emit a SOF marker */ 286/* Emit a SOF marker */
287{ 287{
288 int ci; 288 int ci;
289 jpeg_component_info *compptr; 289 jpeg_component_info *compptr;
290 290
291 emit_marker(cinfo, code); 291 emit_marker(cinfo, code);
292 292
293 emit_2bytes(cinfo, 3 * cinfo->num_components + 2 + 5 + 1); /* length */ 293 emit_2bytes(cinfo, 3 * cinfo->num_components + 2 + 5 + 1); /* length */
294 294
295 /* Make sure image isn't bigger than SOF field can handle */ 295 /* Make sure image isn't bigger than SOF field can handle */
296 if ((long) cinfo->jpeg_height > 65535L || 296 if ((long) cinfo->jpeg_height > 65535L ||
297 (long) cinfo->jpeg_width > 65535L) 297 (long) cinfo->jpeg_width > 65535L)
298 ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) 65535); 298 ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) 65535);
299 299
300 emit_byte(cinfo, cinfo->data_precision); 300 emit_byte(cinfo, cinfo->data_precision);
301 emit_2bytes(cinfo, (int) cinfo->jpeg_height); 301 emit_2bytes(cinfo, (int) cinfo->jpeg_height);
302 emit_2bytes(cinfo, (int) cinfo->jpeg_width); 302 emit_2bytes(cinfo, (int) cinfo->jpeg_width);
303 303
304 emit_byte(cinfo, cinfo->num_components); 304 emit_byte(cinfo, cinfo->num_components);
305 305
306 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; 306 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
307 ci++, compptr++) { 307 ci++, compptr++) {
308 emit_byte(cinfo, compptr->component_id); 308 emit_byte(cinfo, compptr->component_id);
309 emit_byte(cinfo, (compptr->h_samp_factor << 4) + compptr->v_samp_factor); 309 emit_byte(cinfo, (compptr->h_samp_factor << 4) + compptr->v_samp_factor);
310 emit_byte(cinfo, compptr->quant_tbl_no); 310 emit_byte(cinfo, compptr->quant_tbl_no);
311 } 311 }
312} 312}
313 313
314 314
315LOCAL(void) 315LOCAL(void)
316emit_sos (j_compress_ptr cinfo) 316emit_sos (j_compress_ptr cinfo)
317/* Emit a SOS marker */ 317/* Emit a SOS marker */
318{ 318{
319 int i, td, ta; 319 int i, td, ta;
320 jpeg_component_info *compptr; 320 jpeg_component_info *compptr;
321 321
322 emit_marker(cinfo, M_SOS); 322 emit_marker(cinfo, M_SOS);
323 323
324 emit_2bytes(cinfo, 2 * cinfo->comps_in_scan + 2 + 1 + 3); /* length */ 324 emit_2bytes(cinfo, 2 * cinfo->comps_in_scan + 2 + 1 + 3); /* length */
325 325
326 emit_byte(cinfo, cinfo->comps_in_scan); 326 emit_byte(cinfo, cinfo->comps_in_scan);
327 327
328 for (i = 0; i < cinfo->comps_in_scan; i++) { 328 for (i = 0; i < cinfo->comps_in_scan; i++) {
329 compptr = cinfo->cur_comp_info[i]; 329 compptr = cinfo->cur_comp_info[i];
330 emit_byte(cinfo, compptr->component_id); 330 emit_byte(cinfo, compptr->component_id);
331 331
332 /* We emit 0 for unused field(s); this is recommended by the P&M text 332 /* We emit 0 for unused field(s); this is recommended by the P&M text
333 * but does not seem to be specified in the standard. 333 * but does not seem to be specified in the standard.
334 */ 334 */
335 335
336 /* DC needs no table for refinement scan */ 336 /* DC needs no table for refinement scan */
337 td = cinfo->Ss == 0 && cinfo->Ah == 0 ? compptr->dc_tbl_no : 0; 337 td = cinfo->Ss == 0 && cinfo->Ah == 0 ? compptr->dc_tbl_no : 0;
338 /* AC needs no table when not present */ 338 /* AC needs no table when not present */
339 ta = cinfo->Se ? compptr->ac_tbl_no : 0; 339 ta = cinfo->Se ? compptr->ac_tbl_no : 0;
340 340
341 emit_byte(cinfo, (td << 4) + ta); 341 emit_byte(cinfo, (td << 4) + ta);
342 } 342 }
343 343
344 emit_byte(cinfo, cinfo->Ss); 344 emit_byte(cinfo, cinfo->Ss);
345 emit_byte(cinfo, cinfo->Se); 345 emit_byte(cinfo, cinfo->Se);
346 emit_byte(cinfo, (cinfo->Ah << 4) + cinfo->Al); 346 emit_byte(cinfo, (cinfo->Ah << 4) + cinfo->Al);
347} 347}
348 348
349 349
350LOCAL(void) 350LOCAL(void)
351emit_pseudo_sos (j_compress_ptr cinfo) 351emit_pseudo_sos (j_compress_ptr cinfo)
352/* Emit a pseudo SOS marker */ 352/* Emit a pseudo SOS marker */
353{ 353{
354 emit_marker(cinfo, M_SOS); 354 emit_marker(cinfo, M_SOS);
355 355
356 emit_2bytes(cinfo, 2 + 1 + 3); /* length */ 356 emit_2bytes(cinfo, 2 + 1 + 3); /* length */
357 357
358 emit_byte(cinfo, 0); /* Ns */ 358 emit_byte(cinfo, 0); /* Ns */
359 359
360 emit_byte(cinfo, 0); /* Ss */ 360 emit_byte(cinfo, 0); /* Ss */
361 emit_byte(cinfo, cinfo->block_size * cinfo->block_size - 1); /* Se */ 361 emit_byte(cinfo, cinfo->block_size * cinfo->block_size - 1); /* Se */
362 emit_byte(cinfo, 0); /* Ah/Al */ 362 emit_byte(cinfo, 0); /* Ah/Al */
363} 363}
364 364
365 365
366LOCAL(void) 366LOCAL(void)
367emit_jfif_app0 (j_compress_ptr cinfo) 367emit_jfif_app0 (j_compress_ptr cinfo)
368/* Emit a JFIF-compliant APP0 marker */ 368/* Emit a JFIF-compliant APP0 marker */
369{ 369{
370 /* 370 /*
371 * Length of APP0 block (2 bytes) 371 * Length of APP0 block (2 bytes)
372 * Block ID (4 bytes - ASCII "JFIF") 372 * Block ID (4 bytes - ASCII "JFIF")
373 * Zero byte (1 byte to terminate the ID string) 373 * Zero byte (1 byte to terminate the ID string)
374 * Version Major, Minor (2 bytes - major first) 374 * Version Major, Minor (2 bytes - major first)
375 * Units (1 byte - 0x00 = none, 0x01 = inch, 0x02 = cm) 375 * Units (1 byte - 0x00 = none, 0x01 = inch, 0x02 = cm)
376 * Xdpu (2 bytes - dots per unit horizontal) 376 * Xdpu (2 bytes - dots per unit horizontal)
377 * Ydpu (2 bytes - dots per unit vertical) 377 * Ydpu (2 bytes - dots per unit vertical)
378 * Thumbnail X size (1 byte) 378 * Thumbnail X size (1 byte)
379 * Thumbnail Y size (1 byte) 379 * Thumbnail Y size (1 byte)
380 */ 380 */
381 381
382 emit_marker(cinfo, M_APP0); 382 emit_marker(cinfo, M_APP0);
383 383
384 emit_2bytes(cinfo, 2 + 4 + 1 + 2 + 1 + 2 + 2 + 1 + 1); /* length */ 384 emit_2bytes(cinfo, 2 + 4 + 1 + 2 + 1 + 2 + 2 + 1 + 1); /* length */
385 385
386 emit_byte(cinfo, 0x4A); /* Identifier: ASCII "JFIF" */ 386 emit_byte(cinfo, 0x4A); /* Identifier: ASCII "JFIF" */
387 emit_byte(cinfo, 0x46); 387 emit_byte(cinfo, 0x46);
388 emit_byte(cinfo, 0x49); 388 emit_byte(cinfo, 0x49);
389 emit_byte(cinfo, 0x46); 389 emit_byte(cinfo, 0x46);
390 emit_byte(cinfo, 0); 390 emit_byte(cinfo, 0);
391 emit_byte(cinfo, cinfo->JFIF_major_version); /* Version fields */ 391 emit_byte(cinfo, cinfo->JFIF_major_version); /* Version fields */
392 emit_byte(cinfo, cinfo->JFIF_minor_version); 392 emit_byte(cinfo, cinfo->JFIF_minor_version);
393 emit_byte(cinfo, cinfo->density_unit); /* Pixel size information */ 393 emit_byte(cinfo, cinfo->density_unit); /* Pixel size information */
394 emit_2bytes(cinfo, (int) cinfo->X_density); 394 emit_2bytes(cinfo, (int) cinfo->X_density);
395 emit_2bytes(cinfo, (int) cinfo->Y_density); 395 emit_2bytes(cinfo, (int) cinfo->Y_density);
396 emit_byte(cinfo, 0); /* No thumbnail image */ 396 emit_byte(cinfo, 0); /* No thumbnail image */
397 emit_byte(cinfo, 0); 397 emit_byte(cinfo, 0);
398} 398}
399 399
400 400
401LOCAL(void) 401LOCAL(void)
402emit_adobe_app14 (j_compress_ptr cinfo) 402emit_adobe_app14 (j_compress_ptr cinfo)
403/* Emit an Adobe APP14 marker */ 403/* Emit an Adobe APP14 marker */
404{ 404{
405 /* 405 /*
406 * Length of APP14 block (2 bytes) 406 * Length of APP14 block (2 bytes)
407 * Block ID (5 bytes - ASCII "Adobe") 407 * Block ID (5 bytes - ASCII "Adobe")
408 * Version Number (2 bytes - currently 100) 408 * Version Number (2 bytes - currently 100)
409 * Flags0 (2 bytes - currently 0) 409 * Flags0 (2 bytes - currently 0)
410 * Flags1 (2 bytes - currently 0) 410 * Flags1 (2 bytes - currently 0)
411 * Color transform (1 byte) 411 * Color transform (1 byte)
412 * 412 *
413 * Although Adobe TN 5116 mentions Version = 101, all the Adobe files 413 * Although Adobe TN 5116 mentions Version = 101, all the Adobe files
414 * now in circulation seem to use Version = 100, so that's what we write. 414 * now in circulation seem to use Version = 100, so that's what we write.
415 * 415 *
416 * We write the color transform byte as 1 if the JPEG color space is 416 * We write the color transform byte as 1 if the JPEG color space is
417 * YCbCr, 2 if it's YCCK, 0 otherwise. Adobe's definition has to do with 417 * YCbCr, 2 if it's YCCK, 0 otherwise. Adobe's definition has to do with
418 * whether the encoder performed a transformation, which is pretty useless. 418 * whether the encoder performed a transformation, which is pretty useless.
419 */ 419 */
420 420
421 emit_marker(cinfo, M_APP14); 421 emit_marker(cinfo, M_APP14);
422 422
423 emit_2bytes(cinfo, 2 + 5 + 2 + 2 + 2 + 1); /* length */ 423 emit_2bytes(cinfo, 2 + 5 + 2 + 2 + 2 + 1); /* length */
424 424
425 emit_byte(cinfo, 0x41); /* Identifier: ASCII "Adobe" */ 425 emit_byte(cinfo, 0x41); /* Identifier: ASCII "Adobe" */
426 emit_byte(cinfo, 0x64); 426 emit_byte(cinfo, 0x64);
427 emit_byte(cinfo, 0x6F); 427 emit_byte(cinfo, 0x6F);
428 emit_byte(cinfo, 0x62); 428 emit_byte(cinfo, 0x62);
429 emit_byte(cinfo, 0x65); 429 emit_byte(cinfo, 0x65);
430 emit_2bytes(cinfo, 100); /* Version */ 430 emit_2bytes(cinfo, 100); /* Version */
431 emit_2bytes(cinfo, 0); /* Flags0 */ 431 emit_2bytes(cinfo, 0); /* Flags0 */
432 emit_2bytes(cinfo, 0); /* Flags1 */ 432 emit_2bytes(cinfo, 0); /* Flags1 */
433 switch (cinfo->jpeg_color_space) { 433 switch (cinfo->jpeg_color_space) {
434 case JCS_YCbCr: 434 case JCS_YCbCr:
435 emit_byte(cinfo, 1); /* Color transform = 1 */ 435 emit_byte(cinfo, 1); /* Color transform = 1 */
436 break; 436 break;
437 case JCS_YCCK: 437 case JCS_YCCK:
438 emit_byte(cinfo, 2); /* Color transform = 2 */ 438 emit_byte(cinfo, 2); /* Color transform = 2 */
439 break; 439 break;
440 default: 440 default:
441 emit_byte(cinfo, 0); /* Color transform = 0 */ 441 emit_byte(cinfo, 0); /* Color transform = 0 */
442 break; 442 break;
443 } 443 }
444} 444}
445 445
446 446
447/* 447/*
448 * These routines allow writing an arbitrary marker with parameters. 448 * These routines allow writing an arbitrary marker with parameters.
449 * The only intended use is to emit COM or APPn markers after calling 449 * The only intended use is to emit COM or APPn markers after calling
450 * write_file_header and before calling write_frame_header. 450 * write_file_header and before calling write_frame_header.
451 * Other uses are not guaranteed to produce desirable results. 451 * Other uses are not guaranteed to produce desirable results.
452 * Counting the parameter bytes properly is the caller's responsibility. 452 * Counting the parameter bytes properly is the caller's responsibility.
453 */ 453 */
454 454
455METHODDEF(void) 455METHODDEF(void)
456write_marker_header (j_compress_ptr cinfo, int marker, unsigned int datalen) 456write_marker_header (j_compress_ptr cinfo, int marker, unsigned int datalen)
457/* Emit an arbitrary marker header */ 457/* Emit an arbitrary marker header */
458{ 458{
459 if (datalen > (unsigned int) 65533) /* safety check */ 459 if (datalen > (unsigned int) 65533) /* safety check */
460 ERREXIT(cinfo, JERR_BAD_LENGTH); 460 ERREXIT(cinfo, JERR_BAD_LENGTH);
461 461
462 emit_marker(cinfo, (JPEG_MARKER) marker); 462 emit_marker(cinfo, (JPEG_MARKER) marker);
463 463
464 emit_2bytes(cinfo, (int) (datalen + 2)); /* total length */ 464 emit_2bytes(cinfo, (int) (datalen + 2)); /* total length */
465} 465}
466 466
467METHODDEF(void) 467METHODDEF(void)
468write_marker_byte (j_compress_ptr cinfo, int val) 468write_marker_byte (j_compress_ptr cinfo, int val)
469/* Emit one byte of marker parameters following write_marker_header */ 469/* Emit one byte of marker parameters following write_marker_header */
470{ 470{
471 emit_byte(cinfo, val); 471 emit_byte(cinfo, val);
472} 472}
473 473
474 474
475/* 475/*
476 * Write datastream header. 476 * Write datastream header.
477 * This consists of an SOI and optional APPn markers. 477 * This consists of an SOI and optional APPn markers.
478 * We recommend use of the JFIF marker, but not the Adobe marker, 478 * We recommend use of the JFIF marker, but not the Adobe marker,
479 * when using YCbCr or grayscale data. The JFIF marker should NOT 479 * when using YCbCr or grayscale data. The JFIF marker should NOT
480 * be used for any other JPEG colorspace. The Adobe marker is helpful 480 * be used for any other JPEG colorspace. The Adobe marker is helpful
481 * to distinguish RGB, CMYK, and YCCK colorspaces. 481 * to distinguish RGB, CMYK, and YCCK colorspaces.
482 * Note that an application can write additional header markers after 482 * Note that an application can write additional header markers after
483 * jpeg_start_compress returns. 483 * jpeg_start_compress returns.
484 */ 484 */
485 485
486METHODDEF(void) 486METHODDEF(void)
487write_file_header (j_compress_ptr cinfo) 487write_file_header (j_compress_ptr cinfo)
488{ 488{
489 my_marker_ptr marker = (my_marker_ptr) cinfo->marker; 489 my_marker_ptr marker = (my_marker_ptr) cinfo->marker;
490 490
491 emit_marker(cinfo, M_SOI); /* first the SOI */ 491 emit_marker(cinfo, M_SOI); /* first the SOI */
492 492
493 /* SOI is defined to reset restart interval to 0 */ 493 /* SOI is defined to reset restart interval to 0 */
494 marker->last_restart_interval = 0; 494 marker->last_restart_interval = 0;
495 495
496 if (cinfo->write_JFIF_header) /* next an optional JFIF APP0 */ 496 if (cinfo->write_JFIF_header) /* next an optional JFIF APP0 */
497 emit_jfif_app0(cinfo); 497 emit_jfif_app0(cinfo);
498 if (cinfo->write_Adobe_marker) /* next an optional Adobe APP14 */ 498 if (cinfo->write_Adobe_marker) /* next an optional Adobe APP14 */
499 emit_adobe_app14(cinfo); 499 emit_adobe_app14(cinfo);
500} 500}
501 501
502 502
503/* 503/*
504 * Write frame header. 504 * Write frame header.
505 * This consists of DQT and SOFn markers, and a conditional pseudo SOS marker. 505 * This consists of DQT and SOFn markers, and a conditional pseudo SOS marker.
506 * Note that we do not emit the SOF until we have emitted the DQT(s). 506 * Note that we do not emit the SOF until we have emitted the DQT(s).
507 * This avoids compatibility problems with incorrect implementations that 507 * This avoids compatibility problems with incorrect implementations that
508 * try to error-check the quant table numbers as soon as they see the SOF. 508 * try to error-check the quant table numbers as soon as they see the SOF.
509 */ 509 */
510 510
511METHODDEF(void) 511METHODDEF(void)
512write_frame_header (j_compress_ptr cinfo) 512write_frame_header (j_compress_ptr cinfo)
513{ 513{
514 int ci, prec; 514 int ci, prec;
515 boolean is_baseline; 515 boolean is_baseline;
516 jpeg_component_info *compptr; 516 jpeg_component_info *compptr;
517 517
518 /* Emit DQT for each quantization table. 518 /* Emit DQT for each quantization table.
519 * Note that emit_dqt() suppresses any duplicate tables. 519 * Note that emit_dqt() suppresses any duplicate tables.
520 */ 520 */
521 prec = 0; 521 prec = 0;
522 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; 522 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
523 ci++, compptr++) { 523 ci++, compptr++) {
524 prec += emit_dqt(cinfo, compptr->quant_tbl_no); 524 prec += emit_dqt(cinfo, compptr->quant_tbl_no);
525 } 525 }
526 /* now prec is nonzero iff there are any 16-bit quant tables. */ 526 /* now prec is nonzero iff there are any 16-bit quant tables. */
527 527
528 /* Check for a non-baseline specification. 528 /* Check for a non-baseline specification.
529 * Note we assume that Huffman table numbers won't be changed later. 529 * Note we assume that Huffman table numbers won't be changed later.
530 */ 530 */
531 if (cinfo->arith_code || cinfo->progressive_mode || 531 if (cinfo->arith_code || cinfo->progressive_mode ||
532 cinfo->data_precision != 8 || cinfo->block_size != DCTSIZE) { 532 cinfo->data_precision != 8 || cinfo->block_size != DCTSIZE) {
533 is_baseline = FALSE; 533 is_baseline = FALSE;
534 } else { 534 } else {
535 is_baseline = TRUE; 535 is_baseline = TRUE;
536 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; 536 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
537 ci++, compptr++) { 537 ci++, compptr++) {
538 if (compptr->dc_tbl_no > 1 || compptr->ac_tbl_no > 1) 538 if (compptr->dc_tbl_no > 1 || compptr->ac_tbl_no > 1)
539 is_baseline = FALSE; 539 is_baseline = FALSE;
540 } 540 }
541 if (prec && is_baseline) { 541 if (prec && is_baseline) {
542 is_baseline = FALSE; 542 is_baseline = FALSE;
543 /* If it's baseline except for quantizer size, warn the user */ 543 /* If it's baseline except for quantizer size, warn the user */
544 TRACEMS(cinfo, 0, JTRC_16BIT_TABLES); 544 TRACEMS(cinfo, 0, JTRC_16BIT_TABLES);
545 } 545 }
546 } 546 }
547 547
548 /* Emit the proper SOF marker */ 548 /* Emit the proper SOF marker */
549 if (cinfo->arith_code) { 549 if (cinfo->arith_code) {
550 if (cinfo->progressive_mode) 550 if (cinfo->progressive_mode)
551 emit_sof(cinfo, M_SOF10); /* SOF code for progressive arithmetic */ 551 emit_sof(cinfo, M_SOF10); /* SOF code for progressive arithmetic */
552 else 552 else
553 emit_sof(cinfo, M_SOF9); /* SOF code for sequential arithmetic */ 553 emit_sof(cinfo, M_SOF9); /* SOF code for sequential arithmetic */
554 } else { 554 } else {
555 if (cinfo->progressive_mode) 555 if (cinfo->progressive_mode)
556 emit_sof(cinfo, M_SOF2); /* SOF code for progressive Huffman */ 556 emit_sof(cinfo, M_SOF2); /* SOF code for progressive Huffman */
557 else if (is_baseline) 557 else if (is_baseline)
558 emit_sof(cinfo, M_SOF0); /* SOF code for baseline implementation */ 558 emit_sof(cinfo, M_SOF0); /* SOF code for baseline implementation */
559 else 559 else
560 emit_sof(cinfo, M_SOF1); /* SOF code for non-baseline Huffman file */ 560 emit_sof(cinfo, M_SOF1); /* SOF code for non-baseline Huffman file */
561 } 561 }
562 562
563 /* Check to emit pseudo SOS marker */ 563 /* Check to emit pseudo SOS marker */
564 if (cinfo->progressive_mode && cinfo->block_size != DCTSIZE) 564 if (cinfo->progressive_mode && cinfo->block_size != DCTSIZE)
565 emit_pseudo_sos(cinfo); 565 emit_pseudo_sos(cinfo);
566} 566}
567 567
568 568
569/* 569/*
570 * Write scan header. 570 * Write scan header.
571 * This consists of DHT or DAC markers, optional DRI, and SOS. 571 * This consists of DHT or DAC markers, optional DRI, and SOS.
572 * Compressed data will be written following the SOS. 572 * Compressed data will be written following the SOS.
573 */ 573 */
574 574
575METHODDEF(void) 575METHODDEF(void)
576write_scan_header (j_compress_ptr cinfo) 576write_scan_header (j_compress_ptr cinfo)
577{ 577{
578 my_marker_ptr marker = (my_marker_ptr) cinfo->marker; 578 my_marker_ptr marker = (my_marker_ptr) cinfo->marker;
579 int i; 579 int i;
580 jpeg_component_info *compptr; 580 jpeg_component_info *compptr;
581 581
582 if (cinfo->arith_code) { 582 if (cinfo->arith_code) {
583 /* Emit arith conditioning info. We may have some duplication 583 /* Emit arith conditioning info. We may have some duplication
584 * if the file has multiple scans, but it's so small it's hardly 584 * if the file has multiple scans, but it's so small it's hardly
585 * worth worrying about. 585 * worth worrying about.
586 */ 586 */
587 emit_dac(cinfo); 587 emit_dac(cinfo);
588 } else { 588 } else {
589 /* Emit Huffman tables. 589 /* Emit Huffman tables.
590 * Note that emit_dht() suppresses any duplicate tables. 590 * Note that emit_dht() suppresses any duplicate tables.
591 */ 591 */
592 for (i = 0; i < cinfo->comps_in_scan; i++) { 592 for (i = 0; i < cinfo->comps_in_scan; i++) {
593 compptr = cinfo->cur_comp_info[i]; 593 compptr = cinfo->cur_comp_info[i];
594 /* DC needs no table for refinement scan */ 594 /* DC needs no table for refinement scan */
595 if (cinfo->Ss == 0 && cinfo->Ah == 0) 595 if (cinfo->Ss == 0 && cinfo->Ah == 0)
596 emit_dht(cinfo, compptr->dc_tbl_no, FALSE); 596 emit_dht(cinfo, compptr->dc_tbl_no, FALSE);
597 /* AC needs no table when not present */ 597 /* AC needs no table when not present */
598 if (cinfo->Se) 598 if (cinfo->Se)
599 emit_dht(cinfo, compptr->ac_tbl_no, TRUE); 599 emit_dht(cinfo, compptr->ac_tbl_no, TRUE);
600 } 600 }
601 } 601 }
602 602
603 /* Emit DRI if required --- note that DRI value could change for each scan. 603 /* Emit DRI if required --- note that DRI value could change for each scan.
604 * We avoid wasting space with unnecessary DRIs, however. 604 * We avoid wasting space with unnecessary DRIs, however.
605 */ 605 */
606 if (cinfo->restart_interval != marker->last_restart_interval) { 606 if (cinfo->restart_interval != marker->last_restart_interval) {
607 emit_dri(cinfo); 607 emit_dri(cinfo);
608 marker->last_restart_interval = cinfo->restart_interval; 608 marker->last_restart_interval = cinfo->restart_interval;
609 } 609 }
610 610
611 emit_sos(cinfo); 611 emit_sos(cinfo);
612} 612}
613 613
614 614
615/* 615/*
616 * Write datastream trailer. 616 * Write datastream trailer.
617 */ 617 */
618 618
619METHODDEF(void) 619METHODDEF(void)
620write_file_trailer (j_compress_ptr cinfo) 620write_file_trailer (j_compress_ptr cinfo)
621{ 621{
622 emit_marker(cinfo, M_EOI); 622 emit_marker(cinfo, M_EOI);
623} 623}
624 624
625 625
626/* 626/*
627 * Write an abbreviated table-specification datastream. 627 * Write an abbreviated table-specification datastream.
628 * This consists of SOI, DQT and DHT tables, and EOI. 628 * This consists of SOI, DQT and DHT tables, and EOI.
629 * Any table that is defined and not marked sent_table = TRUE will be 629 * Any table that is defined and not marked sent_table = TRUE will be
630 * emitted. Note that all tables will be marked sent_table = TRUE at exit. 630 * emitted. Note that all tables will be marked sent_table = TRUE at exit.
631 */ 631 */
632 632
633METHODDEF(void) 633METHODDEF(void)
634write_tables_only (j_compress_ptr cinfo) 634write_tables_only (j_compress_ptr cinfo)
635{ 635{
636 int i; 636 int i;
637 637
638 emit_marker(cinfo, M_SOI); 638 emit_marker(cinfo, M_SOI);
639 639
640 for (i = 0; i < NUM_QUANT_TBLS; i++) { 640 for (i = 0; i < NUM_QUANT_TBLS; i++) {
641 if (cinfo->quant_tbl_ptrs[i] != NULL) 641 if (cinfo->quant_tbl_ptrs[i] != NULL)
642 (void) emit_dqt(cinfo, i); 642 (void) emit_dqt(cinfo, i);
643 } 643 }
644 644
645 if (! cinfo->arith_code) { 645 if (! cinfo->arith_code) {
646 for (i = 0; i < NUM_HUFF_TBLS; i++) { 646 for (i = 0; i < NUM_HUFF_TBLS; i++) {
647 if (cinfo->dc_huff_tbl_ptrs[i] != NULL) 647 if (cinfo->dc_huff_tbl_ptrs[i] != NULL)
648 emit_dht(cinfo, i, FALSE); 648 emit_dht(cinfo, i, FALSE);
649 if (cinfo->ac_huff_tbl_ptrs[i] != NULL) 649 if (cinfo->ac_huff_tbl_ptrs[i] != NULL)
650 emit_dht(cinfo, i, TRUE); 650 emit_dht(cinfo, i, TRUE);
651 } 651 }
652 } 652 }
653 653
654 emit_marker(cinfo, M_EOI); 654 emit_marker(cinfo, M_EOI);
655} 655}
656 656
657 657
658/* 658/*
659 * Initialize the marker writer module. 659 * Initialize the marker writer module.
660 */ 660 */
661 661
662GLOBAL(void) 662GLOBAL(void)
663jinit_marker_writer (j_compress_ptr cinfo) 663jinit_marker_writer (j_compress_ptr cinfo)
664{ 664{
665 my_marker_ptr marker; 665 my_marker_ptr marker;
666 666
667 /* Create the subobject */ 667 /* Create the subobject */
668 marker = (my_marker_ptr) 668 marker = (my_marker_ptr)
669 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, 669 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
670 SIZEOF(my_marker_writer)); 670 SIZEOF(my_marker_writer));
671 cinfo->marker = (struct jpeg_marker_writer *) marker; 671 cinfo->marker = (struct jpeg_marker_writer *) marker;
672 /* Initialize method pointers */ 672 /* Initialize method pointers */
673 marker->pub.write_file_header = write_file_header; 673 marker->pub.write_file_header = write_file_header;
674 marker->pub.write_frame_header = write_frame_header; 674 marker->pub.write_frame_header = write_frame_header;
675 marker->pub.write_scan_header = write_scan_header; 675 marker->pub.write_scan_header = write_scan_header;
676 marker->pub.write_file_trailer = write_file_trailer; 676 marker->pub.write_file_trailer = write_file_trailer;
677 marker->pub.write_tables_only = write_tables_only; 677 marker->pub.write_tables_only = write_tables_only;
678 marker->pub.write_marker_header = write_marker_header; 678 marker->pub.write_marker_header = write_marker_header;
679 marker->pub.write_marker_byte = write_marker_byte; 679 marker->pub.write_marker_byte = write_marker_byte;
680 /* Initialize private state */ 680 /* Initialize private state */
681 marker->last_restart_interval = 0; 681 marker->last_restart_interval = 0;
682} 682}