Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1091)

Unified Diff: wrppm.c

Issue 1953443002: Update to libjpeg_turbo 1.4.90 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libjpeg_turbo.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « wrppm.h ('k') | wrrle.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: wrppm.c
diff --git a/wrppm.c b/wrppm.c
index 68e0c85c3ca16115444a775c8a19ac4b726fce40..40fbf1fc108c314220926594b9e449896d27c254 100644
--- a/wrppm.c
+++ b/wrppm.c
@@ -1,10 +1,13 @@
/*
* wrppm.c
*
+ * This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1996, Thomas G. Lane.
* Modified 2009 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.
+ * It was modified by The libjpeg-turbo Project to include only code and
+ * information relevant to libjpeg-turbo.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
*
* This file contains routines to write output images in PPM/PGM format.
* The extended 2-byte-per-sample raw PPM/PGM formats are supported.
@@ -16,7 +19,8 @@
* an ordinary stdio stream.
*/
-#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
+#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
+#include "wrppm.h"
#ifdef PPM_SUPPORTED
@@ -42,11 +46,11 @@
#define PPM_MAXVAL 255
#else
/* The word-per-sample format always puts the MSB first. */
-#define PUTPPMSAMPLE(ptr,v) \
- { register int val_ = v; \
- *ptr++ = (char) ((val_ >> 8) & 0xFF); \
- *ptr++ = (char) (val_ & 0xFF); \
- }
+#define PUTPPMSAMPLE(ptr,v) \
+ { register int val_ = v; \
+ *ptr++ = (char) ((val_ >> 8) & 0xFF); \
+ *ptr++ = (char) (val_ & 0xFF); \
+ }
#define BYTESPERSAMPLE 2
#define PPM_MAXVAL ((1<<BITS_IN_JSAMPLE)-1)
#endif
@@ -55,30 +59,10 @@
/*
* When JSAMPLE is the same size as char, we can just fwrite() the
- * decompressed data to the PPM or PGM file. On PCs, in order to make this
- * work the output buffer must be allocated in near data space, because we are
- * assuming small-data memory model wherein fwrite() can't reach far memory.
- * If you need to process very wide images on a PC, you might have to compile
- * in large-memory model, or else replace fwrite() with a putc() loop ---
- * which will be much slower.
+ * decompressed data to the PPM or PGM file.
*/
-/* Private version of data destination object */
-
-typedef struct {
- struct djpeg_dest_struct pub; /* public fields */
-
- /* Usually these two pointers point to the same place: */
- char *iobuffer; /* fwrite's I/O buffer */
- JSAMPROW pixrow; /* decompressor output buffer */
- size_t buffer_width; /* width of I/O buffer */
- JDIMENSION samples_per_row; /* JSAMPLEs per output row */
-} ppm_dest_struct;
-
-typedef ppm_dest_struct * ppm_dest_ptr;
-
-
/*
* Write some pixel data.
* In this module rows_supplied will always be 1.
@@ -89,7 +73,7 @@ typedef ppm_dest_struct * ppm_dest_ptr;
METHODDEF(void)
put_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
- JDIMENSION rows_supplied)
+ JDIMENSION rows_supplied)
{
ppm_dest_ptr dest = (ppm_dest_ptr) dinfo;
@@ -104,10 +88,10 @@ put_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
METHODDEF(void)
copy_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
- JDIMENSION rows_supplied)
+ JDIMENSION rows_supplied)
{
ppm_dest_ptr dest = (ppm_dest_ptr) dinfo;
- register char * bufferptr;
+ register char *bufferptr;
register JSAMPROW ptr;
register JDIMENSION col;
@@ -127,10 +111,10 @@ copy_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
METHODDEF(void)
put_demapped_rgb (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
- JDIMENSION rows_supplied)
+ JDIMENSION rows_supplied)
{
ppm_dest_ptr dest = (ppm_dest_ptr) dinfo;
- register char * bufferptr;
+ register char *bufferptr;
register int pixval;
register JSAMPROW ptr;
register JSAMPROW color_map0 = cinfo->colormap[0];
@@ -152,10 +136,10 @@ put_demapped_rgb (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
METHODDEF(void)
put_demapped_gray (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
- JDIMENSION rows_supplied)
+ JDIMENSION rows_supplied)
{
ppm_dest_ptr dest = (ppm_dest_ptr) dinfo;
- register char * bufferptr;
+ register char *bufferptr;
register JSAMPROW ptr;
register JSAMPROW color_map = cinfo->colormap[0];
register JDIMENSION col;
@@ -183,14 +167,14 @@ start_output_ppm (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
case JCS_GRAYSCALE:
/* emit header for raw PGM format */
fprintf(dest->pub.output_file, "P5\n%ld %ld\n%d\n",
- (long) cinfo->output_width, (long) cinfo->output_height,
- PPM_MAXVAL);
+ (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",
- (long) cinfo->output_width, (long) cinfo->output_height,
- PPM_MAXVAL);
+ (long) cinfo->output_width, (long) cinfo->output_height,
+ PPM_MAXVAL);
break;
default:
ERREXIT(cinfo, JERR_PPM_COLORSPACE);
@@ -224,21 +208,21 @@ jinit_write_ppm (j_decompress_ptr cinfo)
/* 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));
+ sizeof(ppm_dest_struct));
dest->pub.start_output = start_output_ppm;
dest->pub.finish_output = finish_output_ppm;
/* Calculate output image dimensions so we can allocate space */
jpeg_calc_output_dimensions(cinfo);
- /* Create physical I/O buffer. Note we make this near on a PC. */
+ /* Create physical I/O buffer */
dest->samples_per_row = cinfo->output_width * cinfo->out_color_components;
- dest->buffer_width = dest->samples_per_row * (BYTESPERSAMPLE * SIZEOF(char));
+ dest->buffer_width = dest->samples_per_row * (BYTESPERSAMPLE * sizeof(char));
dest->iobuffer = (char *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, dest->buffer_width);
if (cinfo->quantize_colors || BITS_IN_JSAMPLE != 8 ||
- SIZEOF(JSAMPLE) != SIZEOF(char)) {
+ sizeof(JSAMPLE) != sizeof(char)) {
/* When quantizing, we need an output buffer for colormap indexes
* that's separate from the physical I/O buffer. We also need a
* separate buffer if pixel format translation must take place.
@@ -256,7 +240,6 @@ jinit_write_ppm (j_decompress_ptr cinfo)
} 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;
« no previous file with comments | « wrppm.h ('k') | wrrle.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698