summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/libjpeg/wrrle.c
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2023-12-06 06:05:40 +1100
committer Vas Crabb <vas@vastheman.com>2023-12-06 06:05:40 +1100
commit73751bcea9a5365e5f4d427986ba4f75fe0300ef (patch)
tree40f937b5d5e541a8ac68a80154bf30762e42c048 /3rdparty/libjpeg/wrrle.c
parent8b2ea383f5f4dffd15c9684e94b7a0d6868d2711 (diff)
3rdparty/libjpeg: Updated to version 9e.
Diffstat (limited to '3rdparty/libjpeg/wrrle.c')
-rw-r--r--3rdparty/libjpeg/wrrle.c59
1 files changed, 30 insertions, 29 deletions
diff --git a/3rdparty/libjpeg/wrrle.c b/3rdparty/libjpeg/wrrle.c
index a4e73372de6..dc2fadb8871 100644
--- a/3rdparty/libjpeg/wrrle.c
+++ b/3rdparty/libjpeg/wrrle.c
@@ -2,6 +2,7 @@
* wrrle.c
*
* Copyright (C) 1991-1996, Thomas G. Lane.
+ * Modified 2017-2019 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.
*
@@ -61,6 +62,7 @@ typedef struct {
typedef rle_dest_struct * rle_dest_ptr;
+
/* Forward declarations */
METHODDEF(void) rle_put_pixel_rows
JPP((j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
@@ -78,7 +80,7 @@ start_output_rle (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
{
rle_dest_ptr dest = (rle_dest_ptr) dinfo;
size_t cmapsize;
- int i, ci;
+ int ci, i;
#ifdef PROGRESS_REPORT
cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress;
#endif
@@ -122,8 +124,8 @@ start_output_rle (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
/* Shifting would need adjustment for JSAMPLEs wider than 8 bits. */
for (ci = 0; ci < cinfo->out_color_components; ci++) {
for (i = 0; i < cinfo->actual_number_of_colors; i++) {
- dest->colormap[ci * CMAPLENGTH + i] =
- GETJSAMPLE(cinfo->colormap[ci][i]) << 8;
+ dest->colormap[ci * CMAPLENGTH + i] =
+ GETJSAMPLE(cinfo->colormap[ci][i]) << 8;
}
}
}
@@ -162,6 +164,7 @@ rle_put_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
}
}
+
/*
* Finish up at the end of the file.
*
@@ -173,7 +176,7 @@ finish_output_rle (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
{
rle_dest_ptr dest = (rle_dest_ptr) dinfo;
rle_hdr header; /* Output file information */
- rle_pixel **rle_row, *red, *green, *blue;
+ rle_pixel **rle_row, *red_ptr, *green_ptr, *blue_ptr;
JSAMPROW output_row;
char cmapcomment[80];
int row, col;
@@ -220,37 +223,37 @@ finish_output_rle (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
#endif
if (cinfo->output_components == 1) {
- for (row = cinfo->output_height-1; row >= 0; row--) {
+ for (row = cinfo->output_height - 1; row >= 0; row--) {
rle_row = (rle_pixel **) (*cinfo->mem->access_virt_sarray)
- ((j_common_ptr) cinfo, dest->image,
+ ((j_common_ptr) cinfo, dest->image,
(JDIMENSION) row, (JDIMENSION) 1, FALSE);
rle_putrow(rle_row, (int) cinfo->output_width, &header);
#ifdef PROGRESS_REPORT
if (progress != NULL) {
- progress->pub.pass_counter++;
- (*progress->pub.progress_monitor) ((j_common_ptr) cinfo);
+ progress->pub.pass_counter++;
+ (*progress->pub.progress_monitor) ((j_common_ptr) cinfo);
}
#endif
}
} else {
- for (row = cinfo->output_height-1; row >= 0; row--) {
- rle_row = (rle_pixel **) dest->rle_row;
+ for (row = cinfo->output_height - 1; row >= 0; row--) {
output_row = * (*cinfo->mem->access_virt_sarray)
- ((j_common_ptr) cinfo, dest->image,
+ ((j_common_ptr) cinfo, dest->image,
(JDIMENSION) row, (JDIMENSION) 1, FALSE);
- red = rle_row[0];
- green = rle_row[1];
- blue = rle_row[2];
+ rle_row = dest->rle_row;
+ red_ptr = rle_row[0];
+ green_ptr = rle_row[1];
+ blue_ptr = rle_row[2];
for (col = cinfo->output_width; col > 0; col--) {
- *red++ = GETJSAMPLE(*output_row++);
- *green++ = GETJSAMPLE(*output_row++);
- *blue++ = GETJSAMPLE(*output_row++);
+ *red_ptr++ = GETJSAMPLE(*output_row++);
+ *green_ptr++ = GETJSAMPLE(*output_row++);
+ *blue_ptr++ = GETJSAMPLE(*output_row++);
}
rle_putrow(rle_row, (int) cinfo->output_width, &header);
#ifdef PROGRESS_REPORT
if (progress != NULL) {
- progress->pub.pass_counter++;
- (*progress->pub.progress_monitor) ((j_common_ptr) cinfo);
+ progress->pub.pass_counter++;
+ (*progress->pub.progress_monitor) ((j_common_ptr) cinfo);
}
#endif
}
@@ -263,8 +266,8 @@ finish_output_rle (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
/* Emit file trailer */
rle_puteof(&header);
- fflush(dest->pub.output_file);
- if (ferror(dest->pub.output_file))
+ JFFLUSH(dest->pub.output_file);
+ if (JFERROR(dest->pub.output_file))
ERREXIT(cinfo, JERR_FILE_WRITE);
}
@@ -279,9 +282,8 @@ jinit_write_rle (j_decompress_ptr cinfo)
rle_dest_ptr dest;
/* Create module interface object, fill in method pointers */
- dest = (rle_dest_ptr)
- (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
- SIZEOF(rle_dest_struct));
+ dest = (rle_dest_ptr) (*cinfo->mem->alloc_small)
+ ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(rle_dest_struct));
dest->pub.start_output = start_output_rle;
dest->pub.finish_output = finish_output_rle;
@@ -289,17 +291,16 @@ jinit_write_rle (j_decompress_ptr cinfo)
jpeg_calc_output_dimensions(cinfo);
/* Allocate a work array for output to the RLE library. */
- dest->rle_row = (*cinfo->mem->alloc_sarray)
- ((j_common_ptr) cinfo, JPOOL_IMAGE,
- cinfo->output_width, (JDIMENSION) cinfo->output_components);
+ dest->rle_row = (*cinfo->mem->alloc_sarray) ((j_common_ptr) cinfo,
+ JPOOL_IMAGE, cinfo->output_width, (JDIMENSION) cinfo->output_components);
/* Allocate a virtual array to hold the image. */
dest->image = (*cinfo->mem->request_virt_sarray)
((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE,
- (JDIMENSION) (cinfo->output_width * cinfo->output_components),
+ cinfo->output_width * (JDIMENSION) cinfo->output_components,
cinfo->output_height, (JDIMENSION) 1);
- return (djpeg_dest_ptr) dest;
+ return &dest->pub;
}
#endif /* RLE_SUPPORTED */