Coverage Report

Created: 2025-07-11 07:02

/src/libjpeg-turbo.main/src/rdppm.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * rdppm.c
3
 *
4
 * This file was part of the Independent JPEG Group's software:
5
 * Copyright (C) 1991-1997, Thomas G. Lane.
6
 * Modified 2009 by Bill Allombert, Guido Vollbeding.
7
 * libjpeg-turbo Modifications:
8
 * Copyright (C) 2015-2017, 2020-2024, D. R. Commander.
9
 * For conditions of distribution and use, see the accompanying README.ijg
10
 * file.
11
 *
12
 * This file contains routines to read input images in PPM/PGM format.
13
 * The extended 2-byte-per-sample raw PPM/PGM formats are supported.
14
 * The PBMPLUS library is NOT required to compile this software
15
 * (but it is highly useful as a set of PPM image manipulation programs).
16
 *
17
 * These routines may need modification for non-Unix environments or
18
 * specialized applications.  As they stand, they assume input from
19
 * an ordinary stdio stream.  They further assume that reading begins
20
 * at the start of the file; start_input may need work if the
21
 * user interface has already read some data (e.g., to determine that
22
 * the file is indeed PPM format).
23
 */
24
25
#include "cmyk.h"
26
#include "cdjpeg.h"             /* Common decls for cjpeg/djpeg applications */
27
28
#if defined(PPM_SUPPORTED) && \
29
    (BITS_IN_JSAMPLE != 16 || defined(C_LOSSLESS_SUPPORTED))
30
31
32
/* Portions of this code are based on the PBMPLUS library, which is:
33
**
34
** Copyright (C) 1988 by Jef Poskanzer.
35
**
36
** Permission to use, copy, modify, and distribute this software and its
37
** documentation for any purpose and without fee is hereby granted, provided
38
** that the above copyright notice appear in all copies and that both that
39
** copyright notice and this permission notice appear in supporting
40
** documentation.  This software is provided "as is" without express or
41
** implied warranty.
42
*/
43
44
45
/* Macros to deal with unsigned chars as efficiently as compiler allows */
46
47
typedef unsigned char U_CHAR;
48
0
#define UCH(x)  ((int)(x))
49
50
51
#define ReadOK(file, buffer, len) \
52
0
  (fread(buffer, 1, len, file) == ((size_t)(len)))
53
54
static int alpha_index[JPEG_NUMCS] = {
55
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 3, 3, 0, 0, -1
56
};
57
58
59
/* Private version of data source object */
60
61
typedef struct {
62
  struct cjpeg_source_struct pub; /* public fields */
63
64
  /* Usually these two pointers point to the same place: */
65
  U_CHAR *iobuffer;             /* fread's I/O buffer */
66
  _JSAMPROW pixrow;             /* compressor input buffer */
67
  size_t buffer_width;          /* width of I/O buffer */
68
  _JSAMPLE *rescale;            /* => maxval-remapping array, or NULL */
69
  unsigned int maxval;
70
} ppm_source_struct;
71
72
typedef ppm_source_struct *ppm_source_ptr;
73
74
75
LOCAL(int)
76
pbm_getc(FILE *infile)
77
/* Read next char, skipping over any comments */
78
/* A comment/newline sequence is returned as a newline */
79
0
{
80
0
  register int ch;
81
82
0
  ch = getc(infile);
83
0
  if (ch == '#') {
84
0
    do {
85
0
      ch = getc(infile);
86
0
    } while (ch != '\n' && ch != EOF);
87
0
  }
88
0
  return ch;
89
0
}
Unexecuted instantiation: rdppm-8.c:pbm_getc
Unexecuted instantiation: rdppm-12.c:pbm_getc
Unexecuted instantiation: rdppm-16.c:pbm_getc
90
91
92
LOCAL(unsigned int)
93
read_pbm_integer(j_compress_ptr cinfo, FILE *infile, unsigned int maxval)
94
/* Read an unsigned decimal integer from the PPM file */
95
/* Swallows one trailing character after the integer */
96
/* Note that on a 16-bit-int machine, only values up to 64k can be read. */
97
/* This should not be a problem in practice. */
98
0
{
99
0
  register int ch;
100
0
  register unsigned int val;
101
102
  /* Skip any leading whitespace */
103
0
  do {
104
0
    ch = pbm_getc(infile);
105
0
    if (ch == EOF)
106
0
      ERREXIT(cinfo, JERR_INPUT_EOF);
107
0
  } while (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r');
108
109
0
  if (ch < '0' || ch > '9')
110
0
    ERREXIT(cinfo, JERR_PPM_NONNUMERIC);
111
112
0
  val = ch - '0';
113
0
  while ((ch = pbm_getc(infile)) >= '0' && ch <= '9') {
114
0
    val *= 10;
115
0
    val += ch - '0';
116
0
    if (val > maxval)
117
0
      ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
118
0
  }
119
120
0
  return val;
121
0
}
Unexecuted instantiation: rdppm-8.c:read_pbm_integer
Unexecuted instantiation: rdppm-12.c:read_pbm_integer
Unexecuted instantiation: rdppm-16.c:read_pbm_integer
122
123
124
/*
125
 * Read one row of pixels.
126
 *
127
 * We provide several different versions depending on input file format.
128
 * In all cases, input is scaled to cinfo->data_precision.
129
 *
130
 * A really fast path is provided for reading byte/sample raw files with
131
 * maxval <= _MAXJSAMPLE and maxval == (1U << cinfo->data_precision) - 1U,
132
 * which is the normal case for 8-bit data.
133
 */
134
135
136
METHODDEF(JDIMENSION)
137
get_text_gray_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
138
/* This version is for reading text-format PGM files with any maxval */
139
0
{
140
0
  ppm_source_ptr source = (ppm_source_ptr)sinfo;
141
0
  FILE *infile = source->pub.input_file;
142
0
  register _JSAMPROW ptr;
143
0
  register _JSAMPLE *rescale = source->rescale;
144
0
  JDIMENSION col;
145
0
  unsigned int maxval = source->maxval;
146
147
0
  ptr = source->pub._buffer[0];
148
0
  for (col = cinfo->image_width; col > 0; col--) {
149
0
    *ptr++ = rescale[read_pbm_integer(cinfo, infile, maxval)];
150
0
  }
151
0
  return 1;
152
0
}
Unexecuted instantiation: rdppm-8.c:get_text_gray_row
Unexecuted instantiation: rdppm-12.c:get_text_gray_row
Unexecuted instantiation: rdppm-16.c:get_text_gray_row
153
154
155
0
#define GRAY_RGB_READ_LOOP(read_op, alpha_set_op) { \
156
0
  for (col = cinfo->image_width; col > 0; col--) { \
157
0
    ptr[rindex] = ptr[gindex] = ptr[bindex] = read_op; \
158
0
    alpha_set_op \
159
0
    ptr += ps; \
160
0
  } \
161
0
}
162
163
METHODDEF(JDIMENSION)
164
get_text_gray_rgb_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
165
/* This version is for reading text-format PGM files with any maxval and
166
   converting to extended RGB */
167
0
{
168
0
  ppm_source_ptr source = (ppm_source_ptr)sinfo;
169
0
  FILE *infile = source->pub.input_file;
170
0
  register _JSAMPROW ptr;
171
0
  register _JSAMPLE *rescale = source->rescale;
172
0
  JDIMENSION col;
173
0
  unsigned int maxval = source->maxval;
174
0
  register int rindex = rgb_red[cinfo->in_color_space];
175
0
  register int gindex = rgb_green[cinfo->in_color_space];
176
0
  register int bindex = rgb_blue[cinfo->in_color_space];
177
0
  register int aindex = alpha_index[cinfo->in_color_space];
178
0
  register int ps = rgb_pixelsize[cinfo->in_color_space];
179
180
0
  ptr = source->pub._buffer[0];
181
0
  if (maxval == (1U << cinfo->data_precision) - 1U) {
182
0
    if (aindex >= 0)
183
0
      GRAY_RGB_READ_LOOP((_JSAMPLE)read_pbm_integer(cinfo, infile, maxval),
184
0
                         ptr[aindex] = (_JSAMPLE)maxval;)
185
0
    else
186
0
      GRAY_RGB_READ_LOOP((_JSAMPLE)read_pbm_integer(cinfo, infile, maxval), {})
187
0
  } else {
188
0
    if (aindex >= 0)
189
0
      GRAY_RGB_READ_LOOP(rescale[read_pbm_integer(cinfo, infile, maxval)],
190
0
                         ptr[aindex] = (1 << cinfo->data_precision) - 1;)
191
0
    else
192
0
      GRAY_RGB_READ_LOOP(rescale[read_pbm_integer(cinfo, infile, maxval)], {})
193
0
  }
194
0
  return 1;
195
0
}
Unexecuted instantiation: rdppm-8.c:get_text_gray_rgb_row
Unexecuted instantiation: rdppm-12.c:get_text_gray_rgb_row
Unexecuted instantiation: rdppm-16.c:get_text_gray_rgb_row
196
197
198
METHODDEF(JDIMENSION)
199
get_text_gray_cmyk_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
200
/* This version is for reading text-format PGM files with any maxval and
201
   converting to CMYK */
202
0
{
203
0
  ppm_source_ptr source = (ppm_source_ptr)sinfo;
204
0
  FILE *infile = source->pub.input_file;
205
0
  register _JSAMPROW ptr;
206
0
  register _JSAMPLE *rescale = source->rescale;
207
0
  JDIMENSION col;
208
0
  unsigned int maxval = source->maxval;
209
210
0
  ptr = source->pub._buffer[0];
211
0
  if (maxval == (1U << cinfo->data_precision) - 1U) {
212
0
    for (col = cinfo->image_width; col > 0; col--) {
213
0
      _JSAMPLE gray = (_JSAMPLE)read_pbm_integer(cinfo, infile, maxval);
214
0
      rgb_to_cmyk(maxval, gray, gray, gray, ptr, ptr + 1, ptr + 2, ptr + 3);
215
0
      ptr += 4;
216
0
    }
217
0
  } else {
218
0
    for (col = cinfo->image_width; col > 0; col--) {
219
0
      _JSAMPLE gray = rescale[read_pbm_integer(cinfo, infile, maxval)];
220
0
      rgb_to_cmyk(maxval, gray, gray, gray, ptr, ptr + 1, ptr + 2, ptr + 3);
221
0
      ptr += 4;
222
0
    }
223
0
  }
224
0
  return 1;
225
0
}
Unexecuted instantiation: rdppm-8.c:get_text_gray_cmyk_row
Unexecuted instantiation: rdppm-12.c:get_text_gray_cmyk_row
Unexecuted instantiation: rdppm-16.c:get_text_gray_cmyk_row
226
227
228
0
#define RGB_READ_LOOP(read_op, alpha_set_op) { \
229
0
  for (col = cinfo->image_width; col > 0; col--) { \
230
0
    ptr[rindex] = read_op; \
231
0
    ptr[gindex] = read_op; \
232
0
    ptr[bindex] = read_op; \
233
0
    alpha_set_op \
234
0
    ptr += ps; \
235
0
  } \
