Coverage Report

Created: 2026-06-10 06:17

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