new files in libtiff 3.6.1

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30665 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2004-11-20 00:17:39 +00:00
parent 32f2ebbf2f
commit 7da0253866
10 changed files with 4952 additions and 0 deletions

129
src/tiff/Makefile.lcc Normal file
View File

@@ -0,0 +1,129 @@
# $Header$
#
# Tag Image File Format Library
#
# 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 Stanford 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.
#
DESTDIR=.
#
INSTALL=install
NULL=
IPATH= -I. -I../jpeg
CONF_LIBRARY=\
${NULL}
COPTS= -Oloop -cwagshf -d1 -b0 -v -DNDEBUG -rr -j135i
CFLAGS= ${COPTS} ${IPATH} ${CONF_LIBRARY}
#
INCS= tiff.h tiffio.h
SRCS= tif_fax3.c \
tif_fax4.c \
tif_aux.c \
tif_atari.c \
tif_ccittrle.c \
tif_close.c \
tif_compress.c \
tif_dir.c \
tif_dirinfo.c \
tif_dirread.c \
tif_dirwrite.c \
tif_dumpmode.c \
tif_error.c \
tif_getimage.c \
tif_jpeg.c \
tif_flush.c \
tif_lzw.c \
tif_next.c \
tif_open.c \
tif_packbits.c \
tif_print.c \
tif_read.c \
tif_swab.c \
tif_strip.c \
tif_thunder.c \
tif_tile.c \
tif_version.c \
tif_warning.c \
tif_write.c \
${NULL}
OBJS= tif_fax3.o \
tif_fax4.o \
tif_aux.o \
tif_atari.o \
tif_ccittrle.o \
tif_close.o \
tif_compress.o \
tif_dir.o \
tif_dirinfo.o \
tif_dirread.o \
tif_dirwrite.o \
tif_dumpmode.o \
tif_error.o \
tif_getimage.o \
tif_jpeg.o \
tif_flush.o \
tif_lzw.o \
tif_next.o \
tif_open.o \
tif_packbits.o \
tif_print.o \
tif_read.o \
tif_swab.o \
tif_strip.o \
tif_thunder.o \
tif_tile.o \
tif_version.o \
tif_warning.o \
tif_write.o \
${NULL}
ALL= tiffrnb.lib
all: ${ALL}
${ALL}: ${OBJS}
${AR} ${ARFLAGS} $@ r $<
${OBJS}: tiffio.h tiff.h tiffcomp.h tiffiop.h tiffconf.h
tif_fax3.o: tif_fax3.c g3states.h t4.h tif_fax3.h
g3states.h: mkg3states.c t4.h
${CC} -o mkg3states.ttp ${CFLAGS} mkg3states.c
./mkg3states -c > g3states.h
install: all installh
-for i in ${ALL}; do \
${INSTALL} -c -m 644 $$i ${DESTDIR}/lib/$$i; \
done
installh: ${INCS}
-for i in ${INCS}; do \
h=`basename $$i`; \
cmp -s $$i ${DESTDIR}/include/$$h || \
${INSTALL} -c -m 444 $$i ${DESTDIR}/include/$$h; \
done
clean:
rm -f ${ALL} ${OBJS} mkg3states.ttp mkg3states.o g3states.h
tags: ${SRCS}
${CTAGS} ${SRCS}

1046
src/tiff/fax3sm_winnt.c Normal file

File diff suppressed because it is too large Load Diff

102
src/tiff/libtiff.def Normal file
View File

