From 42c17c594782cb383cd0bae64d228dc81e5f60ea Mon Sep 17 00:00:00 2001 From: wiredfool Date: Thu, 21 Nov 2013 20:28:00 -0800 Subject: [PATCH] Removing unused, redundant compression variable. Actual compression setting is in the imagefiledirectory --- decode.c | 43 +---------------------------------------- encode.c | 42 ---------------------------------------- libImaging/TiffDecode.c | 4 ++-- libImaging/TiffDecode.h | 2 +- 4 files changed, 4 insertions(+), 87 deletions(-) diff --git a/decode.c b/decode.c index 4bdfbeef2..f3ac60e51 100644 --- a/decode.c +++ b/decode.c @@ -427,7 +427,6 @@ PyImaging_LibTiffDecoderNew(PyObject* self, PyObject* args) char* mode; char* rawmode; char* compname; - int compression; int fp; if (! PyArg_ParseTuple(args, "sssi", &mode, &rawmode, &compname, &fp)) @@ -435,46 +434,6 @@ PyImaging_LibTiffDecoderNew(PyObject* self, PyObject* args) TRACE(("new tiff decoder %s\n", compname)); - /* UNDONE -- we can probably do almost any arbitrary compression here, - * since we're effective passing in the whole file in one shot and - * getting back the data row by row. V2 maybe - */ - - if (strcasecmp(compname, "tiff_ccitt") == 0) { - compression = COMPRESSION_CCITTRLE; - - } else if (strcasecmp(compname, "group3") == 0) { - compression = COMPRESSION_CCITTFAX3; - - } else if (strcasecmp(compname, "group4") == 0) { - compression = COMPRESSION_CCITTFAX4; - - } else if (strcasecmp(compname, "tiff_jpeg") == 0) { - compression = COMPRESSION_OJPEG; - - } else if (strcasecmp(compname, "tiff_adobe_deflate") == 0) { - compression = COMPRESSION_ADOBE_DEFLATE; - - } else if (strcasecmp(compname, "tiff_thunderscan") == 0) { - compression = COMPRESSION_THUNDERSCAN; - - } else if (strcasecmp(compname, "tiff_deflate") == 0) { - compression = COMPRESSION_DEFLATE; - - } else if (strcasecmp(compname, "tiff_sgilog") == 0) { - compression = COMPRESSION_SGILOG; - - } else if (strcasecmp(compname, "tiff_sgilog24") == 0) { - compression = COMPRESSION_SGILOG24; - - } else if (strcasecmp(compname, "tiff_raw_16") == 0) { - compression = COMPRESSION_CCITTRLEW; - - } else { - PyErr_SetString(PyExc_ValueError, "unknown compession"); - return NULL; - } - decoder = PyImaging_DecoderNew(sizeof(TIFFSTATE)); if (decoder == NULL) return NULL; @@ -482,7 +441,7 @@ PyImaging_LibTiffDecoderNew(PyObject* self, PyObject* args) if (get_unpacker(decoder, mode, rawmode) < 0) return NULL; - if (! ImagingLibTiffInit(&decoder->state, compression, fp)) { + if (! ImagingLibTiffInit(&decoder->state, fp)) { Py_DECREF(decoder); PyErr_SetString(PyExc_RuntimeError, "tiff codec initialization failed"); return NULL; diff --git a/encode.c b/encode.c index 10ed90d12..ea61d4e3f 100644 --- a/encode.c +++ b/encode.c @@ -673,7 +673,6 @@ PyImaging_LibTiffEncoderNew(PyObject* self, PyObject* args) char* rawmode; char* compname; char* filename; - int compression; int fp; PyObject *dir; @@ -706,47 +705,6 @@ PyImaging_LibTiffEncoderNew(PyObject* self, PyObject* args) TRACE(("new tiff encoder %s fp: %d, filename: %s \n", compname, fp, filename)); - /* UNDONE -- we can probably do almost any arbitrary compression here, - * so long as we're doing row/stripe based actions and not tiles. - */ - - if (strcasecmp(compname, "tiff_ccitt") == 0) { - compression = COMPRESSION_CCITTRLE; - - } else if (strcasecmp(compname, "group3") == 0) { - compression = COMPRESSION_CCITTFAX3; - - } else if (strcasecmp(compname, "group4") == 0) { - compression = COMPRESSION_CCITTFAX4; - - } else if (strcasecmp(compname, "tiff_jpeg") == 0) { - compression = COMPRESSION_OJPEG; - - } else if (strcasecmp(compname, "tiff_adobe_deflate") == 0) { - compression = COMPRESSION_ADOBE_DEFLATE; - - } else if (strcasecmp(compname, "tiff_thunderscan") == 0) { - compression = COMPRESSION_THUNDERSCAN; - - } else if (strcasecmp(compname, "tiff_deflate") == 0) { - compression = COMPRESSION_DEFLATE; - - } else if (strcasecmp(compname, "tiff_sgilog") == 0) { - compression = COMPRESSION_SGILOG; - - } else if (strcasecmp(compname, "tiff_sgilog24") == 0) { - compression = COMPRESSION_SGILOG24; - - } else if (strcasecmp(compname, "tiff_raw_16") == 0) { - compression = COMPRESSION_CCITTRLEW; - - } else { - PyErr_SetString(PyExc_ValueError, "unknown compession"); - return NULL; - } - - TRACE(("Found compression: %d\n", compression)); - encoder = PyImaging_EncoderNew(sizeof(TIFFSTATE)); if (encoder == NULL) return NULL; diff --git a/libImaging/TiffDecode.c b/libImaging/TiffDecode.c index d535a5033..787cd4506 100644 --- a/libImaging/TiffDecode.c +++ b/libImaging/TiffDecode.c @@ -142,11 +142,11 @@ void _tiffUnmapProc(thandle_t hdata, tdata_t base, toff_t size) { (void) hdata; (void) base; (void) size; } -int ImagingLibTiffInit(ImagingCodecState state, int compression, int fp) { +int ImagingLibTiffInit(ImagingCodecState state, int fp) { TIFFSTATE *clientstate = (TIFFSTATE *)state->context; TRACE(("initing libtiff\n")); - TRACE(("Compression: %d, filepointer: %d \n", compression, fp)); + TRACE(("filepointer: %d \n", fp)); TRACE(("State: count %d, state %d, x %d, y %d, ystep %d\n", state->count, state->state, state->x, state->y, state->ystep)); TRACE(("State: xsize %d, ysize %d, xoff %d, yoff %d \n", state->xsize, state->ysize, diff --git a/libImaging/TiffDecode.h b/libImaging/TiffDecode.h index 306b3fab4..90fe3c9d4 100644 --- a/libImaging/TiffDecode.h +++ b/libImaging/TiffDecode.h @@ -38,7 +38,7 @@ typedef struct { -extern int ImagingLibTiffInit(ImagingCodecState state, int compression, int fp); +extern int ImagingLibTiffInit(ImagingCodecState state, int fp); extern int ImagingLibTiffEncodeInit(ImagingCodecState state, char *filename, int fp); extern int ImagingLibTiffSetField(ImagingCodecState state, ttag_t tag, ...);