236
0
}
237
238
METHODDEF(JDIMENSION)
239
get_text_rgb_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
240
/* This version is for reading text-format PPM files with any maxval */
241
0
{
242
0
  ppm_source_ptr source = (ppm_source_ptr)sinfo;
243
0
  FILE *infile = source->pub.input_file;
244
0
  register _JSAMPROW ptr;
245
0
  register _JSAMPLE *rescale = source->rescale;
246
0
  JDIMENSION col;
247
0
  unsigned int maxval = source->maxval;
248
0
  register int rindex = rgb_red[cinfo->in_color_space];
249
0
  register int gindex = rgb_green[cinfo->in_color_space];
250
0
  register int bindex = rgb_blue[cinfo->in_color_space];
251
0
  register int aindex = alpha_index[cinfo->in_color_space];
252
0
  register int ps = rgb_pixelsize[cinfo->in_color_space];
253
254
0
  ptr = source->pub._buffer[0];
255
0
  if (maxval == (1U << cinfo->data_precision) - 1U) {
256
0
    if (aindex >= 0)
257
0
      RGB_READ_LOOP((_JSAMPLE)read_pbm_integer(cinfo, infile, maxval),
258
0
                    ptr[aindex] = (_JSAMPLE)maxval;)
259
0
    else
260
0
      RGB_READ_LOOP((_JSAMPLE)read_pbm_integer(cinfo, infile, maxval), {})
261
0
  } else {
262
0
    if (aindex >= 0)
263
0
      RGB_READ_LOOP(rescale[read_pbm_integer(cinfo, infile, maxval)],
264
0
                    ptr[aindex] = (1 << cinfo->data_precision) - 1;)
265
0
    else
266
0
      RGB_READ_LOOP(rescale[read_pbm_integer(cinfo, infile, maxval)], {})
267
0
  }
268
0
  return 1;
269
0
}
Unexecuted instantiation: rdppm-8.c:get_text_rgb_row
Unexecuted instantiation: rdppm-12.c:get_text_rgb_row
Unexecuted instantiation: rdppm-16.c:get_text_rgb_row
270
271
272
METHODDEF(JDIMENSION)
273
get_text_rgb_cmyk_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
274
/* This version is for reading text-format PPM files with any maxval and
275
   converting to CMYK */
276
0
{
277
0
  ppm_source_ptr source = (ppm_source_ptr)sinfo;
278
0
  FILE *infile = source->pub.input_file;
279
0
  register _JSAMPROW ptr;
280
0
  register _JSAMPLE *rescale = source->rescale;
281
0
  JDIMENSION col;
282
0
  unsigned int maxval = source->maxval;
283
284
0
  ptr = source->pub._buffer[0];
285
0
  if (maxval == (1U << cinfo->data_precision) - 1U) {
286
0
    for (col = cinfo->image_width; col > 0; col--) {
287
0
      _JSAMPLE r = (_JSAMPLE)read_pbm_integer(cinfo, infile, maxval);
288
0
      _JSAMPLE g = (_JSAMPLE)read_pbm_integer(cinfo, infile, maxval);
289
0
      _JSAMPLE b = (_JSAMPLE)read_pbm_integer(cinfo, infile, maxval);
290
0
      rgb_to_cmyk(maxval, r, g, b, ptr, ptr + 1, ptr + 2, ptr + 3);
291
0
      ptr += 4;
292
0
    }
293
0
  } else {
294
0
    for (col = cinfo->image_width; col > 0; col--) {
295
0
      _JSAMPLE r = rescale[read_pbm_integer(cinfo, infile, maxval)];
296
0
      _JSAMPLE g = rescale[read_pbm_integer(cinfo, infile, maxval)];
297
0
      _JSAMPLE b = rescale[read_pbm_integer(cinfo, infile, maxval)];
298
0
      rgb_to_cmyk(maxval, r, g, b, ptr, ptr + 1, ptr + 2, ptr + 3);
299
0
      ptr += 4;
300
0
    }
301
0
  }
302
0
  return 1;
303
0
}
Unexecuted instantiation: rdppm-8.c:get_text_rgb_cmyk_row
Unexecuted instantiation: rdppm-12.c:get_text_rgb_cmyk_row
Unexecuted instantiation: rdppm-16.c:get_text_rgb_cmyk_row
304
305
306
METHODDEF(JDIMENSION)
307
get_scaled_gray_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
308
/* This version is for reading raw-byte-format PGM files with any maxval */
309
0
{
310
0
  ppm_source_ptr source = (ppm_source_ptr)sinfo;
311
0
  register _JSAMPROW ptr;
312
0
  register U_CHAR *bufferptr;
313
0
  register _JSAMPLE *rescale = source->rescale;
314
0
  JDIMENSION col;
315
316
0
  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
317
0
    ERREXIT(cinfo, JERR_INPUT_EOF);
318
0
  ptr = source->pub._buffer[0];
319
0
  bufferptr = source->iobuffer;
320
0
  for (col = cinfo->image_width; col > 0; col--) {
321
0
    *ptr++ = rescale[UCH(*bufferptr++)];
322
0
  }
323
0
  return 1;
324
0
}
Unexecuted instantiation: rdppm-8.c:get_scaled_gray_row
Unexecuted instantiation: rdppm-12.c:get_scaled_gray_row
Unexecuted instantiation: rdppm-16.c:get_scaled_gray_row
325
326
327
METHODDEF(JDIMENSION)
328
get_gray_rgb_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
329
/* This version is for reading raw-byte-format PGM files with any maxval
330
   and converting to extended RGB */