@@ -0,0 +1,102 @@
LIBRARY libtiff
EXPORTS TIFFOpen
TIFFGetVersion
TIFFClose
TIFFFlush
TIFFFlushData
TIFFGetField
TIFFVGetField
TIFFGetFieldDefaulted
TIFFVGetFieldDefaulted
TIFFGetTagListEntry
TIFFGetTagListCount
TIFFReadDirectory
TIFFScanlineSize
TIFFStripSize
TIFFVStripSize
TIFFRawStripSize
TIFFTileRowSize
TIFFTileSize
TIFFVTileSize
TIFFFileno
TIFFGetMode
TIFFIsTiled
TIFFIsByteSwapped
TIFFCIELabToRGBInit
TIFFCIELabToXYZ
TIFFXYZToRGB
TIFFYCbCrToRGBInit
TIFFYCbCrtoRGB
TIFFCurrentRow
TIFFCurrentDirectory
TIFFCurrentStrip
TIFFCurrentTile
TIFFDataWidth
TIFFReadBufferSetup
TIFFLastDirectory
TIFFSetDirectory
TIFFSetSubDirectory
TIFFUnlinkDirectory
TIFFSetField
TIFFVSetField
TIFFCheckpointDirectory
TIFFWriteDirectory
TIFFRewriteDirectory
TIFFPrintDirectory
TIFFReadScanline
TIFFWriteScanline
TIFFReadRGBAImage
TIFFReadRGBAImageOriented
TIFFPrintDirectory
TIFFReadScanline
TIFFWriteScanline
TIFFReadRGBAImage
TIFFFdOpen
TIFFClientOpen
TIFFFileName
TIFFError
TIFFWarning
TIFFSetErrorHandler
TIFFSetWarningHandler
TIFFComputeTile
TIFFCheckTile
TIFFNumberOfTiles
TIFFReadTile
TIFFWriteTile
TIFFComputeStrip
TIFFNumberOfStrips
TIFFRGBAImageBegin
TIFFRGBAImageEnd
TIFFReadEncodedStrip
TIFFReadRawStrip
TIFFReadEncodedTile
TIFFReadRawTile
TIFFReadRGBATile
TIFFReadRGBAStrip
TIFFWriteEncodedStrip
TIFFWriteRawStrip
TIFFWriteEncodedTile
TIFFWriteRawTile
TIFFSetWriteOffset
TIFFSwabDouble
TIFFSwabShort
TIFFSwabLong
TIFFSwabArrayOfShort
TIFFSwabArrayOfLong
TIFFSwabArrayOfDouble
TIFFReverseBits
TIFFGetBitRevTable
TIFFDefaultStripSize
TIFFDefaultTileSize
TIFFRasterScanlineSize
_TIFFmalloc
_TIFFrealloc
_TIFFfree
_TIFFmemset
_TIFFmemcpy
_TIFFmemcmp
TIFFCreateDirectory
TIFFDefaultStripSize

436
src/tiff/mkg3states.c Normal file
View File

