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
......
/* $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,17 +72,18 @@ _TIFFCheckRealloc(TIFF* tif, tdata_t buffer, ...@@ -46,17 +72,18 @@ _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);
} }
...@@ -65,13 +92,13 @@ static int ...@@ -65,13 +92,13 @@ 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,10 +46,10 @@ ...@@ -45,10 +46,10 @@
void void
TIFFCleanup(TIFF* tif) TIFFCleanup(TIFF* tif)
{ {
if (tif->tif_mode != O_RDONLY)
/* /*
* Flush buffered data and directory (if dirty). * Flush buffered data and directory (if dirty).
*/ */
if (tif->tif_mode != O_RDONLY)
TIFFFlush(tif); TIFFFlush(tif);
(*tif->tif_cleanup)(tif); (*tif->tif_cleanup)(tif);
TIFFFreeDirectory(tif); TIFFFreeDirectory(tif);
...@@ -56,7 +57,9 @@ TIFFCleanup(TIFF* tif) ...@@ -56,7 +57,9 @@ TIFFCleanup(TIFF* 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,25 +72,34 @@ TIFFCleanup(TIFF* tif) ...@@ -69,25 +72,34 @@ 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++) {
{ TIFFField *fld = tif->tif_fields[i];
TIFFFieldInfo *fld = tif->tif_fieldinfo[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_fieldinfo); _TIFFfree(tif->tif_fields);
}
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
...@@ -69,6 +69,9 @@ static int NotConfigured(TIFF*, int); ...@@ -69,6 +69,9 @@ static int NotConfigured(TIFF*, int);
#ifndef LOGLUV_SUPPORT #ifndef LOGLUV_SUPPORT
#define TIFFInitSGILog NotConfigured #define TIFFInitSGILog NotConfigured
#endif #endif
#ifndef LZMA_SUPPORT
#define TIFFInitLZMA NotConfigured
#endif
/* /*
* Compression schemes statically built into the library. * Compression schemes statically built into the library.
...@@ -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 }
}; };
...@@ -116,6 +120,7 @@ NotConfigured(TIFF* tif, int scheme) ...@@ -116,6 +120,7 @@ NotConfigured(TIFF* tif, int scheme)
{ {
(void) scheme; (void) scheme;
tif->tif_fixuptags = _notConfigured;
tif->tif_decodestatus = FALSE; tif->tif_decodestatus = FALSE;
tif->tif_setupdecode = _notConfigured; tif->tif_setupdecode = _notConfigured;
tif->tif_encodestatus = FALSE; tif->tif_encodestatus = FALSE;
......
/* $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
...@@ -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,6 +135,7 @@ static void _TIFFvoid(TIFF* tif) { (void) tif; } ...@@ -128,6 +135,7 @@ 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;
...@@ -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;
...@@ -246,8 +254,9 @@ TIFFGetConfiguredCODECs() ...@@ -246,8 +254,9 @@ 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 *)
...@@ -269,7 +278,7 @@ TIFFGetConfiguredCODECs() ...@@ -269,7 +278,7 @@ TIFFGetConfiguredCODECs()
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++;
} }
} }
......
This diff is collapsed.
This diff is collapsed.
/* $Id: tif_dir.h,v 1.30.2.3 2010-06-09 21:15:27 bfriesen Exp $ */ /* $Id: tif_dir.h,v 1.54 2011-02-18 20:53:05 fwarmerdam Exp $ */
/* /*
* Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1988-1997 Sam Leffler
...@@ -30,6 +30,34 @@ ...@@ -30,6 +30,34 @@
* ``Library-private'' Directory-related Definitions. * ``Library-private'' Directory-related Definitions.
*/ */
typedef struct {
const TIFFField *info;
int count;
void *value;
} TIFFTagValue;
/*
* TIFF Image File Directories are comprised of a table of field
* descriptors of the form shown below. The table is sorted in
* ascending order by tag. The values associated with each entry are
* disjoint and may appear anywhere in the file (so long as they are
* placed on a word boundary).
*
* If the value is 4 bytes or less, in ClassicTIFF, or 8 bytes or less in
* BigTIFF, then it is placed in the offset field to save space. If so,
* it is left-justified in the offset field.
*/
typedef struct {
uint16 tdir_tag; /* see below */
uint16 tdir_type; /* data type; see below */
uint64 tdir_count; /* number of items; length in spec */
union {
uint16 toff_short;
uint32 toff_long;
uint64 toff_long8;
} tdir_offset; /* either offset or the data itself if fits */
} TIFFDirEntry;
/* /*
* Internal format of a TIFF directory entry. * Internal format of a TIFF directory entry.
*/ */
...@@ -51,7 +79,8 @@ typedef struct { ...@@ -51,7 +79,8 @@ typedef struct {
uint16 td_samplesperpixel; uint16 td_samplesperpixel;
uint32 td_rowsperstrip; uint32 td_rowsperstrip;
uint16 td_minsamplevalue, td_maxsamplevalue; uint16 td_minsamplevalue, td_maxsamplevalue;
double td_sminsamplevalue, td_smaxsamplevalue; double* td_sminsamplevalue;
double* td_smaxsamplevalue;
float td_xresolution, td_yresolution; float td_xresolution, td_yresolution;
uint16 td_resolutionunit; uint16 td_resolutionunit;
uint16 td_planarconfig; uint16 td_planarconfig;
...@@ -64,19 +93,23 @@ typedef struct { ...@@ -64,19 +93,23 @@ typedef struct {
/* even though the name is misleading, td_stripsperimage is the number /* even though the name is misleading, td_stripsperimage is the number
* of striles (=strips or tiles) per plane, and td_nstrips the total * of striles (=strips or tiles) per plane, and td_nstrips the total
* number of striles */ * number of striles */
tstrile_t td_stripsperimage; uint32 td_stripsperimage;
tstrile_t td_nstrips; /* size of offset & bytecount arrays */ uint32 td_nstrips; /* size of offset & bytecount arrays */
toff_t* td_stripoffset; uint64* td_stripoffset;
toff_t* td_stripbytecount; /* FIXME: it should be tsize_t array */ uint64* td_stripbytecount;
int td_stripbytecountsorted; /* is the bytecount array sorted ascending? */ int td_stripbytecountsorted; /* is the bytecount array sorted ascending? */
#if defined(DEFER_STRILE_LOAD)
TIFFDirEntry td_stripoffset_entry; /* for deferred loading */
TIFFDirEntry td_stripbytecount_entry; /* for deferred loading */
#endif
uint16 td_nsubifd; uint16 td_nsubifd;
uint32* td_subifd; uint64* td_subifd;
/* YCbCr parameters */ /* YCbCr parameters */
uint16 td_ycbcrsubsampling[2]; uint16 td_ycbcrsubsampling[2];
uint16 td_ycbcrpositioning; uint16 td_ycbcrpositioning;
/* Colorimetry parameters */ /* Colorimetry parameters */
float* td_refblackwhite;
uint16* td_transferfunction[3]; uint16* td_transferfunction[3];
float* td_refblackwhite;
/* CMYK parameters */ /* CMYK parameters */
int td_inknameslen; int td_inknameslen;
char* td_inknames; char* td_inknames;
...@@ -86,18 +119,15 @@ typedef struct { ...@@ -86,18 +119,15 @@ typedef struct {
} TIFFDirectory; } TIFFDirectory;
/* /*
* Field flags used to indicate fields that have * Field flags used to indicate fields that have been set in a directory, and
* been set in a directory, and to reference fields * to reference fields when manipulating a directory.
* when manipulating a directory.
*/ */
/* /*
* FIELD_IGNORE is used to signify tags that are to * FIELD_IGNORE is used to signify tags that are to be processed but otherwise
* be processed but otherwise ignored. This permits * ignored. This permits antiquated tags to be quietly read and discarded.
* antiquated tags to be quietly read and discarded. * Note that a bit *is* allocated for ignored tags; this is understood by the
* Note that a bit *is* allocated for ignored tags; * directory reading logic which uses this fact to avoid special-case handling
* this is understood by the directory reading logic
* which uses this fact to avoid special-case handling
*/ */
#define FIELD_IGNORE 0 #define FIELD_IGNORE 0
...@@ -144,29 +174,17 @@ typedef struct { ...@@ -144,29 +174,17 @@ typedef struct {
/* /*
* Pseudo-tags don't normally need field bits since they * Pseudo-tags don't normally need field bits since they are not written to an
* are not written to an output file (by definition). * output file (by definition). The library also has express logic to always
* The library also has express logic to always query a * query a codec for a pseudo-tag so allocating a field bit for one is a
* codec for a pseudo-tag so allocating a field bit for * waste. If codec wants to promote the notion of a pseudo-tag being ``set''
* one is a waste. If codec wants to promote the notion * or ``unset'' then it can do using internal state flags without polluting
* of a pseudo-tag being ``set'' or ``unset'' then it can * the field bit space defined for real tags.
* do using internal state flags without polluting the
* field bit space defined for real tags.
*/ */
#define FIELD_PSEUDO 0 #define FIELD_PSEUDO 0
#define FIELD_LAST (32*FIELD_SETLONGS-1) #define FIELD_LAST (32*FIELD_SETLONGS-1)
#define TIFFExtractData(tif, type, v) \
((uint32) ((tif)->tif_header.tiff_magic == TIFF_BIGENDIAN ? \
((v) >> (tif)->tif_typeshift[type]) & (tif)->tif_typemask[type] : \
(v) & (tif)->tif_typemask[type]))
#define TIFFInsertData(tif, type, v) \
((uint32) ((tif)->tif_header.tiff_magic == TIFF_BIGENDIAN ? \
((v) & (tif)->tif_typemask[type]) << (tif)->tif_typeshift[type] : \
(v) & (tif)->tif_typemask[type]))
#define BITn(n) (((unsigned long)1L)<<((n)&0x1f)) #define BITn(n) (((unsigned long)1L)<<((n)&0x1f))
#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n)/32]) #define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n)/32])
#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field)) #define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
...@@ -176,25 +194,103 @@ typedef struct { ...@@ -176,25 +194,103 @@ typedef struct {
#define FieldSet(fields, f) (fields[(f)/32] & BITn(f)) #define FieldSet(fields, f) (fields[(f)/32] & BITn(f))
#define ResetFieldBit(fields, f) (fields[(f)/32] &= ~BITn(f)) #define ResetFieldBit(fields, f) (fields[(f)/32] &= ~BITn(f))
typedef enum {
TIFF_SETGET_UNDEFINED = 0,
TIFF_SETGET_ASCII = 1,
TIFF_SETGET_UINT8 = 2,
TIFF_SETGET_SINT8 = 3,
TIFF_SETGET_UINT16 = 4,
TIFF_SETGET_SINT16 = 5,
TIFF_SETGET_UINT32 = 6,
TIFF_SETGET_SINT32 = 7,
TIFF_SETGET_UINT64 = 8,
TIFF_SETGET_SINT64 = 9,
TIFF_SETGET_FLOAT = 10,
TIFF_SETGET_DOUBLE = 11,
TIFF_SETGET_IFD8 = 12,
TIFF_SETGET_INT = 13,
TIFF_SETGET_UINT16_PAIR = 14,
TIFF_SETGET_C0_ASCII = 15,
TIFF_SETGET_C0_UINT8 = 16,
TIFF_SETGET_C0_SINT8 = 17,
TIFF_SETGET_C0_UINT16 = 18,
TIFF_SETGET_C0_SINT16 = 19,
TIFF_SETGET_C0_UINT32 = 20,
TIFF_SETGET_C0_SINT32 = 21,
TIFF_SETGET_C0_UINT64 = 22,
TIFF_SETGET_C0_SINT64 = 23,
TIFF_SETGET_C0_FLOAT = 24,
TIFF_SETGET_C0_DOUBLE = 25,
TIFF_SETGET_C0_IFD8 = 26,
TIFF_SETGET_C16_ASCII = 27,
TIFF_SETGET_C16_UINT8 = 28,
TIFF_SETGET_C16_SINT8 = 29,
TIFF_SETGET_C16_UINT16 = 30,
TIFF_SETGET_C16_SINT16 = 31,
TIFF_SETGET_C16_UINT32 = 32,
TIFF_SETGET_C16_SINT32 = 33,
TIFF_SETGET_C16_UINT64 = 34,
TIFF_SETGET_C16_SINT64 = 35,
TIFF_SETGET_C16_FLOAT = 36,
TIFF_SETGET_C16_DOUBLE = 37,
TIFF_SETGET_C16_IFD8 = 38,
TIFF_SETGET_C32_ASCII = 39,
TIFF_SETGET_C32_UINT8 = 40,
TIFF_SETGET_C32_SINT8 = 41,
TIFF_SETGET_C32_UINT16 = 42,
TIFF_SETGET_C32_SINT16 = 43,
TIFF_SETGET_C32_UINT32 = 44,
TIFF_SETGET_C32_SINT32 = 45,
TIFF_SETGET_C32_UINT64 = 46,
TIFF_SETGET_C32_SINT64 = 47,
TIFF_SETGET_C32_FLOAT = 48,
TIFF_SETGET_C32_DOUBLE = 49,
TIFF_SETGET_C32_IFD8 = 50,
TIFF_SETGET_OTHER = 51
} TIFFSetGetFieldType;
#if defined(__cplusplus) #if defined(__cplusplus)
extern "C" { extern "C" {
#endif #endif
extern const TIFFFieldInfo *_TIFFGetFieldInfo(size_t *);
extern const TIFFFieldInfo *_TIFFGetExifFieldInfo(size_t *); extern const TIFFFieldArray* _TIFFGetFields(void);
extern void _TIFFSetupFieldInfo(TIFF*, const TIFFFieldInfo[], size_t); extern const TIFFFieldArray* _TIFFGetExifFields(void);
extern int _TIFFMergeFieldInfo(TIFF*, const TIFFFieldInfo[], int); extern void _TIFFSetupFields(TIFF* tif, const TIFFFieldArray* infoarray);
extern void _TIFFPrintFieldInfo(TIFF*, FILE*); extern void _TIFFPrintFieldInfo(TIFF*, FILE*);
extern TIFFDataType _TIFFSampleToTagType(TIFF*);
extern const TIFFFieldInfo* _TIFFFindOrRegisterFieldInfo( TIFF *tif, extern int _TIFFFillStriles(TIFF*);
ttag_t tag,
TIFFDataType dt ); typedef enum {
extern TIFFFieldInfo* _TIFFCreateAnonFieldInfo( TIFF *tif, ttag_t tag, tfiatImage,
TIFFDataType dt ); tfiatExif,
tfiatOther
#define _TIFFFindFieldInfo TIFFFindFieldInfo } TIFFFieldArrayType;
#define _TIFFFindFieldInfoByName TIFFFindFieldInfoByName
#define _TIFFFieldWithTag TIFFFieldWithTag struct _TIFFFieldArray {
#define _TIFFFieldWithName TIFFFieldWithName TIFFFieldArrayType type; /* array type, will be used to determine if IFD is image and such */
uint32 allocated_size; /* 0 if array is constant, other if modified by future definition extension support */
uint32 count; /* number of elements in fields array */
TIFFField* fields; /* actual field info */
};
struct _TIFFField {
uint32 field_tag; /* field's tag */
short field_readcount; /* read count/TIFF_VARIABLE/TIFF_SPP */
short field_writecount; /* write count/TIFF_VARIABLE */
TIFFDataType field_type; /* type of associated data */
uint32 reserved; /* reserved for future extension */
TIFFSetGetFieldType set_field_type; /* type to be passed to TIFFSetField */
TIFFSetGetFieldType get_field_type; /* type to be passed to TIFFGetField */
unsigned short field_bit; /* bit in fieldsset bit vector */
unsigned char field_oktochange; /* if true, can change while writing */
unsigned char field_passcount; /* if true, pass dir count on set */
char* field_name; /* ASCII name */
TIFFFieldArray* field_subfields; /* if field points to child ifds, child ifd field definition array */
};
extern int _TIFFMergeFields(TIFF*, const TIFFField[], uint32);
extern const TIFFField* _TIFFFindOrRegisterField(TIFF *, uint32, TIFFDataType);
extern TIFFField* _TIFFCreateAnonField(TIFF *, uint32, TIFFDataType);
#if defined(__cplusplus) #if defined(__cplusplus)
} }
...@@ -202,6 +298,7 @@ extern TIFFFieldInfo* _TIFFCreateAnonFieldInfo( TIFF *tif, ttag_t tag, ...@@ -202,6 +298,7 @@ extern TIFFFieldInfo* _TIFFCreateAnonFieldInfo( TIFF *tif, ttag_t tag,
#endif /* _TIFFDIR_ */ #endif /* _TIFFDIR_ */
/* vim: set ts=8 sts=8 sw=8 noet: */ /* 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.
/* $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,15 +31,22 @@ ...@@ -31,15 +31,22 @@
*/ */
#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)
...@@ -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);
} }
/* /*
...@@ -108,6 +124,7 @@ int ...@@ -108,6 +124,7 @@ 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;
......
/* $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
......
/* $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,14 +32,57 @@ ...@@ -32,14 +32,57 @@
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) &&
!TIFFWriteDirectory(tif)) /* In update (r+) mode we try to detect the case where
return (0); only the strip/tile map has been altered, and we try to
rewrite only that portion of the directory without
making any other changes */
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); 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.
/* $Id: tif_jbig.c,v 1.2.2.3 2010-06-08 18:50:42 bfriesen Exp $ */ /* $Id: tif_jbig.c,v 1.15 2010-03-10 18:56:48 bfriesen Exp $ */
/* /*
* Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1988-1997 Sam Leffler
...@@ -37,44 +37,18 @@ ...@@ -37,44 +37,18 @@
#ifdef JBIG_SUPPORT #ifdef JBIG_SUPPORT
#include "jbig.h" #include "jbig.h"
typedef struct
{
uint32 recvparams; /* encoded Class 2 session params */
char* subaddress; /* subaddress string */
uint32 recvtime; /* time spend receiving in seconds */
char* faxdcs; /* encoded fax parameters (DCS, Table 2/T.30) */
TIFFVGetMethod vgetparent;
TIFFVSetMethod vsetparent;
} JBIGState;
#define GetJBIGState(tif) ((JBIGState*)(tif)->tif_data)
#define FIELD_RECVPARAMS (FIELD_CODEC+0)
#define FIELD_SUBADDRESS (FIELD_CODEC+1)
#define FIELD_RECVTIME (FIELD_CODEC+2)
#define FIELD_FAXDCS (FIELD_CODEC+3)
static const TIFFFieldInfo jbigFieldInfo[] =
{
{TIFFTAG_FAXRECVPARAMS, 1, 1, TIFF_LONG, FIELD_RECVPARAMS, TRUE, FALSE, "FaxRecvParams"},
{TIFFTAG_FAXSUBADDRESS, -1, -1, TIFF_ASCII, FIELD_SUBADDRESS, TRUE, FALSE, "FaxSubAddress"},
{TIFFTAG_FAXRECVTIME, 1, 1, TIFF_LONG, FIELD_RECVTIME, TRUE, FALSE, "FaxRecvTime"},
{TIFFTAG_FAXDCS, -1, -1, TIFF_ASCII, FIELD_FAXDCS, TRUE, FALSE, "FaxDcs"},
};
static int JBIGSetupDecode(TIFF* tif) static int JBIGSetupDecode(TIFF* tif)
{ {
if (TIFFNumberOfStrips(tif) != 1) if (TIFFNumberOfStrips(tif) != 1)
{ {
TIFFError("JBIG", "Multistrip images not supported in decoder"); TIFFErrorExt(tif->tif_clientdata, "JBIG", "Multistrip images not supported in decoder");
return 0; return 0;
} }
return 1; return 1;
} }
static int JBIGDecode(TIFF* tif, tidata_t buffer, tsize_t size, tsample_t s) static int JBIGDecode(TIFF* tif, uint8* buffer, tmsize_t size, uint16 s)
{ {
struct jbg_dec_state decoder; struct jbg_dec_state decoder;
int decodeStatus = 0; int decodeStatus = 0;
...@@ -89,7 +63,7 @@ static int JBIGDecode(TIFF* tif, tidata_t buffer, tsize_t size, tsample_t s) ...@@ -89,7 +63,7 @@ static int JBIGDecode(TIFF* tif, tidata_t buffer, tsize_t size, tsample_t s)
jbg_dec_init(&decoder); jbg_dec_init(&decoder);
#if defined(HAVE_JBG_NEWLEN) #if defined(HAVE_JBG_NEWLEN)
jbg_newlen(tif->tif_rawdata, tif->tif_rawdatasize); jbg_newlen(tif->tif_rawdata, (size_t)tif->tif_rawdatasize);
/* /*
* I do not check the return status of jbg_newlen because even if this * I do not check the return status of jbg_newlen because even if this
* function fails it does not necessarily mean that decoding the image * function fails it does not necessarily mean that decoding the image
...@@ -102,8 +76,8 @@ static int JBIGDecode(TIFF* tif, tidata_t buffer, tsize_t size, tsample_t s) ...@@ -102,8 +76,8 @@ static int JBIGDecode(TIFF* tif, tidata_t buffer, tsize_t size, tsample_t s)
*/ */
#endif /* HAVE_JBG_NEWLEN */ #endif /* HAVE_JBG_NEWLEN */
decodeStatus = jbg_dec_in(&decoder, tif->tif_rawdata, decodeStatus = jbg_dec_in(&decoder, (unsigned char*)tif->tif_rawdata,
tif->tif_rawdatasize, NULL); (size_t)tif->tif_rawdatasize, NULL);
if (JBG_EOK != decodeStatus) if (JBG_EOK != decodeStatus)
{ {
/* /*
...@@ -111,7 +85,9 @@ static int JBIGDecode(TIFF* tif, tidata_t buffer, tsize_t size, tsample_t s) ...@@ -111,7 +85,9 @@ static int JBIGDecode(TIFF* tif, tidata_t buffer, tsize_t size, tsample_t s)
* JBIG-KIT. Since the 2.0 the error reporting functions were * JBIG-KIT. Since the 2.0 the error reporting functions were
* changed. We will handle both cases here. * changed. We will handle both cases here.
*/ */
TIFFError("JBIG", "Error (%d) decoding: %s", decodeStatus, TIFFErrorExt(tif->tif_clientdata,
"JBIG", "Error (%d) decoding: %s",
decodeStatus,
#if defined(JBG_EN) #if defined(JBG_EN)
jbg_strerror(decodeStatus, JBG_EN) jbg_strerror(decodeStatus, JBG_EN)
#else #else
...@@ -131,19 +107,19 @@ static int JBIGSetupEncode(TIFF* tif) ...@@ -131,19 +107,19 @@ static int JBIGSetupEncode(TIFF* tif)
{ {
if (TIFFNumberOfStrips(tif) != 1) if (TIFFNumberOfStrips(tif) != 1)
{ {
TIFFError("JBIG", "Multistrip images not supported in encoder"); TIFFErrorExt(tif->tif_clientdata, "JBIG", "Multistrip images not supported in encoder");
return 0; return 0;
} }
return 1; return 1;
} }
static int JBIGCopyEncodedData(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) static int JBIGCopyEncodedData(TIFF* tif, unsigned char* pp, size_t cc, uint16 s)
{ {
(void) s; (void) s;
while (cc > 0) while (cc > 0)
{ {
tsize_t n = cc; tmsize_t n = (tmsize_t)cc;
if (tif->tif_rawcc + n > tif->tif_rawdatasize) if (tif->tif_rawcc + n > tif->tif_rawdatasize)
{ {
...@@ -155,7 +131,7 @@ static int JBIGCopyEncodedData(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) ...@@ -155,7 +131,7 @@ static int JBIGCopyEncodedData(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s)
tif->tif_rawcp += n; tif->tif_rawcp += n;
tif->tif_rawcc += n; tif->tif_rawcc += n;
pp += n; pp += n;
cc -= n; cc -= (size_t)n;
if (tif->tif_rawcc >= tif->tif_rawdatasize && if (tif->tif_rawcc >= tif->tif_rawdatasize &&
!TIFFFlushData1(tif)) !TIFFFlushData1(tif))
{ {
...@@ -166,19 +142,19 @@ static int JBIGCopyEncodedData(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) ...@@ -166,19 +142,19 @@ static int JBIGCopyEncodedData(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s)
return (1); return (1);
} }
static void JBIGOutputBie(unsigned char* buffer, size_t len, void *userData) static void JBIGOutputBie(unsigned char* buffer, size_t len, void* userData)
{ {
TIFF* tif = (TIFF*)userData; TIFF* tif = (TIFF*)userData;
if (isFillOrder(tif, tif->tif_dir.td_fillorder)) if (isFillOrder(tif, tif->tif_dir.td_fillorder))
{ {
TIFFReverseBits(buffer, len); TIFFReverseBits(buffer, (tmsize_t)len);
} }
JBIGCopyEncodedData(tif, buffer, len, 0); JBIGCopyEncodedData(tif, buffer, len, 0);
} }
static int JBIGEncode(TIFF* tif, tidata_t buffer, tsize_t size, tsample_t s) static int JBIGEncode(TIFF* tif, uint8* buffer, tmsize_t size, uint16 s)
{ {
TIFFDirectory* dir = &tif->tif_dir; TIFFDirectory* dir = &tif->tif_dir;
struct jbg_enc_state encoder; struct jbg_enc_state encoder;
...@@ -202,156 +178,10 @@ static int JBIGEncode(TIFF* tif, tidata_t buffer, tsize_t size, tsample_t s) ...@@ -202,156 +178,10 @@ static int JBIGEncode(TIFF* tif, tidata_t buffer, tsize_t size, tsample_t s)
return 1; return 1;
} }
static void JBIGCleanup(TIFF* tif)
{
JBIGState *sp = GetJBIGState(tif);
assert(sp != 0);
tif->tif_tagmethods.vgetfield = sp->vgetparent;
tif->tif_tagmethods.vsetfield = sp->vsetparent;
_TIFFfree(tif->tif_data);
tif->tif_data = NULL;
_TIFFSetDefaultCompressionState(tif);
}
static void JBIGPrintDir(TIFF* tif, FILE* fd, long flags)
{
JBIGState* codec = GetJBIGState(tif);
(void)flags;
if (TIFFFieldSet(tif, FIELD_RECVPARAMS))
{
fprintf(fd,
" Fax Receive Parameters: %08lx\n",
(unsigned long)codec->recvparams);
}
if (TIFFFieldSet(tif, FIELD_SUBADDRESS))
{
fprintf(fd,
" Fax SubAddress: %s\n",
codec->subaddress);
}
if (TIFFFieldSet(tif, FIELD_RECVTIME))
{
fprintf(fd,
" Fax Receive Time: %lu secs\n",
(unsigned long)codec->recvtime);
}
if (TIFFFieldSet(tif, FIELD_FAXDCS))
{
fprintf(fd,
" Fax DCS: %s\n",
codec->faxdcs);
}
}
static int JBIGVGetField(TIFF* tif, ttag_t tag, va_list ap)
{
JBIGState* codec = GetJBIGState(tif);
switch (tag)
{
case TIFFTAG_FAXRECVPARAMS:
*va_arg(ap, uint32*) = codec->recvparams;
break;
case TIFFTAG_FAXSUBADDRESS:
*va_arg(ap, char**) = codec->subaddress;
break;
case TIFFTAG_FAXRECVTIME:
*va_arg(ap, uint32*) = codec->recvtime;
break;
case TIFFTAG_FAXDCS:
*va_arg(ap, char**) = codec->faxdcs;
break;
default:
return (*codec->vgetparent)(tif, tag, ap);
}
return 1;
}
static int JBIGVSetField(TIFF* tif, ttag_t tag, va_list ap)
{
JBIGState* codec = GetJBIGState(tif);
switch (tag)
{
case TIFFTAG_FAXRECVPARAMS:
codec->recvparams = va_arg(ap, uint32);
break;
case TIFFTAG_FAXSUBADDRESS:
_TIFFsetString(&codec->subaddress, va_arg(ap, char*));
break;
case TIFFTAG_FAXRECVTIME:
codec->recvtime = va_arg(ap, uint32);
break;
case TIFFTAG_FAXDCS:
_TIFFsetString(&codec->faxdcs, va_arg(ap, char*));
break;
default:
return (*codec->vsetparent)(tif, tag, ap);
}
TIFFSetFieldBit(tif, _TIFFFieldWithTag(tif, tag)->field_bit);
tif->tif_flags |= TIFF_DIRTYDIRECT;
return 1;
}
int TIFFInitJBIG(TIFF* tif, int scheme) int TIFFInitJBIG(TIFF* tif, int scheme)
{ {
JBIGState* codec = NULL;
assert(scheme == COMPRESSION_JBIG); assert(scheme == COMPRESSION_JBIG);
/*
* Merge codec-specific tag information.
*/
if (!_TIFFMergeFieldInfo(tif, jbigFieldInfo,
TIFFArrayCount(jbigFieldInfo))) {
TIFFErrorExt(tif->tif_clientdata, "TIFFInitJBIG",
"Merging JBIG codec-specific tags failed");
return 0;
}
/* Allocate memory for the JBIGState structure.*/
tif->tif_data = (tdata_t)_TIFFmalloc(sizeof(JBIGState));
if (tif->tif_data == NULL)
{
TIFFError("TIFFInitJBIG", "Not enough memory for JBIGState");
return 0;
}
_TIFFmemset(tif->tif_data, 0, sizeof(JBIGState));
codec = GetJBIGState(tif);
/* Initialize codec private fields */
codec->recvparams = 0;
codec->subaddress = NULL;
codec->faxdcs = NULL;
codec->recvtime = 0;
/*
* Override parent get/set field methods.
*/
codec->vgetparent = tif->tif_tagmethods.vgetfield;
codec->vsetparent = tif->tif_tagmethods.vsetfield;
tif->tif_tagmethods.vgetfield = JBIGVGetField;
tif->tif_tagmethods.vsetfield = JBIGVSetField;
tif->tif_tagmethods.printdir = JBIGPrintDir;
/* /*
* These flags are set so the JBIG Codec can control when to reverse * These flags are set so the JBIG Codec can control when to reverse
* bits and when not to and to allow the jbig decoder and bit reverser * bits and when not to and to allow the jbig decoder and bit reverser
...@@ -367,8 +197,6 @@ int TIFFInitJBIG(TIFF* tif, int scheme) ...@@ -367,8 +197,6 @@ int TIFFInitJBIG(TIFF* tif, int scheme)
tif->tif_setupencode = JBIGSetupEncode; tif->tif_setupencode = JBIGSetupEncode;
tif->tif_encodestrip = JBIGEncode; tif->tif_encodestrip = JBIGEncode;
tif->tif_cleanup = JBIGCleanup;
return 1; return 1;
} }
......
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);
} }
......
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.
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.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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