331
0
{
332
0
  ppm_source_ptr source = (ppm_source_ptr)sinfo;
333
0
  register _JSAMPROW ptr;
334
0
  register U_CHAR *bufferptr;
335
0
  register _JSAMPLE *rescale = source->rescale;
336
0
  JDIMENSION col;
337
0
  unsigned int maxval = source->maxval;
338
0
  register int rindex = rgb_red[cinfo->in_color_space];
339
0
  register int gindex = rgb_green[cinfo->in_color_space];
340
0
  register int bindex = rgb_blue[cinfo->in_color_space];
341
0
  register int aindex = alpha_index[cinfo->in_color_space];
342
0
  register int ps = rgb_pixelsize[cinfo->in_color_space];
343
344
0
  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
345
0
    ERREXIT(cinfo, JERR_INPUT_EOF);
346
0
  ptr = source->pub._buffer[0];
347
0
  bufferptr = source->iobuffer;
348
0
  if (maxval == (1U << cinfo->data_precision) - 1U) {
349
0
    if (aindex >= 0)
350
0
      GRAY_RGB_READ_LOOP(*bufferptr++, ptr[aindex] = (_JSAMPLE)maxval;)
351
0
    else
352
0
      GRAY_RGB_READ_LOOP(*bufferptr++, {})
353
0
  } else {
354
0
    if (aindex >= 0)
355
0
      GRAY_RGB_READ_LOOP(rescale[UCH(*bufferptr++)],
356
0
                         ptr[aindex] = (1 << cinfo->data_precision) - 1;)
357
0
    else
358
0
      GRAY_RGB_READ_LOOP(rescale[UCH(*bufferptr++)], {})
359
0
  }
360
0
  return 1;
361
0
}
Unexecuted instantiation: rdppm-8.c:get_gray_rgb_row
Unexecuted instantiation: rdppm-12.c:get_gray_rgb_row
Unexecuted instantiation: rdppm-16.c:get_gray_rgb_row
362
363
364
METHODDEF(JDIMENSION)
365
get_gray_cmyk_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
366
/* This version is for reading raw-byte-format PGM files with any maxval
367
   and converting to CMYK */
368
0
{
369
0
  ppm_source_ptr source = (ppm_source_ptr)sinfo;
370
0
  register _JSAMPROW ptr;
371
0
  register U_CHAR *bufferptr;
372
0
  register _JSAMPLE *rescale = source->rescale;
373
0
  JDIMENSION col;
374
0
  unsigned int maxval = source->maxval;
375
376
0
  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
377
0
    ERREXIT(cinfo, JERR_INPUT_EOF);
378
0
  ptr = source->pub._buffer[0];
379
0
  bufferptr = source->iobuffer;
380
0
  if (maxval == (1U << cinfo->data_precision) - 1U) {
381
0
    for (col = cinfo->image_width; col > 0; col--) {
382
0
      _JSAMPLE gray = *bufferptr++;
383
0
      rgb_to_cmyk(maxval, gray, gray, gray, ptr, ptr + 1, ptr + 2, ptr + 3);
384
0
      ptr += 4;
385
0
    }
386
0
  } else {
387
0
    for (col = cinfo->image_width; col > 0; col--) {
388
0
      _JSAMPLE gray = rescale[UCH(*bufferptr++)];
389
0
      rgb_to_cmyk(maxval, gray, gray, gray, ptr, ptr + 1, ptr + 2, ptr + 3);
390
0
      ptr += 4;
391
0
    }
392
0
  }
393
0
  return 1;
394
0
}
Unexecuted instantiation: rdppm-8.c:get_gray_cmyk_row
Unexecuted instantiation: rdppm-12.c:get_gray_cmyk_row
Unexecuted instantiation: rdppm-16.c:get_gray_cmyk_row
395
396
397
METHODDEF(JDIMENSION)
398
get_rgb_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
399
/* This version is for reading raw-byte-format PPM files with any maxval */
400
0
{
401
0
  ppm_source_ptr source = (ppm_source_ptr)sinfo;
402
0
  register _JSAMPROW ptr;
403
0
  register U_CHAR *bufferptr;
404
0
  register _JSAMPLE *rescale = source->rescale;
405
0
  JDIMENSION col;
406
0
  unsigned int maxval = source->maxval;
407
0
  register int rindex = rgb_red[cinfo->in_color_space];
408
0
  register int gindex = rgb_green[cinfo->in_color_space];
409
0
  register int bindex = rgb_blue[cinfo->in_color_space];
410
0
  register int aindex = alpha_index[cinfo->in_color_space];
411
0
  register int ps = rgb_pixelsize[cinfo->in_color_space];
412
413
0
  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
414
0
    ERREXIT(cinfo, JERR_INPUT_EOF);
415
0
  ptr = source->pub._buffer[0];
416
0
  bufferptr = source->iobuffer;
417
0
  if (maxval == (1U << cinfo->data_precision) - 1U) {
418
0
    if (aindex >= 0)
419
0
      RGB_READ_LOOP(*bufferptr++, ptr[aindex] = (_JSAMPLE)maxval;)
420
0
    else
421
0
      RGB_READ_LOOP(*bufferptr++, {})
422
0
  } else {
423
0
    if (aindex >= 0)
424
0
      RGB_READ_LOOP(rescale[UCH(*bufferptr++)],
425
0
                    ptr[aindex] = (1 << cinfo->data_precision) - 1;)
426
0
    else
427
0
      RGB_READ_LOOP(rescale[UCH(*bufferptr++)], {})
428
0
  }
429
0
  return 1;
430
0
}
Unexecuted instantiation: rdppm-8.c:get_rgb_row
Unexecuted instantiation: rdppm-12.c:get_rgb_row
Unexecuted instantiation: rdppm-16.c:get_rgb_row
431
432
433
METHODDEF(JDIMENSION)
434
get_rgb_cmyk_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
435
/* This version is for reading raw-byte-format PPM files with any maxval and
436
   converting to CMYK */