@@ -0,0 +1,436 @@
/* "$Header$ */
/*
* Copyright (c) 1991-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.
*/
/* Initialise fax decoder tables
* Decoder support is derived, with permission, from the code
* in Frank Cringle's viewfax program;
* Copyright (C) 1990, 1995 Frank D. Cringle.
*/
#if defined(unix) || defined(__unix)
#include "port.h"
#else
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#endif
#include "tif_fax3.h"
#define streq(a,b) (strcmp(a,b) == 0)
/* NB: can't use names in tif_fax3.h 'cuz they are declared const */
TIFFFaxTabEnt MainTable[128];
TIFFFaxTabEnt WhiteTable[4096];
TIFFFaxTabEnt BlackTable[8192];
struct proto {
uint16 code; /* right justified, lsb-first, zero filled */
uint16 val; /* (pixel count)<<4 + code width */
};
static struct proto Pass[] = {
{ 0x0008, 4 },
{ 0, 0 }
};
static struct proto Horiz[] = {
{ 0x0004, 3 },
{ 0, 0 }
};
static struct proto V0[] = {
{ 0x0001, 1 },
{ 0, 0 }
};
static struct proto VR[] = {
{ 0x0006, (1<<4)+3 },
{ 0x0030, (2<<4)+6 },
{ 0x0060, (3<<4)+7 },
{ 0, 0 }
};
static struct proto VL[] = {
{ 0x0002, (1<<4)+3 },
{ 0x0010, (2<<4)+6 },
{ 0x0020, (3<<4)+7 },
{ 0, 0 }
};
static struct proto Ext[] = {
{ 0x0040, 7 },
{ 0, 0 }
};
static struct proto EOLV[] = {
{ 0x0000, 7 },
{ 0, 0 }
};
static struct proto MakeUpW[] = {
{ 0x001b, 1029 },
{ 0x0009, 2053 },
{ 0x003a, 3078 },
{ 0x0076, 4103 },
{ 0x006c, 5128 },
{ 0x00ec, 6152 },
{ 0x0026, 7176 },
{ 0x00a6, 8200 },
{ 0x0016, 9224 },
{ 0x00e6, 10248 },
{ 0x0066, 11273 },
{ 0x0166, 12297 },
{ 0x0096, 13321 },
{ 0x0196, 14345 },
{ 0x0056, 15369 },
{ 0x0156, 16393 },
{ 0x00d6, 17417 },
{ 0x01d6, 18441 },
{ 0x0036, 19465 },
{ 0x0136, 20489 },
{ 0x00b6, 21513 },
{ 0x01b6, 22537 },
{ 0x0032, 23561 },
{ 0x0132, 24585 },
{ 0x00b2, 25609 },
{ 0x0006, 26630 },
{ 0x01b2, 27657 },
{ 0, 0 }
};
static struct proto MakeUpB[] = {
{ 0x03c0, 1034 },
{ 0x0130, 2060 },
{ 0x0930, 3084 },
{ 0x0da0, 4108 },
{ 0x0cc0, 5132 },
{ 0x02c0, 6156 },
{ 0x0ac0, 7180 },
{ 0x06c0, 8205 },
{ 0x16c0, 9229 },
{ 0x0a40, 10253 },
{ 0x1a40, 11277 },
{ 0x0640, 12301 },
{ 0x1640, 13325 },
{ 0x09c0, 14349 },
{ 0x19c0, 15373 },
{ 0x05c0, 16397 },
{ 0x15c0, 17421 },
{ 0x0dc0, 18445 },
{ 0x1dc0, 19469 },
{ 0x0940, 20493 },
{ 0x1940, 21517 },
{ 0x0540, 22541 },
{ 0x1540, 23565 },
{ 0x0b40, 24589 },
{ 0x1b40, 25613 },
{ 0x04c0, 26637 },
{ 0x14c0, 27661 },
{ 0, 0 }
};
static struct proto MakeUp[] = {
{ 0x0080, 28683 },
{ 0x0180, 29707 },
{ 0x0580, 30731 },
{ 0x0480, 31756 },
{ 0x0c80, 32780 },
{ 0x0280, 33804 },
{ 0x0a80, 34828 },
{ 0x0680, 35852 },
{ 0x0e80, 36876 },
{ 0x0380, 37900 },
{ 0x0b80, 38924 },
{ 0x0780, 39948 },
{ 0x0f80, 40972 },
{ 0, 0 }
};
static struct proto TermW[] = {
{ 0x00ac, 8 },
{ 0x0038, 22 },
{ 0x000e, 36 },
{ 0x0001, 52 },
{ 0x000d, 68 },
{ 0x0003, 84 },
{ 0x0007, 100 },
{ 0x000f, 116 },
{ 0x0019, 133 },
{ 0x0005, 149 },
{ 0x001c, 165 },
{ 0x0002, 181 },
{ 0x0004, 198 },
{ 0x0030, 214 },
{ 0x000b, 230 },
{ 0x002b, 246 },
{ 0x0015, 262 },
{ 0x0035, 278 },
{ 0x0072, 295 },
{ 0x0018, 311 },
{ 0x0008, 327 },
{ 0x0074, 343 },
{ 0x0060, 359 },
{ 0x0010, 375 },
{ 0x000a, 391 },
{ 0x006a, 407 },
{ 0x0064, 423 },
{ 0x0012, 439 },
{ 0x000c, 455 },
{ 0x0040, 472 },
{ 0x00c0, 488 },
{ 0x0058, 504 },
{ 0x00d8, 520 },
{ 0x0048, 536 },
{ 0x00c8, 552 },
{ 0x0028, 568 },
{ 0x00a8, 584 },
{ 0x0068, 600 },
{ 0x00e8, 616 },
{ 0x0014, 632 },
{ 0x0094, 648 },
{ 0x0054, 664 },
{ 0x00d4, 680 },
{ 0x0034, 696 },
{ 0x00b4, 712 },
{ 0x0020, 728 },
{ 0x00a0, 744 },
{ 0x0050, 760 },
{ 0x00d0, 776 },
{ 0x004a, 792 },
{ 0x00ca, 808 },
{ 0x002a, 824 },
{ 0x00aa, 840 },
{ 0x0024, 856 },
{ 0x00a4, 872 },
{ 0x001a, 888 },
{ 0x009a, 904 },
{ 0x005a, 920 },
{ 0x00da, 936 },
{ 0x0052, 952 },
{ 0x00d2, 968 },
{ 0x004c, 984 },
{ 0x00cc, 1000 },
{ 0x002c, 1016 },
{ 0, 0 }
};
static struct proto TermB[] = {
{ 0x03b0, 10 },
{ 0x0002, 19 },
{ 0x0003, 34 },
{ 0x0001, 50 },
{ 0x0006, 67 },
{ 0x000c, 84 },
{ 0x0004, 100 },
{ 0x0018, 117 },
{ 0x0028, 134 },
{ 0x0008, 150 },
{ 0x0010, 167 },
{ 0x0050, 183 },
{ 0x0070, 199 },
{ 0x0020, 216 },
{ 0x00e0, 232 },
{ 0x0030, 249 },
{ 0x03a0, 266 },
{ 0x0060, 282 },
{ 0x0040, 298 },
{ 0x0730, 315 },
{ 0x00b0, 331 },
{ 0x01b0, 347 },
{ 0x0760, 363 },
{ 0x00a0, 379 },
{ 0x0740, 395 },
{ 0x00c0, 411 },
{ 0x0530, 428 },
{ 0x0d30, 444 },
{ 0x0330, 460 },
{ 0x0b30, 476 },
{ 0x0160, 492 },
{ 0x0960, 508 },
{ 0x0560, 524 },
{ 0x0d60, 540 },
{ 0x04b0, 556 },
{ 0x0cb0, 572 },
{ 0x02b0, 588 },
{ 0x0ab0, 604 },
{ 0x06b0, 620 },
{ 0x0eb0, 636 },
{ 0x0360, 652 },
{ 0x0b60, 668 },
{ 0x05b0, 684 },
{ 0x0db0, 700 },
{ 0x02a0, 716 },
{ 0x0aa0, 732 },
{ 0x06a0, 748 },
{ 0x0ea0, 764 },
{ 0x0260, 780 },
{ 0x0a60, 796 },
{ 0x04a0, 812 },
{ 0x0ca0, 828 },
{ 0x0240, 844 },
{ 0x0ec0, 860 },
{ 0x01c0, 876 },
{ 0x0e40, 892 },
{ 0x0140, 908 },
{ 0x01a0, 924 },
{ 0x09a0, 940 },
{ 0x0d40, 956 },
{ 0x0340, 972 },
{ 0x05a0, 988 },
{ 0x0660, 1004 },
{ 0x0e60, 1020 },
{ 0, 0 }
};
static struct proto EOLH[] = {
{ 0x0000, 11 },
{ 0, 0 }
};
static void
FillTable(TIFFFaxTabEnt *T, int Size, struct proto *P, int State)
{
int limit = 1 << Size;
while (P->val) {
int width = P->val & 15;
int param = P->val >> 4;
int incr = 1 << width;
int code;
for (code = P->code; code < limit; code += incr) {
TIFFFaxTabEnt *E = T+code;
E->State = State;
E->Width = width;
E->Param = param;
}
P++;
}
}
static char* storage_class = "";
static char* const_class = "";
static int packoutput = 1;
static char* prebrace = "";
static char* postbrace = "";
void
WriteTable(FILE* fd, const TIFFFaxTabEnt* T, int Size, const char* name)
{
int i;
char* sep;
fprintf(fd, "%s %s TIFFFaxTabEnt %s[%d] = {",
storage_class, const_class, name, Size);
if (packoutput) {
sep = "\n";
for (i = 0; i < Size; i++) {
fprintf(fd, "%s%s%d,%d,%d%s",
sep, prebrace, T->State, T->Width, (int) T->Param, postbrace);
if (((i+1) % 12) == 0)
sep = ",\n";
else
sep = ",";
T++;
}
} else {
sep = "\n ";
for (i = 0; i < Size; i++) {
fprintf(fd, "%s%s%3d,%3d,%4d%s",
sep, prebrace, T->State, T->Width, (int) T->Param, postbrace);
if (((i+1) % 6) == 0)
sep = ",\n ";
else
sep = ",";
T++;
}
}
fprintf(fd, "\n};\n");
}
/* initialise the huffman code tables */
int
main(int argc, char* argv[])
{
FILE* fd;
char* outputfile;
int c;
extern int optind;
extern char* optarg;
while ((c = getopt(argc, argv, "c:s:bp")) != -1)
switch (c) {
case 'c':
const_class = optarg;
break;
case 's':
storage_class = optarg;
break;
case 'p':
packoutput = 0;
break;
case 'b':
prebrace = "{";
postbrace = "}";
break;
case '?':
fprintf(stderr,
"usage: %s [-c const] [-s storage] [-p] [-b] file\n",
argv[0]);
return (-1);
}
outputfile = optind < argc ? argv[optind] : "g3states.h";
fd = fopen(outputfile, "w");
if (fd == NULL) {
fprintf(stderr, "%s: %s: Cannot create output file.\n",
argv[0], outputfile);
return (-2);
}
FillTable(MainTable, 7, Pass, S_Pass);
FillTable(MainTable, 7, Horiz, S_Horiz);
FillTable(MainTable, 7, V0, S_V0);
FillTable(MainTable, 7, VR, S_VR);
FillTable(MainTable, 7, VL, S_VL);
FillTable(MainTable, 7, Ext, S_Ext);
FillTable(MainTable, 7, EOLV, S_EOL);
FillTable(WhiteTable, 12, MakeUpW, S_MakeUpW);
FillTable(WhiteTable, 12, MakeUp, S_MakeUp);
FillTable(WhiteTable, 12, TermW, S_TermW);
FillTable(WhiteTable, 12, EOLH, S_EOL);
FillTable(BlackTable, 13, MakeUpB, S_MakeUpB);
FillTable(BlackTable, 13, MakeUp, S_MakeUp);
FillTable(BlackTable, 13, TermB, S_TermB);
FillTable(BlackTable, 13, EOLH, S_EOL);
fprintf(fd, "/* WARNING, this file was automatically generated by the\n");
fprintf(fd, " mkg3states program */\n");
fprintf(fd, "#include \"tiff.h\"\n");
fprintf(fd, "#include \"tif_fax3.h\"\n");
WriteTable(fd, MainTable, 128, "TIFFFaxMainTable");
WriteTable(fd, WhiteTable, 4096, "TIFFFaxWhiteTable");
WriteTable(fd, BlackTable, 8192, "TIFFFaxBlackTable");
fclose(fd);
return (0);
}

