diff options
Diffstat (limited to '')
-rw-r--r-- | libraries/irrlicht-1.8/source/Irrlicht/jpeglib/wrrle.c | 610 |
1 files changed, 305 insertions, 305 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/jpeglib/wrrle.c b/libraries/irrlicht-1.8/source/Irrlicht/jpeglib/wrrle.c index 7a00c0d..a4e7337 100644 --- a/libraries/irrlicht-1.8/source/Irrlicht/jpeglib/wrrle.c +++ b/libraries/irrlicht-1.8/source/Irrlicht/jpeglib/wrrle.c | |||
@@ -1,305 +1,305 @@ | |||
1 | /* | 1 | /* |
2 | * wrrle.c | 2 | * wrrle.c |
3 | * | 3 | * |
4 | * Copyright (C) 1991-1996, Thomas G. Lane. | 4 | * Copyright (C) 1991-1996, Thomas G. Lane. |
5 | * This file is part of the Independent JPEG Group's software. | 5 | * This file is part of the Independent JPEG Group's software. |
6 | * For conditions of distribution and use, see the accompanying README file. | 6 | * For conditions of distribution and use, see the accompanying README file. |
7 | * | 7 | * |
8 | * This file contains routines to write output images in RLE format. | 8 | * This file contains routines to write output images in RLE format. |
9 | * The Utah Raster Toolkit library is required (version 3.1 or later). | 9 | * The Utah Raster Toolkit library is required (version 3.1 or later). |
10 | * | 10 | * |
11 | * These routines may need modification for non-Unix environments or | 11 | * These routines may need modification for non-Unix environments or |
12 | * specialized applications. As they stand, they assume output to | 12 | * specialized applications. As they stand, they assume output to |
13 | * an ordinary stdio stream. | 13 | * an ordinary stdio stream. |
14 | * | 14 | * |
15 | * Based on code contributed by Mike Lijewski, | 15 | * Based on code contributed by Mike Lijewski, |
16 | * with updates from Robert Hutchinson. | 16 | * with updates from Robert Hutchinson. |
17 | */ | 17 | */ |
18 | 18 | ||
19 | #include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ | 19 | #include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ |
20 | 20 | ||
21 | #ifdef RLE_SUPPORTED | 21 | #ifdef RLE_SUPPORTED |
22 | 22 | ||
23 | /* rle.h is provided by the Utah Raster Toolkit. */ | 23 | /* rle.h is provided by the Utah Raster Toolkit. */ |
24 | 24 | ||
25 | #include <rle.h> | 25 | #include <rle.h> |
26 | 26 | ||
27 | /* | 27 | /* |
28 | * We assume that JSAMPLE has the same representation as rle_pixel, | 28 | * We assume that JSAMPLE has the same representation as rle_pixel, |
29 | * to wit, "unsigned char". Hence we can't cope with 12- or 16-bit samples. | 29 | * to wit, "unsigned char". Hence we can't cope with 12- or 16-bit samples. |
30 | */ | 30 | */ |
31 | 31 | ||
32 | #if BITS_IN_JSAMPLE != 8 | 32 | #if BITS_IN_JSAMPLE != 8 |
33 | Sorry, this code only copes with 8-bit JSAMPLEs. /* deliberate syntax err */ | 33 | Sorry, this code only copes with 8-bit JSAMPLEs. /* deliberate syntax err */ |
34 | #endif | 34 | #endif |
35 | 35 | ||
36 | 36 | ||
37 | /* | 37 | /* |
38 | * Since RLE stores scanlines bottom-to-top, we have to invert the image | 38 | * Since RLE stores scanlines bottom-to-top, we have to invert the image |
39 | * from JPEG's top-to-bottom order. To do this, we save the outgoing data | 39 | * from JPEG's top-to-bottom order. To do this, we save the outgoing data |
40 | * in a virtual array during put_pixel_row calls, then actually emit the | 40 | * in a virtual array during put_pixel_row calls, then actually emit the |
41 | * RLE file during finish_output. | 41 | * RLE file during finish_output. |
42 | */ | 42 | */ |
43 | 43 | ||
44 | 44 | ||
45 | /* | 45 | /* |
46 | * For now, if we emit an RLE color map then it is always 256 entries long, | 46 | * For now, if we emit an RLE color map then it is always 256 entries long, |
47 | * though not all of the entries need be used. | 47 | * though not all of the entries need be used. |
48 | */ | 48 | */ |
49 | 49 | ||
50 | #define CMAPBITS 8 | 50 | #define CMAPBITS 8 |
51 | #define CMAPLENGTH (1<<(CMAPBITS)) | 51 | #define CMAPLENGTH (1<<(CMAPBITS)) |
52 | 52 | ||
53 | typedef struct { | 53 | typedef struct { |
54 | struct djpeg_dest_struct pub; /* public fields */ | 54 | struct djpeg_dest_struct pub; /* public fields */ |
55 | 55 | ||
56 | jvirt_sarray_ptr image; /* virtual array to store the output image */ | 56 | jvirt_sarray_ptr image; /* virtual array to store the output image */ |
57 | rle_map *colormap; /* RLE-style color map, or NULL if none */ | 57 | rle_map *colormap; /* RLE-style color map, or NULL if none */ |
58 | rle_pixel **rle_row; /* To pass rows to rle_putrow() */ | 58 | rle_pixel **rle_row; /* To pass rows to rle_putrow() */ |
59 | 59 | ||
60 | } rle_dest_struct; | 60 | } rle_dest_struct; |
61 | 61 | ||
62 | typedef rle_dest_struct * rle_dest_ptr; | 62 | typedef rle_dest_struct * rle_dest_ptr; |
63 | 63 | ||
64 | /* Forward declarations */ | 64 | /* Forward declarations */ |
65 | METHODDEF(void) rle_put_pixel_rows | 65 | METHODDEF(void) rle_put_pixel_rows |
66 | JPP((j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, | 66 | JPP((j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, |
67 | JDIMENSION rows_supplied)); | 67 | JDIMENSION rows_supplied)); |
68 | 68 | ||
69 | 69 | ||
70 | /* | 70 | /* |
71 | * Write the file header. | 71 | * Write the file header. |
72 | * | 72 | * |
73 | * In this module it's easier to wait till finish_output to write anything. | 73 | * In this module it's easier to wait till finish_output to write anything. |
74 | */ | 74 | */ |
75 | 75 | ||
76 | METHODDEF(void) | 76 | METHODDEF(void) |
77 | start_output_rle (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) | 77 | start_output_rle (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) |
78 | { | 78 | { |
79 | rle_dest_ptr dest = (rle_dest_ptr) dinfo; | 79 | rle_dest_ptr dest = (rle_dest_ptr) dinfo; |
80 | size_t cmapsize; | 80 | size_t cmapsize; |
81 | int i, ci; | 81 | int i, ci; |
82 | #ifdef PROGRESS_REPORT | 82 | #ifdef PROGRESS_REPORT |
83 | cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; | 83 | cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; |
84 | #endif | 84 | #endif |
85 | 85 | ||
86 | /* | 86 | /* |
87 | * Make sure the image can be stored in RLE format. | 87 | * Make sure the image can be stored in RLE format. |
88 | * | 88 | * |
89 | * - RLE stores image dimensions as *signed* 16 bit integers. JPEG | 89 | * - RLE stores image dimensions as *signed* 16 bit integers. JPEG |
90 | * uses unsigned, so we have to check the width. | 90 | * uses unsigned, so we have to check the width. |
91 | * | 91 | * |
92 | * - Colorspace is expected to be grayscale or RGB. | 92 | * - Colorspace is expected to be grayscale or RGB. |
93 | * | 93 | * |
94 | * - The number of channels (components) is expected to be 1 (grayscale/ | 94 | * - The number of channels (components) is expected to be 1 (grayscale/ |
95 | * pseudocolor) or 3 (truecolor/directcolor). | 95 | * pseudocolor) or 3 (truecolor/directcolor). |
96 | * (could be 2 or 4 if using an alpha channel, but we aren't) | 96 | * (could be 2 or 4 if using an alpha channel, but we aren't) |
97 | */ | 97 | */ |
98 | 98 | ||
99 | if (cinfo->output_width > 32767 || cinfo->output_height > 32767) | 99 | if (cinfo->output_width > 32767 || cinfo->output_height > 32767) |
100 | ERREXIT2(cinfo, JERR_RLE_DIMENSIONS, cinfo->output_width, | 100 | ERREXIT2(cinfo, JERR_RLE_DIMENSIONS, cinfo->output_width, |
101 | cinfo->output_height); | 101 | cinfo->output_height); |
102 | 102 | ||
103 | if (cinfo->out_color_space != JCS_GRAYSCALE && | 103 | if (cinfo->out_color_space != JCS_GRAYSCALE && |
104 | cinfo->out_color_space != JCS_RGB) | 104 | cinfo->out_color_space != JCS_RGB) |
105 | ERREXIT(cinfo, JERR_RLE_COLORSPACE); | 105 | ERREXIT(cinfo, JERR_RLE_COLORSPACE); |
106 | 106 | ||
107 | if (cinfo->output_components != 1 && cinfo->output_components != 3) | 107 | if (cinfo->output_components != 1 && cinfo->output_components != 3) |
108 | ERREXIT1(cinfo, JERR_RLE_TOOMANYCHANNELS, cinfo->num_components); | 108 | ERREXIT1(cinfo, JERR_RLE_TOOMANYCHANNELS, cinfo->num_components); |
109 | 109 | ||
110 | /* Convert colormap, if any, to RLE format. */ | 110 | /* Convert colormap, if any, to RLE format. */ |
111 | 111 | ||
112 | dest->colormap = NULL; | 112 | dest->colormap = NULL; |
113 | 113 | ||
114 | if (cinfo->quantize_colors) { | 114 | if (cinfo->quantize_colors) { |
115 | /* Allocate storage for RLE-style cmap, zero any extra entries */ | 115 | /* Allocate storage for RLE-style cmap, zero any extra entries */ |
116 | cmapsize = cinfo->out_color_components * CMAPLENGTH * SIZEOF(rle_map); | 116 | cmapsize = cinfo->out_color_components * CMAPLENGTH * SIZEOF(rle_map); |
117 | dest->colormap = (rle_map *) (*cinfo->mem->alloc_small) | 117 | dest->colormap = (rle_map *) (*cinfo->mem->alloc_small) |
118 | ((j_common_ptr) cinfo, JPOOL_IMAGE, cmapsize); | 118 | ((j_common_ptr) cinfo, JPOOL_IMAGE, cmapsize); |
119 | MEMZERO(dest->colormap, cmapsize); | 119 | MEMZERO(dest->colormap, cmapsize); |
120 | 120 | ||
121 | /* Save away data in RLE format --- note 8-bit left shift! */ | 121 | /* Save away data in RLE format --- note 8-bit left shift! */ |
122 | /* Shifting would need adjustment for JSAMPLEs wider than 8 bits. */ | 122 | /* Shifting would need adjustment for JSAMPLEs wider than 8 bits. */ |
123 | for (ci = 0; ci < cinfo->out_color_components; ci++) { | 123 | for (ci = 0; ci < cinfo->out_color_components; ci++) { |
124 | for (i = 0; i < cinfo->actual_number_of_colors; i++) { | 124 | for (i = 0; i < cinfo->actual_number_of_colors; i++) { |
125 | dest->colormap[ci * CMAPLENGTH + i] = | 125 | dest->colormap[ci * CMAPLENGTH + i] = |
126 | GETJSAMPLE(cinfo->colormap[ci][i]) << 8; | 126 | GETJSAMPLE(cinfo->colormap[ci][i]) << 8; |
127 | } | 127 | } |
128 | } | 128 | } |
129 | } | 129 | } |
130 | 130 | ||
131 | /* Set the output buffer to the first row */ | 131 | /* Set the output buffer to the first row */ |
132 | dest->pub.buffer = (*cinfo->mem->access_virt_sarray) | 132 | dest->pub.buffer = (*cinfo->mem->access_virt_sarray) |
133 | ((j_common_ptr) cinfo, dest->image, (JDIMENSION) 0, (JDIMENSION) 1, TRUE); | 133 | ((j_common_ptr) cinfo, dest->image, (JDIMENSION) 0, (JDIMENSION) 1, TRUE); |
134 | dest->pub.buffer_height = 1; | 134 | dest->pub.buffer_height = 1; |
135 | 135 | ||
136 | dest->pub.put_pixel_rows = rle_put_pixel_rows; | 136 | dest->pub.put_pixel_rows = rle_put_pixel_rows; |
137 | 137 | ||
138 | #ifdef PROGRESS_REPORT | 138 | #ifdef PROGRESS_REPORT |
139 | if (progress != NULL) { | 139 | if (progress != NULL) { |
140 | progress->total_extra_passes++; /* count file writing as separate pass */ | 140 | progress->total_extra_passes++; /* count file writing as separate pass */ |
141 | } | 141 | } |
142 | #endif | 142 | #endif |
143 | } | 143 | } |
144 | 144 | ||
145 | 145 | ||
146 | /* | 146 | /* |
147 | * Write some pixel data. | 147 | * Write some pixel data. |
148 | * | 148 | * |
149 | * This routine just saves the data away in a virtual array. | 149 | * This routine just saves the data away in a virtual array. |
150 | */ | 150 | */ |
151 | 151 | ||
152 | METHODDEF(void) | 152 | METHODDEF(void) |
153 | rle_put_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, | 153 | rle_put_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, |
154 | JDIMENSION rows_supplied) | 154 | JDIMENSION rows_supplied) |
155 | { | 155 | { |
156 | rle_dest_ptr dest = (rle_dest_ptr) dinfo; | 156 | rle_dest_ptr dest = (rle_dest_ptr) dinfo; |
157 | 157 | ||
158 | if (cinfo->output_scanline < cinfo->output_height) { | 158 | if (cinfo->output_scanline < cinfo->output_height) { |
159 | dest->pub.buffer = (*cinfo->mem->access_virt_sarray) | 159 | dest->pub.buffer = (*cinfo->mem->access_virt_sarray) |
160 | ((j_common_ptr) cinfo, dest->image, | 160 | ((j_common_ptr) cinfo, dest->image, |
161 | cinfo->output_scanline, (JDIMENSION) 1, TRUE); | 161 | cinfo->output_scanline, (JDIMENSION) 1, TRUE); |
162 | } | 162 | } |
163 | } | 163 | } |
164 | 164 | ||
165 | /* | 165 | /* |
166 | * Finish up at the end of the file. | 166 | * Finish up at the end of the file. |
167 | * | 167 | * |
168 | * Here is where we really output the RLE file. | 168 | * Here is where we really output the RLE file. |
169 | */ | 169 | */ |
170 | 170 | ||
171 | METHODDEF(void) | 171 | METHODDEF(void) |
172 | finish_output_rle (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) | 172 | finish_output_rle (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) |
173 | { | 173 | { |
174 | rle_dest_ptr dest = (rle_dest_ptr) dinfo; | 174 | rle_dest_ptr dest = (rle_dest_ptr) dinfo; |
175 | rle_hdr header; /* Output file information */ | 175 | rle_hdr header; /* Output file information */ |
176 | rle_pixel **rle_row, *red, *green, *blue; | 176 | rle_pixel **rle_row, *red, *green, *blue; |
177 | JSAMPROW output_row; | 177 | JSAMPROW output_row; |
178 | char cmapcomment[80]; | 178 | char cmapcomment[80]; |
179 | int row, col; | 179 | int row, col; |
180 | int ci; | 180 | int ci; |
181 | #ifdef PROGRESS_REPORT | 181 | #ifdef PROGRESS_REPORT |
182 | cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; | 182 | cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; |
183 | #endif | 183 | #endif |
184 | 184 | ||
185 | /* Initialize the header info */ | 185 | /* Initialize the header info */ |
186 | header = *rle_hdr_init(NULL); | 186 | header = *rle_hdr_init(NULL); |
187 | header.rle_file = dest->pub.output_file; | 187 | header.rle_file = dest->pub.output_file; |
188 | header.xmin = 0; | 188 | header.xmin = 0; |
189 | header.xmax = cinfo->output_width - 1; | 189 | header.xmax = cinfo->output_width - 1; |
190 | header.ymin = 0; | 190 | header.ymin = 0; |
191 | header.ymax = cinfo->output_height - 1; | 191 | header.ymax = cinfo->output_height - 1; |
192 | header.alpha = 0; | 192 | header.alpha = 0; |
193 | header.ncolors = cinfo->output_components; | 193 | header.ncolors = cinfo->output_components; |
194 | for (ci = 0; ci < cinfo->output_components; ci++) { | 194 | for (ci = 0; ci < cinfo->output_components; ci++) { |
195 | RLE_SET_BIT(header, ci); | 195 | RLE_SET_BIT(header, ci); |
196 | } | 196 | } |
197 | if (cinfo->quantize_colors) { | 197 | if (cinfo->quantize_colors) { |
198 | header.ncmap = cinfo->out_color_components; | 198 | header.ncmap = cinfo->out_color_components; |
199 | header.cmaplen = CMAPBITS; | 199 | header.cmaplen = CMAPBITS; |
200 | header.cmap = dest->colormap; | 200 | header.cmap = dest->colormap; |
201 | /* Add a comment to the output image with the true colormap length. */ | 201 | /* Add a comment to the output image with the true colormap length. */ |
202 | sprintf(cmapcomment, "color_map_length=%d", cinfo->actual_number_of_colors); | 202 | sprintf(cmapcomment, "color_map_length=%d", cinfo->actual_number_of_colors); |
203 | rle_putcom(cmapcomment, &header); | 203 | rle_putcom(cmapcomment, &header); |
204 | } | 204 | } |
205 | 205 | ||
206 | /* Emit the RLE header and color map (if any) */ | 206 | /* Emit the RLE header and color map (if any) */ |
207 | rle_put_setup(&header); | 207 | rle_put_setup(&header); |
208 | 208 | ||
209 | /* Now output the RLE data from our virtual array. | 209 | /* Now output the RLE data from our virtual array. |
210 | * We assume here that (a) rle_pixel is represented the same as JSAMPLE, | 210 | * We assume here that (a) rle_pixel is represented the same as JSAMPLE, |
211 | * and (b) we are not on a machine where FAR pointers differ from regular. | 211 | * and (b) we are not on a machine where FAR pointers differ from regular. |
212 | */ | 212 | */ |
213 | 213 | ||
214 | #ifdef PROGRESS_REPORT | 214 | #ifdef PROGRESS_REPORT |
215 | if (progress != NULL) { | 215 | if (progress != NULL) { |
216 | progress->pub.pass_limit = cinfo->output_height; | 216 | progress->pub.pass_limit = cinfo->output_height; |
217 | progress->pub.pass_counter = 0; | 217 | progress->pub.pass_counter = 0; |
218 | (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); | 218 | (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); |
219 | } | 219 | } |
220 | #endif | 220 | #endif |
221 | 221 | ||
222 | if (cinfo->output_components == 1) { | 222 | if (cinfo->output_components == 1) { |
223 | for (row = cinfo->output_height-1; row >= 0; row--) { | 223 | for (row = cinfo->output_height-1; row >= 0; row--) { |
224 | rle_row = (rle_pixel **) (*cinfo->mem->access_virt_sarray) | 224 | rle_row = (rle_pixel **) (*cinfo->mem->access_virt_sarray) |
225 | ((j_common_ptr) cinfo, dest->image, | 225 | ((j_common_ptr) cinfo, dest->image, |
226 | (JDIMENSION) row, (JDIMENSION) 1, FALSE); | 226 | (JDIMENSION) row, (JDIMENSION) 1, FALSE); |
227 | rle_putrow(rle_row, (int) cinfo->output_width, &header); | 227 | rle_putrow(rle_row, (int) cinfo->output_width, &header); |
228 | #ifdef PROGRESS_REPORT | 228 | #ifdef PROGRESS_REPORT |
229 | if (progress != NULL) { | 229 | if (progress != NULL) { |
230 | progress->pub.pass_counter++; | 230 | progress->pub.pass_counter++; |
231 | (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); | 231 | (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); |
232 | } | 232 | } |
233 | #endif | 233 | #endif |
234 | } | 234 | } |
235 | } else { | 235 | } else { |
236 | for (row = cinfo->output_height-1; row >= 0; row--) { | 236 | for (row = cinfo->output_height-1; row >= 0; row--) { |
237 | rle_row = (rle_pixel **) dest->rle_row; | 237 | rle_row = (rle_pixel **) dest->rle_row; |
238 | output_row = * (*cinfo->mem->access_virt_sarray) | 238 | output_row = * (*cinfo->mem->access_virt_sarray) |
239 | ((j_common_ptr) cinfo, dest->image, | 239 | ((j_common_ptr) cinfo, dest->image, |
240 | (JDIMENSION) row, (JDIMENSION) 1, FALSE); | 240 | (JDIMENSION) row, (JDIMENSION) 1, FALSE); |
241 | red = rle_row[0]; | 241 | red = rle_row[0]; |
242 | green = rle_row[1]; | 242 | green = rle_row[1]; |
243 | blue = rle_row[2]; | 243 | blue = rle_row[2]; |
244 | for (col = cinfo->output_width; col > 0; col--) { | 244 | for (col = cinfo->output_width; col > 0; col--) { |
245 | *red++ = GETJSAMPLE(*output_row++); | 245 | *red++ = GETJSAMPLE(*output_row++); |
246 | *green++ = GETJSAMPLE(*output_row++); | 246 | *green++ = GETJSAMPLE(*output_row++); |
247 | *blue++ = GETJSAMPLE(*output_row++); | 247 | *blue++ = GETJSAMPLE(*output_row++); |
248 | } | 248 | } |
249 | rle_putrow(rle_row, (int) cinfo->output_width, &header); | 249 | rle_putrow(rle_row, (int) cinfo->output_width, &header); |
250 | #ifdef PROGRESS_REPORT | 250 | #ifdef PROGRESS_REPORT |
251 | if (progress != NULL) { | 251 | if (progress != NULL) { |
252 | progress->pub.pass_counter++; | 252 | progress->pub.pass_counter++; |
253 | (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); | 253 | (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); |
254 | } | 254 | } |
255 | #endif | 255 | #endif |
256 | } | 256 | } |
257 | } | 257 | } |
258 | 258 | ||
259 | #ifdef PROGRESS_REPORT | 259 | #ifdef PROGRESS_REPORT |
260 | if (progress != NULL) | 260 | if (progress != NULL) |
261 | progress->completed_extra_passes++; | 261 | progress->completed_extra_passes++; |
262 | #endif | 262 | #endif |
263 | 263 | ||
264 | /* Emit file trailer */ | 264 | /* Emit file trailer */ |
265 | rle_puteof(&header); | 265 | rle_puteof(&header); |
266 | fflush(dest->pub.output_file); | 266 | fflush(dest->pub.output_file); |
267 | if (ferror(dest->pub.output_file)) | 267 | if (ferror(dest->pub.output_file)) |
268 | ERREXIT(cinfo, JERR_FILE_WRITE); | 268 | ERREXIT(cinfo, JERR_FILE_WRITE); |
269 | } | 269 | } |
270 | 270 | ||
271 | 271 | ||
272 | /* | 272 | /* |
273 | * The module selection routine for RLE format output. | 273 | * The module selection routine for RLE format output. |
274 | */ | 274 | */ |
275 | 275 | ||
276 | GLOBAL(djpeg_dest_ptr) | 276 | GLOBAL(djpeg_dest_ptr) |
277 | jinit_write_rle (j_decompress_ptr cinfo) | 277 | jinit_write_rle (j_decompress_ptr cinfo) |
278 | { | 278 | { |
279 | rle_dest_ptr dest; | 279 | rle_dest_ptr dest; |
280 | 280 | ||
281 | /* Create module interface object, fill in method pointers */ | 281 | /* Create module interface object, fill in method pointers */ |
282 | dest = (rle_dest_ptr) | 282 | dest = (rle_dest_ptr) |
283 | (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, | 283 | (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, |
284 | SIZEOF(rle_dest_struct)); | 284 | SIZEOF(rle_dest_struct)); |
285 | dest->pub.start_output = start_output_rle; | 285 | dest->pub.start_output = start_output_rle; |
286 | dest->pub.finish_output = finish_output_rle; | 286 | dest->pub.finish_output = finish_output_rle; |
287 | 287 | ||
288 | /* Calculate output image dimensions so we can allocate space */ | 288 | /* Calculate output image dimensions so we can allocate space */ |
289 | jpeg_calc_output_dimensions(cinfo); | 289 | jpeg_calc_output_dimensions(cinfo); |
290 | 290 | ||
291 | /* Allocate a work array for output to the RLE library. */ | 291 | /* Allocate a work array for output to the RLE library. */ |
292 | dest->rle_row = (*cinfo->mem->alloc_sarray) | 292 | dest->rle_row = (*cinfo->mem->alloc_sarray) |
293 | ((j_common_ptr) cinfo, JPOOL_IMAGE, | 293 | ((j_common_ptr) cinfo, JPOOL_IMAGE, |
294 | cinfo->output_width, (JDIMENSION) cinfo->output_components); | 294 | cinfo->output_width, (JDIMENSION) cinfo->output_components); |
295 | 295 | ||
296 | /* Allocate a virtual array to hold the image. */ | 296 | /* Allocate a virtual array to hold the image. */ |
297 | dest->image = (*cinfo->mem->request_virt_sarray) | 297 | dest->image = (*cinfo->mem->request_virt_sarray) |
298 | ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, | 298 | ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, |
299 | (JDIMENSION) (cinfo->output_width * cinfo->output_components), | 299 | (JDIMENSION) (cinfo->output_width * cinfo->output_components), |
300 | cinfo->output_height, (JDIMENSION) 1); | 300 | cinfo->output_height, (JDIMENSION) 1); |
301 | 301 | ||
302 | return (djpeg_dest_ptr) dest; | 302 | return (djpeg_dest_ptr) dest; |
303 | } | 303 | } |
304 | 304 | ||
305 | #endif /* RLE_SUPPORTED */ | 305 | #endif /* RLE_SUPPORTED */ |