437
0
{
438
0
  ppm_source_ptr source = (ppm_source_ptr)sinfo;
439
0
  register _JSAMPROW ptr;
440
0
  register U_CHAR *bufferptr;
441
0
  register _JSAMPLE *rescale = source->rescale;
442
0
  JDIMENSION col;
443
0
  unsigned int maxval = source->maxval;
444
445
0
  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
446
0
    ERREXIT(cinfo, JERR_INPUT_EOF);
447
0
  ptr = source->pub._buffer[0];
448
0
  bufferptr = source->iobuffer;
449
0
  if (maxval == (1U << cinfo->data_precision) - 1U) {
450
0
    for (col = cinfo->image_width; col > 0; col--) {
451
0
      _JSAMPLE r = *bufferptr++;
452
0
      _JSAMPLE g = *bufferptr++;
453
0
      _JSAMPLE b = *bufferptr++;
454
0
      rgb_to_cmyk(maxval, r, g, b, ptr, ptr + 1, ptr + 2, ptr + 3);
455
0
      ptr += 4;
456
0
    }
457
0
  } else {
458
0
    for (col = cinfo->image_width; col > 0; col--) {
459
0
      _JSAMPLE r = rescale[UCH(*bufferptr++)];
460
0
      _JSAMPLE g = rescale[UCH(*bufferptr++)];
461
0
      _JSAMPLE b = rescale[UCH(*bufferptr++)];
462
0
      rgb_to_cmyk(maxval, r, g, b, ptr, ptr + 1, ptr + 2, ptr + 3);
463
0
      ptr += 4;
464
0
    }
465
0
  }
466
0
  return 1;
467
0
}
Unexecuted instantiation: rdppm-8.c:get_rgb_cmyk_row
Unexecuted instantiation: rdppm-12.c:get_rgb_cmyk_row
Unexecuted instantiation: rdppm-16.c:get_rgb_cmyk_row
468
469
470
METHODDEF(JDIMENSION)
471
get_raw_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
472
/* This version is for reading raw-byte-format files with
473
 * maxval <= _MAXJSAMPLE and maxval == (1U << cinfo->data_precision) - 1U.
474
 * In this case we just read right into the _JSAMPLE buffer!
475
 * Note that same code works for PPM and PGM files.
476
 */