72
src/tiff/mkspans.c Normal file
View File

@@ -0,0 +1,72 @@
/* $Header$ */
/*
* Copyright (c) 1991-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.
*/
#include "tiffcomp.h"
/*
* Hack program to construct tables used to find
* runs of zeros and ones in Group 3 Fax encoding.
*/
dumparray(name, runs)
char *name;
unsigned char runs[256];
{
register int i;
register char *sep;
printf("static u_char %s[256] = {\n", name);
sep = " ";
for (i = 0; i < 256; i++) {
printf("%s%d", sep, runs[i]);
if (((i + 1) % 16) == 0) {
printf(", /* 0x%02x - 0x%02x */\n", i-15, i);
sep = " ";
} else
sep = ", ";
}
printf("\n};\n");
}
main()
{
unsigned char runs[2][256];
memset(runs[0], 0, 256*sizeof (char));
memset(runs[1], 0, 256*sizeof (char));
{ register int run, runlen, i;
runlen = 1;
for (run = 0x80; run != 0xff; run = (run>>1)|0x80) {
for (i = run-1; i >= 0; i--) {
runs[1][run|i] = runlen;
runs[0][(~(run|i)) & 0xff] = runlen;
}
runlen++;
}
runs[1][0xff] = runs[0][0] = 8;
}
dumparray("bruns", runs[0]);
dumparray("wruns", runs[1]);
}

