blob: afd17c437122c1d7b10ff7eed34d5abe7248ac31 [file] [log] [blame]
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +00001/*
2 * rdtarga.c
3 *
DRC5033f3e2014-05-18 18:33:44 +00004 * This file was part of the Independent JPEG Group's software:
Thomas G. Lane489583f1996-02-07 00:00:00 +00005 * Copyright (C) 1991-1996, Thomas G. Lane.
DRC5033f3e2014-05-18 18:33:44 +00006 * It was modified by The libjpeg-turbo Project to include only code relevant
7 * to libjpeg-turbo.
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +00008 * For conditions of distribution and use, see the accompanying README file.
9 *
10 * This file contains routines to read input images in Targa format.
11 *
12 * These routines may need modification for non-Unix environments or
13 * specialized applications. As they stand, they assume input from
14 * an ordinary stdio stream. They further assume that reading begins
15 * at the start of the file; start_input may need work if the
16 * user interface has already read some data (e.g., to determine that
17 * the file is indeed Targa format).
18 *
19 * Based on code contributed by Lee Daniel Crocker.
20 */
21
DRCe5eaf372014-05-09 18:00:32 +000022#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +000023
24#ifdef TARGA_SUPPORTED
25
26
27/* Macros to deal with unsigned chars as efficiently as compiler allows */
28
29#ifdef HAVE_UNSIGNED_CHAR
30typedef unsigned char U_CHAR;
DRCe5eaf372014-05-09 18:00:32 +000031#define UCH(x) ((int) (x))
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +000032#else /* !HAVE_UNSIGNED_CHAR */
DRC61976bd2014-04-20 19:13:10 +000033#ifdef __CHAR_UNSIGNED__
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +000034typedef char U_CHAR;
DRCe5eaf372014-05-09 18:00:32 +000035#define UCH(x) ((int) (x))
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +000036#else
37typedef char U_CHAR;
DRCe5eaf372014-05-09 18:00:32 +000038#define UCH(x) ((int) (x) & 0xFF)
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +000039#endif
40#endif /* HAVE_UNSIGNED_CHAR */
41
42
DRCe5eaf372014-05-09 18:00:32 +000043#define ReadOK(file,buffer,len) (JFREAD(file,buffer,len) == ((size_t) (len)))
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +000044
45
46/* Private version of data source object */
47
48typedef struct _tga_source_struct * tga_source_ptr;
49
50typedef struct _tga_source_struct {
51 struct cjpeg_source_struct pub; /* public fields */
52
DRCe5eaf372014-05-09 18:00:32 +000053 j_compress_ptr cinfo; /* back link saves passing separate parm */
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +000054
DRCe5eaf372014-05-09 18:00:32 +000055 JSAMPARRAY colormap; /* Targa colormap (converted to my format) */
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +000056
DRCe5eaf372014-05-09 18:00:32 +000057 jvirt_sarray_ptr whole_image; /* Needed if funny input row order */
58 JDIMENSION current_row; /* Current logical row number to read */
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +000059
60 /* Pointer to routine to extract next Targa pixel from input file */
DRCbc56b752014-05-16 10:43:44 +000061 void (*read_pixel) (tga_source_ptr sinfo);
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +000062
63 /* Result of read_pixel is delivered here: */
64 U_CHAR tga_pixel[4];
65
DRCe5eaf372014-05-09 18:00:32 +000066 int pixel_size; /* Bytes per Targa pixel (1 to 4) */
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +000067
68 /* State info for reading RLE-coded pixels; both counts must be init to 0 */
DRCe5eaf372014-05-09 18:00:32 +000069 int block_count; /* # of pixels remaining in RLE block */
70 int dup_pixel_count; /* # of times to duplicate previous pixel */
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +000071
72 /* This saves the correct pixel-row-expansion method for preload_image */
DRCbc56b752014-05-16 10:43:44 +000073 JDIMENSION (*get_pixel_rows) (j_compress_ptr cinfo, cjpeg_source_ptr sinfo);
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +000074} tga_source_struct;
75
76
77/* For expanding 5-bit pixel values to 8-bit with best rounding */
78
79static const UINT8 c5to8bits[32] = {
Thomas G. Lanebc79e061995-08-02 00:00:00 +000080 0, 8, 16, 25, 33, 41, 49, 58,
81 66, 74, 82, 90, 99, 107, 115, 123,
82 132, 140, 148, 156, 165, 173, 181, 189,
83 197, 206, 214, 222, 230, 239, 247, 255
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +000084};
85
86
87
Thomas G. Lane489583f1996-02-07 00:00:00 +000088LOCAL(int)
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +000089read_byte (tga_source_ptr sinfo)
90/* Read next byte from Targa file */
91{
92 register FILE *infile = sinfo->pub.input_file;
93 register int c;
94
95 if ((c = getc(infile)) == EOF)
96 ERREXIT(sinfo->cinfo, JERR_INPUT_EOF);
97 return c;
98}
99
100
Thomas G. Lane489583f1996-02-07 00:00:00 +0000101LOCAL(void)
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +0000102read_colormap (tga_source_ptr sinfo, int cmaplen, int mapentrysize)
103/* Read the colormap from a Targa file */
104{
105 int i;
106
107 /* Presently only handles 24-bit BGR format */
108 if (mapentrysize != 24)
109 ERREXIT(sinfo->cinfo, JERR_TGA_BADCMAP);
110
111 for (i = 0; i < cmaplen; i++) {
112 sinfo->colormap[2][i] = (JSAMPLE) read_byte(sinfo);
113 sinfo->colormap[1][i] = (JSAMPLE) read_byte(sinfo);
114 sinfo->colormap[0][i] = (JSAMPLE) read_byte(sinfo);
115 }
116}
117
118
119/*
120 * read_pixel methods: get a single pixel from Targa file into tga_pixel[]
121 */
122
Thomas G. Lane489583f1996-02-07 00:00:00 +0000123METHODDEF(void)
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +0000124read_non_rle_pixel (tga_source_ptr sinfo)
125/* Read one Targa pixel from the input file; no RLE expansion */
126{
127 register FILE *infile = sinfo->pub.input_file;
128 register int i;
129
130 for (i = 0; i < sinfo->pixel_size; i++) {
131 sinfo->tga_pixel[i] = (U_CHAR) getc(infile);
132 }
133}
134
135
Thomas G. Lane489583f1996-02-07 00:00:00 +0000136METHODDEF(void)
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +0000137read_rle_pixel (tga_source_ptr sinfo)
138/* Read one Targa pixel from the input file, expanding RLE data as needed */
139{
140 register FILE *infile = sinfo->pub.input_file;
141 register int i;
142
143 /* Duplicate previously read pixel? */
144 if (sinfo->dup_pixel_count > 0) {
145 sinfo->dup_pixel_count--;
146 return;
147 }
148
149 /* Time to read RLE block header? */
150 if (--sinfo->block_count < 0) { /* decrement pixels remaining in block */
151 i = read_byte(sinfo);
DRCe5eaf372014-05-09 18:00:32 +0000152 if (i & 0x80) { /* Start of duplicate-pixel block? */
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +0000153 sinfo->dup_pixel_count = i & 0x7F; /* number of dups after this one */
DRCe5eaf372014-05-09 18:00:32 +0000154 sinfo->block_count = 0; /* then read new block header */
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +0000155 } else {
156 sinfo->block_count = i & 0x7F; /* number of pixels after this one */
157 }
158 }
159
160 /* Read next pixel */
161 for (i = 0; i < sinfo->pixel_size; i++) {
162 sinfo->tga_pixel[i] = (U_CHAR) getc(infile);
163 }
164}
165
166
167/*
168 * Read one row of pixels.
169 *
170 * We provide several different versions depending on input file format.
171 */
172
173
Thomas G. Lane489583f1996-02-07 00:00:00 +0000174METHODDEF(JDIMENSION)
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +0000175get_8bit_gray_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
176/* This version is for reading 8-bit grayscale pixels */
177{
178 tga_source_ptr source = (tga_source_ptr) sinfo;
179 register JSAMPROW ptr;
180 register JDIMENSION col;
DRC61976bd2014-04-20 19:13:10 +0000181
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +0000182 ptr = source->pub.buffer[0];
183 for (col = cinfo->image_width; col > 0; col--) {
184 (*source->read_pixel) (source); /* Load next pixel into tga_pixel */
185 *ptr++ = (JSAMPLE) UCH(source->tga_pixel[0]);
186 }
187 return 1;
188}
189
Thomas G. Lane489583f1996-02-07 00:00:00 +0000190METHODDEF(JDIMENSION)
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +0000191get_8bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
192/* This version is for reading 8-bit colormap indexes */
193{
194 tga_source_ptr source = (tga_source_ptr) sinfo;
195 register int t;
196 register JSAMPROW ptr;
197 register JDIMENSION col;
198 register JSAMPARRAY colormap = source->colormap;
199
200 ptr = source->pub.buffer[0];
201 for (col = cinfo->image_width; col > 0; col--) {
202 (*source->read_pixel) (source); /* Load next pixel into tga_pixel */
203 t = UCH(source->tga_pixel[0]);
204 *ptr++ = colormap[0][t];
205 *ptr++ = colormap[1][t];
206 *ptr++ = colormap[2][t];
207 }
208 return 1;
209}
210
Thomas G. Lane489583f1996-02-07 00:00:00 +0000211METHODDEF(JDIMENSION)
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +0000212get_16bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
213/* This version is for reading 16-bit pixels */
214{
215 tga_source_ptr source = (tga_source_ptr) sinfo;
216 register int t;
217 register JSAMPROW ptr;
218 register JDIMENSION col;
DRC61976bd2014-04-20 19:13:10 +0000219
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +0000220 ptr = source->pub.buffer[0];
221 for (col = cinfo->image_width; col > 0; col--) {
222 (*source->read_pixel) (source); /* Load next pixel into tga_pixel */
223 t = UCH(source->tga_pixel[0]);
224 t += UCH(source->tga_pixel[1]) << 8;
225 /* We expand 5 bit data to 8 bit sample width.
226 * The format of the 16-bit (LSB first) input word is
227 * xRRRRRGGGGGBBBBB
228 */
229 ptr[2] = (JSAMPLE) c5to8bits[t & 0x1F];
230 t >>= 5;
231 ptr[1] = (JSAMPLE) c5to8bits[t & 0x1F];
232 t >>= 5;
233 ptr[0] = (JSAMPLE) c5to8bits[t & 0x1F];
234 ptr += 3;
235 }
236 return 1;
237}
238
Thomas G. Lane489583f1996-02-07 00:00:00 +0000239METHODDEF(JDIMENSION)
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +0000240get_24bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
241/* This version is for reading 24-bit pixels */
242{
243 tga_source_ptr source = (tga_source_ptr) sinfo;
244 register JSAMPROW ptr;
245 register JDIMENSION col;
DRC61976bd2014-04-20 19:13:10 +0000246
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +0000247 ptr = source->pub.buffer[0];
248 for (col = cinfo->image_width; col > 0; col--) {
249 (*source->read_pixel) (source); /* Load next pixel into tga_pixel */
250 *ptr++ = (JSAMPLE) UCH(source->tga_pixel[2]); /* change BGR to RGB order */
251 *ptr++ = (JSAMPLE) UCH(source->tga_pixel[1]);
252 *ptr++ = (JSAMPLE) UCH(source->tga_pixel[0]);
253 }
254 return 1;
255}
256
257/*
258 * Targa also defines a 32-bit pixel format with order B,G,R,A.
259 * We presently ignore the attribute byte, so the code for reading
260 * these pixels is identical to the 24-bit routine above.
261 * This works because the actual pixel length is only known to read_pixel.
262 */
263
264#define get_32bit_row get_24bit_row
265
266
267/*
268 * This method is for re-reading the input data in standard top-down
269 * row order. The entire image has already been read into whole_image
270 * with proper conversion of pixel format, but it's in a funny row order.
271 */
272
Thomas G. Lane489583f1996-02-07 00:00:00 +0000273METHODDEF(JDIMENSION)
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +0000274get_memory_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
275{
276 tga_source_ptr source = (tga_source_ptr) sinfo;
277 JDIMENSION source_row;
278
279 /* Compute row of source that maps to current_row of normal order */
280 /* For now, assume image is bottom-up and not interlaced. */
281 /* NEEDS WORK to support interlaced images! */
282 source_row = cinfo->image_height - source->current_row - 1;
283
284 /* Fetch that row from virtual array */
285 source->pub.buffer = (*cinfo->mem->access_virt_sarray)
Thomas G. Lanebc79e061995-08-02 00:00:00 +0000286 ((j_common_ptr) cinfo, source->whole_image,
287 source_row, (JDIMENSION) 1, FALSE);
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +0000288
289 source->current_row++;
290 return 1;
291}
292
293
294/*
295 * This method loads the image into whole_image during the first call on
296 * get_pixel_rows. The get_pixel_rows pointer is then adjusted to call
297 * get_memory_row on subsequent calls.
298 */
299
Thomas G. Lane489583f1996-02-07 00:00:00 +0000300METHODDEF(JDIMENSION)
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +0000301preload_image (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
302{
303 tga_source_ptr source = (tga_source_ptr) sinfo;
304 JDIMENSION row;
305 cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress;
306
307 /* Read the data into a virtual array in input-file row order. */
308 for (row = 0; row < cinfo->image_height; row++) {
309 if (progress != NULL) {
310 progress->pub.pass_counter = (long) row;
311 progress->pub.pass_limit = (long) cinfo->image_height;
312 (*progress->pub.progress_monitor) ((j_common_ptr) cinfo);
313 }
314 source->pub.buffer = (*cinfo->mem->access_virt_sarray)
Thomas G. Lanebc79e061995-08-02 00:00:00 +0000315 ((j_common_ptr) cinfo, source->whole_image, row, (JDIMENSION) 1, TRUE);
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +0000316 (*source->get_pixel_rows) (cinfo, sinfo);
317 }
318 if (progress != NULL)
319 progress->completed_extra_passes++;
320
321 /* Set up to read from the virtual array in unscrambled order */
322 source->pub.get_pixel_rows = get_memory_row;
323 source->current_row = 0;
324 /* And read the first row */
325 return get_memory_row(cinfo, sinfo);
326}
327
328
329/*
330 * Read the file header; return image size and component count.
331 */
332
Thomas G. Lane489583f1996-02-07 00:00:00 +0000333METHODDEF(void)
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +0000334start_input_tga (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
335{
336 tga_source_ptr source = (tga_source_ptr) sinfo;
337 U_CHAR targaheader[18];
338 int idlen, cmaptype, subtype, flags, interlace_type, components;
339 unsigned int width, height, maplen;
340 boolean is_bottom_up;
341
DRCe5eaf372014-05-09 18:00:32 +0000342#define GET_2B(offset) ((unsigned int) UCH(targaheader[offset]) + \
343 (((unsigned int) UCH(targaheader[offset+1])) << 8))
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +0000344
345 if (! ReadOK(source->pub.input_file, targaheader, 18))
346 ERREXIT(cinfo, JERR_INPUT_EOF);
347
348 /* Pretend "15-bit" pixels are 16-bit --- we ignore attribute bit anyway */
349 if (targaheader[16] == 15)
350 targaheader[16] = 16;
351
352 idlen = UCH(targaheader[0]);
353 cmaptype = UCH(targaheader[1]);
354 subtype = UCH(targaheader[2]);
355 maplen = GET_2B(5);
356 width = GET_2B(12);
357 height = GET_2B(14);
358 source->pixel_size = UCH(targaheader[16]) >> 3;
DRCe5eaf372014-05-09 18:00:32 +0000359 flags = UCH(targaheader[17]); /* Image Descriptor byte */
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +0000360
DRCe5eaf372014-05-09 18:00:32 +0000361 is_bottom_up = ((flags & 0x20) == 0); /* bit 5 set => top-down */
362 interlace_type = flags >> 6; /* bits 6/7 are interlace code */
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +0000363
DRCe5eaf372014-05-09 18:00:32 +0000364 if (cmaptype > 1 || /* cmaptype must be 0 or 1 */
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +0000365 source->pixel_size < 1 || source->pixel_size > 4 ||
366 (UCH(targaheader[16]) & 7) != 0 || /* bits/pixel must be multiple of 8 */
DRCe5eaf372014-05-09 18:00:32 +0000367 interlace_type != 0) /* currently don't allow interlaced image */
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +0000368 ERREXIT(cinfo, JERR_TGA_BADPARMS);
DRC61976bd2014-04-20 19:13:10 +0000369
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +0000370 if (subtype > 8) {
371 /* It's an RLE-coded file */
372 source->read_pixel = read_rle_pixel;
373 source->block_count = source->dup_pixel_count = 0;
374 subtype -= 8;
375 } else {
376 /* Non-RLE file */
377 source->read_pixel = read_non_rle_pixel;
378 }
379
380 /* Now should have subtype 1, 2, or 3 */
DRCe5eaf372014-05-09 18:00:32 +0000381 components = 3; /* until proven different */
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +0000382 cinfo->in_color_space = JCS_RGB;
383
384 switch (subtype) {
DRCe5eaf372014-05-09 18:00:32 +0000385 case 1: /* Colormapped image */
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +0000386 if (source->pixel_size == 1 && cmaptype == 1)
387 source->get_pixel_rows = get_8bit_row;
388 else
389 ERREXIT(cinfo, JERR_TGA_BADPARMS);
390 TRACEMS2(cinfo, 1, JTRC_TGA_MAPPED, width, height);
391 break;
DRCe5eaf372014-05-09 18:00:32 +0000392 case 2: /* RGB image */
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +0000393 switch (source->pixel_size) {
394 case 2:
395 source->get_pixel_rows = get_16bit_row;
396 break;
397 case 3:
398 source->get_pixel_rows = get_24bit_row;
399 break;
400 case 4:
401 source->get_pixel_rows = get_32bit_row;
402 break;
403 default:
404 ERREXIT(cinfo, JERR_TGA_BADPARMS);
405 break;
406 }
407 TRACEMS2(cinfo, 1, JTRC_TGA, width, height);
408 break;
DRCe5eaf372014-05-09 18:00:32 +0000409 case 3: /* Grayscale image */
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +0000410 components = 1;
411 cinfo->in_color_space = JCS_GRAYSCALE;
412 if (source->pixel_size == 1)
413 source->get_pixel_rows = get_8bit_gray_row;
414 else
415 ERREXIT(cinfo, JERR_TGA_BADPARMS);
416 TRACEMS2(cinfo, 1, JTRC_TGA_GRAY, width, height);
417 break;
418 default:
419 ERREXIT(cinfo, JERR_TGA_BADPARMS);
420 break;
421 }
422
423 if (is_bottom_up) {
424 /* Create a virtual array to buffer the upside-down image. */
425 source->whole_image = (*cinfo->mem->request_virt_sarray)
Thomas G. Lanebc79e061995-08-02 00:00:00 +0000426 ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE,
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +0000427 (JDIMENSION) width * components, (JDIMENSION) height, (JDIMENSION) 1);
428 if (cinfo->progress != NULL) {
429 cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress;
430 progress->total_extra_passes++; /* count file input as separate pass */
431 }
432 /* source->pub.buffer will point to the virtual array. */
433 source->pub.buffer_height = 1; /* in case anyone looks at it */
434 source->pub.get_pixel_rows = preload_image;
435 } else {
436 /* Don't need a virtual array, but do need a one-row input buffer. */
437 source->whole_image = NULL;
438 source->pub.buffer = (*cinfo->mem->alloc_sarray)
439 ((j_common_ptr) cinfo, JPOOL_IMAGE,
440 (JDIMENSION) width * components, (JDIMENSION) 1);
441 source->pub.buffer_height = 1;
442 source->pub.get_pixel_rows = source->get_pixel_rows;
443 }
DRC61976bd2014-04-20 19:13:10 +0000444
DRCe5eaf372014-05-09 18:00:32 +0000445 while (idlen--) /* Throw away ID field */
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +0000446 (void) read_byte(source);
447
448 if (maplen > 0) {
449 if (maplen > 256 || GET_2B(3) != 0)
450 ERREXIT(cinfo, JERR_TGA_BADCMAP);
451 /* Allocate space to store the colormap */
452 source->colormap = (*cinfo->mem->alloc_sarray)
453 ((j_common_ptr) cinfo, JPOOL_IMAGE, (JDIMENSION) maplen, (JDIMENSION) 3);
454 /* and read it from the file */
455 read_colormap(source, (int) maplen, UCH(targaheader[7]));
456 } else {
DRCe5eaf372014-05-09 18:00:32 +0000457 if (cmaptype) /* but you promised a cmap! */
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +0000458 ERREXIT(cinfo, JERR_TGA_BADPARMS);
459 source->colormap = NULL;
460 }
461
462 cinfo->input_components = components;
463 cinfo->data_precision = 8;
464 cinfo->image_width = width;
465 cinfo->image_height = height;
466}
467
468
469/*
470 * Finish up at the end of the file.
471 */
472
Thomas G. Lane489583f1996-02-07 00:00:00 +0000473METHODDEF(void)
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +0000474finish_input_tga (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
475{
476 /* no work */
477}
478
479
480/*
481 * The module selection routine for Targa format input.
482 */
483
Thomas G. Lane489583f1996-02-07 00:00:00 +0000484GLOBAL(cjpeg_source_ptr)
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +0000485jinit_read_targa (j_compress_ptr cinfo)
486{
487 tga_source_ptr source;
488
489 /* Create module interface object */
490 source = (tga_source_ptr)
491 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
DRC5de454b2014-05-18 19:04:03 +0000492 sizeof(tga_source_struct));
DRCe5eaf372014-05-09 18:00:32 +0000493 source->cinfo = cinfo; /* make back link for subroutines */
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +0000494 /* Fill in method ptrs, except get_pixel_rows which start_input sets */
495 source->pub.start_input = start_input_tga;
496 source->pub.finish_input = finish_input_tga;
497
498 return (cjpeg_source_ptr) source;
499}
500
501#endif /* TARGA_SUPPORTED */