477
0
{
478
0
  ppm_source_ptr source = (ppm_source_ptr)sinfo;
479
480
0
  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
481
0
    ERREXIT(cinfo, JERR_INPUT_EOF);
482
0
  return 1;
483
0
}
Unexecuted instantiation: rdppm-8.c:get_raw_row
Unexecuted instantiation: rdppm-12.c:get_raw_row
Unexecuted instantiation: rdppm-16.c:get_raw_row
484
485
486
METHODDEF(JDIMENSION)
487
get_word_gray_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
488
/* This version is for reading raw-word-format PGM files with any maxval */
489
0
{
490
0
  ppm_source_ptr source = (ppm_source_ptr)sinfo;
491
0
  register _JSAMPROW ptr;
492
0
  register U_CHAR *bufferptr;
493
0
  register _JSAMPLE *rescale = source->rescale;
494
0
  JDIMENSION col;
495
0
  unsigned int maxval = source->maxval;
496
497
0
  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
498
0
    ERREXIT(cinfo, JERR_INPUT_EOF);
499
0
  ptr = source->pub._buffer[0];
500
0
  bufferptr = source->iobuffer;
501
0
  for (col = cinfo->image_width; col > 0; col--) {
502
0
    register unsigned int temp;
503
0
    temp  = UCH(*bufferptr++) << 8;
504
0
    temp |= UCH(*bufferptr++);
505
0
    if (temp > maxval)
506
0
      ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
507
0
    *ptr++ = rescale[temp];
508
0
  }
509
0
  return 1;
510
0
}
Unexecuted instantiation: rdppm-8.c:get_word_gray_row
Unexecuted instantiation: rdppm-12.c:get_word_gray_row
Unexecuted instantiation: rdppm-16.c:get_word_gray_row
511
512
513
METHODDEF(JDIMENSION)
514
get_word_gray_rgb_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
515
/* This version is for reading raw-word-format PGM files with any maxval */
516
0
{
517
0
  ppm_source_ptr source = (ppm_source_ptr)sinfo;
518
0
  register _JSAMPROW ptr;
519
0
  register U_CHAR *bufferptr;
520
0
  register _JSAMPLE *rescale = source->rescale;
521
0
  JDIMENSION col;
522
0
  unsigned int maxval = source->maxval;
523
0
  register int rindex = rgb_red[cinfo->in_color_space];
524
0
  register int gindex = rgb_green[cinfo->in_color_space];
525
0
  register int bindex = rgb_blue[cinfo->in_color_space];
526
0
  register int aindex = alpha_index[cinfo->in_color_space];
527
0
  register int ps = rgb_pixelsize[cinfo->in_color_space];
528
529
0
  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
530
0
    ERREXIT(cinfo, JERR_INPUT_EOF);
531
0
  ptr = source->pub._buffer[0];
532
0
  bufferptr = source->iobuffer;
533
0
  for (col = cinfo->image_width; col > 0; col--) {
534
0
    register unsigned int temp;
535
0
    temp  = UCH(*bufferptr++) << 8;
536
0
    temp |= UCH(*bufferptr++);
537
0
    if (temp > maxval)
538
0
      ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
539
0
    ptr[rindex] = ptr[gindex] = ptr[bindex] = rescale[temp];
540
0
    if (aindex >= 0)
541
0
      ptr[aindex] = (1 << cinfo->data_precision) - 1;
542
0
    ptr += ps;
543
0
  }
544
0
  return 1;
545
0
}
Unexecuted instantiation: rdppm-8.c:get_word_gray_rgb_row
Unexecuted instantiation: rdppm-12.c:get_word_gray_rgb_row
Unexecuted instantiation: rdppm-16.c:get_word_gray_rgb_row
546
547
548
METHODDEF(JDIMENSION)
549
get_word_gray_cmyk_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
550
/* This version is for reading raw-word-format PGM files with any maxval */
551
0
{
552
0
  ppm_source_ptr source = (ppm_source_ptr)sinfo;
553
0
  register _JSAMPROW ptr;
554
0
  register U_CHAR *bufferptr;
555
0
  register _JSAMPLE *rescale = source->rescale;
556
0
  JDIMENSION col;
557
0
  unsigned int maxval = source->maxval;
558
559
0
  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
560
0
    ERREXIT(cinfo, JERR_INPUT_EOF);
561
0
  ptr = source->pub._buffer[0];
562
0
  bufferptr = source->iobuffer;
563
0
  for (col = cinfo->image_width; col > 0; col--) {
564
0
    register unsigned int gray;
565
0
    gray  = UCH(*bufferptr++) << 8;
566
0
    gray |= UCH(*bufferptr++);
567
0
    if (gray > maxval)
568
0
      ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
569
0
    rgb_to_cmyk(maxval, rescale[gray], rescale[gray], rescale[gray], ptr,
570
0
                ptr + 1, ptr + 2, ptr + 3);
571
0
    ptr += 4;
572
0
  }
573
0
  return 1;
574
0
}
Unexecuted instantiation: rdppm-8.c:get_word_gray_cmyk_row
Unexecuted instantiation: rdppm-12.c:get_word_gray_cmyk_row
Unexecuted instantiation: rdppm-16.c:get_word_gray_cmyk_row
575
576
577
METHODDEF(JDIMENSION)
578
get_word_rgb_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
579
/* This version is for reading raw-word-format PPM files with any maxval */
580
0
{
581
0
  ppm_source_ptr source = (ppm_source_ptr)sinfo;
582
0
  register _JSAMPROW ptr;
583
0
  register U_CHAR *bufferptr;
584
0
  register _JSAMPLE *rescale = source->rescale;
585
0
  JDIMENSION col;
586
0
  unsigned int maxval = source->maxval;
587
0
  register int rindex = rgb_red[cinfo->in_color_space];
588
0
  register int gindex = rgb_green[cinfo->in_color_space];
589
0
  register int bindex = rgb_blue[cinfo->in_color_space];
590
0
  register int aindex = alpha_index[cinfo->in_color_space];
591
0
  register int ps = rgb_pixelsize[cinfo->in_color_space];
592
593
0
  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
594
0
    ERREXIT(cinfo, JERR_INPUT_EOF);
595
0
  ptr = source->pub._buffer[0];
596
0
  bufferptr = source->iobuffer;
597
0
  for (col = cinfo->image_width; col > 0; col--) {
598
0
    register unsigned int temp;
599
0
    temp  = UCH(*bufferptr++) << 8;
600
0
    temp |= UCH(*bufferptr++);
601
0
    if (temp > maxval)
602
0
      ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
603
0
    ptr[rindex] = rescale[temp];
604
0
    temp  = UCH(*bufferptr++) << 8;
605
0
    temp |= UCH(*bufferptr++);
606
0
    if (temp > maxval)
607
0
      ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
608
0
    ptr[gindex] = rescale[temp];
609
0
    temp  = UCH(*bufferptr++) << 8;
610
0
    temp |= UCH(*bufferptr++);
611
0
    if (temp > maxval)
612
0
      ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
613
0
    ptr[bindex] = rescale[temp];
614
0
    if (aindex >= 0)
615
0
      ptr[aindex] = (1 << cinfo->data_precision) - 1;
616
0
    ptr += ps;
617
0
  }
618
0
  return 1;
619
0
}
Unexecuted instantiation: rdppm-8.c:get_word_rgb_row
Unexecuted instantiation: rdppm-12.c:get_word_rgb_row
Unexecuted instantiation: rdppm-16.c:get_word_rgb_row
620
621
622
METHODDEF(JDIMENSION)
623
get_word_rgb_cmyk_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
624
/* This version is for reading raw-word-format PPM files with any maxval */
625
0
{
626
0
  ppm_source_ptr source = (ppm_source_ptr)sinfo;
627
0
  register _JSAMPROW ptr;
628
0
  register U_CHAR *bufferptr;
629
0
  register _JSAMPLE *rescale = source->rescale;
630
0
  JDIMENSION col;
631
0
  unsigned int maxval = source->maxval;
632
633
0
  if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
634
0
    ERREXIT(cinfo, JERR_INPUT_EOF);
635
0
  ptr = source->pub._buffer[0];
636
0
  bufferptr = source->iobuffer;
637
0
  for (col = cinfo->image_width; col > 0; col--) {
638
0
    register unsigned int r, g, b;
639
0
    r  = UCH(*bufferptr++) << 8;
640
0
    r |= UCH(*bufferptr++);
641
0
    if (r > maxval)
642
0
      ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
643
0
    g  = UCH(*bufferptr++) << 8;
644
0
    g |= UCH(*bufferptr++);
645
0
    if (g > maxval)
646
0
      ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
647
0
    b  = UCH(*bufferptr++) << 8;
648
0
    b |= UCH(*bufferptr++);
649
0
    if (b > maxval)
650
0
      ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
651
0
    rgb_to_cmyk(maxval, rescale[r], rescale[g], rescale[b], ptr, ptr + 1,
652
0
                ptr + 2, ptr + 3);
653
0
    ptr += 4;
654
0
  }
655
0
  return 1;
656
0
}
Unexecuted instantiation: rdppm-8.c:get_word_rgb_cmyk_row
Unexecuted instantiation: rdppm-12.c:get_word_rgb_cmyk_row
Unexecuted instantiation: rdppm-16.c:get_word_rgb_cmyk_row
657
658
659
/*
660
 * Read the file header; return image size and component count.
661
 */