148
src/tiff/mkversion.c Normal file
View File

@@ -0,0 +1,148 @@
/* "$Header$ */
/*
* Copyright (c) 1995-1997 Sam Leffler
* Copyright (c) 1995-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.
*/
/*
* Generate a library version string for systems that
* do not have a shell (by default this is done with
* awk and echo from the Makefile).
*
* This was written by Peter Greenham for Acorn systems.
*
* Syntax: mkversion [-v version-file] [<outfile>]
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static void
usage(void)
{
fprintf(stderr,
"usage: mkversion [-v version-file]\n"
" [-r releasedate-file] [outfile]\n");
exit(-1);
}
static FILE*
openFile(char* filename)
{
FILE* fd = fopen(filename, "r");
if (fd == NULL) {
fprintf(stderr, "mkversion: %s: Could not open for reading.\n",
filename);
exit(-1);
}
return (fd);
}
int
main(int argc, char* argv[])
{
char* versionFile = "../VERSION";
char* releaseDateFile = "../RELEASE-DATE";
char version[128];
char rawReleaseDate[128];
char tiffLibVersion[128];
FILE* fd;
char* cp;
argc--, argv++;
while (argc > 0 && argv[0][0] == '-') {
if (strcmp(argv[0], "-v") == 0) {
if (argc < 1)
usage();
argc--, argv++;
versionFile = argv[0];
} else if (strcmp(argv[0], "-r") == 0) {
if (argc < 1)
usage();
argc--, argv++;
releaseDateFile = argv[0];
} else
usage();
argc--, argv++;
}
/*
* Read the VERSION file.
*/
fd = openFile(versionFile);
if (fgets(version, sizeof (version)-1, fd) == NULL) {
fprintf(stderr, "mkversion: No version information in %s.\n",
versionFile);
exit(-1);
}
cp = strchr(version, '\n');
if (cp)
*cp = '\0';
fclose(fd);
/*
* Read the RELEASE-DATE, and translate format to emit TIFFLIB_VERSION.
*/
fd = openFile(releaseDateFile);
if (fgets(rawReleaseDate, sizeof (rawReleaseDate)-1, fd) == NULL) {
fprintf(stderr, "mkversion: No release date information in %s.\n",
releaseDateFile);
exit(-1);
}
fclose(fd);
sprintf( tiffLibVersion, "#define TIFFLIB_VERSION %4.4s%2.2s%2.2s",
rawReleaseDate+6,
rawReleaseDate+0,
rawReleaseDate+3 );
/*
* Emit the tiffvers.h file.
*/
if (argc > 0) {
fd = fopen(argv[0], "w");
if (fd == NULL) {
fprintf(stderr, "mkversion: %s: Could not open for writing.\n",
argv[0]);
exit(-1);
}
} else
fd = stdout;
fprintf(fd, "#define TIFFLIB_VERSION_STR \"LIBTIFF, Version %s\\n", version);
fprintf(fd, "Copyright (c) 1988-1996 Sam Leffler\\n");
fprintf(fd, "Copyright (c) 1991-1996 Silicon Graphics, Inc.\"\n");
fprintf( fd,
"/*\n"
" * This define can be used in code that requires\n"
" * compilation-related definitions specific to a\n"
" * version or versions of the library. Runtime\n"
" * version checking should be done based on the\n"
" * string returned by TIFFGetVersion.\n"
" */\n" );
fprintf(fd, "%s\n", tiffLibVersion );
if (fd != stdout)
fclose(fd);
return (0);
}

