mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-26 09:14:27 +03:00
Whitespace, 8 space tabs -> 4 spaces
This commit is contained in:
parent
a2663641b6
commit
454a914b56
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
#include "Imaging.h"
|
#include "Imaging.h"
|
||||||
|
|
||||||
#ifdef HAVE_LIBJPEG
|
#ifdef HAVE_LIBJPEG
|
||||||
|
|
||||||
#undef HAVE_PROTOTYPES
|
#undef HAVE_PROTOTYPES
|
||||||
#undef HAVE_STDLIB_H
|
#undef HAVE_STDLIB_H
|
||||||
|
@ -39,7 +39,7 @@
|
||||||
|
|
||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
/* Suspending input handler */
|
/* Suspending input handler */
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
|
|
||||||
METHODDEF(void)
|
METHODDEF(void)
|
||||||
|
@ -61,16 +61,16 @@ skip_input_data(j_decompress_ptr cinfo, long num_bytes)
|
||||||
JPEGSOURCE* source = (JPEGSOURCE*) cinfo->src;
|
JPEGSOURCE* source = (JPEGSOURCE*) cinfo->src;
|
||||||
|
|
||||||
if (num_bytes > (long) source->pub.bytes_in_buffer) {
|
if (num_bytes > (long) source->pub.bytes_in_buffer) {
|
||||||
/* We need to skip more data than we have in the buffer.
|
/* We need to skip more data than we have in the buffer.
|
||||||
This will force the JPEG library to suspend decoding. */
|
This will force the JPEG library to suspend decoding. */
|
||||||
source->skip = num_bytes - source->pub.bytes_in_buffer;
|
source->skip = num_bytes - source->pub.bytes_in_buffer;
|
||||||
source->pub.next_input_byte += source->pub.bytes_in_buffer;
|
source->pub.next_input_byte += source->pub.bytes_in_buffer;
|
||||||
source->pub.bytes_in_buffer = 0;
|
source->pub.bytes_in_buffer = 0;
|
||||||
} else {
|
} else {
|
||||||
/* Skip portion of the buffer */
|
/* Skip portion of the buffer */
|
||||||
source->pub.bytes_in_buffer -= num_bytes;
|
source->pub.bytes_in_buffer -= num_bytes;
|
||||||
source->pub.next_input_byte += num_bytes;
|
source->pub.next_input_byte += num_bytes;
|
||||||
source->skip = 0;
|
source->skip = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ jpeg_buffer_src(j_decompress_ptr cinfo, JPEGSOURCE* source)
|
||||||
|
|
||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
/* Error handler */
|
/* Error handler */
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
|
|
||||||
METHODDEF(void)
|
METHODDEF(void)
|
||||||
|
@ -111,7 +111,7 @@ output(j_common_ptr cinfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
/* Decoder */
|
/* Decoder */
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -121,23 +121,23 @@ ImagingJpegDecode(Imaging im, ImagingCodecState state, UINT8* buf, int bytes)
|
||||||
int ok;
|
int ok;
|
||||||
|
|
||||||
if (setjmp(context->error.setjmp_buffer)) {
|
if (setjmp(context->error.setjmp_buffer)) {
|
||||||
/* JPEG error handler */
|
/* JPEG error handler */
|
||||||
jpeg_destroy_decompress(&context->cinfo);
|
jpeg_destroy_decompress(&context->cinfo);
|
||||||
state->errcode = IMAGING_CODEC_BROKEN;
|
state->errcode = IMAGING_CODEC_BROKEN;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!state->state) {
|
if (!state->state) {
|
||||||
|
|
||||||
/* Setup decompression context */
|
/* Setup decompression context */
|
||||||
context->cinfo.err = jpeg_std_error(&context->error.pub);
|
context->cinfo.err = jpeg_std_error(&context->error.pub);
|
||||||
context->error.pub.error_exit = error;
|
context->error.pub.error_exit = error;
|
||||||
context->error.pub.output_message = output;
|
context->error.pub.output_message = output;
|
||||||
jpeg_create_decompress(&context->cinfo);
|
jpeg_create_decompress(&context->cinfo);
|
||||||
jpeg_buffer_src(&context->cinfo, &context->source);
|
jpeg_buffer_src(&context->cinfo, &context->source);
|
||||||
|
|
||||||
/* Ready to decode */
|
/* Ready to decode */
|
||||||
state->state = 1;
|
state->state = 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,115 +146,115 @@ ImagingJpegDecode(Imaging im, ImagingCodecState state, UINT8* buf, int bytes)
|
||||||
context->source.pub.bytes_in_buffer = bytes;
|
context->source.pub.bytes_in_buffer = bytes;
|
||||||
|
|
||||||
if (context->source.skip > 0) {
|
if (context->source.skip > 0) {
|
||||||
skip_input_data(&context->cinfo, context->source.skip);
|
skip_input_data(&context->cinfo, context->source.skip);
|
||||||
if (context->source.skip > 0)
|
if (context->source.skip > 0)
|
||||||
return context->source.pub.next_input_byte - buf;
|
return context->source.pub.next_input_byte - buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (state->state) {
|
switch (state->state) {
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
|
|
||||||
/* Read JPEG header, until we find an image body. */
|
/* Read JPEG header, until we find an image body. */
|
||||||
do {
|
do {
|
||||||
|
|
||||||
/* Note that we cannot return unless we have decoded
|
/* Note that we cannot return unless we have decoded
|
||||||
as much data as possible. */
|
as much data as possible. */
|
||||||
ok = jpeg_read_header(&context->cinfo, FALSE);
|
ok = jpeg_read_header(&context->cinfo, FALSE);
|
||||||
|
|
||||||
} while (ok == JPEG_HEADER_TABLES_ONLY);
|
} while (ok == JPEG_HEADER_TABLES_ONLY);
|
||||||
|
|
||||||
if (ok == JPEG_SUSPENDED)
|
if (ok == JPEG_SUSPENDED)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* Decoder settings */
|
/* Decoder settings */
|
||||||
|
|
||||||
/* jpegmode indicates whats in the file; if not set, we'll
|
/* jpegmode indicates whats in the file; if not set, we'll
|
||||||
trust the decoder */
|
trust the decoder */
|
||||||
if (strcmp(context->jpegmode, "L") == 0)
|
if (strcmp(context->jpegmode, "L") == 0)
|
||||||
context->cinfo.jpeg_color_space = JCS_GRAYSCALE;
|
context->cinfo.jpeg_color_space = JCS_GRAYSCALE;
|
||||||
else if (strcmp(context->jpegmode, "RGB") == 0)
|
else if (strcmp(context->jpegmode, "RGB") == 0)
|
||||||
context->cinfo.jpeg_color_space = JCS_RGB;
|
context->cinfo.jpeg_color_space = JCS_RGB;
|
||||||
else if (strcmp(context->jpegmode, "CMYK") == 0)
|
else if (strcmp(context->jpegmode, "CMYK") == 0)
|
||||||
context->cinfo.jpeg_color_space = JCS_CMYK;
|
context->cinfo.jpeg_color_space = JCS_CMYK;
|
||||||
else if (strcmp(context->jpegmode, "YCbCr") == 0)
|
else if (strcmp(context->jpegmode, "YCbCr") == 0)
|
||||||
context->cinfo.jpeg_color_space = JCS_YCbCr;
|
context->cinfo.jpeg_color_space = JCS_YCbCr;
|
||||||
else if (strcmp(context->jpegmode, "YCbCrK") == 0) {
|
else if (strcmp(context->jpegmode, "YCbCrK") == 0) {
|
||||||
context->cinfo.jpeg_color_space = JCS_YCCK;
|
context->cinfo.jpeg_color_space = JCS_YCCK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* rawmode indicates what we want from the decoder. if not
|
/* rawmode indicates what we want from the decoder. if not
|
||||||
set, conversions are disabled */
|
set, conversions are disabled */
|
||||||
if (strcmp(context->rawmode, "L") == 0)
|
if (strcmp(context->rawmode, "L") == 0)
|
||||||
context->cinfo.out_color_space = JCS_GRAYSCALE;
|
context->cinfo.out_color_space = JCS_GRAYSCALE;
|
||||||
else if (strcmp(context->rawmode, "RGB") == 0)
|
else if (strcmp(context->rawmode, "RGB") == 0)
|
||||||
context->cinfo.out_color_space = JCS_RGB;
|
context->cinfo.out_color_space = JCS_RGB;
|
||||||
else if (strcmp(context->rawmode, "CMYK") == 0 ||
|
else if (strcmp(context->rawmode, "CMYK") == 0 ||
|
||||||
strcmp(context->rawmode, "CMYK;I") == 0)
|
strcmp(context->rawmode, "CMYK;I") == 0)
|
||||||
context->cinfo.out_color_space = JCS_CMYK;
|
context->cinfo.out_color_space = JCS_CMYK;
|
||||||
else if (strcmp(context->rawmode, "YCbCr") == 0)
|
else if (strcmp(context->rawmode, "YCbCr") == 0)
|
||||||
context->cinfo.out_color_space = JCS_YCbCr;
|
context->cinfo.out_color_space = JCS_YCbCr;
|
||||||
else if (strcmp(context->rawmode, "YCbCrK") == 0)
|
else if (strcmp(context->rawmode, "YCbCrK") == 0)
|
||||||
context->cinfo.out_color_space = JCS_YCCK;
|
context->cinfo.out_color_space = JCS_YCCK;
|
||||||
else {
|
else {
|
||||||
/* Disable decoder conversions */
|
/* Disable decoder conversions */
|
||||||
context->cinfo.jpeg_color_space = JCS_UNKNOWN;
|
context->cinfo.jpeg_color_space = JCS_UNKNOWN;
|
||||||
context->cinfo.out_color_space = JCS_UNKNOWN;
|
context->cinfo.out_color_space = JCS_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (context->scale > 1) {
|
if (context->scale > 1) {
|
||||||
context->cinfo.scale_num = 1;
|
context->cinfo.scale_num = 1;
|
||||||
context->cinfo.scale_denom = context->scale;
|
context->cinfo.scale_denom = context->scale;
|
||||||
}
|
}
|
||||||
if (context->draft) {
|
if (context->draft) {
|
||||||
context->cinfo.do_fancy_upsampling = FALSE;
|
context->cinfo.do_fancy_upsampling = FALSE;
|
||||||
context->cinfo.dct_method = JDCT_FASTEST;
|
context->cinfo.dct_method = JDCT_FASTEST;
|
||||||
}
|
}
|
||||||
|
|
||||||
state->state++;
|
state->state++;
|
||||||
/* fall through */
|
/* fall through */
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
|
|
||||||
/* Set things up for decompression (this processes the entire
|
/* Set things up for decompression (this processes the entire
|
||||||
file if necessary to return data line by line) */
|
file if necessary to return data line by line) */
|
||||||
if (!jpeg_start_decompress(&context->cinfo))
|
if (!jpeg_start_decompress(&context->cinfo))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
state->state++;
|
state->state++;
|
||||||
/* fall through */
|
/* fall through */
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
|
|
||||||
/* Decompress a single line of data */
|
/* Decompress a single line of data */
|
||||||
ok = 1;
|
ok = 1;
|
||||||
while (state->y < state->ysize) {
|
while (state->y < state->ysize) {
|
||||||
ok = jpeg_read_scanlines(&context->cinfo, &state->buffer, 1);
|
ok = jpeg_read_scanlines(&context->cinfo, &state->buffer, 1);
|
||||||
if (ok != 1)
|
if (ok != 1)
|
||||||
break;
|
break;
|
||||||
state->shuffle((UINT8*) im->image[state->y + state->yoff] +
|
state->shuffle((UINT8*) im->image[state->y + state->yoff] +
|
||||||
state->xoff * im->pixelsize, state->buffer,
|
state->xoff * im->pixelsize, state->buffer,
|
||||||
state->xsize);
|
state->xsize);
|
||||||
state->y++;
|
state->y++;
|
||||||
}
|
}
|
||||||
if (ok != 1)
|
if (ok != 1)
|
||||||
break;
|
break;
|
||||||
state->state++;
|
state->state++;
|
||||||
/* fall through */
|
/* fall through */
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
|
|
||||||
/* Finish decompression */
|
/* Finish decompression */
|
||||||
if (!jpeg_finish_decompress(&context->cinfo)) {
|
if (!jpeg_finish_decompress(&context->cinfo)) {
|
||||||
/* FIXME: add strictness mode test */
|
/* FIXME: add strictness mode test */
|
||||||
if (state->y < state->ysize)
|
if (state->y < state->ysize)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clean up */
|
/* Clean up */
|
||||||
jpeg_destroy_decompress(&context->cinfo);
|
jpeg_destroy_decompress(&context->cinfo);
|
||||||
/* if (jerr.pub.num_warnings) return BROKEN; */
|
/* if (jerr.pub.num_warnings) return BROKEN; */
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user