662
663
METHODDEF(void)
664
start_input_ppm(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
665
0
{
666
0
  ppm_source_ptr source = (ppm_source_ptr)sinfo;
667
0
  int c;
668
0
  unsigned int w, h, maxval;
669
0
  boolean need_iobuffer, use_raw_buffer, need_rescale;
670
671
0
  if (getc(source->pub.input_file) != 'P')
672
0
    ERREXIT(cinfo, JERR_PPM_NOT);
673
674
0
  c = getc(source->pub.input_file); /* subformat discriminator character */
675
676
  /* detect unsupported variants (ie, PBM) before trying to read header */
677
0
  switch (c) {
678
0
  case '2':                     /* it's a text-format PGM file */
679
0
  case '3':                     /* it's a text-format PPM file */
680
0
  case '5':                     /* it's a raw-format PGM file */
681
0
  case '6':                     /* it's a raw-format PPM file */
682
0
    break;
683
0
  default:
684
0
    ERREXIT(cinfo, JERR_PPM_NOT);
685
0
    break;
686
0
  }
687
688
  /* fetch the remaining header info */
689
0
  w = read_pbm_integer(cinfo, source->pub.input_file, 65535);
690
0
  h = read_pbm_integer(cinfo, source->pub.input_file, 65535);
691
0
  maxval = read_pbm_integer(cinfo, source->pub.input_file, 65535);
692
693
0
  if (w <= 0 || h <= 0 || maxval <= 0) /* error check */
694
0
    ERREXIT(cinfo, JERR_PPM_NOT);
695
0
  if (sinfo->max_pixels && (unsigned long long)w * h > sinfo->max_pixels)
696
0
    ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, sinfo->max_pixels);
697
698
0
  cinfo->image_width = (JDIMENSION)w;
699
0
  cinfo->image_height = (JDIMENSION)h;
700
0
  source->maxval = maxval;
701
702
  /* initialize flags to most common settings */
703
0
  need_iobuffer = TRUE;         /* do we need an I/O buffer? */
704
0
  use_raw_buffer = FALSE;       /* do we map input buffer onto I/O buffer? */
705
0
  need_rescale = TRUE;          /* do we need a rescale array? */
706
707
0
  switch (c) {
708
0
  case '2':                     /* it's a text-format PGM file */
709
0
    if (cinfo->in_color_space == JCS_UNKNOWN ||
710
0
        cinfo->in_color_space == JCS_RGB)
711
0
      cinfo->in_color_space = JCS_GRAYSCALE;
712
0
    TRACEMS3(cinfo, 1, JTRC_PGM_TEXT, w, h, maxval);
713
0
    if (cinfo->in_color_space == JCS_GRAYSCALE)
714
0
      source->pub.get_pixel_rows = get_text_gray_row;
715
0
    else if (IsExtRGB(cinfo->in_color_space))
716
0
      source->pub.get_pixel_rows = get_text_gray_rgb_row;
717
0
    else if (cinfo->in_color_space == JCS_CMYK)
718
0
      source->pub.get_pixel_rows = get_text_gray_cmyk_row;
719
0
    else
720
0
      ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
721
0
    need_iobuffer = FALSE;
722
0
    break;
723
724
0
  case '3':                     /* it's a text-format PPM file */
725
0
    if (cinfo->in_color_space == JCS_UNKNOWN)
726
0
      cinfo->in_color_space = JCS_EXT_RGB;
727
0
    TRACEMS3(cinfo, 1, JTRC_PPM_TEXT, w, h, maxval);
728
0
    if (IsExtRGB(cinfo->in_color_space))
729
0
      source->pub.get_pixel_rows = get_text_rgb_row;
730
0
    else if (cinfo->in_color_space == JCS_CMYK)
731
0
      source->pub.get_pixel_rows = get_text_rgb_cmyk_row;
732
0
    else
733
0
      ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
734
0
    need_iobuffer = FALSE;
735
0
    break;
736
737
0
  case '5':                     /* it's a raw-format PGM file */
738
0
    if (cinfo->in_color_space == JCS_UNKNOWN ||
739
0
        cinfo->in_color_space == JCS_RGB)
740
0
      cinfo->in_color_space = JCS_GRAYSCALE;
741
0
    TRACEMS3(cinfo, 1, JTRC_PGM, w, h, maxval);
742
0
    if (maxval > 255) {
743
0
      if (cinfo->in_color_space == JCS_GRAYSCALE)
744
0
        source->pub.get_pixel_rows = get_word_gray_row;
745
0
      else if (IsExtRGB(cinfo->in_color_space))
746
0
        source->pub.get_pixel_rows = get_word_gray_rgb_row;
747
0
      else if (cinfo->in_color_space == JCS_CMYK)
748
0
        source->pub.get_pixel_rows = get_word_gray_cmyk_row;
749
0
      else
750
0
        ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
751
0
    } else if (maxval <= _MAXJSAMPLE && sizeof(_JSAMPLE) == sizeof(U_CHAR) &&
752
0
               maxval == ((1U << cinfo->data_precision) - 1U) &&
753
0
               cinfo->in_color_space == JCS_GRAYSCALE) {
754
0
      source->pub.get_pixel_rows = get_raw_row;
755
0
      use_raw_buffer = TRUE;
756
0
      need_rescale = FALSE;
757
0
    } else {
758
0
      if (cinfo->in_color_space == JCS_GRAYSCALE)
759
0
        source->pub.get_pixel_rows = get_scaled_gray_row;
760
0
      else if (IsExtRGB(cinfo->in_color_space))
761
0
        source->pub.get_pixel_rows = get_gray_rgb_row;
762
0
      else if (cinfo->in_color_space == JCS_CMYK)
763
0
        source->pub.get_pixel_rows = get_gray_cmyk_row;
764
0
      else
765
0
        ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
766
0
    }
767
0
    break;
768
769
0
  case '6':                     /* it's a raw-format PPM file */
770
0
    if (cinfo->in_color_space == JCS_UNKNOWN)
771
0
      cinfo->in_color_space = JCS_EXT_RGB;
772
0
    TRACEMS3(cinfo, 1, JTRC_PPM, w, h, maxval);
773
0
    if (maxval > 255) {
774
0
      if (IsExtRGB(cinfo->in_color_space))
775
0
        source->pub.get_pixel_rows = get_word_rgb_row;
776
0
      else if (cinfo->in_color_space == JCS_CMYK)
777
0
        source->pub.get_pixel_rows = get_word_rgb_cmyk_row;
778
0
      else
779
0
        ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
780
0
    } else if (maxval <= _MAXJSAMPLE && sizeof(_JSAMPLE) == sizeof(U_CHAR) &&
781
0
               maxval == ((1U << cinfo->data_precision) - 1U) &&
782
0
#if RGB_RED == 0 && RGB_GREEN == 1 && RGB_BLUE == 2 && RGB_PIXELSIZE == 3
783
0
               (cinfo->in_color_space == JCS_EXT_RGB ||
784
0
                cinfo->in_color_space == JCS_RGB)) {
785
#else
786
               cinfo->in_color_space == JCS_EXT_RGB) {
787
#endif
788
0
      source->pub.get_pixel_rows = get_raw_row;
789
0
      use_raw_buffer = TRUE;
790
0
      need_rescale = FALSE;
791
0
    } else {
792
0
      if (IsExtRGB(cinfo->in_color_space))
793
0
        source->pub.get_pixel_rows = get_rgb_row;
794
0
      else if (cinfo->in_color_space == JCS_CMYK)
795
0
        source->pub.get_pixel_rows = get_rgb_cmyk_row;
796
0
      else
797
0
        ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
798
0
    }
799
0
    break;
800
0
  }
801
802
0
  if (IsExtRGB(cinfo->in_color_space))
803
0
    cinfo->input_components = rgb_pixelsize[cinfo->in_color_space];
804
0
  else if (cinfo->in_color_space == JCS_GRAYSCALE)
805
0
    cinfo->input_components = 1;
806
0
  else if (cinfo->in_color_space == JCS_CMYK)
807
0
    cinfo->input_components = 4;
808
809
  /* Allocate space for I/O buffer: 1 or 3 bytes or words/pixel. */
810
0
  if (need_iobuffer) {
811
0
    if (c == '6')
812
0
      source->buffer_width = (size_t)w * 3 *
813
0
        ((maxval <= 255) ? sizeof(U_CHAR) : (2 * sizeof(U_CHAR)));
814
0
    else
815
0
      source->buffer_width = (size_t)w *
816
0
        ((maxval <= 255) ? sizeof(U_CHAR) : (2 * sizeof(U_CHAR)));
817
0
    source->iobuffer = (U_CHAR *)
818
0
      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
819
0
                                  source->buffer_width);
820
0
  }