268
src/tiff/tif_color.c Normal file
View File

@@ -0,0 +1,268 @@
/* $Header$ */
/*
* 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.
*/
/*
* CIE L*a*b* to CIE XYZ and CIE XYZ to RGB conversion routines are taken
* from the VIPS library (http://www.vips.ecs.soton.ac.uk) with
* the permission of John Cupitt, the VIPS author.
*/
/*
* TIFF Library.
*
* Color space conversion routines.
*/
#include "tiffiop.h"
#include <math.h>
/*
* Convert color value from the CIE L*a*b* 1976 space to CIE XYZ.
*/
void
TIFFCIELabToXYZ(TIFFCIELabToRGB *cielab, uint32 l, int32 a, int32 b,
float *X, float *Y, float *Z)
{
float L = (float)l * 100.0F / 255.0F;
float cby, tmp;
if( L < 8.856F ) {
*Y = (L * cielab->Y0) / 903.292F;
cby = 7.787F * (*Y / cielab->Y0) + 16.0F / 116.0F;
} else {
cby = (L + 16.0F) / 116.0F;
*Y = cielab->Y0 * cby * cby * cby;
}
tmp = (float)a / 500.0F + cby;
if( tmp < 0.2069F )
*X = cielab->X0 * (tmp - 0.13793F) / 7.787F;
else
*X = cielab->X0 * tmp * tmp * tmp;
tmp = cby - (float)b / 200.0F;
if( tmp < 0.2069F )
*Z = cielab->Z0 * (tmp - 0.13793F) / 7.787F;
else
*Z = cielab->Z0 * tmp * tmp * tmp;
}
#define RINT(R) ((uint32)((R)>0?((R)+0.5):((R)-0.5)))
/*
* Convert color value from the XYZ space to RGB.
*/
void
TIFFXYZToRGB(TIFFCIELabToRGB *cielab, float X, float Y, float Z,
uint32 *r, uint32 *g, uint32 *b)
{
int i;
float Yr, Yg, Yb;
float *matrix = &cielab->display.d_mat[0][0];
/* Multiply through the matrix to get luminosity values. */
Yr = matrix[0] * X + matrix[1] * Y + matrix[2] * Z;
Yg = matrix[3] * X + matrix[4] * Y + matrix[5] * Z;
Yb = matrix[6] * X + matrix[7] * Y + matrix[8] * Z;
/* Clip input */
Yr = TIFFmax( Yr, cielab->display.d_Y0R );
Yg = TIFFmax( Yg, cielab->display.d_Y0G );
Yb = TIFFmax( Yb, cielab->display.d_Y0B );
/* Turn luminosity to colour value. */
i = TIFFmin(cielab->range,
(int)((Yr - cielab->display.d_Y0R) / cielab->rstep));
*r = RINT(cielab->Yr2r[i]);
i = TIFFmin(cielab->range,
(int)((Yg - cielab->display.d_Y0G) / cielab->gstep));
*g = RINT(cielab->Yg2g[i]);
i = TIFFmin(cielab->range,
(int)((Yb - cielab->display.d_Y0B) / cielab->bstep));
*b = RINT(cielab->Yb2b[i]);
/* Clip output. */
*r = TIFFmin( *r, cielab->display.d_Vrwr );
*g = TIFFmin( *g, cielab->display.d_Vrwg );
*b = TIFFmin( *b, cielab->display.d_Vrwb );
}
#undef RINT
/*
* Allocate conversion state structures and make look_up tables for
* the Yr,Yb,Yg <=> r,g,b conversions.
*/
int
TIFFCIELabToRGBInit(TIFFCIELabToRGB* cielab,
TIFFDisplay *display, float *refWhite)
{
int i;
float gamma;
cielab->range = CIELABTORGB_TABLE_RANGE;
_TIFFmemcpy(&cielab->display, display, sizeof(TIFFDisplay));
/* Red */
gamma = 1.0F / cielab->display.d_gammaR ;
cielab->rstep =
(cielab->display.d_YCR - cielab->display.d_Y0R) / cielab->range;
for(i = 0; i <= cielab->range; i++) {
cielab->Yr2r[i] = cielab->display.d_Vrwr
* ((float)pow((double)i / cielab->range, gamma));
}
/* Green */
gamma = 1.0F / cielab->display.d_gammaG ;
cielab->gstep =
(cielab->display.d_YCR - cielab->display.d_Y0R) / cielab->range;
for(i = 0; i <= cielab->range; i++) {
cielab->Yg2g[i] = cielab->display.d_Vrwg
* ((float)pow((double)i / cielab->range, gamma));
}
/* Blue */
gamma = 1.0F / cielab->display.d_gammaB ;
cielab->bstep =
(cielab->display.d_YCR - cielab->display.d_Y0R) / cielab->range;
for(i = 0; i <= cielab->range; i++) {
cielab->Yb2b[i] = cielab->display.d_Vrwb
* ((float)pow((double)i / cielab->range, gamma));
}
/* Init reference white point */
cielab->X0 = refWhite[0];
cielab->Y0 = refWhite[1];
cielab->Z0 = refWhite[2];
return 0;
}
/*
* Convert color value from the YCbCr space to CIE XYZ.
* The colorspace conversion algorithm comes from the IJG v5a code;
* see below for more information on how it works.
*/
#define SHIFT 16
#define FIX(x) ((int32)((x) * (1L<<SHIFT) + 0.5))
#define ONE_HALF ((int32)(1<<(SHIFT-1)))
#define Code2V(c, RB, RW, CR) ((((c)-(int32)(RB))*(float)(CR))/(float)((RW)-(RB)))
#define CLAMP(f,min,max) ((f)<(min)?(min):(f)>(max)?(max):(f))
void
TIFFYCbCrtoRGB(TIFFYCbCrToRGB *ycbcr, uint32 Y, int32 Cb, int32 Cr,
uint32 *r, uint32 *g, uint32 *b)
{
/* XXX: Only 8-bit YCbCr input supported for now */
Y = CLAMP(Y, 0, 255), Cb = CLAMP(Cb, 0, 255), Cr = CLAMP(Cr, 0, 255);
*r = ycbcr->clamptab[ycbcr->Y_tab[Y] + ycbcr->Cr_r_tab[Cr]];
*g = ycbcr->clamptab[ycbcr->Y_tab[Y]
+ (int)((ycbcr->Cb_g_tab[Cb] + ycbcr->Cr_g_tab[Cr]) >> SHIFT)];
*b = ycbcr->clamptab[ycbcr->Y_tab[Y] + ycbcr->Cb_b_tab[Cb]];
}
/*
* Initialize the YCbCr->RGB conversion tables. The conversion
* is done according to the 6.0 spec:
*
* R = Y + Cr*(2 - 2*LumaRed)
* B = Y + Cb*(2 - 2*LumaBlue)
* G = Y
* - LumaBlue*Cb*(2-2*LumaBlue)/LumaGreen
* - LumaRed*Cr*(2-2*LumaRed)/LumaGreen
*
* To avoid floating point arithmetic the fractional constants that
* come out of the equations are represented as fixed point values
* in the range 0...2^16. We also eliminate multiplications by
* pre-calculating possible values indexed by Cb and Cr (this code
* assumes conversion is being done for 8-bit samples).
*/
int
TIFFYCbCrToRGBInit(TIFFYCbCrToRGB* ycbcr, float *luma, float *refBlackWhite)
{
TIFFRGBValue* clamptab;
int i;
#define LumaRed luma[0]
#define LumaGreen luma[1]
#define LumaBlue luma[2]
clamptab = (TIFFRGBValue*)(
(tidata_t) ycbcr+TIFFroundup(sizeof (TIFFYCbCrToRGB), sizeof (long)));
_TIFFmemset(clamptab, 0, 256); /* v < 0 => 0 */
ycbcr->clamptab = (clamptab += 256);
for (i = 0; i < 256; i++)
clamptab[i] = (TIFFRGBValue) i;
_TIFFmemset(clamptab+256, 255, 2*256); /* v > 255 => 255 */
ycbcr->Cr_r_tab = (int*) (clamptab + 3*256);
ycbcr->Cb_b_tab = ycbcr->Cr_r_tab + 256;
ycbcr->Cr_g_tab = (int32*) (ycbcr->Cb_b_tab + 256);
ycbcr->Cb_g_tab = ycbcr->Cr_g_tab + 256;
ycbcr->Y_tab = ycbcr->Cb_g_tab + 256;
{ float f1 = 2-2*LumaRed; int32 D1 = FIX(f1);
float f2 = LumaRed*f1/LumaGreen; int32 D2 = -FIX(f2);
float f3 = 2-2*LumaBlue; int32 D3 = FIX(f3);
float f4 = LumaBlue*f3/LumaGreen; int32 D4 = -FIX(f4);
int x;
#undef LumaBlue
#undef LumaGreen
#undef LumaRed
/*
* i is the actual input pixel value in the range 0..255
* Cb and Cr values are in the range -128..127 (actually
* they are in a range defined by the ReferenceBlackWhite
* tag) so there is some range shifting to do here when
* constructing tables indexed by the raw pixel data.
*/
for (i = 0, x = -128; i < 256; i++, x++) {
int32 Cr = (int32)Code2V(x, refBlackWhite[4] - 128.0F,
refBlackWhite[5] - 128.0F, 127);
int32 Cb = (int32)Code2V(x, refBlackWhite[2] - 128.0F,
refBlackWhite[3] - 128.0F, 127);
ycbcr->Cr_r_tab[i] = (int32)((D1*Cr + ONE_HALF)>>SHIFT);
ycbcr->Cb_b_tab[i] = (int32)((D3*Cb + ONE_HALF)>>SHIFT);
ycbcr->Cr_g_tab[i] = D2*Cr;
ycbcr->Cb_g_tab[i] = D4*Cb + ONE_HALF;
ycbcr->Y_tab[i] =
(int32)Code2V(x + 128, refBlackWhite[0], refBlackWhite[1], 255);
}
}
return 0;
}
#undef CLAMP
#undef Code2V
#undef SHIFT
#undef ONE_HALF
#undef FIX

