summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/libjpeg/wrppm.c
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/libjpeg/wrppm.c')
-rw-r--r--3rdparty/libjpeg/wrppm.c43
1 files changed, 19 insertions, 24 deletions
diff --git a/3rdparty/libjpeg/wrppm.c b/3rdparty/libjpeg/wrppm.c
index 68e0c85c3ca..c9e03ad10db 100644
--- a/3rdparty/libjpeg/wrppm.c
+++ b/3rdparty/libjpeg/wrppm.c
@@ -2,7 +2,7 @@
* wrppm.c
*
* Copyright (C) 1991-1996, Thomas G. Lane.
- * Modified 2009 by Guido Vollbeding.
+ * Modified 2009-2020 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
@@ -111,7 +111,7 @@ copy_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
register JSAMPROW ptr;
register JDIMENSION col;
- ptr = dest->pub.buffer[0];
+ ptr = dest->pixrow;
bufferptr = dest->iobuffer;
for (col = dest->samples_per_row; col > 0; col--) {
PUTPPMSAMPLE(bufferptr, GETJSAMPLE(*ptr++));
@@ -138,7 +138,7 @@ put_demapped_rgb (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
register JSAMPROW color_map2 = cinfo->colormap[2];
register JDIMENSION col;
- ptr = dest->pub.buffer[0];
+ ptr = dest->pixrow;
bufferptr = dest->iobuffer;
for (col = cinfo->output_width; col > 0; col--) {
pixval = GETJSAMPLE(*ptr++);
@@ -149,7 +149,6 @@ put_demapped_rgb (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
(void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width);
}
-
METHODDEF(void)
put_demapped_gray (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
JDIMENSION rows_supplied)
@@ -157,13 +156,13 @@ put_demapped_gray (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
ppm_dest_ptr dest = (ppm_dest_ptr) dinfo;
register char * bufferptr;
register JSAMPROW ptr;
- register JSAMPROW color_map = cinfo->colormap[0];
+ register JSAMPROW color_map0 = cinfo->colormap[0];
register JDIMENSION col;
- ptr = dest->pub.buffer[0];
+ ptr = dest->pixrow;
bufferptr = dest->iobuffer;
for (col = cinfo->output_width; col > 0; col--) {
- PUTPPMSAMPLE(bufferptr, GETJSAMPLE(color_map[GETJSAMPLE(*ptr++)]));
+ PUTPPMSAMPLE(bufferptr, GETJSAMPLE(color_map0[GETJSAMPLE(*ptr++)]));
}
(void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width);
}
@@ -176,19 +175,17 @@ put_demapped_gray (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
METHODDEF(void)
start_output_ppm (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
{
- ppm_dest_ptr dest = (ppm_dest_ptr) dinfo;
-
/* Emit file header */
switch (cinfo->out_color_space) {
case JCS_GRAYSCALE:
/* emit header for raw PGM format */
- fprintf(dest->pub.output_file, "P5\n%ld %ld\n%d\n",
+ fprintf(dinfo->output_file, "P5\n%ld %ld\n%d\n",
(long) cinfo->output_width, (long) cinfo->output_height,
PPM_MAXVAL);
break;
case JCS_RGB:
/* emit header for raw PPM format */
- fprintf(dest->pub.output_file, "P6\n%ld %ld\n%d\n",
+ fprintf(dinfo->output_file, "P6\n%ld %ld\n%d\n",
(long) cinfo->output_width, (long) cinfo->output_height,
PPM_MAXVAL);
break;
@@ -206,8 +203,8 @@ METHODDEF(void)
finish_output_ppm (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
{
/* Make sure we wrote the output file OK */
- fflush(dinfo->output_file);
- if (ferror(dinfo->output_file))
+ JFFLUSH(dinfo->output_file);
+ if (JFERROR(dinfo->output_file))
ERREXIT(cinfo, JERR_FILE_WRITE);
}
@@ -222,9 +219,8 @@ jinit_write_ppm (j_decompress_ptr cinfo)
ppm_dest_ptr dest;
/* Create module interface object, fill in method pointers */
- dest = (ppm_dest_ptr)
- (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
- SIZEOF(ppm_dest_struct));
+ dest = (ppm_dest_ptr) (*cinfo->mem->alloc_small)
+ ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(ppm_dest_struct));
dest->pub.start_output = start_output_ppm;
dest->pub.finish_output = finish_output_ppm;
@@ -243,10 +239,9 @@ jinit_write_ppm (j_decompress_ptr cinfo)
* that's separate from the physical I/O buffer. We also need a
* separate buffer if pixel format translation must take place.
*/
- dest->pub.buffer = (*cinfo->mem->alloc_sarray)
- ((j_common_ptr) cinfo, JPOOL_IMAGE,
- cinfo->output_width * cinfo->output_components, (JDIMENSION) 1);
- dest->pub.buffer_height = 1;
+ dest->pixrow = (JSAMPROW) (*cinfo->mem->alloc_large)
+ ((j_common_ptr) cinfo, JPOOL_IMAGE, (size_t) cinfo->output_width *
+ (size_t) cinfo->output_components * SIZEOF(JSAMPLE));
if (! cinfo->quantize_colors)
dest->pub.put_pixel_rows = copy_pixel_rows;
else if (cinfo->out_color_space == JCS_GRAYSCALE)
@@ -255,15 +250,15 @@ jinit_write_ppm (j_decompress_ptr cinfo)
dest->pub.put_pixel_rows = put_demapped_rgb;
} else {
/* We will fwrite() directly from decompressor output buffer. */
- /* Synthesize a JSAMPARRAY pointer structure */
/* Cast here implies near->far pointer conversion on PCs */
dest->pixrow = (JSAMPROW) dest->iobuffer;
- dest->pub.buffer = & dest->pixrow;
- dest->pub.buffer_height = 1;
dest->pub.put_pixel_rows = put_pixel_rows;
}
+ /* Synthesize a JSAMPARRAY pointer structure */
+ dest->pub.buffer = & dest->pixrow;
+ dest->pub.buffer_height = 1;
- return (djpeg_dest_ptr) dest;
+ return &dest->pub;
}
#endif /* PPM_SUPPORTED */