821
822
  /* Create compressor input buffer. */
823
0
  if (use_raw_buffer) {
824
    /* For unscaled raw-input case, we can just map it onto the I/O buffer. */
825
    /* Synthesize a _JSAMPARRAY pointer structure */
826
0
    source->pixrow = (_JSAMPROW)source->iobuffer;
827
0
    source->pub._buffer = &source->pixrow;
828
0
    source->pub.buffer_height = 1;
829
0
  } else {
830
    /* Need to translate anyway, so make a separate sample buffer. */
831
0
    source->pub._buffer = (_JSAMPARRAY)(*cinfo->mem->alloc_sarray)
832
0
      ((j_common_ptr)cinfo, JPOOL_IMAGE,
833
0
       (JDIMENSION)w * cinfo->input_components, (JDIMENSION)1);
834
0
    source->pub.buffer_height = 1;
835
0
  }
836
837
  /* Compute the rescaling array if required. */
838
0
  if (need_rescale) {
839
0
    long val, half_maxval;
840
841
    /* On 16-bit-int machines we have to be careful of maxval = 65535 */
842
0
    source->rescale = (_JSAMPLE *)
843
0
      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
844
0
                                  (size_t)(((long)MAX(maxval, 255) + 1L) *
845
0
                                           sizeof(_JSAMPLE)));
846
0
    memset(source->rescale, 0, (size_t)(((long)MAX(maxval, 255) + 1L) *
847
0
                                        sizeof(_JSAMPLE)));
848
0
    half_maxval = maxval / 2;
849
0
    for (val = 0; val <= (long)maxval; val++) {
850
      /* The multiplication here must be done in 32 bits to avoid overflow */
851
0
      source->rescale[val] =
852
0
        (_JSAMPLE)((val * ((1 << cinfo->data_precision) - 1) + half_maxval) /
853
0
                   maxval);
854
0
    }
855
0
  }
856
0
}
Unexecuted instantiation: rdppm-8.c:start_input_ppm
Unexecuted instantiation: rdppm-12.c:start_input_ppm
Unexecuted instantiation: rdppm-16.c:start_input_ppm
857
858
859
/*
860
 * Finish up at the end of the file.
861
 */
862
863
METHODDEF(void)
864
finish_input_ppm(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
865
0
{
866
  /* no work */
867
0
}
Unexecuted instantiation: rdppm-8.c:finish_input_ppm
Unexecuted instantiation: rdppm-12.c:finish_input_ppm
Unexecuted instantiation: rdppm-16.c:finish_input_ppm
868
869
870
/*
871
 * The module selection routine for PPM format input.
872
 */
873
874
GLOBAL(cjpeg_source_ptr)
875
_jinit_read_ppm(j_compress_ptr cinfo)
876
0
{
877
0
  ppm_source_ptr source;
878
879
#if BITS_IN_JSAMPLE == 8
880
0
  if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
881
#else
882
0
  if (cinfo->data_precision > BITS_IN_JSAMPLE ||
883
0
      cinfo->data_precision < BITS_IN_JSAMPLE - 3)
884
0
#endif
885
0
    ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
886
887
  /* Create module interface object */
888
0
  source = (ppm_source_ptr)
889
0
    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
890
0
                                sizeof(ppm_source_struct));
891
  /* Fill in method ptrs, except get_pixel_rows which start_input sets */
892
0
  source->pub.start_input = start_input_ppm;
893
0
  source->pub.finish_input = finish_input_ppm;
894
0
  source->pub.max_pixels = 0;
895
896
0
  return (cjpeg_source_ptr)source;
897
0
}
Unexecuted instantiation: jinit_read_ppm
Unexecuted instantiation: j12init_read_ppm
Unexecuted instantiation: j16init_read_ppm
898
899
#endif /* defined(PPM_SUPPORTED) &&
900
          (BITS_IN_JSAMPLE != 16 || defined(C_LOSSLESS_SUPPORTED)) */