112
src/tiff/tif_extension.c Normal file
View File

@@ -0,0 +1,112 @@
/* $Header$ */
/*
* 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.
*
* Various routines support external extension of the tag set, and other
* application extension capabilities.
*/
#include "tiffiop.h"
#include <assert.h>
int TIFFGetTagListCount( TIFF *tif )
{
TIFFDirectory* td = &tif->tif_dir;
return td->td_customValueCount;
}
ttag_t TIFFGetTagListEntry( TIFF *tif, int tag_index )
{
TIFFDirectory* td = &tif->tif_dir;
if( tag_index < 0 || tag_index >= td->td_customValueCount )
return (ttag_t) -1;
else
return td->td_customValues[tag_index].info->field_tag;
}
/*
** This provides read/write access to the TIFFTagMethods within the TIFF
** structure to application code without giving access to the private
** TIFF structure.
*/
TIFFTagMethods *TIFFAccessTagMethods( TIFF *tif )
{
return &(tif->tif_tagmethods);
}
void *TIFFGetClientInfo( TIFF *tif, const char *name )
{
TIFFClientInfoLink *link = tif->tif_clientinfo;
while( link != NULL && strcmp(link->name,name) != 0 )
link = link->next;
if( link != NULL )
return link->data;
else
return NULL;
}
void TIFFSetClientInfo( TIFF *tif, void *data, const char *name )
{
TIFFClientInfoLink *link = tif->tif_clientinfo;
/*
** Do we have an existing link with this name? If so, just
** set it.
*/
while( link != NULL && strcmp(link->name,name) != 0 )
link = link->next;
if( link != NULL )
{
link->data = data;
return;
}
/*
** Create a new link.
*/
link = (TIFFClientInfoLink *) _TIFFmalloc(sizeof(TIFFClientInfoLink));
assert (link != NULL);
link->next = tif->tif_clientinfo;
link->name = (char *) _TIFFmalloc(strlen(name)+1);
assert (link->name != NULL);
strcpy(link->name, name);
link->data = data;
tif->tif_clientinfo = link;
}

2630
src/tiff/tif_ojpeg.c Normal file

File diff suppressed because it is too large Load Diff

9
src/tiff/tiffvers.h Normal file
View File

@@ -0,0 +1,9 @@
#define TIFFLIB_VERSION_STR "LIBTIFF, Version 3.6.1\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc."
/*
* This define can be used in code that requires
* compilation-related definitions specific to a
* version or versions of the library. Runtime
* version checking should be done based on the
* string returned by TIFFGetVersion.
*/
#define TIFFLIB_VERSION 20031226