Commit bc4f63e5 authored by Alexander Shishkov's avatar Alexander Shishkov

updated libtiff: from 3.9.5 to 4.0.1 #1609

parent d00fa6b8
...@@ -67,10 +67,6 @@ if(WIN32) ...@@ -67,10 +67,6 @@ if(WIN32)
set(lib_srcs ${lib_srcs} tif_win32.c) set(lib_srcs ${lib_srcs} tif_win32.c)
endif(WIN32) endif(WIN32)
#if(APPLE)
# set(lib_srcs ${lib_srcs} tif_apple.c)
#endif(APPLE)
file(GLOB lib_hdrs *.h*) file(GLOB lib_hdrs *.h*)
if(MSVC) if(MSVC)
......
/* $Id: t4.h,v 1.1.1.1.2.1 2010-06-08 18:50:41 bfriesen Exp $ */ /* $Id: t4.h,v 1.3 2010-03-10 18:56:48 bfriesen Exp $ */
/* /*
* Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1988-1997 Sam Leffler
* Copyright (c) 1991-1997 Silicon Graphics, Inc. * Copyright (c) 1991-1997 Silicon Graphics, Inc.
* *
* Permission to use, copy, modify, distribute, and sell this software and * Permission to use, copy, modify, distribute, and sell this software and
* its documentation for any purpose is hereby granted without fee, provided * its documentation for any purpose is hereby granted without fee, provided
* that (i) the above copyright notices and this permission notice appear in * that (i) the above copyright notices and this permission notice appear in
* all copies of the software and related documentation, and (ii) the names of * all copies of the software and related documentation, and (ii) the names of
* Sam Leffler and Silicon Graphics may not be used in any advertising or * Sam Leffler and Silicon Graphics may not be used in any advertising or
* publicity relating to the software without the specific, prior written * publicity relating to the software without the specific, prior written
* permission of Sam Leffler and Silicon Graphics. * permission of Sam Leffler and Silicon Graphics.
* *
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
* *
* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE. * OF THIS SOFTWARE.
*/ */
...@@ -33,18 +33,18 @@ ...@@ -33,18 +33,18 @@
* worthwhile to make code & length 8 bits. * worthwhile to make code & length 8 bits.
*/ */
typedef struct tableentry { typedef struct tableentry {
unsigned short length; /* bit length of g3 code */ unsigned short length; /* bit length of g3 code */
unsigned short code; /* g3 code */ unsigned short code; /* g3 code */
short runlen; /* run length in bits */ short runlen; /* run length in bits */
} tableentry; } tableentry;
#define EOL 0x001 /* EOL code value - 0000 0000 0000 1 */ #define EOL 0x001 /* EOL code value - 0000 0000 0000 1 */
/* status values returned instead of a run length */ /* status values returned instead of a run length */
#define G3CODE_EOL -1 /* NB: ACT_EOL - ACT_WRUNT */ #define G3CODE_EOL -1 /* NB: ACT_EOL - ACT_WRUNT */
#define G3CODE_INVALID -2 /* NB: ACT_INVALID - ACT_WRUNT */ #define G3CODE_INVALID -2 /* NB: ACT_INVALID - ACT_WRUNT */
#define G3CODE_EOF -3 /* end of input data */ #define G3CODE_EOF -3 /* end of input data */
#define G3CODE_INCOMP -4 /* incomplete run code */ #define G3CODE_INCOMP -4 /* incomplete run code */
/* /*
* Note that these tables are ordered such that the * Note that these tables are ordered such that the
...@@ -279,8 +279,8 @@ const tableentry TIFFFaxBlackCodes[] = { ...@@ -279,8 +279,8 @@ const tableentry TIFFFaxBlackCodes[] = {
{ 12, 0x0, G3CODE_INVALID }, /* 0000 0000 0000 */ { 12, 0x0, G3CODE_INVALID }, /* 0000 0000 0000 */
}; };
#else #else
extern const tableentry TIFFFaxWhiteCodes[]; extern const tableentry TIFFFaxWhiteCodes[];
extern const tableentry TIFFFaxBlackCodes[]; extern const tableentry TIFFFaxBlackCodes[];
#endif #endif
#endif /* _T4_ */ #endif /* _T4_ */
/* /*
......
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/Attic/tif_apple.c,v 1.3.2.1 2010-06-08 18:50:41 bfriesen Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
* Copyright (c) 1991-1997 Silicon Graphics, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and
* its documentation for any purpose is hereby granted without fee, provided
* that (i) the above copyright notices and this permission notice appear in
* all copies of the software and related documentation, and (ii) the names of
* Sam Leffler and Silicon Graphics may not be used in any advertising or
* publicity relating to the software without the specific, prior written
* permission of Sam Leffler and Silicon Graphics.
*
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
*
* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*/
/*
* TIFF Library Macintosh-specific routines.
*
* These routines use only Toolbox and high-level File Manager traps.
* They make no calls to the THINK C "unix" compatibility library. Also,
* malloc is not used directly but it is still referenced internally by
* the ANSI library in rare cases. Heap fragmentation by the malloc ring
* buffer is therefore minimized.
*
* O_RDONLY and O_RDWR are treated identically here. The tif_mode flag is
* checked in TIFFWriteCheck().
*
* Create below fills in a blank creator signature and sets the file type
* to 'TIFF'. It is much better for the application to do this by Create'ing
* the file first and TIFFOpen'ing it later.
* ---------
* This code has been "Carbonized", and may not work with older MacOS versions.
* If so, grab the tif_apple.c out of an older libtiff distribution, like
* 3.5.5 from www.libtiff.org.
*/
#include "tiffiop.h"
#include <Errors.h>
#include <Files.h>
#include <Memory.h>
#include <Script.h>
#if defined(__PPCC__) || defined(__SC__) || defined(__MRC__) || defined(applec)
#define CtoPstr c2pstr
#endif
static tsize_t
_tiffReadProc(thandle_t fd, tdata_t buf, tsize_t size)
{
return (FSRead((short) fd, (long*) &size, (char*) buf) == noErr ?
size : (tsize_t) -1);
}
static tsize_t
_tiffWriteProc(thandle_t fd, tdata_t buf, tsize_t size)
{
return (FSWrite((short) fd, (long*) &size, (char*) buf) == noErr ?
size : (tsize_t) -1);
}
static toff_t
_tiffSeekProc(thandle_t fd, toff_t off, int whence)
{
long fpos, size;
if (GetEOF((short) fd, &size) != noErr)
return EOF;
(void) GetFPos((short) fd, &fpos);
switch (whence) {
case SEEK_CUR:
if (off + fpos > size)
SetEOF((short) fd, off + fpos);
if (SetFPos((short) fd, fsFromMark, off) != noErr)
return EOF;
break;
case SEEK_END:
if (off > 0)
SetEOF((short) fd, off + size);
if (SetFPos((short) fd, fsFromStart, off + size) != noErr)
return EOF;
break;
case SEEK_SET:
if (off > size)
SetEOF((short) fd, off);
if (SetFPos((short) fd, fsFromStart, off) != noErr)
return EOF;
break;
}
return (toff_t)(GetFPos((short) fd, &fpos) == noErr ? fpos : EOF);
}
static int
_tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize)
{
return (0);
}
static void
_tiffUnmapProc(thandle_t fd, tdata_t base, toff_t size)
{
}
static int
_tiffCloseProc(thandle_t fd)
{
return (FSClose((short) fd));
}
static toff_t
_tiffSizeProc(thandle_t fd)
{
long size;
if (GetEOF((short) fd, &size) != noErr) {
TIFFErrorExt(fd, "_tiffSizeProc", "%s: Cannot get file size");
return (-1L);
}
return ((toff_t) size);
}
/*
* Open a TIFF file descriptor for read/writing.
*/
TIFF*
TIFFFdOpen(int fd, const char* name, const char* mode)
{
TIFF* tif;
tif = TIFFClientOpen(name, mode, (thandle_t) fd,
_tiffReadProc, _tiffWriteProc, _tiffSeekProc, _tiffCloseProc,
_tiffSizeProc, _tiffMapProc, _tiffUnmapProc);
if (tif)
tif->tif_fd = fd;
return (tif);
}
static void ourc2pstr( char* inString )
{
int sLen = strlen( inString );
BlockMoveData( inString, &inString[1], sLen );
inString[0] = sLen;
}
/*
* Open a TIFF file for read/writing.
*/
TIFF*
TIFFOpen(const char* name, const char* mode)
{
static const char module[] = "TIFFOpen";
Str255 pname;
FInfo finfo;
short fref;
OSErr err;
FSSpec fSpec;
strcpy((char*) pname, name);
ourc2pstr((char*) pname);
err = FSMakeFSSpec( 0, 0, pname, &fSpec );
switch (_TIFFgetMode(mode, module)) {
default:
return ((TIFF*) 0);
case O_RDWR | O_CREAT | O_TRUNC:
if (FSpGetFInfo(&fSpec, &finfo) == noErr)
FSpDelete(&fSpec);
/* fall through */
case O_RDWR | O_CREAT:
if ((err = FSpGetFInfo(&fSpec, &finfo)) == fnfErr) {
if (FSpCreate(&fSpec, ' ', 'TIFF', smSystemScript) != noErr)
goto badCreate;
if (FSpOpenDF(&fSpec, fsRdWrPerm, &fref) != noErr)
goto badOpen;
} else if (err == noErr) {
if (FSpOpenDF(&fSpec, fsRdWrPerm, &fref) != noErr)
goto badOpen;
} else
goto badOpen;
break;
case O_RDONLY:
if (FSpOpenDF(&fSpec, fsRdPerm, &fref) != noErr)
goto badOpen;
break;
case O_RDWR:
if (FSpOpenDF(&fSpec, fsRdWrPerm, &fref) != noErr)
goto badOpen;
break;
}
return (TIFFFdOpen((int) fref, name, mode));
badCreate:
TIFFErrorExt(0, module, "%s: Cannot create", name);
return ((TIFF*) 0);
badOpen:
TIFFErrorExt(0, module, "%s: Cannot open", name);
return ((TIFF*) 0);
}
void
_TIFFmemset(tdata_t p, int v, tsize_t c)
{
memset(p, v, (size_t) c);
}
void
_TIFFmemcpy(tdata_t d, const tdata_t s, tsize_t c)
{
memcpy(d, s, (size_t) c);
}
int
_TIFFmemcmp(const tdata_t p1, const tdata_t p2, tsize_t c)
{
return (memcmp(p1, p2, (size_t) c));
}
tdata_t
_TIFFmalloc(tsize_t s)
{
return (NewPtr((size_t) s));
}
void
_TIFFfree(tdata_t p)
{
DisposePtr(p);
}
tdata_t
_TIFFrealloc(tdata_t p, tsize_t s)
{
Ptr n = p;
SetPtrSize(p, (size_t) s);
if (MemError() && (n = NewPtr((size_t) s)) != NULL) {
BlockMove(p, n, GetPtrSize(p));
DisposePtr(p);
}
return ((tdata_t) n);
}
static void
appleWarningHandler(const char* module, const char* fmt, va_list ap)
{
if (module != NULL)
fprintf(stderr, "%s: ", module);
fprintf(stderr, "Warning, ");
vfprintf(stderr, fmt, ap);
fprintf(stderr, ".\n");
}
TIFFErrorHandler _TIFFwarningHandler = appleWarningHandler;
static void
appleErrorHandler(const char* module, const char* fmt, va_list ap)
{
if (module != NULL)
fprintf(stderr, "%s: ", module);
vfprintf(stderr, fmt, ap);
fprintf(stderr, ".\n");
}
TIFFErrorHandler _TIFFerrorHandler = appleErrorHandler;
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/
/* $Id: tif_aux.c,v 1.20.2.3 2010-06-09 21:15:27 bfriesen Exp $ */ /* $Id: tif_aux.c,v 1.26 2010-07-01 15:33:28 dron Exp $ */
/* /*
* Copyright (c) 1991-1997 Sam Leffler * Copyright (c) 1991-1997 Sam Leffler
...@@ -33,12 +33,38 @@ ...@@ -33,12 +33,38 @@
#include "tif_predict.h" #include "tif_predict.h"
#include <math.h> #include <math.h>
tdata_t uint32
_TIFFCheckRealloc(TIFF* tif, tdata_t buffer, _TIFFMultiply32(TIFF* tif, uint32 first, uint32 second, const char* where)
size_t nmemb, size_t elem_size, const char* what)
{ {
tdata_t cp = NULL; uint32 bytes = first * second;
tsize_t bytes = nmemb * elem_size;
if (second && bytes / second != first) {
TIFFErrorExt(tif->tif_clientdata, where, "Integer overflow in %s", where);
bytes = 0;
}
return bytes;
}
uint64
_TIFFMultiply64(TIFF* tif, uint64 first, uint64 second, const char* where)
{
uint64 bytes = first * second;
if (second && bytes / second != first) {
TIFFErrorExt(tif->tif_clientdata, where, "Integer overflow in %s", where);
bytes = 0;
}
return bytes;
}
void*
_TIFFCheckRealloc(TIFF* tif, void* buffer,
tmsize_t nmemb, tmsize_t elem_size, const char* what)
{
void* cp = NULL;
tmsize_t bytes = nmemb * elem_size;
/* /*
* XXX: Check for integer overflow. * XXX: Check for integer overflow.
...@@ -46,32 +72,33 @@ _TIFFCheckRealloc(TIFF* tif, tdata_t buffer, ...@@ -46,32 +72,33 @@ _TIFFCheckRealloc(TIFF* tif, tdata_t buffer,
if (nmemb && elem_size && bytes / elem_size == nmemb) if (nmemb && elem_size && bytes / elem_size == nmemb)
cp = _TIFFrealloc(buffer, bytes); cp = _TIFFrealloc(buffer, bytes);
if (cp == NULL) if (cp == NULL) {
TIFFErrorExt(tif->tif_clientdata, tif->tif_name, TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
"Failed to allocate memory for %s " "Failed to allocate memory for %s "
"(%ld elements of %ld bytes each)", "(%ld elements of %ld bytes each)",
what,(long) nmemb, (long) elem_size); what,(long) nmemb, (long) elem_size);
}
return cp; return cp;
} }
tdata_t void*
_TIFFCheckMalloc(TIFF* tif, size_t nmemb, size_t elem_size, const char* what) _TIFFCheckMalloc(TIFF* tif, tmsize_t nmemb, tmsize_t elem_size, const char* what)
{ {
return _TIFFCheckRealloc(tif, NULL, nmemb, elem_size, what); return _TIFFCheckRealloc(tif, NULL, nmemb, elem_size, what);
} }
static int static int
TIFFDefaultTransferFunction(TIFFDirectory* td) TIFFDefaultTransferFunction(TIFFDirectory* td)
{ {
uint16 **tf = td->td_transferfunction; uint16 **tf = td->td_transferfunction;
tsize_t i, n, nbytes; tmsize_t i, n, nbytes;
tf[0] = tf[1] = tf[2] = 0; tf[0] = tf[1] = tf[2] = 0;
if (td->td_bitspersample >= sizeof(tsize_t) * 8 - 2) if (td->td_bitspersample >= sizeof(tmsize_t) * 8 - 2)
return 0; return 0;
n = 1<<td->td_bitspersample; n = ((tmsize_t)1)<<td->td_bitspersample;
nbytes = n * sizeof (uint16); nbytes = n * sizeof (uint16);
if (!(tf[0] = (uint16 *)_TIFFmalloc(nbytes))) if (!(tf[0] = (uint16 *)_TIFFmalloc(nbytes)))
return 0; return 0;
...@@ -140,7 +167,7 @@ TIFFDefaultRefBlackWhite(TIFFDirectory* td) ...@@ -140,7 +167,7 @@ TIFFDefaultRefBlackWhite(TIFFDirectory* td)
* place in the library -- in TIFFDefaultDirectory. * place in the library -- in TIFFDefaultDirectory.
*/ */
int int
TIFFVGetFieldDefaulted(TIFF* tif, ttag_t tag, va_list ap) TIFFVGetFieldDefaulted(TIFF* tif, uint32 tag, va_list ap)
{ {
TIFFDirectory *td = &tif->tif_dir; TIFFDirectory *td = &tif->tif_dir;
...@@ -269,7 +296,7 @@ TIFFVGetFieldDefaulted(TIFF* tif, ttag_t tag, va_list ap) ...@@ -269,7 +296,7 @@ TIFFVGetFieldDefaulted(TIFF* tif, ttag_t tag, va_list ap)
* value if the tag is not present in the directory. * value if the tag is not present in the directory.
*/ */
int int
TIFFGetFieldDefaulted(TIFF* tif, ttag_t tag, ...) TIFFGetFieldDefaulted(TIFF* tif, uint32 tag, ...)
{ {
int ok; int ok;
va_list ap; va_list ap;
...@@ -280,6 +307,47 @@ TIFFGetFieldDefaulted(TIFF* tif, ttag_t tag, ...) ...@@ -280,6 +307,47 @@ TIFFGetFieldDefaulted(TIFF* tif, ttag_t tag, ...)
return (ok); return (ok);
} }
struct _Int64Parts {
int32 low, high;
};
typedef union {
struct _Int64Parts part;
int64 value;
} _Int64;
float
_TIFFUInt64ToFloat(uint64 ui64)
{
_Int64 i;
i.value = ui64;
if (i.part.high >= 0) {
return (float)i.value;
} else {
long double df;
df = (long double)i.value;
df += 18446744073709551616.0; /* adding 2**64 */
return (float)df;
}
}
double
_TIFFUInt64ToDouble(uint64 ui64)
{
_Int64 i;
i.value = ui64;
if (i.part.high >= 0) {
return (double)i.value;
} else {
long double df;
df = (long double)i.value;
df += 18446744073709551616.0; /* adding 2**64 */
return (double)df;
}
}
/* vim: set ts=8 sts=8 sw=8 noet: */ /* vim: set ts=8 sts=8 sw=8 noet: */
/* /*
* Local Variables: * Local Variables:
......
/* $Id: tif_close.c,v 1.10.2.1 2010-06-08 18:50:41 bfriesen Exp $ */ /* $Id: tif_close.c,v 1.19 2010-03-10 18:56:48 bfriesen Exp $ */
/* /*
* Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1988-1997 Sam Leffler
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
* TIFF Library. * TIFF Library.
*/ */
#include "tiffiop.h" #include "tiffiop.h"
#include <string.h>
/************************************************************************/ /************************************************************************/
/* TIFFCleanup() */ /* TIFFCleanup() */
...@@ -45,18 +46,20 @@ ...@@ -45,18 +46,20 @@
void void
TIFFCleanup(TIFF* tif) TIFFCleanup(TIFF* tif)
{ {
/*
* Flush buffered data and directory (if dirty).
*/
if (tif->tif_mode != O_RDONLY) if (tif->tif_mode != O_RDONLY)
/* TIFFFlush(tif);
* Flush buffered data and directory (if dirty).
*/
TIFFFlush(tif);
(*tif->tif_cleanup)(tif); (*tif->tif_cleanup)(tif);
TIFFFreeDirectory(tif); TIFFFreeDirectory(tif);
if (tif->tif_dirlist) if (tif->tif_dirlist)
_TIFFfree(tif->tif_dirlist); _TIFFfree(tif->tif_dirlist);
/* Clean up client info links */ /*
* Clean up client info links.
*/
while( tif->tif_clientinfo ) while( tif->tif_clientinfo )
{ {
TIFFClientInfoLink *link = tif->tif_clientinfo; TIFFClientInfoLink *link = tif->tif_clientinfo;
...@@ -69,27 +72,36 @@ TIFFCleanup(TIFF* tif) ...@@ -69,27 +72,36 @@ TIFFCleanup(TIFF* tif)
if (tif->tif_rawdata && (tif->tif_flags&TIFF_MYBUFFER)) if (tif->tif_rawdata && (tif->tif_flags&TIFF_MYBUFFER))
_TIFFfree(tif->tif_rawdata); _TIFFfree(tif->tif_rawdata);
if (isMapped(tif)) if (isMapped(tif))
TIFFUnmapFileContents(tif, tif->tif_base, tif->tif_size); TIFFUnmapFileContents(tif, tif->tif_base, (toff_t)tif->tif_size);
/* Clean up custom fields */ /*
if (tif->tif_nfields > 0) * Clean up custom fields.
{ */
size_t i; if (tif->tif_fields && tif->tif_nfields > 0) {
uint32 i;
for (i = 0; i < tif->tif_nfields; i++)
{ for (i = 0; i < tif->tif_nfields; i++) {
TIFFFieldInfo *fld = tif->tif_fieldinfo[i]; TIFFField *fld = tif->tif_fields[i];
if (fld->field_bit == FIELD_CUSTOM && if (fld->field_bit == FIELD_CUSTOM &&
strncmp("Tag ", fld->field_name, 4) == 0) strncmp("Tag ", fld->field_name, 4) == 0) {
{ _TIFFfree(fld->field_name);
_TIFFfree(fld->field_name); _TIFFfree(fld);
_TIFFfree(fld); }
} }
}
_TIFFfree(tif->tif_fields);
_TIFFfree(tif->tif_fieldinfo);
} }
if (tif->tif_nfieldscompat > 0) {
uint32 i;
for (i = 0; i < tif->tif_nfieldscompat; i++) {
if (tif->tif_fieldscompat[i].allocated_size)
_TIFFfree(tif->tif_fieldscompat[i].fields);
}
_TIFFfree(tif->tif_fieldscompat);
}
_TIFFfree(tif); _TIFFfree(tif);
} }
...@@ -117,6 +129,8 @@ TIFFClose(TIFF* tif) ...@@ -117,6 +129,8 @@ TIFFClose(TIFF* tif)
(void) (*closeproc)(fd); (void) (*closeproc)(fd);
} }
/* vim: set ts=8 sts=8 sw=8 noet: */
/* /*
* Local Variables: * Local Variables:
* mode: c * mode: c
......
/* $Id: tif_codec.c,v 1.10.2.2 2010-06-08 18:50:41 bfriesen Exp $ */ /* $Id: tif_codec.c,v 1.15 2010-12-14 12:53:00 dron Exp $ */
/* /*
* Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1988-1997 Sam Leffler
...@@ -31,43 +31,46 @@ ...@@ -31,43 +31,46 @@
*/ */
#include "tiffiop.h" #include "tiffiop.h"
static int NotConfigured(TIFF*, int); static int NotConfigured(TIFF*, int);
#ifndef LZW_SUPPORT #ifndef LZW_SUPPORT
#define TIFFInitLZW NotConfigured #define TIFFInitLZW NotConfigured
#endif #endif
#ifndef PACKBITS_SUPPORT #ifndef PACKBITS_SUPPORT
#define TIFFInitPackBits NotConfigured #define TIFFInitPackBits NotConfigured
#endif #endif
#ifndef THUNDER_SUPPORT #ifndef THUNDER_SUPPORT
#define TIFFInitThunderScan NotConfigured #define TIFFInitThunderScan NotConfigured
#endif #endif
#ifndef NEXT_SUPPORT #ifndef NEXT_SUPPORT
#define TIFFInitNeXT NotConfigured #define TIFFInitNeXT NotConfigured
#endif #endif
#ifndef JPEG_SUPPORT #ifndef JPEG_SUPPORT
#define TIFFInitJPEG NotConfigured #define TIFFInitJPEG NotConfigured
#endif #endif
#ifndef OJPEG_SUPPORT #ifndef OJPEG_SUPPORT
#define TIFFInitOJPEG NotConfigured #define TIFFInitOJPEG NotConfigured
#endif #endif
#ifndef CCITT_SUPPORT #ifndef CCITT_SUPPORT
#define TIFFInitCCITTRLE NotConfigured #define TIFFInitCCITTRLE NotConfigured
#define TIFFInitCCITTRLEW NotConfigured #define TIFFInitCCITTRLEW NotConfigured
#define TIFFInitCCITTFax3 NotConfigured #define TIFFInitCCITTFax3 NotConfigured
#define TIFFInitCCITTFax4 NotConfigured #define TIFFInitCCITTFax4 NotConfigured
#endif #endif
#ifndef JBIG_SUPPORT #ifndef JBIG_SUPPORT
#define TIFFInitJBIG NotConfigured #define TIFFInitJBIG NotConfigured
#endif #endif
#ifndef ZIP_SUPPORT #ifndef ZIP_SUPPORT
#define TIFFInitZIP NotConfigured #define TIFFInitZIP NotConfigured
#endif #endif
#ifndef PIXARLOG_SUPPORT #ifndef PIXARLOG_SUPPORT
#define TIFFInitPixarLog NotConfigured #define TIFFInitPixarLog NotConfigured
#endif #endif
#ifndef LOGLUV_SUPPORT #ifndef LOGLUV_SUPPORT
#define TIFFInitSGILog NotConfigured #define TIFFInitSGILog NotConfigured
#endif
#ifndef LZMA_SUPPORT
#define TIFFInitLZMA NotConfigured
#endif #endif
/* /*
...@@ -95,6 +98,7 @@ TIFFCodec _TIFFBuiltinCODECS[] = { ...@@ -95,6 +98,7 @@ TIFFCodec _TIFFBuiltinCODECS[] = {
{ "PixarLog", COMPRESSION_PIXARLOG, TIFFInitPixarLog }, { "PixarLog", COMPRESSION_PIXARLOG, TIFFInitPixarLog },
{ "SGILog", COMPRESSION_SGILOG, TIFFInitSGILog }, { "SGILog", COMPRESSION_SGILOG, TIFFInitSGILog },
{ "SGILog24", COMPRESSION_SGILOG24, TIFFInitSGILog }, { "SGILog24", COMPRESSION_SGILOG24, TIFFInitSGILog },
{ "LZMA", COMPRESSION_LZMA, TIFFInitLZMA },
{ NULL, 0, NULL } { NULL, 0, NULL }
}; };
...@@ -114,13 +118,14 @@ _notConfigured(TIFF* tif) ...@@ -114,13 +118,14 @@ _notConfigured(TIFF* tif)
static int static int
NotConfigured(TIFF* tif, int scheme) NotConfigured(TIFF* tif, int scheme)
{ {
(void) scheme; (void) scheme;
tif->tif_decodestatus = FALSE; tif->tif_fixuptags = _notConfigured;
tif->tif_setupdecode = _notConfigured; tif->tif_decodestatus = FALSE;
tif->tif_encodestatus = FALSE; tif->tif_setupdecode = _notConfigured;
tif->tif_setupencode = _notConfigured; tif->tif_encodestatus = FALSE;
return (1); tif->tif_setupencode = _notConfigured;
return (1);
} }
/************************************************************************/ /************************************************************************/
...@@ -129,7 +134,7 @@ NotConfigured(TIFF* tif, int scheme) ...@@ -129,7 +134,7 @@ NotConfigured(TIFF* tif, int scheme)
/** /**
* Check whether we have working codec for the specific coding scheme. * Check whether we have working codec for the specific coding scheme.
* *
* @return returns 1 if the codec is configured and working. Otherwise * @return returns 1 if the codec is configured and working. Otherwise
* 0 will be returned. * 0 will be returned.
*/ */
...@@ -140,14 +145,14 @@ TIFFIsCODECConfigured(uint16 scheme) ...@@ -140,14 +145,14 @@ TIFFIsCODECConfigured(uint16 scheme)
const TIFFCodec* codec = TIFFFindCODEC(scheme); const TIFFCodec* codec = TIFFFindCODEC(scheme);
if(codec == NULL) { if(codec == NULL) {
return 0; return 0;
} }
if(codec->init == NULL) { if(codec->init == NULL) {
return 0; return 0;
} }
if(codec->init != NotConfigured){ if(codec->init != NotConfigured){
return 1; return 1;
} }
return 0; return 0;
} }
......
/* $Id: tif_color.c,v 1.12.2.2 2010-12-14 02:23:09 faxguy Exp $ */ /* $Id: tif_color.c,v 1.19 2010-12-14 02:22:42 faxguy Exp $ */
/* /*
* Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1988-1997 Sam Leffler
...@@ -123,7 +123,7 @@ TIFFXYZToRGB(TIFFCIELabToRGB *cielab, float X, float Y, float Z, ...@@ -123,7 +123,7 @@ TIFFXYZToRGB(TIFFCIELabToRGB *cielab, float X, float Y, float Z,
*/ */
int int
TIFFCIELabToRGBInit(TIFFCIELabToRGB* cielab, TIFFCIELabToRGBInit(TIFFCIELabToRGB* cielab,
TIFFDisplay *display, float *refWhite) const TIFFDisplay *display, float *refWhite)
{ {
int i; int i;
double gamma; double gamma;
...@@ -224,7 +224,7 @@ TIFFYCbCrToRGBInit(TIFFYCbCrToRGB* ycbcr, float *luma, float *refBlackWhite) ...@@ -224,7 +224,7 @@ TIFFYCbCrToRGBInit(TIFFYCbCrToRGB* ycbcr, float *luma, float *refBlackWhite)
#define LumaBlue luma[2] #define LumaBlue luma[2]
clamptab = (TIFFRGBValue*)( clamptab = (TIFFRGBValue*)(
(tidata_t) ycbcr+TIFFroundup(sizeof (TIFFYCbCrToRGB), sizeof (long))); (uint8*) ycbcr+TIFFroundup_32(sizeof (TIFFYCbCrToRGB), sizeof (long)));
_TIFFmemset(clamptab, 0, 256); /* v < 0 => 0 */ _TIFFmemset(clamptab, 0, 256); /* v < 0 => 0 */
ycbcr->clamptab = (clamptab += 256); ycbcr->clamptab = (clamptab += 256);
for (i = 0; i < 256; i++) for (i = 0; i < 256; i++)
......
/* $Id: tif_compress.c,v 1.13.2.1 2010-06-08 18:50:41 bfriesen Exp $ */ /* $Id: tif_compress.c,v 1.22 2010-03-10 18:56:48 bfriesen Exp $ */
/* /*
* Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1988-1997 Sam Leffler
...@@ -36,11 +36,11 @@ TIFFNoEncode(TIFF* tif, const char* method) ...@@ -36,11 +36,11 @@ TIFFNoEncode(TIFF* tif, const char* method)
{ {
const TIFFCodec* c = TIFFFindCODEC(tif->tif_dir.td_compression); const TIFFCodec* c = TIFFFindCODEC(tif->tif_dir.td_compression);
if (c) { if (c) {
TIFFErrorExt(tif->tif_clientdata, tif->tif_name, TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
"%s %s encoding is not implemented", "%s %s encoding is not implemented",
c->name, method); c->name, method);
} else { } else {
TIFFErrorExt(tif->tif_clientdata, tif->tif_name, TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
"Compression scheme %u %s encoding is not implemented", "Compression scheme %u %s encoding is not implemented",
tif->tif_dir.td_compression, method); tif->tif_dir.td_compression, method);
...@@ -49,21 +49,21 @@ TIFFNoEncode(TIFF* tif, const char* method) ...@@ -49,21 +49,21 @@ TIFFNoEncode(TIFF* tif, const char* method)
} }
int int
_TIFFNoRowEncode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) _TIFFNoRowEncode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s)
{ {
(void) pp; (void) cc; (void) s; (void) pp; (void) cc; (void) s;
return (TIFFNoEncode(tif, "scanline")); return (TIFFNoEncode(tif, "scanline"));
} }
int int
_TIFFNoStripEncode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) _TIFFNoStripEncode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s)
{ {
(void) pp; (void) cc; (void) s; (void) pp; (void) cc; (void) s;
return (TIFFNoEncode(tif, "strip")); return (TIFFNoEncode(tif, "strip"));
} }
int int
_TIFFNoTileEncode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) _TIFFNoTileEncode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s)
{ {
(void) pp; (void) cc; (void) s; (void) pp; (void) cc; (void) s;
return (TIFFNoEncode(tif, "tile")); return (TIFFNoEncode(tif, "tile"));
...@@ -86,21 +86,28 @@ TIFFNoDecode(TIFF* tif, const char* method) ...@@ -86,21 +86,28 @@ TIFFNoDecode(TIFF* tif, const char* method)
} }
int int
_TIFFNoRowDecode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) _TIFFNoFixupTags(TIFF* tif)
{
(void) tif;
return (1);
}
int
_TIFFNoRowDecode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s)
{ {
(void) pp; (void) cc; (void) s; (void) pp; (void) cc; (void) s;
return (TIFFNoDecode(tif, "scanline")); return (TIFFNoDecode(tif, "scanline"));
} }
int int
_TIFFNoStripDecode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) _TIFFNoStripDecode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s)
{ {
(void) pp; (void) cc; (void) s; (void) pp; (void) cc; (void) s;
return (TIFFNoDecode(tif, "strip")); return (TIFFNoDecode(tif, "strip"));
} }
int int
_TIFFNoTileDecode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) _TIFFNoTileDecode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s)
{ {
(void) pp; (void) cc; (void) s; (void) pp; (void) cc; (void) s;
return (TIFFNoDecode(tif, "tile")); return (TIFFNoDecode(tif, "tile"));
...@@ -116,7 +123,7 @@ _TIFFNoSeek(TIFF* tif, uint32 off) ...@@ -116,7 +123,7 @@ _TIFFNoSeek(TIFF* tif, uint32 off)
} }
int int
_TIFFNoPreCode(TIFF* tif, tsample_t s) _TIFFNoPreCode(TIFF* tif, uint16 s)
{ {
(void) tif; (void) s; (void) tif; (void) s;
return (1); return (1);
...@@ -128,19 +135,20 @@ static void _TIFFvoid(TIFF* tif) { (void) tif; } ...@@ -128,19 +135,20 @@ static void _TIFFvoid(TIFF* tif) { (void) tif; }
void void
_TIFFSetDefaultCompressionState(TIFF* tif) _TIFFSetDefaultCompressionState(TIFF* tif)
{ {
tif->tif_fixuptags = _TIFFNoFixupTags;
tif->tif_decodestatus = TRUE; tif->tif_decodestatus = TRUE;
tif->tif_setupdecode = _TIFFtrue; tif->tif_setupdecode = _TIFFtrue;
tif->tif_predecode = _TIFFNoPreCode; tif->tif_predecode = _TIFFNoPreCode;
tif->tif_decoderow = _TIFFNoRowDecode; tif->tif_decoderow = _TIFFNoRowDecode;
tif->tif_decodestrip = _TIFFNoStripDecode; tif->tif_decodestrip = _TIFFNoStripDecode;
tif->tif_decodetile = _TIFFNoTileDecode; tif->tif_decodetile = _TIFFNoTileDecode;
tif->tif_encodestatus = TRUE; tif->tif_encodestatus = TRUE;
tif->tif_setupencode = _TIFFtrue; tif->tif_setupencode = _TIFFtrue;
tif->tif_preencode = _TIFFNoPreCode; tif->tif_preencode = _TIFFNoPreCode;
tif->tif_postencode = _TIFFtrue; tif->tif_postencode = _TIFFtrue;
tif->tif_encoderow = _TIFFNoRowEncode; tif->tif_encoderow = _TIFFNoRowEncode;
tif->tif_encodestrip = _TIFFNoStripEncode; tif->tif_encodestrip = _TIFFNoStripEncode;
tif->tif_encodetile = _TIFFNoTileEncode; tif->tif_encodetile = _TIFFNoTileEncode;
tif->tif_close = _TIFFvoid; tif->tif_close = _TIFFvoid;
tif->tif_seek = _TIFFNoSeek; tif->tif_seek = _TIFFNoSeek;
tif->tif_cleanup = _TIFFvoid; tif->tif_cleanup = _TIFFvoid;
...@@ -170,10 +178,10 @@ TIFFSetCompressionScheme(TIFF* tif, int scheme) ...@@ -170,10 +178,10 @@ TIFFSetCompressionScheme(TIFF* tif, int scheme)
* by this library. * by this library.
*/ */
typedef struct _codec { typedef struct _codec {
struct _codec* next; struct _codec* next;
TIFFCodec* info; TIFFCodec* info;
} codec_t; } codec_t;
static codec_t* registeredCODECS = NULL; static codec_t* registeredCODECS = NULL;
const TIFFCodec* const TIFFCodec*
TIFFFindCODEC(uint16 scheme) TIFFFindCODEC(uint16 scheme)
...@@ -194,12 +202,12 @@ TIFFCodec* ...@@ -194,12 +202,12 @@ TIFFCodec*
TIFFRegisterCODEC(uint16 scheme, const char* name, TIFFInitMethod init) TIFFRegisterCODEC(uint16 scheme, const char* name, TIFFInitMethod init)
{ {
codec_t* cd = (codec_t*) codec_t* cd = (codec_t*)
_TIFFmalloc(sizeof (codec_t) + sizeof (TIFFCodec) + strlen(name)+1); _TIFFmalloc((tmsize_t)(sizeof (codec_t) + sizeof (TIFFCodec) + strlen(name)+1));
if (cd != NULL) { if (cd != NULL) {
cd->info = (TIFFCodec*) ((tidata_t) cd + sizeof (codec_t)); cd->info = (TIFFCodec*) ((uint8*) cd + sizeof (codec_t));
cd->info->name = (char*) cd->info->name = (char*)
((tidata_t) cd->info + sizeof (TIFFCodec)); ((uint8*) cd->info + sizeof (TIFFCodec));
strcpy(cd->info->name, name); strcpy(cd->info->name, name);
cd->info->scheme = scheme; cd->info->scheme = scheme;
cd->info->init = init; cd->info->init = init;
...@@ -244,13 +252,14 @@ TIFFUnRegisterCODEC(TIFFCodec* c) ...@@ -244,13 +252,14 @@ TIFFUnRegisterCODEC(TIFFCodec* c)
TIFFCodec* TIFFCodec*
TIFFGetConfiguredCODECs() TIFFGetConfiguredCODECs()
{ {
int i = 1; int i = 1;
codec_t *cd; codec_t *cd;
const TIFFCodec *c; const TIFFCodec* c;
TIFFCodec *codecs = NULL, *new_codecs; TIFFCodec* codecs = NULL;
TIFFCodec* new_codecs;
for (cd = registeredCODECS; cd; cd = cd->next) { for (cd = registeredCODECS; cd; cd = cd->next) {
new_codecs = (TIFFCodec *) new_codecs = (TIFFCodec *)
_TIFFrealloc(codecs, i * sizeof(TIFFCodec)); _TIFFrealloc(codecs, i * sizeof(TIFFCodec));
if (!new_codecs) { if (!new_codecs) {
_TIFFfree (codecs); _TIFFfree (codecs);
...@@ -260,16 +269,16 @@ TIFFGetConfiguredCODECs() ...@@ -260,16 +269,16 @@ TIFFGetConfiguredCODECs()
_TIFFmemcpy(codecs + i - 1, cd, sizeof(TIFFCodec)); _TIFFmemcpy(codecs + i - 1, cd, sizeof(TIFFCodec));
i++; i++;
} }
for (c = _TIFFBuiltinCODECS; c->name; c++) { for (c = _TIFFBuiltinCODECS; c->name; c++) {
if (TIFFIsCODECConfigured(c->scheme)) { if (TIFFIsCODECConfigured(c->scheme)) {
new_codecs = (TIFFCodec *) new_codecs = (TIFFCodec *)
_TIFFrealloc(codecs, i * sizeof(TIFFCodec)); _TIFFrealloc(codecs, i * sizeof(TIFFCodec));
if (!new_codecs) { if (!new_codecs) {
_TIFFfree (codecs); _TIFFfree (codecs);
return NULL; return NULL;
} }
codecs = new_codecs; codecs = new_codecs;
_TIFFmemcpy(codecs + i - 1, (const tdata_t)c, sizeof(TIFFCodec)); _TIFFmemcpy(codecs + i - 1, (const void*)c, sizeof(TIFFCodec));
i++; i++;
} }
} }
...@@ -282,7 +291,7 @@ TIFFGetConfiguredCODECs() ...@@ -282,7 +291,7 @@ TIFFGetConfiguredCODECs()
codecs = new_codecs; codecs = new_codecs;
_TIFFmemset(codecs + i - 1, 0, sizeof(TIFFCodec)); _TIFFmemset(codecs + i - 1, 0, sizeof(TIFFCodec));
return codecs; return codecs;
} }
/* vim: set ts=8 sts=8 sw=8 noet: */ /* vim: set ts=8 sts=8 sw=8 noet: */
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_dumpmode.c,v 1.5.2.2 2010-06-08 18:50:42 bfriesen Exp $ */ /* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_dumpmode.c,v 1.14 2011-04-02 20:54:09 bfriesen Exp $ */
/* /*
* Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1988-1997 Sam Leffler
...@@ -31,22 +31,29 @@ ...@@ -31,22 +31,29 @@
*/ */
#include "tiffiop.h" #include "tiffiop.h"
static int
DumpFixupTags(TIFF* tif)
{
(void) tif;
return (1);
}
/* /*
* Encode a hunk of pixels. * Encode a hunk of pixels.
*/ */
static int static int
DumpModeEncode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) DumpModeEncode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s)
{ {
(void) s; (void) s;
while (cc > 0) { while (cc > 0) {
tsize_t n; tmsize_t n;
n = cc; n = cc;
if (tif->tif_rawcc + n > tif->tif_rawdatasize) if (tif->tif_rawcc + n > tif->tif_rawdatasize)
n = tif->tif_rawdatasize - tif->tif_rawcc; n = tif->tif_rawdatasize - tif->tif_rawcc;
assert( n > 0 ); assert( n > 0 );
/* /*
* Avoid copy if client has setup raw * Avoid copy if client has setup raw
* data buffer to avoid extra copy. * data buffer to avoid extra copy.
...@@ -68,15 +75,24 @@ DumpModeEncode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) ...@@ -68,15 +75,24 @@ DumpModeEncode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s)
* Decode a hunk of pixels. * Decode a hunk of pixels.
*/ */
static int static int
DumpModeDecode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) DumpModeDecode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s)
{ {
static const char module[] = "DumpModeDecode";
(void) s; (void) s;
/* fprintf(stderr,"DumpModeDecode: scanline %ld, expected %ld bytes, got %ld bytes\n", */
/* (long) tif->tif_row, (long) tif->tif_rawcc, (long) cc); */
if (tif->tif_rawcc < cc) { if (tif->tif_rawcc < cc) {
TIFFErrorExt(tif->tif_clientdata, tif->tif_name, #if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
"DumpModeDecode: Not enough data for scanline %d", TIFFErrorExt(tif->tif_clientdata, module,
tif->tif_row); "Not enough data for scanline %lu, expected a request for at most %I64d bytes, got a request for %I64d bytes",
(unsigned long) tif->tif_row,
(signed __int64) tif->tif_rawcc,
(signed __int64) cc);
#else
TIFFErrorExt(tif->tif_clientdata, module,
"Not enough data for scanline %lu, expected a request for at most %lld bytes, got a request for %lld bytes",
(unsigned long) tif->tif_row,
(signed long long) tif->tif_rawcc,
(signed long long) cc);
#endif
return (0); return (0);
} }
/* /*
...@@ -86,7 +102,7 @@ DumpModeDecode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) ...@@ -86,7 +102,7 @@ DumpModeDecode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s)
if (tif->tif_rawcp != buf) if (tif->tif_rawcp != buf)
_TIFFmemcpy(buf, tif->tif_rawcp, cc); _TIFFmemcpy(buf, tif->tif_rawcp, cc);
tif->tif_rawcp += cc; tif->tif_rawcp += cc;
tif->tif_rawcc -= cc; tif->tif_rawcc -= cc;
return (1); return (1);
} }
...@@ -108,12 +124,13 @@ int ...@@ -108,12 +124,13 @@ int
TIFFInitDumpMode(TIFF* tif, int scheme) TIFFInitDumpMode(TIFF* tif, int scheme)
{ {
(void) scheme; (void) scheme;
tif->tif_fixuptags = DumpFixupTags;
tif->tif_decoderow = DumpModeDecode; tif->tif_decoderow = DumpModeDecode;
tif->tif_decodestrip = DumpModeDecode; tif->tif_decodestrip = DumpModeDecode;
tif->tif_decodetile = DumpModeDecode; tif->tif_decodetile = DumpModeDecode;
tif->tif_encoderow = DumpModeEncode; tif->tif_encoderow = DumpModeEncode;
tif->tif_encodestrip = DumpModeEncode; tif->tif_encodestrip = DumpModeEncode;
tif->tif_encodetile = DumpModeEncode; tif->tif_encodetile = DumpModeEncode;
tif->tif_seek = DumpModeSeek; tif->tif_seek = DumpModeSeek;
return (1); return (1);
} }
......
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_error.c,v 1.4.2.1 2010-06-08 18:50:42 bfriesen Exp $ */ /* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_error.c,v 1.5 2010-03-10 18:56:48 bfriesen Exp $ */
/* /*
* Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1988-1997 Sam Leffler
......
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_extension.c,v 1.4.2.1 2010-06-08 18:50:42 bfriesen Exp $ */ /* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_extension.c,v 1.7 2010-03-10 18:56:48 bfriesen Exp $ */
/* /*
* Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1988-1997 Sam Leffler
...@@ -41,13 +41,13 @@ int TIFFGetTagListCount( TIFF *tif ) ...@@ -41,13 +41,13 @@ int TIFFGetTagListCount( TIFF *tif )
return td->td_customValueCount; return td->td_customValueCount;
} }
ttag_t TIFFGetTagListEntry( TIFF *tif, int tag_index ) uint32 TIFFGetTagListEntry( TIFF *tif, int tag_index )
{ {
TIFFDirectory* td = &tif->tif_dir; TIFFDirectory* td = &tif->tif_dir;
if( tag_index < 0 || tag_index >= td->td_customValueCount ) if( tag_index < 0 || tag_index >= td->td_customValueCount )
return (ttag_t) -1; return (uint32)(-1);
else else
return td->td_customValues[tag_index].info->field_tag; return td->td_customValues[tag_index].info->field_tag;
} }
...@@ -102,7 +102,7 @@ void TIFFSetClientInfo( TIFF *tif, void *data, const char *name ) ...@@ -102,7 +102,7 @@ void TIFFSetClientInfo( TIFF *tif, void *data, const char *name )
link = (TIFFClientInfoLink *) _TIFFmalloc(sizeof(TIFFClientInfoLink)); link = (TIFFClientInfoLink *) _TIFFmalloc(sizeof(TIFFClientInfoLink));
assert (link != NULL); assert (link != NULL);
link->next = tif->tif_clientinfo; link->next = tif->tif_clientinfo;
link->name = (char *) _TIFFmalloc(strlen(name)+1); link->name = (char *) _TIFFmalloc((tmsize_t)(strlen(name)+1));
assert (link->name != NULL); assert (link->name != NULL);
strcpy(link->name, name); strcpy(link->name, name);
link->data = data; link->data = data;
......
This diff is collapsed.
/* $Id: tif_fax3.h,v 1.5.2.3 2011-03-10 20:22:33 fwarmerdam Exp $ */ /* $Id: tif_fax3.h,v 1.9 2011-03-10 20:23:07 fwarmerdam Exp $ */
/* /*
* Copyright (c) 1990-1997 Sam Leffler * Copyright (c) 1990-1997 Sam Leffler
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
* data in the run array as needed (e.g. to append zero runs to bring * data in the run array as needed (e.g. to append zero runs to bring
* the count up to a nice multiple). * the count up to a nice multiple).
*/ */
typedef void (*TIFFFaxFillFunc)(unsigned char*, uint32*, uint32*, uint32); typedef void (*TIFFFaxFillFunc)(unsigned char*, uint32*, uint32*, uint32);
/* /*
* The default run filler; made external for other decoders. * The default run filler; made external for other decoders.
...@@ -60,36 +60,36 @@ typedef void (*TIFFFaxFillFunc)(unsigned char*, uint32*, uint32*, uint32); ...@@ -60,36 +60,36 @@ typedef void (*TIFFFaxFillFunc)(unsigned char*, uint32*, uint32*, uint32);
#if defined(__cplusplus) #if defined(__cplusplus)
extern "C" { extern "C" {
#endif #endif
extern void _TIFFFax3fillruns(unsigned char*, uint32*, uint32*, uint32); extern void _TIFFFax3fillruns(unsigned char*, uint32*, uint32*, uint32);
#if defined(__cplusplus) #if defined(__cplusplus)
} }
#endif #endif
/* finite state machine codes */ /* finite state machine codes */
#define S_Null 0 #define S_Null 0
#define S_Pass 1 #define S_Pass 1
#define S_Horiz 2 #define S_Horiz 2
#define S_V0 3 #define S_V0 3
#define S_VR 4 #define S_VR 4
#define S_VL 5 #define S_VL 5
#define S_Ext 6 #define S_Ext 6
#define S_TermW 7 #define S_TermW 7
#define S_TermB 8 #define S_TermB 8
#define S_MakeUpW 9 #define S_MakeUpW 9
#define S_MakeUpB 10 #define S_MakeUpB 10
#define S_MakeUp 11 #define S_MakeUp 11
#define S_EOL 12 #define S_EOL 12
typedef struct { /* state table entry */ typedef struct { /* state table entry */
unsigned char State; /* see above */ unsigned char State; /* see above */
unsigned char Width; /* width of code in bits */ unsigned char Width; /* width of code in bits */
uint32 Param; /* unsigned 32-bit run length in bits */ uint32 Param; /* unsigned 32-bit run length in bits */
} TIFFFaxTabEnt; } TIFFFaxTabEnt;
extern const TIFFFaxTabEnt TIFFFaxMainTable[]; extern const TIFFFaxTabEnt TIFFFaxMainTable[];
extern const TIFFFaxTabEnt TIFFFaxWhiteTable[]; extern const TIFFFaxTabEnt TIFFFaxWhiteTable[];
extern const TIFFFaxTabEnt TIFFFaxBlackTable[]; extern const TIFFFaxTabEnt TIFFFaxBlackTable[];
/* /*
* The following macros define the majority of the G3/G4 decoder * The following macros define the majority of the G3/G4 decoder
......
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_flush.c,v 1.3.2.1 2010-06-08 18:50:42 bfriesen Exp $ */ /* $Id: tif_flush.c,v 1.9 2010-03-31 06:40:10 fwarmerdam Exp $ */
/* /*
* Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1988-1997 Sam Leffler
...@@ -32,15 +32,58 @@ ...@@ -32,15 +32,58 @@
int int
TIFFFlush(TIFF* tif) TIFFFlush(TIFF* tif)
{ {
if( tif->tif_mode == O_RDONLY )
return 1;
if (tif->tif_mode != O_RDONLY) { if (!TIFFFlushData(tif))
if (!TIFFFlushData(tif)) return (0);
return (0);
if ((tif->tif_flags & TIFF_DIRTYDIRECT) && /* In update (r+) mode we try to detect the case where
!TIFFWriteDirectory(tif)) only the strip/tile map has been altered, and we try to
return (0); rewrite only that portion of the directory without
} making any other changes */
return (1);
if( (tif->tif_flags & TIFF_DIRTYSTRIP)
&& !(tif->tif_flags & TIFF_DIRTYDIRECT)
&& tif->tif_mode == O_RDWR )
{
uint64 *offsets=NULL, *sizes=NULL;
if( TIFFIsTiled(tif) )
{
if( TIFFGetField( tif, TIFFTAG_TILEOFFSETS, &offsets )
&& TIFFGetField( tif, TIFFTAG_TILEBYTECOUNTS, &sizes )
&& _TIFFRewriteField( tif, TIFFTAG_TILEOFFSETS, TIFF_LONG8,
tif->tif_dir.td_nstrips, offsets )
&& _TIFFRewriteField( tif, TIFFTAG_TILEBYTECOUNTS, TIFF_LONG8,
tif->tif_dir.td_nstrips, sizes ) )
{
tif->tif_flags &= ~TIFF_DIRTYSTRIP;
tif->tif_flags &= ~TIFF_BEENWRITING;
return 1;
}
}
else
{
if( TIFFGetField( tif, TIFFTAG_STRIPOFFSETS, &offsets )
&& TIFFGetField( tif, TIFFTAG_STRIPBYTECOUNTS, &sizes )
&& _TIFFRewriteField( tif, TIFFTAG_STRIPOFFSETS, TIFF_LONG8,
tif->tif_dir.td_nstrips, offsets )
&& _TIFFRewriteField( tif, TIFFTAG_STRIPBYTECOUNTS, TIFF_LONG8,
tif->tif_dir.td_nstrips, sizes ) )
{
tif->tif_flags &= ~TIFF_DIRTYSTRIP;
tif->tif_flags &= ~TIFF_BEENWRITING;
return 1;
}
}
}
if ((tif->tif_flags & (TIFF_DIRTYDIRECT|TIFF_DIRTYSTRIP))
&& !TIFFRewriteDirectory(tif))
return (0);
return (1);
} }
/* /*
...@@ -56,7 +99,7 @@ int ...@@ -56,7 +99,7 @@ int
TIFFFlushData(TIFF* tif) TIFFFlushData(TIFF* tif)
{ {
if ((tif->tif_flags & TIFF_BEENWRITING) == 0) if ((tif->tif_flags & TIFF_BEENWRITING) == 0)
return (0); return (1);
if (tif->tif_flags & TIFF_POSTENCODE) { if (tif->tif_flags & TIFF_POSTENCODE) {
tif->tif_flags &= ~TIFF_POSTENCODE; tif->tif_flags &= ~TIFF_POSTENCODE;
if (!(*tif->tif_postencode)(tif)) if (!(*tif->tif_postencode)(tif))
...@@ -65,6 +108,7 @@ TIFFFlushData(TIFF* tif) ...@@ -65,6 +108,7 @@ TIFFFlushData(TIFF* tif)
return (TIFFFlushData1(tif)); return (TIFFFlushData1(tif));
} }
/* vim: set ts=8 sts=8 sw=8 noet: */
/* /*
* Local Variables: * Local Variables:
* mode: c * mode: c
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
#include "tiffiop.h"
#if defined(JPEG_DUAL_MODE_8_12)
# define TIFFInitJPEG TIFFInitJPEG_12
# include LIBJPEG_12_PATH
# include "tif_jpeg.c"
int TIFFReInitJPEG_12( TIFF *tif, int scheme, int is_encode )
{
JPEGState* sp;
assert(scheme == COMPRESSION_JPEG);
sp = JState(tif);
sp->tif = tif; /* back link */
/*
* Override parent get/set field methods.
*/
tif->tif_tagmethods.vgetfield = JPEGVGetField; /* hook for codec tags */
tif->tif_tagmethods.vsetfield = JPEGVSetField; /* hook for codec tags */
tif->tif_tagmethods.printdir = JPEGPrintDir; /* hook for codec tags */
/*
* Install codec methods.
*/
tif->tif_fixuptags = JPEGFixupTags;
tif->tif_setupdecode = JPEGSetupDecode;
tif->tif_predecode = JPEGPreDecode;
tif->tif_decoderow = JPEGDecode;
tif->tif_decodestrip = JPEGDecode;
tif->tif_decodetile = JPEGDecode;
tif->tif_setupencode = JPEGSetupEncode;
tif->tif_preencode = JPEGPreEncode;
tif->tif_postencode = JPEGPostEncode;
tif->tif_encoderow = JPEGEncode;
tif->tif_encodestrip = JPEGEncode;
tif->tif_encodetile = JPEGEncode;
tif->tif_cleanup = JPEGCleanup;
tif->tif_defstripsize = JPEGDefaultStripSize;
tif->tif_deftilesize = JPEGDefaultTileSize;
tif->tif_flags |= TIFF_NOBITREV; /* no bit reversal, please */
sp->cinfo_initialized = FALSE;
if( is_encode )
return JPEGSetupEncode(tif);
else
return JPEGSetupDecode(tif);
}
#endif /* defined(JPEG_DUAL_MODE_8_12) */
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/* $Id: tif_next.c,v 1.8.2.1 2010-06-08 18:50:42 bfriesen Exp $ */ /* $Id: tif_next.c,v 1.13 2010-03-10 18:56:48 bfriesen Exp $ */
/* /*
* Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1988-1997 Sam Leffler
...@@ -46,12 +46,13 @@ ...@@ -46,12 +46,13 @@
#define WHITE ((1<<2)-1) #define WHITE ((1<<2)-1)
static int static int
NeXTDecode(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) NeXTDecode(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s)
{ {
static const char module[] = "NeXTDecode";
unsigned char *bp, *op; unsigned char *bp, *op;
tsize_t cc; tmsize_t cc;
tidata_t row; uint8* row;
tsize_t scanline, n; tmsize_t scanline, n;
(void) s; (void) s;
/* /*
...@@ -59,12 +60,17 @@ NeXTDecode(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) ...@@ -59,12 +60,17 @@ NeXTDecode(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s)
* white (we assume a PhotometricInterpretation * white (we assume a PhotometricInterpretation
* of ``min-is-black''). * of ``min-is-black'').
*/ */
for (op = buf, cc = occ; cc-- > 0;) for (op = (unsigned char*) buf, cc = occ; cc-- > 0;)
*op++ = 0xff; *op++ = 0xff;
bp = (unsigned char *)tif->tif_rawcp; bp = (unsigned char *)tif->tif_rawcp;
cc = tif->tif_rawcc; cc = tif->tif_rawcc;
scanline = tif->tif_scanlinesize; scanline = tif->tif_scanlinesize;
if (occ % scanline)
{
TIFFErrorExt(tif->tif_clientdata, module, "Fractional scanlines cannot be read");
return (0);
}
for (row = buf; occ > 0; occ -= scanline, row += scanline) { for (row = buf; occ > 0; occ -= scanline, row += scanline) {
n = *bp++, cc--; n = *bp++, cc--;
switch (n) { switch (n) {
...@@ -79,7 +85,7 @@ NeXTDecode(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) ...@@ -79,7 +85,7 @@ NeXTDecode(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s)
cc -= scanline; cc -= scanline;
break; break;
case LITERALSPAN: { case LITERALSPAN: {
tsize_t off; tmsize_t off;
/* /*
* The scanline has a literal span that begins at some * The scanline has a literal span that begins at some
* offset. * offset.
...@@ -105,7 +111,7 @@ NeXTDecode(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) ...@@ -105,7 +111,7 @@ NeXTDecode(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s)
*/ */
op = row; op = row;
for (;;) { for (;;) {
grey = (n>>6) & 0x3; grey = (uint32)((n>>6) & 0x3);
n &= 0x3f; n &= 0x3f;
/* /*
* Ensure the run does not exceed the scanline * Ensure the run does not exceed the scanline
...@@ -124,11 +130,11 @@ NeXTDecode(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) ...@@ -124,11 +130,11 @@ NeXTDecode(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s)
} }
} }
} }
tif->tif_rawcp = (tidata_t) bp; tif->tif_rawcp = (uint8*) bp;
tif->tif_rawcc = cc; tif->tif_rawcc = cc;
return (1); return (1);
bad: bad:
TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "NeXTDecode: Not enough data for scanline %ld", TIFFErrorExt(tif->tif_clientdata, module, "Not enough data for scanline %ld",
(long) tif->tif_row); (long) tif->tif_row);
return (0); return (0);
} }
...@@ -137,8 +143,8 @@ int ...@@ -137,8 +143,8 @@ int
TIFFInitNeXT(TIFF* tif, int scheme) TIFFInitNeXT(TIFF* tif, int scheme)
{ {
(void) scheme; (void) scheme;
tif->tif_decoderow = NeXTDecode; tif->tif_decoderow = NeXTDecode;
tif->tif_decodestrip = NeXTDecode; tif->tif_decodestrip = NeXTDecode;
tif->tif_decodetile = NeXTDecode; tif->tif_decodetile = NeXTDecode;
return (1); return (1);
} }
......
This diff is collapsed.
This diff is collapsed.
/* $Id: tif_packbits.c,v 1.13.2.2 2010-06-08 18:50:42 bfriesen Exp $ */ /* $Id: tif_packbits.c,v 1.20 2010-03-10 18:56:49 bfriesen Exp $ */
/* /*
* Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1988-1997 Sam Leffler
...@@ -34,19 +34,19 @@ ...@@ -34,19 +34,19 @@
#include <stdio.h> #include <stdio.h>
static int static int
PackBitsPreEncode(TIFF* tif, tsample_t s) PackBitsPreEncode(TIFF* tif, uint16 s)
{ {
(void) s; (void) s;
if (!(tif->tif_data = (tidata_t)_TIFFmalloc(sizeof(tsize_t)))) if (!(tif->tif_data = (uint8*)_TIFFmalloc(sizeof(tmsize_t))))
return (0); return (0);
/* /*
* Calculate the scanline/tile-width size in bytes. * Calculate the scanline/tile-width size in bytes.
*/ */
if (isTiled(tif)) if (isTiled(tif))
*(tsize_t*)tif->tif_data = TIFFTileRowSize(tif); *(tmsize_t*)tif->tif_data = TIFFTileRowSize(tif);
else else
*(tsize_t*)tif->tif_data = TIFFScanlineSize(tif); *(tmsize_t*)tif->tif_data = TIFFScanlineSize(tif);
return (1); return (1);
} }
...@@ -58,21 +58,16 @@ PackBitsPostEncode(TIFF* tif) ...@@ -58,21 +58,16 @@ PackBitsPostEncode(TIFF* tif)
return (1); return (1);
} }
/*
* NB: tidata is the type representing *(tidata_t);
* if tidata_t is made signed then this type must
* be adjusted accordingly.
*/
typedef unsigned char tidata;
/* /*
* Encode a run of pixels. * Encode a run of pixels.
*/ */
static int static int
PackBitsEncode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) PackBitsEncode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s)
{ {
unsigned char* bp = (unsigned char*) buf; unsigned char* bp = (unsigned char*) buf;
tidata_t op, ep, lastliteral; uint8* op;
uint8* ep;
uint8* lastliteral;
long n, slop; long n, slop;
int b; int b;
enum { BASE, LITERAL, RUN, LITERAL_RUN } state; enum { BASE, LITERAL, RUN, LITERAL_RUN } state;
...@@ -98,8 +93,8 @@ PackBitsEncode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) ...@@ -98,8 +93,8 @@ PackBitsEncode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s)
* front of the buffer. * front of the buffer.
*/ */
if (state == LITERAL || state == LITERAL_RUN) { if (state == LITERAL || state == LITERAL_RUN) {
slop = op - lastliteral; slop = (long)(op - lastliteral);
tif->tif_rawcc += lastliteral - tif->tif_rawcp; tif->tif_rawcc += (tmsize_t)(lastliteral - tif->tif_rawcp);
if (!TIFFFlushData1(tif)) if (!TIFFFlushData1(tif))
return (-1); return (-1);
op = tif->tif_rawcp; op = tif->tif_rawcp;
...@@ -107,7 +102,7 @@ PackBitsEncode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) ...@@ -107,7 +102,7 @@ PackBitsEncode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s)
*op++ = *lastliteral++; *op++ = *lastliteral++;
lastliteral = tif->tif_rawcp; lastliteral = tif->tif_rawcp;
} else { } else {
tif->tif_rawcc += op - tif->tif_rawcp; tif->tif_rawcc += (tmsize_t)(op - tif->tif_rawcp);
if (!TIFFFlushData1(tif)) if (!TIFFFlushData1(tif))
return (-1); return (-1);
op = tif->tif_rawcp; op = tif->tif_rawcp;
...@@ -118,17 +113,17 @@ PackBitsEncode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) ...@@ -118,17 +113,17 @@ PackBitsEncode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s)
if (n > 1) { if (n > 1) {
state = RUN; state = RUN;
if (n > 128) { if (n > 128) {
*op++ = (tidata) -127; *op++ = (uint8) -127;
*op++ = (tidataval_t) b; *op++ = (uint8) b;
n -= 128; n -= 128;
goto again; goto again;
} }
*op++ = (tidataval_t)(-(n-1)); *op++ = (uint8)(-(n-1));
*op++ = (tidataval_t) b; *op++ = (uint8) b;
} else { } else {
lastliteral = op; lastliteral = op;
*op++ = 0; *op++ = 0;
*op++ = (tidataval_t) b; *op++ = (uint8) b;
state = LITERAL; state = LITERAL;
} }
break; break;
...@@ -136,33 +131,33 @@ PackBitsEncode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) ...@@ -136,33 +131,33 @@ PackBitsEncode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s)
if (n > 1) { if (n > 1) {
state = LITERAL_RUN; state = LITERAL_RUN;
if (n > 128) { if (n > 128) {
*op++ = (tidata) -127; *op++ = (uint8) -127;
*op++ = (tidataval_t) b; *op++ = (uint8) b;
n -= 128; n -= 128;
goto again; goto again;
} }
*op++ = (tidataval_t)(-(n-1)); /* encode run */ *op++ = (uint8)(-(n-1)); /* encode run */
*op++ = (tidataval_t) b; *op++ = (uint8) b;
} else { /* extend literal */ } else { /* extend literal */
if (++(*lastliteral) == 127) if (++(*lastliteral) == 127)
state = BASE; state = BASE;
*op++ = (tidataval_t) b; *op++ = (uint8) b;
} }
break; break;
case RUN: /* last object was run */ case RUN: /* last object was run */
if (n > 1) { if (n > 1) {
if (n > 128) { if (n > 128) {
*op++ = (tidata) -127; *op++ = (uint8) -127;
*op++ = (tidataval_t) b; *op++ = (uint8) b;
n -= 128; n -= 128;
goto again; goto again;
} }
*op++ = (tidataval_t)(-(n-1)); *op++ = (uint8)(-(n-1));
*op++ = (tidataval_t) b; *op++ = (uint8) b;
} else { } else {
lastliteral = op; lastliteral = op;
*op++ = 0; *op++ = 0;
*op++ = (tidataval_t) b; *op++ = (uint8) b;
state = LITERAL; state = LITERAL;
} }
break; break;
...@@ -173,7 +168,7 @@ PackBitsEncode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) ...@@ -173,7 +168,7 @@ PackBitsEncode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s)
* case we convert literal-run-literal * case we convert literal-run-literal
* to a single literal. * to a single literal.
*/ */
if (n == 1 && op[-2] == (tidata) -1 && if (n == 1 && op[-2] == (uint8) -1 &&
*lastliteral < 126) { *lastliteral < 126) {
state = (((*lastliteral) += 2) == 127 ? state = (((*lastliteral) += 2) == 127 ?
BASE : LITERAL); BASE : LITERAL);
...@@ -183,7 +178,7 @@ PackBitsEncode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) ...@@ -183,7 +178,7 @@ PackBitsEncode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s)
goto again; goto again;
} }
} }
tif->tif_rawcc += op - tif->tif_rawcp; tif->tif_rawcc += (tmsize_t)(op - tif->tif_rawcp);
tif->tif_rawcp = op; tif->tif_rawcp = op;
return (1); return (1);
} }
...@@ -196,12 +191,12 @@ PackBitsEncode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) ...@@ -196,12 +191,12 @@ PackBitsEncode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s)
* when it was encoded by strips. * when it was encoded by strips.
*/ */
static int static int
PackBitsEncodeChunk(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) PackBitsEncodeChunk(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s)
{ {
tsize_t rowsize = *(tsize_t*)tif->tif_data; tmsize_t rowsize = *(tmsize_t*)tif->tif_data;
while ((long)cc > 0) { while (cc > 0) {
int chunk = rowsize; tmsize_t chunk = rowsize;
if( cc < chunk ) if( cc < chunk )
chunk = cc; chunk = cc;
...@@ -215,17 +210,18 @@ PackBitsEncodeChunk(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) ...@@ -215,17 +210,18 @@ PackBitsEncodeChunk(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s)
} }
static int static int
PackBitsDecode(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) PackBitsDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s)
{ {
static const char module[] = "PackBitsDecode";
char *bp; char *bp;
tsize_t cc; tmsize_t cc;
long n; long n;
int b; int b;
(void) s; (void) s;
bp = (char*) tif->tif_rawcp; bp = (char*) tif->tif_rawcp;
cc = tif->tif_rawcc; cc = tif->tif_rawcc;
while (cc > 0 && (long)occ > 0) { while (cc > 0 && occ > 0) {
n = (long) *bp++, cc--; n = (long) *bp++, cc--;
/* /*
* Watch out for compilers that * Watch out for compilers that
...@@ -236,39 +232,37 @@ PackBitsDecode(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) ...@@ -236,39 +232,37 @@ PackBitsDecode(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s)
if (n < 0) { /* replicate next byte -n+1 times */ if (n < 0) { /* replicate next byte -n+1 times */
if (n == -128) /* nop */ if (n == -128) /* nop */
continue; continue;
n = -n + 1; n = -n + 1;
if( occ < n ) if( occ < (tmsize_t)n )
{ {
TIFFWarningExt(tif->tif_clientdata, tif->tif_name, TIFFWarningExt(tif->tif_clientdata, module,
"PackBitsDecode: discarding %ld bytes " "Discarding %lu bytes to avoid buffer overrun",
"to avoid buffer overrun", (unsigned long) ((tmsize_t)n - occ));
n - occ); n = (long)occ;
n = occ; }
}
occ -= n; occ -= n;
b = *bp++, cc--; b = *bp++, cc--; /* TODO: may be reading past input buffer here when input data is corrupt or ends prematurely */
while (n-- > 0) while (n-- > 0)
*op++ = (tidataval_t) b; *op++ = (uint8) b;
} else { /* copy next n+1 bytes literally */ } else { /* copy next n+1 bytes literally */
if (occ < n + 1) if (occ < (tmsize_t)(n + 1))
{ {
TIFFWarningExt(tif->tif_clientdata, tif->tif_name, TIFFWarningExt(tif->tif_clientdata, module,
"PackBitsDecode: discarding %ld bytes " "Discarding %lu bytes to avoid buffer overrun",
"to avoid buffer overrun", (unsigned long) ((tmsize_t)n - occ + 1));
n - occ + 1); n = (long)occ - 1;
n = occ - 1; }
} _TIFFmemcpy(op, bp, ++n); /* TODO: may be reading past input buffer here when input data is corrupt or ends prematurely */
_TIFFmemcpy(op, bp, ++n);
op += n; occ -= n; op += n; occ -= n;
bp += n; cc -= n; bp += n; cc -= n;
} }
} }
tif->tif_rawcp = (tidata_t) bp; tif->tif_rawcp = (uint8*) bp;
tif->tif_rawcc = cc; tif->tif_rawcc = cc;
if (occ > 0) { if (occ > 0) {
TIFFErrorExt(tif->tif_clientdata, tif->tif_name, TIFFErrorExt(tif->tif_clientdata, module,
"PackBitsDecode: Not enough data for scanline %ld", "Not enough data for scanline %lu",
(long) tif->tif_row); (unsigned long) tif->tif_row);
return (0); return (0);
} }
return (1); return (1);
...@@ -282,7 +276,7 @@ TIFFInitPackBits(TIFF* tif, int scheme) ...@@ -282,7 +276,7 @@ TIFFInitPackBits(TIFF* tif, int scheme)
tif->tif_decodestrip = PackBitsDecode; tif->tif_decodestrip = PackBitsDecode;
tif->tif_decodetile = PackBitsDecode; tif->tif_decodetile = PackBitsDecode;
tif->tif_preencode = PackBitsPreEncode; tif->tif_preencode = PackBitsPreEncode;
tif->tif_postencode = PackBitsPostEncode; tif->tif_postencode = PackBitsPostEncode;
tif->tif_encoderow = PackBitsEncode; tif->tif_encoderow = PackBitsEncode;
tif->tif_encodestrip = PackBitsEncodeChunk; tif->tif_encodestrip = PackBitsEncodeChunk;
tif->tif_encodetile = PackBitsEncodeChunk; tif->tif_encodetile = PackBitsEncodeChunk;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_version.c,v 1.2.2.1 2010-06-08 18:50:43 bfriesen Exp $ */ /* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_version.c,v 1.3 2010-03-10 18:56:49 bfriesen Exp $ */
/* /*
* Copyright (c) 1992-1997 Sam Leffler * Copyright (c) 1992-1997 Sam Leffler
* Copyright (c) 1992-1997 Silicon Graphics, Inc. * Copyright (c) 1992-1997 Silicon Graphics, Inc.
......
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_warning.c,v 1.2.2.1 2010-06-08 18:50:43 bfriesen Exp $ */ /* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_warning.c,v 1.3 2010-03-10 18:56:49 bfriesen Exp $ */
/* /*
* Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1988-1997 Sam Leffler
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/* $Id: tiffio.hxx,v 1.1.2.1 2010-06-08 18:50:43 bfriesen Exp $ */ /* $Id: tiffio.hxx,v 1.3 2010-06-08 18:55:15 bfriesen Exp $ */
/* /*
* Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1988-1997 Sam Leffler
...@@ -34,8 +34,8 @@ ...@@ -34,8 +34,8 @@
#include <iostream> #include <iostream>
#include "tiff.h" #include "tiff.h"
extern TIFF* TIFFStreamOpen(const char*, std::ostream *); extern TIFF* TIFFStreamOpen(const char*, std::ostream *);
extern TIFF* TIFFStreamOpen(const char*, std::istream *); extern TIFF* TIFFStreamOpen(const char*, std::istream *);
#endif /* _TIFFIO_HXX_ */ #endif /* _TIFFIO_HXX_ */
......
This diff is collapsed.
#define TIFFLIB_VERSION_STR "LIBTIFF, Version 3.9.5\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc." #define TIFFLIB_VERSION_STR "LIBTIFF, Version 4.0.1\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc."
/* /*
* This define can be used in code that requires * This define can be used in code that requires
* compilation-related definitions specific to a * compilation-related definitions specific to a
...@@ -6,4 +6,4 @@ ...@@ -6,4 +6,4 @@
* version checking should be done based on the * version checking should be done based on the
* string returned by TIFFGetVersion. * string returned by TIFFGetVersion.
*/ */
#define TIFFLIB_VERSION 20110409 #define TIFFLIB_VERSION 20120218
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment