summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'contrib')
-rw-r--r--contrib/CVS/Entries13
-rw-r--r--contrib/CVS/Repository1
-rw-r--r--contrib/CVS/Root1
-rw-r--r--contrib/acorn/CVS/Entries7
-rw-r--r--contrib/acorn/CVS/Repository1
-rw-r--r--contrib/acorn/CVS/Root1
-rw-r--r--contrib/addtiffo/Makefile27
-rwxr-xr-xcontrib/addtiffo/Makefile.vc27
-rw-r--r--contrib/addtiffo/README145
-rw-r--r--contrib/addtiffo/addtiffo.c115
-rw-r--r--contrib/addtiffo/rawblockedimage.cpp403
-rw-r--r--contrib/addtiffo/rawblockedimage.h108
-rw-r--r--contrib/addtiffo/tif_overview.cpp559
-rw-r--r--contrib/dbs/CVS/Entries7
-rw-r--r--contrib/dbs/CVS/Repository1
-rw-r--r--contrib/dbs/CVS/Root1
-rw-r--r--contrib/dbs/xtiff/CVS/Entries6
-rw-r--r--contrib/dbs/xtiff/CVS/Repository1
-rw-r--r--contrib/dbs/xtiff/CVS/Root1
-rw-r--r--contrib/dosdjgpp/CVS/Entries7
-rw-r--r--contrib/dosdjgpp/CVS/Repository1
-rw-r--r--contrib/dosdjgpp/CVS/Root1
-rw-r--r--contrib/dosdjgpp/Makefile.lib2
-rw-r--r--contrib/dosdjgpp/Makefile.tools2
-rw-r--r--contrib/dosdjgpp/Makefile.top2
-rw-r--r--contrib/iptcutil/CVS/Entries5
-rw-r--r--contrib/iptcutil/CVS/Repository1
-rw-r--r--contrib/iptcutil/CVS/Root1
-rw-r--r--contrib/iptcutil/Makefile12
-rw-r--r--contrib/iptcutil/iptcutil.c920
-rw-r--r--contrib/iptcutil/test.iptcbin1107 -> 0 bytes
-rw-r--r--contrib/iptcutil/test.txt32
-rw-r--r--contrib/mac-cw/CVS/Entries8
-rw-r--r--contrib/mac-cw/CVS/Repository1
-rw-r--r--contrib/mac-cw/CVS/Root1
-rw-r--r--contrib/mac-mpw/CVS/Entries8
-rw-r--r--contrib/mac-mpw/CVS/Repository1
-rw-r--r--contrib/mac-mpw/CVS/Root1
-rw-r--r--contrib/mfs/CVS/Entries3
-rw-r--r--contrib/mfs/CVS/Repository1
-rw-r--r--contrib/mfs/CVS/Root1
-rw-r--r--contrib/pds/CVS/Entries6
-rw-r--r--contrib/pds/CVS/Repository1
-rw-r--r--contrib/pds/CVS/Root1
-rw-r--r--contrib/pds/tif_imageiter.c2
-rw-r--r--contrib/pds/tif_pdsdirread.c2
-rw-r--r--contrib/pds/tif_pdsdirwrite.c2
-rw-r--r--contrib/ras/CVS/Entries4
-rw-r--r--contrib/ras/CVS/Repository1
-rw-r--r--contrib/ras/CVS/Root1
-rw-r--r--contrib/tags/Makefile.gcc56
-rw-r--r--contrib/tags/Makefile.mpw67
-rw-r--r--contrib/tags/README116
-rw-r--r--contrib/tags/listtif.c32
-rw-r--r--contrib/tags/maketif.c70
-rw-r--r--contrib/tags/xtif_dir.c343
-rw-r--r--contrib/tags/xtiffio.h52
-rw-r--r--contrib/tags/xtiffiop.h65
-rw-r--r--contrib/vms/CVS/Entries2
-rw-r--r--contrib/vms/CVS/Repository1
-rw-r--r--contrib/vms/CVS/Root1
-rw-r--r--contrib/vms/libtiff/CVS/Entries6
-rw-r--r--contrib/vms/libtiff/CVS/Repository1
-rw-r--r--contrib/vms/libtiff/CVS/Root1
-rw-r--r--contrib/vms/tools/CVS/Entries2
-rw-r--r--contrib/vms/tools/CVS/Repository1
-rw-r--r--contrib/vms/tools/CVS/Root1
-rw-r--r--contrib/win32/CVS/Entries4
-rw-r--r--contrib/win32/CVS/Repository1
-rw-r--r--contrib/win32/CVS/Root1
-rw-r--r--contrib/win95/CVS/Entries4
-rw-r--r--contrib/win95/CVS/Repository1
-rw-r--r--contrib/win95/CVS/Root1
-rw-r--r--contrib/winnt/CVS/Entries8
-rw-r--r--contrib/winnt/CVS/Repository1
-rw-r--r--contrib/winnt/CVS/Root1
76 files changed, 2191 insertions, 1104 deletions
diff --git a/contrib/CVS/Entries b/contrib/CVS/Entries
deleted file mode 100644
index ab0ad631..00000000
--- a/contrib/CVS/Entries
+++ /dev/null
@@ -1,13 +0,0 @@
-D/acorn////
-D/dbs////
-D/dosdjgpp////
-D/iptcutil////
-D/mac-cw////
-D/mac-mpw////
-D/mfs////
-D/pds////
-D/ras////
-D/vms////
-D/win32////
-D/win95////
-D/winnt////
diff --git a/contrib/CVS/Repository b/contrib/CVS/Repository
deleted file mode 100644
index ae63d111..00000000
--- a/contrib/CVS/Repository
+++ /dev/null
@@ -1 +0,0 @@
-/usr/local/cvs/internal/libtiff/contrib
diff --git a/contrib/CVS/Root b/contrib/CVS/Root
deleted file mode 100644
index 8dff0f68..00000000
--- a/contrib/CVS/Root
+++ /dev/null
@@ -1 +0,0 @@
-/usr/local/cvs
diff --git a/contrib/acorn/CVS/Entries b/contrib/acorn/CVS/Entries
deleted file mode 100644
index 442bb996..00000000
--- a/contrib/acorn/CVS/Entries
+++ /dev/null
@@ -1,7 +0,0 @@
-/Makefile/1.1.1.1/Tue Jul 27 21:50:26 1999//
-/ReadMe/1.1.1.1/Tue Jul 27 21:50:26 1999//
-/SetVars/1.1.1.1/Tue Jul 27 21:50:26 1999//
-/cleanlib/1.1.1.1/Tue Jul 27 21:50:26 1999//
-/convert/1.1.1.1/Tue Jul 27 21:50:26 1999//
-/install/1.1.1.1/Tue Jul 27 21:50:26 1999//
-D
diff --git a/contrib/acorn/CVS/Repository b/contrib/acorn/CVS/Repository
deleted file mode 100644
index f1a274a6..00000000
--- a/contrib/acorn/CVS/Repository
+++ /dev/null
@@ -1 +0,0 @@
-/usr/local/cvs/internal/libtiff/contrib/acorn
diff --git a/contrib/acorn/CVS/Root b/contrib/acorn/CVS/Root
deleted file mode 100644
index 8dff0f68..00000000
--- a/contrib/acorn/CVS/Root
+++ /dev/null
@@ -1 +0,0 @@
-/usr/local/cvs
diff --git a/contrib/addtiffo/Makefile b/contrib/addtiffo/Makefile
new file mode 100644
index 00000000..81759b42
--- /dev/null
+++ b/contrib/addtiffo/Makefile
@@ -0,0 +1,27 @@
+#
+# If libtiff.a is installed in /usr/lib or /usr/local/lib just point
+# LIBTIFF_DIR there. It doesn't need a full libtiff tree.
+#
+LIBTIFF_DIR = ../../libtiff
+#
+CC = gcc
+CXX = gcc
+CFLAGS = -O -I$(LIBTIFF_DIR)
+LIBS = $(LIBTIFF_DIR)/libtiff.a -lm
+
+addtiffo: addtiffo.o tif_overview.o rawblockedimage.o
+ $(CXX) $(CFLAGS) addtiffo.o tif_overview.o rawblockedimage.o \
+ $(LIBS) -o addtiffo
+
+
+addtiffo.o: addtiffo.c
+ $(CC) -c $(CFLAGS) addtiffo.c
+
+tif_overview.o: tif_overview.cpp
+ $(CXX) -c $(CFLAGS) tif_overview.cpp
+
+rawblockedimage.o: rawblockedimage.cpp
+ $(CXX) -c $(CFLAGS) rawblockedimage.cpp
+
+clean:
+ rm *.o addtiffo
diff --git a/contrib/addtiffo/Makefile.vc b/contrib/addtiffo/Makefile.vc
new file mode 100755
index 00000000..32b489b3
--- /dev/null
+++ b/contrib/addtiffo/Makefile.vc
@@ -0,0 +1,27 @@
+#
+# If libtiff.a is installed in /usr/lib or /usr/local/lib just point
+# LIBTIFF_DIR there. It doesn't need a full libtiff tree.
+#
+LIBTIFF_DIR = ..\..\libtiff
+#
+CC = cl.exe
+CPPC = cl.exe
+CFLAGS = -O -I$(LIBTIFF_DIR)
+LIBS = $(LIBTIFF_DIR)\tiff.lib
+
+addtiffo: addtiffo.obj tif_overview.obj rawblockedimage.obj
+ $(CC) $(CFLAGS) addtiffo.obj tif_overview.obj rawblockedimage.obj \
+ $(LIBS) /Feaddtiffo.exe
+
+
+addtiffo.obj: addtiffo.c
+ $(CC) -c $(CFLAGS) addtiffo.c
+
+tif_overview.obj: tif_overview.cpp
+ $(CPPC) -c $(CFLAGS) tif_overview.cpp
+
+rawblockedimage.obj: rawblockedimage.cpp
+ $(CPPC) -c $(CFLAGS) rawblockedimage.cpp
+
+clean:
+ del *.obj addtiffo.exe
diff --git a/contrib/addtiffo/README b/contrib/addtiffo/README
new file mode 100644
index 00000000..01346573
--- /dev/null
+++ b/contrib/addtiffo/README
@@ -0,0 +1,145 @@
+ addtiffo 1.0
+ ============
+
+The addtiffo utility is used to add overview pyramids to an existing
+TIFF or GeoTIFF file. Some applications can take advantage of these
+overviews to accelerate overview display performance of large rasters.
+
+This release of addtiffo is primarily intended for compatibility testing
+with applications, and to see if there is interest in a cleaner release
+of the capability ... perhaps incorporation into the libtiff tools
+distribution.
+
+Please feel free to contact me with questions, or problems.
+
+warmerda@home.com
+http://members.home.com/warmerda
+
+
+Usage
+-----
+
+Usage: addtiffo [-subifd] tiff_filename [resolution_reductions]
+
+Example:
+ % addtiffo abc.tif 2 4 8 16
+
+The numeric arguments are the list of reduction factors to
+generate. In this example a 1/2, 1/4 1/8 and 1/16
+
+
+
+Limitations
+-----------
+
+See tif_overview.cpp for up to date details.
+
+ o RawBlockedImage will create temporary files in the current directory
+ to cache the overviews so it doesn't have to hold them all in memory.
+ If the application crashes these will not be deleted (*.rbi).
+
+ o Currently only images with bits_per_sample of a multiple of eight
+ will work.
+
+ o The downsampler currently just takes the top left pixel from the
+ source rectangle. Eventually sampling options of averaging, mode, and
+ ``center pixel'' should be offered.
+
+ o The code will attempt to use the same kind of compression,
+ photometric interpretation, and organization as the source image, but
+ it doesn't copy geotiff tags to the reduced resolution images.
+
+ o Reduced resolution overviews for multi-sample files will currently
+ always be generated as PLANARCONFIG_SEPARATE. This could be fixed
+ reasonable easily if needed to improve compatibility with other
+ packages. Many don't properly support PLANARCONFIG_SEPARATE.
+
+ o Overviews are always written as appended IFDs, rather than using the
+ ``tree of tree's'' approach using the SUBIFD tag. I wanted to implement
+ both, but it isn't currently easy to add a SUBIFD tag to an existing
+ main tiff IFD with libtiff. I hope to try this again later.
+
+
+TIFF File Tags
+--------------
+
+The results of running addtiffo on a 1024x1024 tiled greyscale file
+with the arguments ``2 4 8 16'' is to add four additional TIFF directories
+appended on the file with the SUBFILETYPE flag to 0x1 indicating the extra
+items are reduced resolution images.
+
+The tiffinfo output of such a file might look like this:
+
+TIFF Directory at offset 0x118008
+ Image Width: 1024 Image Length: 1024
+ Tile Width: 256 Tile Length: 112
+ Bits/Sample: 8
+ Compression Scheme: none
+ Photometric Interpretation: min-is-black
+ Samples/Pixel: 1
+ Planar Configuration: single image plane
+TIFF Directory at offset 0x15e1d2
+ Subfile Type: reduced-resolution image (1 = 0x1)
+ Image Width: 512 Image Length: 512
+ Tile Width: 256 Tile Length: 112
+ Bits/Sample: 8
+ Compression Scheme: none
+ Photometric Interpretation: min-is-black
+ Samples/Pixel: 1
+ Planar Configuration: separate image planes
+TIFF Directory at offset 0x1732b8
+ Subfile Type: reduced-resolution image (1 = 0x1)
+ Image Width: 256 Image Length: 256
+ Tile Width: 256 Tile Length: 112
+ Bits/Sample: 8
+ Compression Scheme: none
+ Photometric Interpretation: min-is-black
+ Samples/Pixel: 1
+ Planar Configuration: separate image planes
+TIFF Directory at offset 0x17a366
+ Subfile Type: reduced-resolution image (1 = 0x1)
+ Image Width: 128 Image Length: 128
+ Tile Width: 128 Tile Length: 112
+ Bits/Sample: 8
+ Compression Scheme: none
+ Photometric Interpretation: min-is-black
+ Samples/Pixel: 1
+ Planar Configuration: separate image planes
+TIFF Directory at offset 0x17b40c
+ Subfile Type: reduced-resolution image (1 = 0x1)
+ Image Width: 64 Image Length: 64
+ Tile Width: 64 Tile Length: 64
+ Bits/Sample: 8
+ Compression Scheme: none
+ Photometric Interpretation: min-is-black
+ Samples/Pixel: 1
+ Planar Configuration: separate image planes
+
+
+Building
+--------
+
+You will need a C, and C++ compiler. You will need to have libtiff already
+built and installed. The provided Makefile should work on most Unix systems.
+A similar file will be needed for Windows, but is not provided.
+
+The CFLAGS and LIBS macros in the Makefile will have to be updated to
+point to the correct location of the libtiff include files, and library.
+
+
+Credits
+-------
+
+ o Intergraph Corporation for partially funding the work.
+
+ o Global Geomatics for partially funding reorganization of the overview
+ building ability as a separate utility.
+
+ o Orrin Long, and Ed Grissom of Intergraph for explaining what needed to
+ be done.
+
+ o Max Martinez of Erdas for his discussion of external overviews.
+
+ o Frank Warmerdam for writing the bulk of the code.
+
+ o Sam Leffler since this only exists because of his libtiff.
diff --git a/contrib/addtiffo/addtiffo.c b/contrib/addtiffo/addtiffo.c
new file mode 100644
index 00000000..67d70d5c
--- /dev/null
+++ b/contrib/addtiffo/addtiffo.c
@@ -0,0 +1,115 @@
+/******************************************************************************
+ * $Id: addtiffo.c,v 1.1 1999/08/17 01:47:59 warmerda Exp $
+ *
+ * Project: GeoTIFF Overview Builder
+ * Purpose: Mainline for building overviews in a TIFF file.
+ * Author: Frank Warmerdam, warmerda@home.com
+ *
+ ******************************************************************************
+ * Copyright (c) 1999, Frank Warmerdam
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ ******************************************************************************
+ *
+ * $Log: addtiffo.c,v $
+ * Revision 1.1 1999/08/17 01:47:59 warmerda
+ * New
+ *
+ * Revision 1.1 1999/03/12 17:46:32 warmerda
+ * New
+ *
+ * Revision 1.2 1999/02/11 22:27:12 warmerda
+ * Added multi-sample support
+ *
+ * Revision 1.1 1999/02/11 18:12:30 warmerda
+ * New
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "tiffio.h"
+
+void TIFFBuildOverviews( const char *, int, int *, int );
+
+/************************************************************************/
+/* main() */
+/************************************************************************/
+
+int main( int argc, char ** argv )
+
+{
+ int anOverviews[100];
+ int nOverviewCount = 0;
+ int bUseSubIFD = 0;
+
+/* -------------------------------------------------------------------- */
+/* Usage: */
+/* -------------------------------------------------------------------- */
+ if( argc < 2 )
+ {
+ printf( "Usage: addtiffo tiff_filename [resolution_reductions]\n" );
+ printf( "\n" );
+ printf( "Example:\n" );
+ printf( " %% addtifo abc.tif 2 4 8 16\n" );
+ exit( 1 );
+ }
+
+ if( strcmp(argv[1],"-subifd") == 0 )
+ {
+ bUseSubIFD = 1;
+ argv++;
+ }
+
+/* -------------------------------------------------------------------- */
+/* Collect the user requested reduction factors. */
+/* -------------------------------------------------------------------- */
+ while( nOverviewCount < argc - 2 && nOverviewCount < 100 )
+ {
+ anOverviews[nOverviewCount] = atoi(argv[nOverviewCount+2]);
+ nOverviewCount++;
+ }
+
+/* -------------------------------------------------------------------- */
+/* Default to four overview levels. It would be nicer if it */
+/* defaulted based on the size of the source image. */
+/* -------------------------------------------------------------------- */
+ if( nOverviewCount == 0 )
+ {
+ nOverviewCount = 4;
+
+ anOverviews[0] = 2;
+ anOverviews[1] = 4;
+ anOverviews[2] = 8;
+ anOverviews[3] = 16;
+ }
+
+/* -------------------------------------------------------------------- */
+/* Build the overview. */
+/* -------------------------------------------------------------------- */
+ TIFFBuildOverviews( argv[1], nOverviewCount, anOverviews, bUseSubIFD );
+
+/* -------------------------------------------------------------------- */
+/* Optionally test for memory leaks. */
+/* -------------------------------------------------------------------- */
+#ifdef DBMALLOC
+ malloc_dump(1);
+#endif
+
+ exit( 0 );
+}
diff --git a/contrib/addtiffo/rawblockedimage.cpp b/contrib/addtiffo/rawblockedimage.cpp
new file mode 100644
index 00000000..8a37afd5
--- /dev/null
+++ b/contrib/addtiffo/rawblockedimage.cpp
@@ -0,0 +1,403 @@
+/******************************************************************************
+ * $Id: rawblockedimage.cpp,v 1.1 1999/08/17 01:47:59 warmerda Exp $
+ *
+ * Project: GeoTIFF Overview Builder
+ * Purpose: Implement the RawBlockedImage class, for holding ``under
+ * construction'' overviews in a temporary file.
+ * Author: Frank Warmerdam, warmerda@home.com
+ *
+ ******************************************************************************
+ * Copyright (c) 1999, Frank Warmerdam
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ ******************************************************************************
+ *
+ * $Log: rawblockedimage.cpp,v $
+ * Revision 1.1 1999/08/17 01:47:59 warmerda
+ * New
+ *
+ * Revision 1.2 1999/03/12 17:29:34 warmerda
+ * Use _WIN32 rather than WIN32.
+ *
+ */
+
+#include <assert.h>
+#include <string.h>
+
+#include <stdlib.h>
+
+#ifndef _WIN32
+# include <unistd.h>
+#endif
+
+#include "rawblockedimage.h"
+
+#ifndef FALSE
+# define FALSE 0
+# define TRUE 1
+#endif
+
+#ifndef MAX
+# define MIN(a,b) ((a<b) ? a : b)
+# define MAX(a,b) ((a>b) ? a : b)
+#endif
+
+/************************************************************************/
+/* RawBlockedImage() */
+/************************************************************************/
+
+RawBlockedImage::RawBlockedImage( int nXSizeIn, int nYSizeIn,
+ int nBlockXSizeIn, int nBlockYSizeIn,
+ int nBitsPerPixelIn )
+
+{
+ static int nTempCounter = 0;
+ char szFilename[128];
+
+/* -------------------------------------------------------------------- */
+/* Initialize stuff. */
+/* -------------------------------------------------------------------- */
+ nXSize = nXSizeIn;
+ nYSize = nYSizeIn;
+ nBlockXSize = nBlockXSizeIn;
+ nBlockYSize = nBlockYSizeIn;
+ nBitsPerPixel = nBitsPerPixelIn;
+
+/* -------------------------------------------------------------------- */
+/* Create the raw temporary file, trying to verify first that */
+/* it doesn't already exist. */
+/* -------------------------------------------------------------------- */
+ fp = NULL;
+ while( fp == NULL )
+ {
+ sprintf( szFilename, "temp_%d.rbi", nTempCounter++ );
+ fp = fopen( szFilename, "r" );
+ if( fp != NULL )
+ fclose( fp );
+ else
+ fp = fopen( szFilename, "w+b" );
+ }
+
+ pszFilename = strdup( szFilename );
+ nCurFileSize = 0;
+
+/* -------------------------------------------------------------------- */
+/* Initialize other stuff. */
+/* -------------------------------------------------------------------- */
+ nBlocksPerRow = (nXSize + nBlockXSize - 1) / nBlockXSize;
+ nBlocksPerColumn = (nYSize + nBlockYSize - 1) / nBlockYSize;
+ nBytesPerBlock = (nBlockXSize*nBlockYSize*nBitsPerPixel + 7) / 8;
+
+ nBlocks = nBlocksPerRow * nBlocksPerColumn;
+ nBlocksInCache = 0;
+ nMaxBlocksInCache = MIN(nBlocks, 2*nBlocksPerRow);
+
+ papoBlocks = (RawBlock **) calloc(sizeof(RawBlock*),nBlocks);
+
+ poLRUHead = NULL;
+ poLRUTail = NULL;
+}
+
+/************************************************************************/
+/* ~RawBlockedImage() */
+/************************************************************************/
+
+RawBlockedImage::~RawBlockedImage()
+
+{
+ int i;
+
+ for( i = 0; i < nBlocks; i++ )
+ {
+ if( papoBlocks[i] != NULL )
+ {
+ if( papoBlocks[i]->pabyData != NULL )
+ free( papoBlocks[i]->pabyData );
+
+ delete papoBlocks[i];
+ }
+ }
+
+ if( papoBlocks != NULL)
+ free( papoBlocks );
+
+ fclose( fp );
+
+ unlink( pszFilename ); /* wrap this? */
+
+ free( pszFilename );
+}
+
+/************************************************************************/
+/* InsertInLRUList() */
+/* */
+/* Insert this link at the beginning of the LRU list. First */
+/* removed from it's current position if it is in the list. */
+/************************************************************************/
+
+void RawBlockedImage::InsertInLRUList( RawBlock * poBlock )
+
+{
+/* -------------------------------------------------------------------- */
+/* Remove from list, if it is currently in it. */
+/* -------------------------------------------------------------------- */
+ if( poBlock->poPrevLRU != NULL || poLRUHead == poBlock )
+ RemoveFromLRUList( poBlock );
+
+/* -------------------------------------------------------------------- */
+/* Add at the head. */
+/* -------------------------------------------------------------------- */
+ if( poLRUHead != NULL )
+ {
+ poLRUHead->poPrevLRU = poBlock;
+ }
+
+ poBlock->poNextLRU = poLRUHead;
+ poLRUHead = poBlock;
+
+ if( poLRUTail == NULL )
+ poLRUTail = poBlock;
+}
+
+/************************************************************************/
+/* RemoveFromLRUList() */
+/* */
+/* Remove this block from the LRU list, if present. */
+/************************************************************************/
+
+void RawBlockedImage::RemoveFromLRUList( RawBlock * poBlock )
+
+{
+/* -------------------------------------------------------------------- */
+/* Is it even in the list? */
+/* -------------------------------------------------------------------- */
+ if( poBlock->poPrevLRU == NULL && poLRUHead != poBlock )
+ return;
+
+/* -------------------------------------------------------------------- */
+/* Fix the link before this in the list (or head pointer). */
+/* -------------------------------------------------------------------- */
+ if( poBlock->poPrevLRU == NULL )
+ {
+ poLRUHead = poBlock->poNextLRU;
+ }
+ else
+ {
+ poBlock->poPrevLRU->poNextLRU = poBlock->poNextLRU;
+ }
+
+/* -------------------------------------------------------------------- */
+/* Fix the link after this one, or the tail pointer. */
+/* -------------------------------------------------------------------- */
+ if( poBlock->poNextLRU == NULL )
+ {
+ poLRUTail = poBlock->poPrevLRU;
+ }
+ else
+ {
+ poBlock->poNextLRU->poPrevLRU = poBlock->poPrevLRU;
+ }
+
+/* -------------------------------------------------------------------- */
+/* Update this link to indicate it isn't in the list now. */
+/* -------------------------------------------------------------------- */
+ poBlock->poPrevLRU = poBlock->poNextLRU = NULL;
+}
+
+
+/************************************************************************/
+/* FlushBlock() */
+/************************************************************************/
+
+void RawBlockedImage::FlushBlock( RawBlock * poBlock )
+
+{
+/* -------------------------------------------------------------------- */
+/* If we aren't given a particular block to flush, then select */
+/* the lest recently used one from the LRU list. */
+/* -------------------------------------------------------------------- */
+ if( poBlock == NULL )
+ {
+ if( poLRUTail == NULL )
+ return;
+
+ poBlock = poLRUTail;
+ }
+
+/* -------------------------------------------------------------------- */
+/* Remove from the LRU list. */
+/* -------------------------------------------------------------------- */
+ RemoveFromLRUList( poBlock );
+
+/* -------------------------------------------------------------------- */
+/* If the block has no data, then it doesn't really need to be */
+/* flushed. */
+/* -------------------------------------------------------------------- */
+ if( poBlock->pabyData == NULL )
+ return;
+
+/* -------------------------------------------------------------------- */
+/* Is this block dirty? If so we will have to try and save it. */
+/* -------------------------------------------------------------------- */
+ if( poBlock->nDirty )
+ {
+ if( poBlock->nPositionInFile == -1 )
+ poBlock->nPositionInFile = nCurFileSize;
+
+ nCurFileSize += nBytesPerBlock;
+ if( fseek( fp, poBlock->nPositionInFile, SEEK_SET ) != 0 )
+ {
+ fprintf( stderr,
+ "Seek to %d in overview spill file %s failed.\n",
+ poBlock->nPositionInFile, pszFilename );
+ exit( 1 );
+ }
+
+ if( fwrite( poBlock->pabyData, 1, nBytesPerBlock, fp )
+ != (size_t) nBytesPerBlock )
+ {
+ fprintf( stderr,
+ "Write of %d bytes at %d in overview spill file %s.\n"
+ "Is the disk full?\n",
+ nBytesPerBlock, poBlock->nPositionInFile, pszFilename );
+ exit( 1 );
+ }
+
+ poBlock->nDirty = FALSE;
+ }
+
+/* -------------------------------------------------------------------- */
+/* Free the data block, and decrement used count. */
+/* -------------------------------------------------------------------- */
+ nBlocksInCache--;
+ if( poBlock->pabyData != NULL )
+ free( poBlock->pabyData );
+ poBlock->pabyData = NULL;
+}
+
+
+/************************************************************************/
+/* GetRawBlock() */
+/************************************************************************/
+
+RawBlock *RawBlockedImage::GetRawBlock( int nXOff, int nYOff )
+
+{
+ int nBlock = nXOff + nYOff * nBlocksPerRow;
+ RawBlock *poBlock;
+
+ assert( nBlock >= 0 && nBlock < nBlocks );
+
+/* -------------------------------------------------------------------- */
+/* Is this the first request? If so, create the block object, */
+/* initialize the data memory, and return it. */
+/* -------------------------------------------------------------------- */
+ poBlock = papoBlocks[nBlock];
+ if( poBlock == NULL )
+ {
+ poBlock = papoBlocks[nBlock] = new RawBlock;
+ poBlock->nDirty = FALSE;
+ poBlock->poPrevLRU = poBlock->poNextLRU = NULL;
+ poBlock->nPositionInFile = -1;
+ poBlock->pabyData = (unsigned char *) calloc(1,nBytesPerBlock);
+ nBlocksInCache++;
+
+ if( poBlock->pabyData == NULL )
+ {
+ fprintf( stderr,
+ "RawBlockedImage::GetRawBlock() - out of memory\n" );
+ exit( 1 );
+ }
+ }
+
+/* -------------------------------------------------------------------- */
+/* Does this block need to be read off disk? */
+/* -------------------------------------------------------------------- */
+ else if( poBlock->nPositionInFile >= 0 && poBlock->pabyData == NULL )
+ {
+ nBlocksInCache++;
+ poBlock->pabyData = (unsigned char *) calloc(1,nBytesPerBlock);
+ fseek( fp, poBlock->nPositionInFile, SEEK_SET );
+ fread( poBlock->pabyData, nBytesPerBlock, 1, fp );
+ }
+
+/* -------------------------------------------------------------------- */
+/* Does the data need to be allocated? */
+/* -------------------------------------------------------------------- */
+ else if( poBlock->pabyData == NULL )
+ {
+ poBlock->pabyData = (unsigned char *) calloc(1,nBytesPerBlock);
+ if( poBlock->pabyData == NULL )
+ {
+ fprintf( stderr,
+ "RawBlockedImage::GetRawBlock() - out of memory\n" );
+ exit( 1 );
+ }
+ }
+
+/* -------------------------------------------------------------------- */
+/* Push on the LRU stack, or pop it back to the top. */
+/* -------------------------------------------------------------------- */
+ InsertInLRUList( poBlock );
+
+/* -------------------------------------------------------------------- */
+/* If we have exceeded our self imposed caching limit, flush */
+/* one block. */
+/* -------------------------------------------------------------------- */
+ if( nBlocksInCache > nMaxBlocksInCache )
+ FlushBlock( NULL );
+
+ return( poBlock );
+}
+
+/************************************************************************/
+/* GetTile() */
+/************************************************************************/
+
+unsigned char *RawBlockedImage::GetTile( int nXOff, int nYOff )
+
+{
+ RawBlock *poBlock;
+
+ poBlock = GetRawBlock(nXOff,nYOff);
+ if( poBlock != NULL )
+ return poBlock->pabyData;
+ else
+ return NULL;
+}
+
+/************************************************************************/
+/* GetTileForUpdate() */
+/************************************************************************/
+
+unsigned char *RawBlockedImage::GetTileForUpdate( int nXOff, int nYOff )
+
+{
+ RawBlock *poBlock;
+
+ poBlock = GetRawBlock(nXOff,nYOff);
+ if( poBlock != NULL )
+ {
+ poBlock->nDirty = TRUE;
+
+ return poBlock->pabyData;
+ }
+ else
+ return NULL;
+}
diff --git a/contrib/addtiffo/rawblockedimage.h b/contrib/addtiffo/rawblockedimage.h
new file mode 100644
index 00000000..35aa56a6
--- /dev/null
+++ b/contrib/addtiffo/rawblockedimage.h
@@ -0,0 +1,108 @@
+/******************************************************************************
+ * $Id: rawblockedimage.h,v 1.1 1999/08/17 01:47:59 warmerda Exp $
+ *
+ * Project: GeoTIFF Overview Builder
+ * Purpose: Implement the RawBlockedImage class, for holding ``under
+ * construction'' overviews in a temporary file.
+ * Author: Frank Warmerdam, warmerda@home.com
+ *
+ ******************************************************************************
+ * Copyright (c) 1999, Frank Warmerdam
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ ******************************************************************************
+ *
+ * $Log:
+ */
+
+#ifndef RAWBLOCKEDIMAGE_H_INCLUDED
+#define RAWBLOCKEDIMAGE_H_INCLUDED
+
+#include <stdio.h>
+
+/************************************************************************/
+/* ==================================================================== */
+/* RawBlockedImage */
+/* */
+/* The RawBlockedImage class is used to maintain a single band */
+/* raster tiled image on disk. */
+/* ==================================================================== */
+/************************************************************************/
+
+class RawBlock
+{
+public:
+ RawBlock *poNextLRU;
+ RawBlock *poPrevLRU;
+
+ int nDirty;
+ int nPositionInFile;
+
+ unsigned char *pabyData;
+};
+
+class RawBlockedImage
+{
+ int nXSize;
+ int nYSize;
+
+ int nBlockXSize;
+ int nBlockYSize;
+ int nBitsPerPixel;
+ int nBytesPerBlock;
+
+ int nBlocksPerRow;
+ int nBlocksPerColumn;
+
+ int nBlocks;
+ RawBlock **papoBlocks;
+
+ int nBlocksInCache;
+ int nMaxBlocksInCache;
+
+ FILE *fp;
+ int nCurFileSize;
+ char *pszFilename;
+
+ RawBlock *GetRawBlock( int, int );
+ void FlushBlock( RawBlock * );
+ void InsertInLRUList( RawBlock * );
+ void RemoveFromLRUList( RawBlock * );
+
+ RawBlock *poLRUHead;
+ RawBlock *poLRUTail;
+
+public:
+ RawBlockedImage( int nXSize, int nYSize,
+ int nBlockXSize, int nBlockYSize,
+ int nBitsPerPixel );
+
+ ~RawBlockedImage();
+
+ unsigned char*GetTile( int, int );
+ unsigned char*GetTileForUpdate( int, int );
+
+ int GetBlockXSize() { return nBlockXSize; }
+ int GetBlockYSize() { return nBlockYSize; }
+ int GetXSize() { return nXSize; }
+ int GetYSize() { return nYSize; }
+ int GetBitsPerPixel() { return nBitsPerPixel; }
+};
+
+#endif /* ndef RAWBLOCKEDIMAGE_H_INCLUDED */
diff --git a/contrib/addtiffo/tif_overview.cpp b/contrib/addtiffo/tif_overview.cpp
new file mode 100644
index 00000000..45322c93
--- /dev/null
+++ b/contrib/addtiffo/tif_overview.cpp
@@ -0,0 +1,559 @@
+/******************************************************************************
+ * $Id: tif_overview.cpp,v 1.1 1999/08/17 01:47:59 warmerda Exp $
+ *
+ * Project: TIFF Overview Builder
+ * Purpose: Library function for building overviews in a TIFF file.
+ * Author: Frank Warmerdam, warmerda@home.com
+ *
+ * Notes:
+ * o This module uses the RawBlockedImage class to hold the overviews as
+ * they are being built since we can't easily be reading from one directory
+ * in a TIFF file, and writing to a bunch of others.
+ *
+ * o RawBlockedImage will create temporary files in the current directory
+ * to cache the overviews so it doesn't have to hold them all in memory.
+ * If the application crashes these will not be deleted (*.rbi).
+ *
+ * o Currently only images with bits_per_sample of a multiple of eight
+ * will work.
+ *
+ * o The downsampler currently just takes the top left pixel from the
+ * source rectangle. Eventually sampling options of averaging, mode, and
+ * ``center pixel'' should be offered.
+ *
+ * o The code will attempt to use the same kind of compression,
+ * photometric interpretation, and organization as the source image, but
+ * it doesn't copy geotiff tags to the reduced resolution images.
+ *
+ * o Reduced resolution overviews for multi-sample files will currently
+ * always be generated as PLANARCONFIG_SEPARATE. This could be fixed
+ * reasonable easily if needed to improve compatibility with other
+ * packages. Many don't properly support PLANARCONFIG_SEPARATE.
+ *
+ ******************************************************************************
+ * Copyright (c) 1999, Frank Warmerdam
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ ******************************************************************************
+ *
+ * $Log: tif_overview.cpp,v $
+ * Revision 1.1 1999/08/17 01:47:59 warmerda
+ * New
+ *
+ * Revision 1.7 1999/03/12 17:47:26 warmerda
+ * made independent of CPL
+ *
+ * Revision 1.6 1999/02/24 16:24:00 warmerda
+ * Don't include cpl_string.h
+ *
+ * Revision 1.5 1999/02/11 22:27:12 warmerda
+ * Added multi-sample support
+ *
+ * Revision 1.4 1999/02/11 19:23:39 warmerda
+ * Only fix on multiples of 16 in block size if it is a tiled file.
+ *
+ * Revision 1.3 1999/02/11 19:21:14 warmerda
+ * Limit tile sizes to multiples of 16
+ *
+ * Revision 1.2 1999/02/11 18:37:43 warmerda
+ * Removed debugging malloc stuff.
+ *
+ * Revision 1.1 1999/02/11 18:12:30 warmerda
+ * New
+ *
+ */
+
+#include <stdio.h>
+#include <assert.h>
+#include <stdlib.h>
+
+#include "tiffio.h"
+#include "rawblockedimage.h"
+
+#ifndef FALSE
+# define FALSE 0
+# define TRUE 1
+#endif
+
+#ifndef MAX
+# define MIN(a,b) ((a<b) ? a : b)
+# define MAX(a,b) ((a>b) ? a : b)
+#endif
+
+extern "C" {
+ void TIFFBuildOverviews( const char *, int, int *, int );
+}
+
+/************************************************************************/
+/* TIFF_WriteOverview() */
+/************************************************************************/
+
+static
+void TIFF_WriteOverview( TIFF *hTIFF, int nSamples, RawBlockedImage **papoRBI,
+ int bTiled, int nCompressFlag, int nPhotometric,
+ unsigned short *panRed,
+ unsigned short *panGreen,
+ unsigned short *panBlue,
+ int bUseSubIFDs )
+
+{
+ int iSample;
+ RawBlockedImage *poRBI = papoRBI[0];
+
+/* -------------------------------------------------------------------- */
+/* Setup TIFF fields. */
+/* -------------------------------------------------------------------- */
+ TIFFSetField( hTIFF, TIFFTAG_IMAGEWIDTH, poRBI->GetXSize() );
+ TIFFSetField( hTIFF, TIFFTAG_IMAGELENGTH, poRBI->GetYSize() );
+ TIFFSetField( hTIFF, TIFFTAG_PLANARCONFIG,
+ PLANARCONFIG_SEPARATE );
+
+ TIFFSetField( hTIFF, TIFFTAG_BITSPERSAMPLE, poRBI->GetBitsPerPixel() );
+ TIFFSetField( hTIFF, TIFFTAG_SAMPLESPERPIXEL, nSamples );
+ TIFFSetField( hTIFF, TIFFTAG_COMPRESSION, nCompressFlag );
+ TIFFSetField( hTIFF, TIFFTAG_PHOTOMETRIC, nPhotometric );
+
+ if( bTiled )
+ {
+ TIFFSetField( hTIFF, TIFFTAG_TILEWIDTH, poRBI->GetBlockXSize() );
+ TIFFSetField( hTIFF, TIFFTAG_TILELENGTH, poRBI->GetBlockYSize() );
+ }
+ else
+ TIFFSetField( hTIFF, TIFFTAG_ROWSPERSTRIP, poRBI->GetBlockYSize() );
+
+ TIFFSetField( hTIFF, TIFFTAG_SUBFILETYPE, FILETYPE_REDUCEDIMAGE );
+
+/* -------------------------------------------------------------------- */
+/* Write color table if one is present. */
+/* -------------------------------------------------------------------- */
+ if( panRed != NULL )
+ {
+ TIFFSetField( hTIFF, TIFFTAG_COLORMAP, panRed, panGreen, panBlue );
+ }
+
+/* -------------------------------------------------------------------- */
+/* Write blocks to TIFF file. */
+/* -------------------------------------------------------------------- */
+ for( iSample = 0; iSample < nSamples; iSample++ )
+ {
+ int iTileX, iTileY;
+
+ poRBI = papoRBI[iSample];
+
+ for( iTileY = 0;
+ iTileY*poRBI->GetBlockYSize() < poRBI->GetYSize();
+ iTileY++ )
+ {
+ for( iTileX = 0;
+ iTileX*poRBI->GetBlockXSize() < poRBI->GetXSize();
+ iTileX++ )
+ {
+ unsigned char *pabyData = poRBI->GetTile( iTileX, iTileY );
+ int nTileID;
+
+ if( bTiled )
+ {
+ nTileID =
+ TIFFComputeTile(hTIFF,
+ iTileX * poRBI->GetBlockXSize(),
+ iTileY * poRBI->GetBlockYSize(),
+ 0, iSample );
+ TIFFWriteEncodedTile( hTIFF, nTileID,
+ pabyData, TIFFTileSize(hTIFF) );
+ }
+ else
+ {
+ nTileID =
+ TIFFComputeStrip(hTIFF, iTileY*poRBI->GetBlockYSize(),
+ iSample);
+
+ TIFFWriteEncodedStrip( hTIFF, nTileID,
+ pabyData, TIFFStripSize( hTIFF ) );
+ }
+ }
+ }
+ }
+
+ TIFFWriteDirectory( hTIFF );
+}
+
+/************************************************************************/
+/* TIFF_DownSample() */
+/* */
+/* Down sample a tile of full res data into a window of a tile */
+/* of downsampled data. */
+/************************************************************************/
+
+static
+void TIFF_DownSample( unsigned char *pabySrcTile,
+ int nBlockXSize, int nBlockYSize,
+ int nPixelSkewBits, int nBitsPerPixel,
+ unsigned char * pabyOTile,
+ int nOBlockXSize, int nOBlockYSize,
+ int nTXOff, int nTYOff, int nOMult )
+
+{
+ int i, j, k, nPixelBytes = (nBitsPerPixel) / 8;
+ int nPixelGroupBytes = (nBitsPerPixel+nPixelSkewBits)/8;
+ unsigned char *pabySrc, *pabyDst;
+
+ assert( nBitsPerPixel >= 8 );
+
+/* -------------------------------------------------------------------- */
+/* Handle case of one or more whole bytes per sample. */
+/* -------------------------------------------------------------------- */
+ for( j = 0; j*nOMult < nBlockYSize; j++ )
+ {
+ if( j + nTYOff >= nOBlockYSize )
+ break;
+
+ pabySrc = pabySrcTile + j*nOMult*nBlockXSize * nPixelGroupBytes;
+ pabyDst = pabyOTile
+ + ((j+nTYOff)*nOBlockXSize + nTXOff) * nPixelBytes;
+
+ for( i = 0; i*nOMult < nBlockXSize; i++ )
+ {
+ if( i + nTXOff >= nOBlockXSize )
+ break;
+
+ /*
+ * For now use simple subsampling, from the top left corner
+ * of the source block of pixels.
+ */
+
+ for( k = 0; k < nPixelBytes; k++ )
+ {
+ *(pabyDst++) = pabySrc[k];
+ }
+
+ pabySrc += nOMult * nPixelGroupBytes;
+ }
+ }
+}
+
+/************************************************************************/
+/* TIFF_ProcessFullResBlock() */
+/* */
+/* Process one block of full res data, downsampling into each */
+/* of the overviews. */
+/************************************************************************/
+
+void TIFF_ProcessFullResBlock( TIFF *hTIFF, int nPlanarConfig,
+ int nOverviews, int * panOvList,
+ int nBitsPerPixel,
+ int nSamples, RawBlockedImage ** papoRawBIs,
+ int nSXOff, int nSYOff,
+ unsigned char *pabySrcTile,
+ int nBlockXSize, int nBlockYSize )
+
+{
+ int iOverview, iSample;
+
+ for( iSample = 0; iSample < nSamples; iSample++ )
+ {
+ /*
+ * We have to read a tile/strip for each sample for
+ * PLANARCONFIG_SEPARATE. Otherwise, we just read all the samples
+ * at once when handling the first sample.
+ */
+ if( nPlanarConfig == PLANARCONFIG_SEPARATE || iSample == 0 )
+ {
+ if( TIFFIsTiled(hTIFF) )
+ {
+ TIFFReadEncodedTile( hTIFF,
+ TIFFComputeTile(hTIFF, nSXOff, nSYOff,
+ 0, iSample ),
+ pabySrcTile,
+ TIFFTileSize(hTIFF));
+ }
+ else
+ {
+ TIFFReadEncodedStrip( hTIFF,
+ TIFFComputeStrip(hTIFF, nSYOff, iSample),
+ pabySrcTile,
+ TIFFStripSize(hTIFF) );
+ }
+ }
+
+ /*
+ * Loop over destination overview layers
+ */
+ for( iOverview = 0; iOverview < nOverviews; iOverview++ )
+ {
+ RawBlockedImage *poRBI = papoRawBIs[iOverview*nSamples + iSample];
+ unsigned char *pabyOTile;
+ int nTXOff, nTYOff, nOXOff, nOYOff, nOMult;
+ int nOBlockXSize = poRBI->GetBlockXSize();
+ int nOBlockYSize = poRBI->GetBlockYSize();
+ int nSkewBits, nSampleByteOffset;
+
+ /*
+ * Fetch the destination overview tile
+ */
+ nOMult = panOvList[iOverview];
+ nOXOff = (nSXOff/nOMult) / nOBlockXSize;
+ nOYOff = (nSYOff/nOMult) / nOBlockYSize;
+ pabyOTile = poRBI->GetTileForUpdate( nOXOff, nOYOff );
+
+ /*
+ * Establish the offset into this tile at which we should
+ * start placing data.
+ */
+ nTXOff = (nSXOff - nOXOff*nOMult*nOBlockXSize) / nOMult;
+ nTYOff = (nSYOff - nOYOff*nOMult*nOBlockYSize) / nOMult;
+
+ /*
+ * Figure out the skew (extra space between ``our samples'') and
+ * the byte offset to the first sample.
+ */
+ assert( (nBitsPerPixel % 8) == 0 );
+ if( nPlanarConfig == PLANARCONFIG_SEPARATE )
+ {
+ nSkewBits = 0;
+ nSampleByteOffset = 0;
+ }
+ else
+ {
+ nSkewBits = nBitsPerPixel * (nSamples-1);
+ nSampleByteOffset = (nBitsPerPixel/8) * iSample;
+ }
+
+ /*
+ * Perform the downsampling.
+ */
+#ifdef DBMALLOC
+ malloc_chain_check( 1 );
+#endif
+ TIFF_DownSample( pabySrcTile + nSampleByteOffset,
+ nBlockXSize, nBlockYSize,
+ nSkewBits, nBitsPerPixel, pabyOTile,
+ poRBI->GetBlockXSize(),
+ poRBI->GetBlockYSize(),
+ nTXOff, nTYOff,
+ nOMult );
+#ifdef DBMALLOC
+ malloc_chain_check( 1 );
+#endif
+ }
+ }
+}
+
+/************************************************************************/
+/* TIFF_BuildOverviews() */
+/* */
+/* Build the requested list of overviews. Overviews are */
+/* maintained in a bunch of temporary files and then these are */
+/* written back to the TIFF file. Only one pass through the */
+/* source TIFF file is made for any number of output */
+/* overviews. */
+/************************************************************************/
+
+void TIFFBuildOverviews( const char * pszTIFFFilename,
+ int nOverviews, int * panOvList,
+ int bUseSubIFDs )
+
+{
+ RawBlockedImage **papoRawBIs;
+ uint32 nXSize, nYSize, nBlockXSize, nBlockYSize;
+ uint16 nBitsPerPixel, nPhotometric, nCompressFlag, nSamples,
+ nPlanarConfig;
+ int bTiled, nSXOff, nSYOff, i, iSample;
+ unsigned char *pabySrcTile;
+ TIFF *hTIFF;
+ uint16 *panRedMap, *panGreenMap, *panBlueMap;
+
+/* -------------------------------------------------------------------- */
+/* Get the base raster size. */
+/* -------------------------------------------------------------------- */
+ hTIFF = TIFFOpen( pszTIFFFilename, "r" );
+ if( hTIFF == NULL )
+ {
+ fprintf( stderr, "TIFFOpen(%s) failed.\n", pszTIFFFilename );
+ exit( 1 );
+ }
+
+ TIFFGetField( hTIFF, TIFFTAG_IMAGEWIDTH, &nXSize );
+ TIFFGetField( hTIFF, TIFFTAG_IMAGELENGTH, &nYSize );
+
+ TIFFGetField( hTIFF, TIFFTAG_BITSPERSAMPLE, &nBitsPerPixel );
+ TIFFGetField( hTIFF, TIFFTAG_SAMPLESPERPIXEL, &nSamples );
+ TIFFGetField( hTIFF, TIFFTAG_PLANARCONFIG, &nPlanarConfig );
+
+ TIFFGetField( hTIFF, TIFFTAG_PHOTOMETRIC, &nPhotometric );
+ TIFFGetField( hTIFF, TIFFTAG_COMPRESSION, &nCompressFlag );
+
+ if( nBitsPerPixel < 8 )
+ {
+ TIFFError( "TIFFBuildOverviews",
+ "File `%s' has samples of %d bits per sample. Sample\n"
+ "sizes of less than 8 bits per sample are not supported.\n",
+ pszTIFFFilename, nBitsPerPixel );
+ return;
+ }
+
+/* -------------------------------------------------------------------- */
+/* Get the base raster block size. */
+/* -------------------------------------------------------------------- */
+ if( TIFFGetField( hTIFF, TIFFTAG_ROWSPERSTRIP, &(nBlockYSize) ) )
+ {
+ nBlockXSize = nXSize;
+ bTiled = FALSE;
+ }
+ else
+ {
+ TIFFGetField( hTIFF, TIFFTAG_TILEWIDTH, &nBlockXSize );
+ TIFFGetField( hTIFF, TIFFTAG_TILELENGTH, &nBlockYSize );
+ bTiled = TRUE;
+ }
+
+/* -------------------------------------------------------------------- */
+/* Capture the pallette if there is one. */
+/* -------------------------------------------------------------------- */
+ if( TIFFGetField( hTIFF, TIFFTAG_COLORMAP,
+ &panRedMap, &panGreenMap, &panBlueMap ) )
+ {
+ uint16 *panRed2, *panGreen2, *panBlue2;
+
+ panRed2 = (uint16 *) calloc(2,256);
+ panGreen2 = (uint16 *) calloc(2,256);
+ panBlue2 = (uint16 *) calloc(2,256);
+
+ memcpy( panRed2, panRedMap, 512 );
+ memcpy( panGreen2, panGreenMap, 512 );
+ memcpy( panBlue2, panBlueMap, 512 );
+
+ panRedMap = panRed2;
+ panGreenMap = panGreen2;
+ panBlueMap = panBlue2;
+ }
+ else
+ {
+ panRedMap = panGreenMap = panBlueMap = NULL;
+ }
+
+/* -------------------------------------------------------------------- */
+/* Initialize the overview raw layers */
+/* -------------------------------------------------------------------- */
+ papoRawBIs = (RawBlockedImage **)
+ calloc(nOverviews*nSamples,sizeof(void*));
+
+ for( i = 0; i < nOverviews; i++ )
+ {
+ int nOXSize, nOYSize, nOBlockXSize, nOBlockYSize;
+
+ nOXSize = (nXSize + panOvList[i] - 1) / panOvList[i];
+ nOYSize = (nYSize + panOvList[i] - 1) / panOvList[i];
+
+ nOBlockXSize = MIN((int)nBlockXSize,nOXSize);
+ nOBlockYSize = MIN((int)nBlockYSize,nOYSize);
+
+ if( bTiled )
+ {
+ if( (nOBlockXSize % 16) != 0 )
+ nOBlockXSize = nOBlockXSize + 16 - (nOBlockXSize % 16);
+
+ if( (nOBlockYSize % 16) != 0 )
+ nOBlockYSize = nOBlockYSize + 16 - (nOBlockYSize % 16);
+ }
+
+ for( iSample = 0; iSample < nSamples; iSample++ )
+ {
+ papoRawBIs[i*nSamples + iSample] =
+ new RawBlockedImage( nOXSize, nOYSize,
+ nOBlockXSize, nOBlockYSize,
+ nBitsPerPixel );
+ }
+ }
+
+/* -------------------------------------------------------------------- */
+/* Allocate a buffer to hold a source block. */
+/* -------------------------------------------------------------------- */
+ if( bTiled )
+ pabySrcTile = (unsigned char *) malloc(TIFFTileSize(hTIFF));
+ else
+ pabySrcTile = (unsigned char *) malloc(TIFFStripSize(hTIFF));
+
+/* -------------------------------------------------------------------- */
+/* Loop over the source raster, applying data to the */
+/* destination raster. */
+/* -------------------------------------------------------------------- */
+ for( nSYOff = 0; nSYOff < (int) nYSize; nSYOff += nBlockYSize )
+ {
+ for( nSXOff = 0; nSXOff < (int) nXSize; nSXOff += nBlockXSize )
+ {
+ /*
+ * Read and resample into the various overview images.
+ */
+
+ TIFF_ProcessFullResBlock( hTIFF, nPlanarConfig,
+ nOverviews, panOvList,
+ nBitsPerPixel, nSamples, papoRawBIs,
+ nSXOff, nSYOff, pabySrcTile,
+ nBlockXSize, nBlockYSize );
+ }
+ }
+
+ free( pabySrcTile );
+
+ TIFFClose( hTIFF );
+
+/* ==================================================================== */
+/* We now have the overview rasters built, and held as */
+/* RawBlockedImage's. Now we need to write them to new TIFF */
+/* layers. */
+/* ==================================================================== */
+ hTIFF = TIFFOpen( pszTIFFFilename, "a" );
+ if( hTIFF == NULL )
+ {
+ fprintf( stderr,
+ "TIFFOpen(%s,\"a\") failed. No overviews written.\n"
+ "Do you have write permissions on that file?\n",
+ pszTIFFFilename );
+ }
+ else
+ {
+ for( i = 0; i < nOverviews; i++ )
+ {
+ TIFF_WriteOverview( hTIFF, nSamples, papoRawBIs + i*nSamples,
+ bTiled, nCompressFlag, nPhotometric,
+ panRedMap, panGreenMap, panBlueMap,
+ bUseSubIFDs );
+ }
+
+ TIFFClose( hTIFF );
+ }
+
+/* -------------------------------------------------------------------- */
+/* Cleanup the rawblockedimage files. */
+/* -------------------------------------------------------------------- */
+ for( i = 0; i < nOverviews*nSamples; i++ )
+ {
+ delete papoRawBIs[i];
+ }
+
+ if( papoRawBIs != NULL )
+ free( papoRawBIs );
+
+ if( panRedMap != NULL )
+ {
+ free( panRedMap );
+ free( panGreenMap );
+ free( panBlueMap );
+ }
+}
diff --git a/contrib/dbs/CVS/Entries b/contrib/dbs/CVS/Entries
deleted file mode 100644
index ec683a83..00000000
--- a/contrib/dbs/CVS/Entries
+++ /dev/null
@@ -1,7 +0,0 @@
-/Imakefile/1.1.1.1/Tue Jul 27 21:50:26 1999//
-/README/1.1.1.1/Tue Jul 27 21:50:26 1999//
-/tiff-bi.c/1.1.1.1/Tue Jul 27 21:50:27 1999//
-/tiff-grayscale.c/1.1.1.1/Tue Jul 27 21:50:27 1999//
-/tiff-palette.c/1.1.1.1/Tue Jul 27 21:50:27 1999//
-/tiff-rgb.c/1.1.1.1/Tue Jul 27 21:50:27 1999//
-D/xtiff////
diff --git a/contrib/dbs/CVS/Repository b/contrib/dbs/CVS/Repository
deleted file mode 100644
index fe1d686a..00000000
--- a/contrib/dbs/CVS/Repository
+++ /dev/null
@@ -1 +0,0 @@
-/usr/local/cvs/internal/libtiff/contrib/dbs
diff --git a/contrib/dbs/CVS/Root b/contrib/dbs/CVS/Root
deleted file mode 100644
index 8dff0f68..00000000
--- a/contrib/dbs/CVS/Root
+++ /dev/null
@@ -1 +0,0 @@
-/usr/local/cvs
diff --git a/contrib/dbs/xtiff/CVS/Entries b/contrib/dbs/xtiff/CVS/Entries
deleted file mode 100644
index fbcdce6e..00000000
--- a/contrib/dbs/xtiff/CVS/Entries
+++ /dev/null
@@ -1,6 +0,0 @@
-/Imakefile/1.1.1.1/Tue Jul 27 21:50:27 1999//
-/README/1.1.1.1/Tue Jul 27 21:50:27 1999//
-/patchlevel.h/1.1.1.1/Tue Jul 27 21:50:27 1999//
-/xtiff.c/1.1.1.1/Tue Jul 27 21:50:27 1999//
-/xtifficon.h/1.1.1.1/Tue Jul 27 21:50:27 1999//
-D
diff --git a/contrib/dbs/xtiff/CVS/Repository b/contrib/dbs/xtiff/CVS/Repository
deleted file mode 100644
index 59671bff..00000000
--- a/contrib/dbs/xtiff/CVS/Repository
+++ /dev/null
@@ -1 +0,0 @@
-/usr/local/cvs/internal/libtiff/contrib/dbs/xtiff
diff --git a/contrib/dbs/xtiff/CVS/Root b/contrib/dbs/xtiff/CVS/Root
deleted file mode 100644
index 8dff0f68..00000000
--- a/contrib/dbs/xtiff/CVS/Root
+++ /dev/null
@@ -1 +0,0 @@
-/usr/local/cvs
diff --git a/contrib/dosdjgpp/CVS/Entries b/contrib/dosdjgpp/CVS/Entries
deleted file mode 100644
index 87919706..00000000
--- a/contrib/dosdjgpp/CVS/Entries
+++ /dev/null
@@ -1,7 +0,0 @@
-/Makefile.lib/1.1.1.1/Tue Jul 27 21:50:27 1999//
-/Makefile.tools/1.1.1.1/Tue Jul 27 21:50:27 1999//
-/Makefile.top/1.1.1.1/Tue Jul 27 21:50:27 1999//
-/README/1.1.1.1/Tue Jul 27 21:50:27 1999//
-/conf.bat/1.1.1.1/Tue Jul 27 21:50:27 1999//
-/port.h/1.1.1.1/Tue Jul 27 21:50:27 1999//
-D
diff --git a/contrib/dosdjgpp/CVS/Repository b/contrib/dosdjgpp/CVS/Repository
deleted file mode 100644
index cdc8c42c..00000000
--- a/contrib/dosdjgpp/CVS/Repository
+++ /dev/null
@@ -1 +0,0 @@
-/usr/local/cvs/internal/libtiff/contrib/dosdjgpp
diff --git a/contrib/dosdjgpp/CVS/Root b/contrib/dosdjgpp/CVS/Root
deleted file mode 100644
index 8dff0f68..00000000
--- a/contrib/dosdjgpp/CVS/Root
+++ /dev/null
@@ -1 +0,0 @@
-/usr/local/cvs
diff --git a/contrib/dosdjgpp/Makefile.lib b/contrib/dosdjgpp/Makefile.lib
index 78ddce85..0cc25e6f 100644
--- a/contrib/dosdjgpp/Makefile.lib
+++ b/contrib/dosdjgpp/Makefile.lib
@@ -1,4 +1,4 @@
-# $Header: /usr/local/cvs/internal/libtiff/contrib/dosdjgpp/Makefile.lib,v 1.1.1.1 1999/07/27 21:50:27 mike Exp $
+# $Header: /cvsroot/osrs/libtiff/contrib/dosdjgpp/Makefile.lib,v 1.1.1.1 1999/07/27 21:50:27 mike Exp $
#
# manually derived from Makefile.in for DJGPP v2.x (GNU C for DOS/386).
#
diff --git a/contrib/dosdjgpp/Makefile.tools b/contrib/dosdjgpp/Makefile.tools
index cb229383..c36227f6 100644
--- a/contrib/dosdjgpp/Makefile.tools
+++ b/contrib/dosdjgpp/Makefile.tools
@@ -1,4 +1,4 @@
-# $Header: /usr/local/cvs/internal/libtiff/contrib/dosdjgpp/Makefile.tools,v 1.1.1.1 1999/07/27 21:50:27 mike Exp $
+# $Header: /cvsroot/osrs/libtiff/contrib/dosdjgpp/Makefile.tools,v 1.1.1.1 1999/07/27 21:50:27 mike Exp $
#
# manually derived from Makefile.in for DJGPP v2.x (GNU C for DOS/386).
#
diff --git a/contrib/dosdjgpp/Makefile.top b/contrib/dosdjgpp/Makefile.top
index 6d4313ca..56c85710 100644
--- a/contrib/dosdjgpp/Makefile.top
+++ b/contrib/dosdjgpp/Makefile.top
@@ -1,5 +1,5 @@
#! smake
-# $Header: /usr/local/cvs/internal/libtiff/contrib/dosdjgpp/Makefile.top,v 1.1.1.1 1999/07/27 21:50:27 mike Exp $
+# $Header: /cvsroot/osrs/libtiff/contrib/dosdjgpp/Makefile.top,v 1.1.1.1 1999/07/27 21:50:27 mike Exp $
#
# manually derived from Makefile.in (though basically nothing remains)
# for DJGPP v2.x (GNU C for DOS/386).
diff --git a/contrib/iptcutil/CVS/Entries b/contrib/iptcutil/CVS/Entries
deleted file mode 100644
index d2a5bf40..00000000
--- a/contrib/iptcutil/CVS/Entries
+++ /dev/null
@@ -1,5 +0,0 @@
-/Makefile/1.1.1.1/Tue Jul 27 21:50:27 1999//
-/iptcutil.c/1.1.1.1/Tue Jul 27 21:50:27 1999//
-/test.iptc/1.1.1.1/Tue Jul 27 21:50:27 1999//
-/test.txt/1.1.1.1/Tue Jul 27 21:50:27 1999//
-D
diff --git a/contrib/iptcutil/CVS/Repository b/contrib/iptcutil/CVS/Repository
deleted file mode 100644
index e00d29ba..00000000
--- a/contrib/iptcutil/CVS/Repository
+++ /dev/null
@@ -1 +0,0 @@
-/usr/local/cvs/internal/libtiff/contrib/iptcutil
diff --git a/contrib/iptcutil/CVS/Root b/contrib/iptcutil/CVS/Root
deleted file mode 100644
index 8dff0f68..00000000
--- a/contrib/iptcutil/CVS/Root
+++ /dev/null
@@ -1 +0,0 @@
-/usr/local/cvs
diff --git a/contrib/iptcutil/Makefile b/contrib/iptcutil/Makefile
deleted file mode 100644
index e8aacda1..00000000
--- a/contrib/iptcutil/Makefile
+++ /dev/null
@@ -1,12 +0,0 @@
-CC=gcc
-CFLAGS=
-iptcutil: iptcutil.c
- $(CC) $(CFLAGS) -o iptcutil iptcutil.c
-
-clean:
- rm iptcutil *~
-
-all: iptcutil
-
-
-
diff --git a/contrib/iptcutil/iptcutil.c b/contrib/iptcutil/iptcutil.c
deleted file mode 100644
index 1ee68bb1..00000000
--- a/contrib/iptcutil/iptcutil.c
+++ /dev/null
@@ -1,920 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#ifdef WIN32
-#include <io.h>
-#endif
-#include <string.h>
-#include <memory.h>
-#include <ctype.h>
-
-#ifdef WIN32
-#define STRNICMP strnicmp
-#else
-#define STRNICMP strncasecmp
-#endif
-
-typedef struct _tag_spec
-{
- short
- id;
-
- char
- *name;
-} tag_spec;
-
-static tag_spec tags[] = {
- 5,"Image Name",
- 7,"Edit Status",
- 10,"Priority",
- 15,"Category",
- 20,"Supplemental Category",
- 22,"Fixture Identifier",
- 25,"Keyword",
- 30,"Release Date",
- 35,"Release Time",
- 40,"Special Instructions",
- 45,"Reference Service",
- 47,"Reference Date",
- 50,"Reference Number",
- 55,"Created Date",
- 60,"Created Time",
- 65,"Originating Program",
- 70,"Program Version",
- 75,"Object Cycle",
- 80,"Byline",
- 85,"Byline Title",
- 90,"City",
- 95,"Province State",
- 100,"Country Code",
- 101,"Country",
- 103,"Original Transmission Reference",
- 105,"Headline",
- 110,"Credit",
- 115,"Source",
- 116,"Copyright String",
- 120,"Caption",
- 121,"Local Caption",
- 122,"Caption Writer",
- 200,"Custom Field 1",
- 201,"Custom Field 2",
- 202,"Custom Field 3",
- 203,"Custom Field 4",
- 204,"Custom Field 5",
- 205,"Custom Field 6",
- 206,"Custom Field 7",
- 207,"Custom Field 8",
- 208,"Custom Field 9",
- 209,"Custom Field 10",
- 210,"Custom Field 11",
- 211,"Custom Field 12",
- 212,"Custom Field 13",
- 213,"Custom Field 14",
- 214,"Custom Field 15",
- 215,"Custom Field 16",
- 216,"Custom Field 17",
- 217,"Custom Field 18",
- 218,"Custom Field 19",
- 219,"Custom Field 20"
-};
-
-/*
- * We format the output using HTML conventions
- * to preserve control characters and such.
- */
-void formatString(FILE *ofile, const char *s, int len)
-{
- putc('"', ofile);
- for (; len > 0; --len, ++s) {
- char c = *s;
- switch (c) {
- case '&':
- fputs("&amp;", ofile);
- break;
-#ifdef HANDLE_GT_LT
- case '<':
- fputs("&lt;", ofile);
- break;
- case '>':
- fputs("&gt;", ofile);
- break;
-#endif
- case '"':
- fputs("&quot;", ofile);
- break;
- default:
- if (iscntrl(c))
- fprintf(ofile, "&#%d;", c);
- else
- putc(*s, ofile);
- break;
- }
- }
- fputs("\"\n", ofile);
-}
-
-typedef struct _html_code
-{
- short
- len;
- const char
- *code,
- val;
-} html_code;
-
-static html_code html_codes[] = {
-#ifdef HANDLE_GT_LT
- 4,"&lt;",'<',
- 4,"&gt;",'>',
-#endif
- 5,"&amp;",'&',
- 6,"&quot;",'"'
-};
-
-/*
- * This routine converts HTML escape sequence
- * back to the original ASCII representation.
- * - returns the number of characters dropped.
- */
-int convertHTMLcodes(char *s, int len)
-{
- if (len <=0 || s==(char*)NULL || *s=='\0')
- return 0;
-
- if (s[1] == '#')
- {
- int val, o;
-
- if (sscanf(s,"&#%d;",&val) == 1)
- {
- o = 3;
- while (s[o] != ';')
- {
- o++;
- if (o > 5)
- break;
- }
- if (o < 5)
- strcpy(s+1, s+1+o);
- *s = val;
- return o;
- }
- }
- else
- {
- int
- i,
- codes = sizeof(html_codes) / sizeof(html_code);
-
- for (i=0; i < codes; i++)
- {
- if (html_codes[i].len <= len)
- if (STRNICMP(s, html_codes[i].code, html_codes[i].len) == 0)
- {
- strcpy(s+1, s+html_codes[i].len);
- *s = html_codes[i].val;
- return html_codes[i].len-1;
- }
- }
- }
-}
-
-int formatIPTC(FILE *ifile, FILE *ofile)
-{
- unsigned int
- foundiptc,
- tagsfound;
-
- unsigned char
- recnum,
- dataset;
-
- unsigned char
- *readable,
- *str;
-
- long
- tagindx,
- taglen;
-
- int
- i,
- tagcount = sizeof(tags) / sizeof(tag_spec);
-
- char
- c;
-
- foundiptc = 0; /* found the IPTC-Header */
- tagsfound = 0; /* number of tags found */
-
- c = getc(ifile);
- while (c != EOF)
- {
- if (c == 0x1c)
- foundiptc = 1;
- else
- {
- if (foundiptc)
- return -1;
- else
- continue;
- }
-
- /* we found the 0x1c tag and now grab the dataset and record number tags */
- dataset = getc(ifile);
- if ((char) dataset == EOF)
- return -1;
- recnum = getc(ifile);
- if ((char) recnum == EOF)
- return -1;
- /* try to match this record to one of the ones in our named table */
- for (i=0; i< tagcount; i++)
- {
- if (tags[i].id == recnum)
- break;
- }
- if (i < tagcount)
- readable = tags[i].name;
- else
- readable = "";
-
- /* then we decode the length of the block that follows - long or short fmt */
- c = getc(ifile);
- if (c == EOF)
- return 0;
- if (c & (unsigned char) 0x80)
- {
- unsigned char
- buffer[4];
-
- for (i=0; i<4; i++)
- {
- c = buffer[i] = getc(ifile);
- if (c == EOF)
- return -1;
- }
- taglen = (((long) buffer[ 0 ]) << 24) |
- (((long) buffer[ 1 ]) << 16) |
- (((long) buffer[ 2 ]) << 8) |
- (((long) buffer[ 3 ]));
- }
- else
- {
- unsigned char
- x = c;
-
- taglen = ((long) x) << 8;
- x = getc(ifile);
- if ((char)x == EOF)
- return -1;
- taglen |= (long) x;
- }
- /* make a buffer to hold the tag data and snag it from the input stream */
- str=(unsigned char *) malloc((unsigned int) (taglen+1));
- if (str == (unsigned char *) NULL)
- {
- printf("Memory allocation failed");
- return 0;
- }
- for (tagindx=0; tagindx<taglen; tagindx++)
- {
- c = str[tagindx] = getc(ifile);
- if (c == EOF)
- return -1;
- }
- str[ taglen ] = 0;
-
- /* now finish up by formatting this binary data into ASCII equivalent */
- if (strlen(readable) > 0)
- fprintf(ofile, "%d#%d#%s=",(unsigned int)dataset, (unsigned int) recnum, readable);
- else
- fprintf(ofile, "%d#%d=",(unsigned int)dataset, (unsigned int) recnum);
- formatString( ofile, str, taglen );
- free(str);
-
- tagsfound++;
-
- c = getc(ifile);
- }
- return tagsfound;
-}
-
-int tokenizer(unsigned inflag,char *token,int tokmax,char *line,
-char *white,char *brkchar,char *quote,char eschar,char *brkused,
-int *next,char *quoted);
-
-char *super_fgets(char *b, int *blen, FILE *file)
-{
- int
- c,
- len;
-
- unsigned char
- *q;
-
- len=*blen;
- for (q=b; ; q++)
- {
- c=fgetc(file);
- if (c == EOF || c == '\n')
- break;
- if (((int)q - (int)b + 1 ) >= (int) len)
- {
- int
- tlen;
-
- tlen=(int)q-(int)b;
- len<<=1;
- b=(unsigned char *) realloc((char *) b,(len+2));
- if ((unsigned char *) b == (unsigned char *) NULL)
- break;
- q=b+tlen;
- }
- *q=(unsigned char) c;
- }
- *blen=0;
- if ((unsigned char *)b != (unsigned char *) NULL)
- {
- int
- tlen;
-
- tlen=(int)q - (int)b;
- if (tlen == 0)
- return (char *) NULL;
- b[tlen] = '\0';
- *blen=++tlen;
- }
- return b;
-}
-
-#define BUFFER_SZ 4096
-
-int main(int argc, char *argv[])
-{
- unsigned int
- length;
-
- unsigned char
- *buffer;
-
- int
- i,
- mode; /* iptc binary, or iptc text */
-
- FILE
- *ifile = stdin,
- *ofile = stdout;
-
- char
- c,
- *usage = "usage: iptcutil -t | -b [-i file] [-o file] <input >output";
-
- if( argc < 2 )
- {
- printf(usage);
- return 1;
- }
-
- mode = 0;
- length = -1;
- buffer = (unsigned char *)NULL;
-
- for (i=1; i<argc; i++)
- {
- c = argv[i][0];
- if (c == '-' || c == '/')
- {
- c = argv[i][1];
- switch( c )
- {
- case 't':
- mode = 1;
-#ifdef WIN32
- /* Set "stdout" to binary mode: */
- _setmode( _fileno( ofile ), _O_BINARY );
-#endif
- break;
- case 'b':
- mode = 0;
-#ifdef WIN32
- /* Set "stdin" to binary mode: */
- _setmode( _fileno( ifile ), _O_BINARY );
-#endif
- break;
- case 'i':
- if (mode == 0)
- ifile = fopen(argv[++i], "rb");
- else
- ifile = fopen(argv[++i], "rt");
- if (ifile == (FILE *)NULL)
- {
- printf("Unable to open: %s\n", argv[i]);
- return 1;
- }
- break;
- case 'o':
- if (mode == 0)
- ofile = fopen(argv[++i], "wt");
- else
- ofile = fopen(argv[++i], "wb");
- if (ofile == (FILE *)NULL)
- {
- printf("Unable to open: %s\n", argv[i]);
- return 1;
- }
- break;
- default:
- printf("Unknown option: %s\n", argv[i]);
- return 1;
- }
- }
- else
- {
- printf(usage);
- return 1;
- }
- }
-
- if (mode == 0) /* handle binary iptc info */
- formatIPTC(ifile, ofile);
-
- if (mode == 1) /* handle text form of iptc info */
- {
- char
- brkused,
- quoted,
- *line,
- *token,
- *newstr;
-
- int
- state,
- next;
-
- unsigned char
- recnum,
- dataset;
-
- int
- inputlen = BUFFER_SZ;
-
- line = (char *) malloc(inputlen);
- token = (char *)NULL;
- while((line = super_fgets(line,&inputlen,ifile))!=NULL)
- {
- state=0;
- next=0;
-
- token = (char *) malloc(inputlen);
- newstr = (char *) malloc(inputlen);
- while(tokenizer(0, token, inputlen, line, "", "=", "\"", 0,
- &brkused,&next,&quoted)==0)
- {
- if (state == 0)
- {
- int
- state,
- next;
-
- char
- brkused,
- quoted;
-
- state=0;
- next=0;
- while(tokenizer(0, newstr, inputlen, token, "", "#", "", 0,
- &brkused, &next, &quoted)==0)
- {
- if (state == 0)
- dataset = (unsigned char) atoi(newstr);
- else
- if (state == 1)
- recnum = (unsigned char) atoi(newstr);
- state++;
- }
- }
- else
- if (state == 1)
- {
- int
- next;
-
- unsigned long
- len;
-
- char
- brkused,
- quoted;
-
- next=0;
- len = strlen(token);
- while(tokenizer(0, newstr, inputlen, token, "", "&", "", 0,
- &brkused, &next, &quoted)==0)
- {
- if (brkused && next > 0)
- {
- char
- *s = &token[next-1];
-
- len -= convertHTMLcodes(s, strlen(s));
- }
- }
-
- fputc(0x1c, ofile);
- fputc(dataset, ofile);
- fputc(recnum, ofile);
- if (len < 0x10000)
- {
- fputc((len >> 8) & 255, ofile);
- fputc(len & 255, ofile);
- }
- else
- {
- fputc(((len >> 24) & 255) | 0x80, ofile);
- fputc((len >> 16) & 255, ofile);
- fputc((len >> 8) & 255, ofile);
- fputc(len & 255, ofile);
- }
- next=0;
- while (len--)
- fputc(token[next++], ofile);
- }
- state++;
- }
- free(token);
- token = (char *)NULL;
- free(newstr);
- newstr = (char *)NULL;
- }
- free(line);
-
- fclose( ifile );
- fclose( ofile );
- }
-
- return 0;
-}
-
-/*
- This routine is a generalized, finite state token parser. It allows
- you extract tokens one at a time from a string of characters. The
- characters used for white space, for break characters, and for quotes
- can be specified. Also, characters in the string can be preceded by
- a specifiable escape character which removes any special meaning the
- character may have.
-
- There are a lot of formal parameters in this subroutine call, but
- once you get familiar with them, this routine is fairly easy to use.
- "#define" macros can be used to generate simpler looking calls for
- commonly used applications of this routine.
-
- First, some terminology:
-
- token: used here, a single unit of information in
- the form of a group of characters.
-
- white space: space that gets ignored (except within quotes
- or when escaped), like blanks and tabs. in
- addition, white space terminates a non-quoted
- token.
-
- break character: a character that separates non-quoted tokens.
- commas are a common break character. the
- usage of break characters to signal the end
- of a token is the same as that of white space,
- except multiple break characters with nothing
- or only white space between generate a null
- token for each two break characters together.
-
- for example, if blank is set to be the white
- space and comma is set to be the break
- character, the line ...
-
- A, B, C , , DEF
-
- ... consists of 5 tokens:
-
- 1) "A"
- 2) "B"
- 3) "C"
- 4) "" (the null string)
- 5) "DEF"
-
- quote character: a character that, when surrounding a group
- of other characters, causes the group of
- characters to be treated as a single token,
- no matter how many white spaces or break
- characters exist in the group. also, a
- token always terminates after the closing
- quote. for example, if ' is the quote
- character, blank is white space, and comma
- is the break character, the following
- string ...
-
- A, ' B, CD'EF GHI
-
- ... consists of 4 tokens:
-
- 1) "A"
- 2) " B, CD" (note the blanks & comma)
- 3) "EF"
- 4) "GHI"
-
- the quote characters themselves do
- not appear in the resultant tokens. the
- double quotes are delimiters i use here for
- documentation purposes only.
-
- escape character: a character which itself is ignored but
- which causes the next character to be
- used as is. ^ and \ are often used as
- escape characters. an escape in the last
- position of the string gets treated as a
- "normal" (i.e., non-quote, non-white,
- non-break, and non-escape) character.
- for example, assume white space, break
- character, and quote are the same as in the
- above examples, and further, assume that
- ^ is the escape character. then, in the
- string ...
-
- ABC, ' DEF ^' GH' I ^ J K^ L ^
-
- ... there are 7 tokens:
-
- 1) "ABC"
- 2) " DEF ' GH"
- 3) "I"
- 4) " " (a lone blank)
- 5) "J"
- 6) "K L"
- 7) "^" (passed as is at end of line)
-
-
- OK, now that you have this background, here's how to call "tokenizer":
-
- result=tokenizer(flag,token,maxtok,string,white,break,quote,escape,
- brkused,next,quoted)
-
- result: 0 if we haven't reached EOS (end of string), and
- 1 if we have (this is an "int").
-
- flag: right now, only the low order 3 bits are used.
- 1 => convert non-quoted tokens to upper case
- 2 => convert non-quoted tokens to lower case
- 0 => do not convert non-quoted tokens
- (this is a "char").
-
- token: a character string containing the returned next token
- (this is a "char[]").
-
- maxtok: the maximum size of "token". characters beyond
- "maxtok" are truncated (this is an "int").
-
- string: the string to be parsed (this is a "char[]").
-
- white: a string of the valid white spaces. example:
-
- char whitesp[]={" \t"};
-
- blank and tab will be valid white space (this is
- a "char[]").
-
- break: a string of the valid break characters. example:
-
- char breakch[]={";,"};
-
- semicolon and comma will be valid break characters
- (this is a "char[]").
-
- IMPORTANT: do not use the name "break" as a C
- variable, as this is a reserved word in C.
-
- quote: a string of the valid quote characters. an example
- would be
-
- char whitesp[]={"'\"");
-
- (this causes single and double quotes to be valid)
- note that a token starting with one of these characters
- needs the same quote character to terminate it.
-
- for example,
-
- "ABC '
-
- is unterminated, but
-
- "DEF" and 'GHI'
-
- are properly terminated. note that different quote
- characters can appear on the same line; only for
- a given token do the quote characters have to be
- the same (this is a "char[]").
-
- escape: the escape character (NOT a string ... only one
- allowed). use zero if none is desired (this is
- a "char").
-
- brkused: the break character used to terminate the current
- token. if the token was quoted, this will be the
- quote used. if the token is the last one on the
- line, this will be zero (this is a pointer to a
- "char").
-
- next: this variable points to the first character of the
- next token. it gets reset by "tokenizer" as it steps
- through the string. set it to 0 upon initialization,
- and leave it alone after that. you can change it
- if you want to jump around in the string or re-parse
- from the beginning, but be careful (this is a
- pointer to an "int").
-
- quoted: set to 1 (true) if the token was quoted and 0 (false)
- if not. you may need this information (for example:
- in C, a string with quotes around it is a character
- string, while one without is an identifier).
-
- (this is a pointer to a "char").
-*/
-
-/* states */
-
-#define IN_WHITE 0
-#define IN_TOKEN 1
-#define IN_QUOTE 2
-#define IN_OZONE 3
-
-int _p_state; /* current state */
-unsigned _p_flag; /* option flag */
-char _p_curquote; /* current quote char */
-int _p_tokpos; /* current token pos */
-
-/* routine to find character in string ... used only by "tokenizer" */
-
-int sindex(char ch,char *string)
-{
- char *cp;
- for(cp=string;*cp;++cp)
- if(ch==*cp)
- return (int)(cp-string); /* return postion of character */
- return -1; /* eol ... no match found */
-}
-
-/* routine to store a character in a string ... used only by "tokenizer" */
-
-void chstore(char *string,int max,char ch)
-{
- char c;
- if(_p_tokpos>=0&&_p_tokpos<max-1)
- {
- if(_p_state==IN_QUOTE)
- c=ch;
- else
- switch(_p_flag&3)
- {
- case 1: /* convert to upper */
- c=toupper(ch);
- break;
-
- case 2: /* convert to lower */
- c=tolower(ch);
- break;
-
- default: /* use as is */
- c=ch;
- break;
- }
- string[_p_tokpos++]=c;
- }
- return;
-}
-
-int tokenizer(unsigned inflag,char *token,int tokmax,char *line,
- char *white,char *brkchar,char *quote,char eschar,char *brkused,
- int *next,char *quoted)
-{
- int qp;
- char c,nc;
-
- *brkused=0; /* initialize to null */
- *quoted=0; /* assume not quoted */
-
- if(!line[*next]) /* if we're at end of line, indicate such */
- return 1;
-
- _p_state=IN_WHITE; /* initialize state */
- _p_curquote=0; /* initialize previous quote char */
- _p_flag=inflag; /* set option flag */
-
- for(_p_tokpos=0;c=line[*next];++(*next)) /* main loop */
- {
- if((qp=sindex(c,brkchar))>=0) /* break */
- {
- switch(_p_state)
- {
- case IN_WHITE: /* these are the same here ... */
- case IN_TOKEN: /* ... just get out */
- case IN_OZONE: /* ditto */
- ++(*next);
- *brkused=brkchar[qp];
- goto byebye;
-
- case IN_QUOTE: /* just keep going */
- chstore(token,tokmax,c);
- break;
- }
- }
- else if((qp=sindex(c,quote))>=0) /* quote */
- {
- switch(_p_state)
- {
- case IN_WHITE: /* these are identical, */
- _p_state=IN_QUOTE; /* change states */
- _p_curquote=quote[qp]; /* save quote char */
- *quoted=1; /* set to true as long as something is in quotes */
- break;
-
- case IN_QUOTE:
- if(quote[qp]==_p_curquote) /* same as the beginning quote? */
- {
- _p_state=IN_OZONE;
- _p_curquote=0;
- }
- else
- chstore(token,tokmax,c); /* treat as regular char */
- break;
-
- case IN_TOKEN:
- case IN_OZONE:
- *brkused=c; /* uses quote as break char */
- goto byebye;
- }
- }
- else if((qp=sindex(c,white))>=0) /* white */
- {
- switch(_p_state)
- {
- case IN_WHITE:
- case IN_OZONE:
- break; /* keep going */
-
- case IN_TOKEN:
- _p_state=IN_OZONE;
- break;
-
- case IN_QUOTE:
- chstore(token,tokmax,c); /* it's valid here */
- break;
- }
- }
- else if(c==eschar) /* escape */
- {
- nc=line[(*next)+1];
- if(nc==0) /* end of line */
- {
- *brkused=0;
- chstore(token,tokmax,c);
- ++(*next);
- goto byebye;
- }
- switch(_p_state)
- {
- case IN_WHITE:
- --(*next);
- _p_state=IN_TOKEN;
- break;
-
- case IN_TOKEN:
- case IN_QUOTE:
- ++(*next);
- chstore(token,tokmax,nc);
- break;
-
- case IN_OZONE:
- goto byebye;
- }
- }
- else /* anything else is just a real character */
- {
- switch(_p_state)
- {
- case IN_WHITE:
- _p_state=IN_TOKEN; /* switch states */
-
- case IN_TOKEN: /* these 2 are */
- case IN_QUOTE: /* identical here */
- chstore(token,tokmax,c);
- break;
-
- case IN_OZONE:
- goto byebye;
- }
- }
- } /* end of main loop */
-
-byebye:
- token[_p_tokpos]=0; /* make sure token ends with EOS */
-
- return 0;
-}
diff --git a/contrib/iptcutil/test.iptc b/contrib/iptcutil/test.iptc
deleted file mode 100644
index a2605622..00000000
--- a/contrib/iptcutil/test.iptc
+++ /dev/null
Binary files differ
diff --git a/contrib/iptcutil/test.txt b/contrib/iptcutil/test.txt
deleted file mode 100644
index d5181004..00000000
--- a/contrib/iptcutil/test.txt
+++ /dev/null
@@ -1,32 +0,0 @@
-2#0="&#0;&#2;"
-2#120#Caption="Chairman of the US House Judiciary Committee, Henry Hyde,R-IL, makes his opening statement during impeachment hearings 11 December on Capitol Hill in Washington, DC. The committee is debating the articles of impechment and my take a vote on the impeachment of US President BIll Clinton on charges that he obstucted justice, lied and abused the power of his office as early as today. AFP PHOTO Paul J. RICHARDS&#13;"
-2#122#Caption Writer="kb/lt"
-2#100#Country Code="USA"
-2#105#Headline="Old fart squeezing two fingers."
-2#30#Release Date="19981211"
-2#35#Release Time="000000+0000"
-2#40#Special Instructions="This is a test. This is only a test. ABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890"
-2#80#Byline="PAUL J. RICHARDS"
-2#85#Byline Title="STF"
-2#110#Credit="AFP"
-2#65#Originating Program="MacDesk Reporter"
-2#115#Source="AFP"
-2#5#Image Name="US-HYDE"
-2#55#Created Date="19981211"
-2#90#City="WASHINGTON"
-2#95#Province State="DC"
-2#101#Country="UNITED STATES"
-2#103#Original Transmission Reference="DCA03"
-2#15#Category="POL"
-2#20#Supplemental Category="GOVERNMENT"
-2#10#Priority="5"
-2#25#Keyword="fart"
-2#25#Keyword="squeezing"
-2#25#Keyword="old"
-2#25#Keyword="fingers"
-2#75#Object Cycle="a"
-2#60#Created Time="000000+0000"
-2#70#Program Version="2.0.3"
-2#130="3S"
-2#135="GB"
-2#231="Kaya A. Hoffmann 12/14/98 12:00:44 PM Copy To : Selects - \\KINYANI\Selects&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;"
diff --git a/contrib/mac-cw/CVS/Entries b/contrib/mac-cw/CVS/Entries
deleted file mode 100644
index 35998199..00000000
--- a/contrib/mac-cw/CVS/Entries
+++ /dev/null
@@ -1,8 +0,0 @@
-/Makefile.script/1.1.1.1/Tue Jul 27 21:50:27 1999//
-/README/1.1.1.1/Tue Jul 27 21:50:27 1999//
-/mac_main.c/1.1.1.1/Tue Jul 27 21:50:27 1999//
-/mac_main.h/1.1.1.1/Tue Jul 27 21:50:27 1999//
-/metrowerks.note/1.1.1.1/Tue Jul 27 21:50:27 1999//
-/mkg3_main.c/1.1.1.1/Tue Jul 27 21:50:27 1999//
-/version.h/1.1.1.1/Tue Jul 27 21:50:27 1999//
-D
diff --git a/contrib/mac-cw/CVS/Repository b/contrib/mac-cw/CVS/Repository
deleted file mode 100644
index d620cc0a..00000000
--- a/contrib/mac-cw/CVS/Repository
+++ /dev/null
@@ -1 +0,0 @@
-/usr/local/cvs/internal/libtiff/contrib/mac-cw
diff --git a/contrib/mac-cw/CVS/Root b/contrib/mac-cw/CVS/Root
deleted file mode 100644
index 8dff0f68..00000000
--- a/contrib/mac-cw/CVS/Root
+++ /dev/null
@@ -1 +0,0 @@
-/usr/local/cvs
diff --git a/contrib/mac-mpw/CVS/Entries b/contrib/mac-mpw/CVS/Entries
deleted file mode 100644
index 5d8ce16e..00000000
--- a/contrib/mac-mpw/CVS/Entries
+++ /dev/null
@@ -1,8 +0,0 @@
-/BUILD.mpw/1.1.1.1/Tue Jul 27 21:50:27 1999//
-/README/1.1.1.1/Tue Jul 27 21:50:27 1999//
-/libtiff.make/1.1.1.1/Tue Jul 27 21:50:27 1999//
-/mactrans.c/1.1.1.1/Tue Jul 27 21:50:27 1999//
-/port.make/1.1.1.1/Tue Jul 27 21:50:27 1999//
-/tools.make/1.1.1.1/Tue Jul 27 21:50:27 1999//
-/top.make/1.1.1.1/Tue Jul 27 21:50:27 1999//
-D
diff --git a/contrib/mac-mpw/CVS/Repository b/contrib/mac-mpw/CVS/Repository
deleted file mode 100644
index 738d5fb9..00000000
--- a/contrib/mac-mpw/CVS/Repository
+++ /dev/null
@@ -1 +0,0 @@
-/usr/local/cvs/internal/libtiff/contrib/mac-mpw
diff --git a/contrib/mac-mpw/CVS/Root b/contrib/mac-mpw/CVS/Root
deleted file mode 100644
index 8dff0f68..00000000
--- a/contrib/mac-mpw/CVS/Root
+++ /dev/null
@@ -1 +0,0 @@
-/usr/local/cvs
diff --git a/contrib/mfs/CVS/Entries b/contrib/mfs/CVS/Entries
deleted file mode 100644
index a9343d70..00000000
--- a/contrib/mfs/CVS/Entries
+++ /dev/null
@@ -1,3 +0,0 @@
-/README/1.1.1.1/Tue Jul 27 21:50:27 1999//
-/mfs_file.c/1.1.1.1/Tue Jul 27 21:50:27 1999//
-D
diff --git a/contrib/mfs/CVS/Repository b/contrib/mfs/CVS/Repository
deleted file mode 100644
index c747801e..00000000
--- a/contrib/mfs/CVS/Repository
+++ /dev/null
@@ -1 +0,0 @@
-/usr/local/cvs/internal/libtiff/contrib/mfs
diff --git a/contrib/mfs/CVS/Root b/contrib/mfs/CVS/Root
deleted file mode 100644
index 8dff0f68..00000000
--- a/contrib/mfs/CVS/Root
+++ /dev/null
@@ -1 +0,0 @@
-/usr/local/cvs
diff --git a/contrib/pds/CVS/Entries b/contrib/pds/CVS/Entries
deleted file mode 100644
index 02b71f54..00000000
--- a/contrib/pds/CVS/Entries
+++ /dev/null
@@ -1,6 +0,0 @@
-/README/1.1.1.1/Tue Jul 27 21:50:27 1999//
-/tif_imageiter.c/1.1.1.1/Tue Jul 27 21:50:27 1999//
-/tif_imageiter.h/1.1.1.1/Tue Jul 27 21:50:27 1999//
-/tif_pdsdirread.c/1.1.1.1/Tue Jul 27 21:50:27 1999//
-/tif_pdsdirwrite.c/1.1.1.1/Tue Jul 27 21:50:27 1999//
-D
diff --git a/contrib/pds/CVS/Repository b/contrib/pds/CVS/Repository
deleted file mode 100644
index 4f26a798..00000000
--- a/contrib/pds/CVS/Repository
+++ /dev/null
@@ -1 +0,0 @@
-/usr/local/cvs/internal/libtiff/contrib/pds
diff --git a/contrib/pds/CVS/Root b/contrib/pds/CVS/Root
deleted file mode 100644
index 8dff0f68..00000000
--- a/contrib/pds/CVS/Root
+++ /dev/null
@@ -1 +0,0 @@
-/usr/local/cvs
diff --git a/contrib/pds/tif_imageiter.c b/contrib/pds/tif_imageiter.c
index 60dfa09b..9b4b6e4a 100644
--- a/contrib/pds/tif_imageiter.c
+++ b/contrib/pds/tif_imageiter.c
@@ -1,4 +1,4 @@
-/* $Header: /usr/local/cvs/internal/libtiff/contrib/pds/tif_imageiter.c,v 1.1.1.1 1999/07/27 21:50:27 mike Exp $ */
+/* $Header: /cvsroot/osrs/libtiff/contrib/pds/tif_imageiter.c,v 1.1.1.1 1999/07/27 21:50:27 mike Exp $ */
/*
* Copyright (c) 1991-1996 Sam Leffler
diff --git a/contrib/pds/tif_pdsdirread.c b/contrib/pds/tif_pdsdirread.c
index 37b5d0f5..dfcd009d 100644
--- a/contrib/pds/tif_pdsdirread.c
+++ b/contrib/pds/tif_pdsdirread.c
@@ -1,4 +1,4 @@
-/* $Header: /usr/local/cvs/internal/libtiff/contrib/pds/tif_pdsdirread.c,v 1.1.1.1 1999/07/27 21:50:27 mike Exp $ */
+/* $Header: /cvsroot/osrs/libtiff/contrib/pds/tif_pdsdirread.c,v 1.1.1.1 1999/07/27 21:50:27 mike Exp $ */
/*
* Copyright (c) 1988-1996 Sam Leffler
diff --git a/contrib/pds/tif_pdsdirwrite.c b/contrib/pds/tif_pdsdirwrite.c
index 6b537515..f982c426 100644
--- a/contrib/pds/tif_pdsdirwrite.c
+++ b/contrib/pds/tif_pdsdirwrite.c
@@ -1,4 +1,4 @@
-/* $Header: /usr/local/cvs/internal/libtiff/contrib/pds/tif_pdsdirwrite.c,v 1.1.1.1 1999/07/27 21:50:27 mike Exp $ */
+/* $Header: /cvsroot/osrs/libtiff/contrib/pds/tif_pdsdirwrite.c,v 1.1.1.1 1999/07/27 21:50:27 mike Exp $ */
/* When writing data to TIFF files, it is often useful to store application-
specific data in a private TIFF directory so that the tags don't need to
diff --git a/contrib/ras/CVS/Entries b/contrib/ras/CVS/Entries
deleted file mode 100644
index 731047ff..00000000
--- a/contrib/ras/CVS/Entries
+++ /dev/null
@@ -1,4 +0,0 @@
-/README/1.1.1.1/Tue Jul 27 21:50:27 1999//
-/ras2tif.c/1.1.1.1/Tue Jul 27 21:50:27 1999//
-/tif2ras.c/1.1.1.1/Tue Jul 27 21:50:27 1999//
-D
diff --git a/contrib/ras/CVS/Repository b/contrib/ras/CVS/Repository
deleted file mode 100644
index b4f81c23..00000000
--- a/contrib/ras/CVS/Repository
+++ /dev/null
@@ -1 +0,0 @@
-/usr/local/cvs/internal/libtiff/contrib/ras
diff --git a/contrib/ras/CVS/Root b/contrib/ras/CVS/Root
deleted file mode 100644
index 8dff0f68..00000000
--- a/contrib/ras/CVS/Root
+++ /dev/null
@@ -1 +0,0 @@
-/usr/local/cvs
diff --git a/contrib/tags/Makefile.gcc b/contrib/tags/Makefile.gcc
new file mode 100644
index 00000000..eeceb750
--- /dev/null
+++ b/contrib/tags/Makefile.gcc
@@ -0,0 +1,56 @@
+# Makefile for XLIBTIFF
+#
+# Written by: Niles Ritter
+#
+# This Makefile is for use with gcc (2.2.2 or later)
+#
+DESTDIR=.
+#
+AR = /usr/bin/ar
+AROPTS = rc
+RANLIB = /usr/bin/ranlib
+NULL=
+
+TIFFLIB=../../libtiff
+PORT=../..
+
+IPATH= -I. -I${TIFFLIB} -I${PORT}
+CONF_LIBRARY=\
+ ${NULL}
+CC= gcc
+COPTS= -g
+CFLAGS= ${COPTS} ${IPATH} ${CONF_LIBRARY}
+#
+LIBS= ./libxtiff.a ${TIFFLIB}/libtiff.a -lm
+
+OBJS= \
+ xtif_dir.o \
+ maketif.o \
+ listtif.o \
+ ${NULL}
+
+PROGS= maketif listtif
+LIBXTIFF= libxtiff.a
+ALL= ${LIBXTIFF} ${PROGS}
+
+all: ${ALL}
+
+library: ${LIBXTIFF}
+
+test: ${PROGS}
+ ./maketif
+ ./listtif
+
+maketif: maketif.o libxtiff.a
+ ${CC} ${COPTS} maketif.o ${LIBS} -o maketif
+
+listtif: listtif.o libxtiff.a
+ ${CC} ${COPTS} listtif.o ${LIBS} -o listtif
+
+libxtiff.a: xtif_dir.o
+ ${AR} ${AROPTS} libxtiff.a xtif_dir.o
+ ${RANLIB} libxtiff.a
+
+clean:
+ rm -f ${ALL} ${OBJS} core a.out newtif.tif
+
diff --git a/contrib/tags/Makefile.mpw b/contrib/tags/Makefile.mpw
new file mode 100644
index 00000000..92f506f3
--- /dev/null
+++ b/contrib/tags/Makefile.mpw
@@ -0,0 +1,67 @@
+#***********************************************************************
+#
+# MPW build file for example LIBXTIFF utilities
+#
+# written by Niles D. Ritter.
+#
+CC = c
+AR = lib -o
+RM = delete -y
+LN = duplicate -y
+
+#debug option
+#DEBUG= -sym full
+DEBUG=
+
+# data/code model options
+#MODEL=
+MODEL= -model far
+
+TIFFLIB = :::libtiff:
+
+LINK.c = Link {LDFLAGS}
+.o Ä .c
+ {CC} {DEBUG} {CFLAGS} {CPPFLAGS} {Default}.c -o {Default}.o
+LDFLAGS = {DEBUG} {MODEL} -c 'MPS ' -t MPST -w
+CFLAGS = {MODEL}
+CPPFLAGS = -I {TIFFLIB}
+OBJS = maketif.o listtif.o xtif_dir.o
+CLEANOBJS = maketif.o listtif.o xtif_dir.o
+CLEANOTHER = newtif.tif
+CLEANINC =
+LIBS = {TIFFLIB}libtiff.o ¶
+ libxtiff.o ¶
+ "{CLibraries}"StdClib.o ¶
+ "{Libraries}"Stubs.o ¶
+ "{Libraries}"Runtime.o ¶
+ "{Libraries}"Interface.o
+
+PROGS= maketif listtif
+LIBXTIFF= libxtiff.o
+ALL= {LIBXTIFF} {PROGS}
+
+all Ä {ALL}
+
+library Ä {LIBXTIFF}
+
+test Ä {PROGS}
+ maketif
+ listtif
+
+compile Ä {OBJS}
+
+maketif Ä maketif.o libxtiff.o
+ {LINK.c} -o maketif maketif.o {LIBS}
+
+listtif Ä listtif.o libxtiff.o
+ {LINK.c} -o listtif listtif.o {LIBS}
+
+libxtiff.o Ä xtif_dir.o
+ lib -o libxtiff.o xtif_dir.o
+
+clean Ä
+ {RM} {CLEANOBJS} || set status 0
+ {RM} {LIBXTIFF} || set status 0
+ {RM} {PROGS} || set status 0
+ {RM} Å.tif || set status 0
+
diff --git a/contrib/tags/README b/contrib/tags/README
new file mode 100644
index 00000000..2d096100
--- /dev/null
+++ b/contrib/tags/README
@@ -0,0 +1,116 @@
+
+Client module for adding to LIBTIFF tagset
+-------------------------------------------
+ Author: Niles Ritter
+
+
+In the past, users of the "libtiff" package had to modify the
+source code of the library if they required additional private tags
+or codes not recognized by libtiff. Thus, whenever
+a new revision of libtiff came out the client would have to
+perform modifications to six or seven different files to re-install
+their tags.
+
+The latest versions of libtiff now provide client software new routines,
+giving them the opportunity to install private extensions at runtime,
+rather than compile-time. This means that the client may encapsulate
+all of their private tags into a separate module, which need only
+be recompiled when new versions of libtiff are released; no manual
+editing of files is required.
+
+How it works
+------------
+
+The mechanism for overriding the tag access has been enabled with
+a single new routine, which has the following calling sequence:
+
+ TIFFExtendProc old_extender;
+
+ old_extender = TIFFSetTagExtender(tag_extender);
+
+which must be called prior to opening or creating TIFF files.
+
+This routine sets a static pointer to the user-specified function
+<tag_extender>, which in turn is called by TIFFDefaultDirectory(),
+just after the usual TIFFSetField() and TIFFGetField() methods
+are defined, and just before the compression tag is set. It also
+returns a pointer to the previously-defined value of the tag-extender,
+so that multiple clients may be installed.
+
+The TIFFExtendProc method that you define should be used to override
+the TIFF file's "vsetfield" and "vgetfield" methods, so that you
+can trap your new, private tags, and install their values into
+a private directory structure. For your convienience, a new pointer
+has also been added to the "TIFF" file structure:
+
+ tidata_t tif_clientdir; /* client TIFF directory */
+
+into which you may install whatever private directory structures you like.
+You should also override the tag-printing method from within your
+"vsetfield" method, to permit the symbolic printing of your new tags.
+
+
+Example Client Code:
+--------------------
+
+An example module has been provided as a template for installing
+your own tags into a client tag extender. The module is called
+"xtif_dir.c", and defines all of the interface routines, tag field
+access, tag printing, etc. for most purpose.
+
+To see how the client module operates, there are three "fake"
+tags currently installed. If you use the existing makefile you can
+build them with:
+
+ make all -f Makefile.gcc !or Makefile.mpw
+ maketif
+ listtif
+
+This will build two example programs called "maketif" and "listtif"
+and then run them. These programs do nothing more than create a small
+file called "newtif.tif", install the fake tags, and then list them out
+using TIFFPrintDirectory().
+
+Installing Private Tags
+-----------------------
+
+To use this module for installing your own tags, edit each of the files
+
+ xtif_dir.c
+ xtiffio.h
+ xtiffiop.h
+
+and search for the string "XXX". At these locations the comments
+will direct you how to install your own tag values, define their
+types, etc. Three examples tags are currently installed, demonstrating
+how to implement multi-valued tags, single-valued tags, and ASCII tags.
+The examples are not valid, registered tags, so you must replace them with
+your own.
+
+To test the routines, also edit the test programs "maketif.c" and
+"listtif.c" and replace the portions of the code that set the
+private tag values and list them.
+
+Once you have edited these files, you may build the client module
+with the Makefile provided, and run the test programs.
+
+To use these files in your own code, the "xtif_dir.c" module defines
+replacement routines for the standard "TIFFOpen()" "TIFFFdOpen",
+and "TIFFClose()" routines, called XTIFFOpen, XTIFFFdOpen and XTIFFClose.
+You must use these routines in order to have the extended tag handlers
+installed. Once installed, the standard TIFFGetField() and TIFFSetField
+routines may be used as before.
+
+Adding Extended Tags to "tools"
+-------------------------------
+To create an extended-tag savvy "tiffinfo" program or other utility, you may
+simply recompile and link the tools to your "libxtiff" library, adding
+
+ -DTIFFOpen=XTIFFOpen -DTIFFClose=XTIFFClose -DTIFFFdOpen=XTIFFFdOpen
+
+to the compile statement.
+
+Bugs, Comments Etc:
+------------------
+ Send all reports and suggestions to ndr@tazboy.jpl.nasa.gov
+ (Niles Ritter).
diff --git a/contrib/tags/listtif.c b/contrib/tags/listtif.c
new file mode 100644
index 00000000..2ea12cea
--- /dev/null
+++ b/contrib/tags/listtif.c
@@ -0,0 +1,32 @@
+/*
+ * listtif.c -- lists a tiff file.
+ */
+
+#include "xtiffio.h"
+#include <stdlib.h>
+
+void main(int argc,char *argv[])
+{
+ char *fname="newtif.tif";
+ int flags;
+
+ TIFF *tif=(TIFF*)0; /* TIFF-level descriptor */
+
+ if (argc>1) fname=argv[1];
+
+ tif=XTIFFOpen(fname,"r");
+ if (!tif) goto failure;
+
+ /* We want the double array listed */
+ flags = TIFFPRINT_MYMULTIDOUBLES;
+
+ TIFFPrintDirectory(tif,stdout,flags);
+ XTIFFClose(tif);
+ exit (0);
+
+failure:
+ printf("failure in listtif\n");
+ if (tif) XTIFFClose(tif);
+ exit (-1);
+}
+
diff --git a/contrib/tags/maketif.c b/contrib/tags/maketif.c
new file mode 100644
index 00000000..aad6f153
--- /dev/null
+++ b/contrib/tags/maketif.c
@@ -0,0 +1,70 @@
+/*
+ * maketif.c -- creates a little TIFF file, with
+ * the XTIFF extended tiff example tags.
+ */
+
+#include <stdlib.h>
+#include "xtiffio.h"
+
+
+void SetUpTIFFDirectory(TIFF *tif);
+void WriteImage(TIFF *tif);
+
+#define WIDTH 20
+#define HEIGHT 20
+
+void main()
+{
+ TIFF *tif=(TIFF*)0; /* TIFF-level descriptor */
+
+ tif=XTIFFOpen("newtif.tif","w");
+ if (!tif) goto failure;
+
+ SetUpTIFFDirectory(tif);
+ WriteImage(tif);
+
+ XTIFFClose(tif);
+ exit (0);
+
+failure:
+ printf("failure in maketif\n");
+ if (tif) XTIFFClose(tif);
+ exit (-1);
+}
+
+
+void SetUpTIFFDirectory(TIFF *tif)
+{
+ double mymulti[6]={0.0,1.0,2.0, 3.1415926, 5.0,1.0};
+ uint32 mysingle=3456;
+ char *ascii="This file was produced by Steven Spielberg. NOT";
+
+ TIFFSetField(tif,TIFFTAG_IMAGEWIDTH,WIDTH);
+ TIFFSetField(tif,TIFFTAG_IMAGELENGTH,HEIGHT);
+ TIFFSetField(tif,TIFFTAG_COMPRESSION,COMPRESSION_NONE);
+ TIFFSetField(tif,TIFFTAG_PHOTOMETRIC,PHOTOMETRIC_MINISBLACK);
+ TIFFSetField(tif,TIFFTAG_PLANARCONFIG,PLANARCONFIG_CONTIG);
+ TIFFSetField(tif,TIFFTAG_BITSPERSAMPLE,8);
+ TIFFSetField(tif,TIFFTAG_ROWSPERSTRIP,20);
+
+ /* Install the extended TIFF tag examples */
+ TIFFSetField(tif,TIFFTAG_EXAMPLE_MULTI,6,mymulti);
+ TIFFSetField(tif,TIFFTAG_EXAMPLE_SINGLE,mysingle);
+ TIFFSetField(tif,TIFFTAG_EXAMPLE_ASCII,ascii);
+}
+
+
+void WriteImage(TIFF *tif)
+{
+ int i;
+ char buffer[WIDTH];
+
+ memset(buffer,0,sizeof(buffer));
+ for (i=0;i<HEIGHT;i++)
+ if (!TIFFWriteScanline(tif, buffer, i, 0))
+ TIFFError("WriteImage","failure in WriteScanline\n");
+}
+
+
+
+
diff --git a/contrib/tags/xtif_dir.c b/contrib/tags/xtif_dir.c
new file mode 100644
index 00000000..c9137aac
--- /dev/null
+++ b/contrib/tags/xtif_dir.c
@@ -0,0 +1,343 @@
+/*
+ * xtif_dir.c
+ *
+ * Extended TIFF Directory Tag Support.
+ *
+ * You may use this file as a template to add your own
+ * extended tags to the library. Only the parts of the code
+ * marked with "XXX" require modification. Three example tags
+ * are shown; you should replace them with your own.
+ *
+ * Author: Niles D. Ritter
+ */
+
+#include "xtiffiop.h"
+#include <stdio.h>
+
+/* Tiff info structure.
+ *
+ * Entry format:
+ * { TAGNUMBER, ReadCount, WriteCount, DataType, FIELDNUM,
+ * OkToChange, PassDirCountOnSet, AsciiName }
+ *
+ * For ReadCount, WriteCount, -1 = unknown; used for mult-valued
+ * tags and ASCII.
+ */
+
+static const TIFFFieldInfo xtiffFieldInfo[] = {
+
+ /* XXX Replace these example tags with your own extended tags */
+ { TIFFTAG_EXAMPLE_MULTI, -1,-1, TIFF_DOUBLE, FIELD_EXAMPLE_MULTI,
+ TRUE, TRUE, "MyMultivaluedTag" },
+ { TIFFTAG_EXAMPLE_SINGLE, 1, 1, TIFF_LONG, FIELD_EXAMPLE_SINGLE,
+ TRUE, FALSE, "MySingleLongTag" },
+ { TIFFTAG_EXAMPLE_ASCII, -1,-1, TIFF_ASCII, FIELD_EXAMPLE_ASCII,
+ TRUE, FALSE, "MyAsciiTag" },
+};
+#define N(a) (sizeof (a) / sizeof (a[0]))
+
+
+static void
+_XTIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
+{
+ xtiff *xt = XTIFFDIR(tif);
+ XTIFFDirectory *xd = &xt->xtif_dir;
+ int i,num;
+
+ /* call the inherited method */
+ if (PARENT(xt,printdir))
+ (PARENT(xt,printdir))(tif,fd,flags);
+
+ /* XXX Add field printing here. Replace the three example
+ * tags implemented below with your own.
+ */
+
+ fprintf(fd,"--My Example Tags--\n");
+
+ /* Our first example tag may have a lot of values, so we
+ * will only print them out if the TIFFPRINT_MYMULTIDOUBLES
+ * flag is passed into the print method.
+ */
+ if (TIFFFieldSet(tif,FIELD_EXAMPLE_MULTI))
+ {
+ fprintf(fd, " My Multi-Valued Doubles:");
+ if (flags & TIFFPRINT_MYMULTIDOUBLES)
+ {
+ double *value = xd->xd_example_multi;
+
+ num = xd->xd_num_multi;
+ fprintf(fd,"(");
+ for (i=0;i<num;i++) fprintf(fd, " %lg", *value++);
+ fprintf(fd,")\n");
+ } else
+ fprintf(fd, "(present)\n");
+ }
+
+ if (TIFFFieldSet(tif,FIELD_EXAMPLE_SINGLE))
+ {
+ fprintf(fd, " My Single Long Tag: %lu\n", xd->xd_example_single);
+ }
+
+ if (TIFFFieldSet(tif,FIELD_EXAMPLE_ASCII))
+ {
+ _TIFFprintAsciiTag(fd,"My ASCII Tag",
+ xd->xd_example_ascii);
+ }
+}
+
+static int
+_XTIFFVSetField(TIFF* tif, ttag_t tag, va_list ap)
+{
+ xtiff *xt = XTIFFDIR(tif);
+ XTIFFDirectory* xd = &xt->xtif_dir;
+ int status = 1;
+ uint32 v32=0;
+ int i=0, v=0;
+ va_list ap1 = ap;
+
+ /* va_start is called by the calling routine */
+
+ switch (tag) {
+ /*
+ * XXX put your extended tags here; replace the implemented
+ * example tags with your own.
+ */
+ case TIFFTAG_EXAMPLE_MULTI:
+ /* multi-valued tags need to store the count as well */
+ xd->xd_num_multi = (uint16) va_arg(ap, int);
+ _TIFFsetDoubleArray(&xd->xd_example_multi, va_arg(ap, double*),
+ (long) xd->xd_num_multi);
+ break;
+ case TIFFTAG_EXAMPLE_SINGLE:
+ xd->xd_example_single = va_arg(ap, uint32);
+ break;
+ case TIFFTAG_EXAMPLE_ASCII:
+ _TIFFsetString(&xd->xd_example_ascii, va_arg(ap, char*));
+ break;
+ default:
+ /* call the inherited method */
+ return (PARENT(xt,vsetfield))(tif,tag,ap);
+ break;
+ }
+ if (status) {
+ /* we have to override the print method here,
+ * after the compression tags have gotten to it.
+ * This makes sense because the only time we would
+ * need the extended print method is if an extended
+ * tag is set by the reader.
+ */
+ if (!(xt->xtif_flags & XTIFFP_PRINT))
+ {
+ PARENT(xt,printdir) = TIFFMEMBER(tif,printdir);
+ TIFFMEMBER(tif,printdir) = _XTIFFPrintDirectory;
+ xt->xtif_flags |= XTIFFP_PRINT;
+ }
+ TIFFSetFieldBit(tif, _TIFFFieldWithTag(tif, tag)->field_bit);
+ tif->tif_flags |= TIFF_DIRTYDIRECT;
+ }
+ va_end(ap);
+ return (status);
+badvalue:
+ TIFFError(tif->tif_name, "%d: Bad value for \"%s\"", v,
+ _TIFFFieldWithTag(tif, tag)->field_name);
+ va_end(ap);
+ return (0);
+badvalue32:
+ TIFFError(tif->tif_name, "%ld: Bad value for \"%s\"", v32,
+ _TIFFFieldWithTag(tif, tag)->field_name);
+ va_end(ap);
+ return (0);
+}
+
+
+static int
+_XTIFFVGetField(TIFF* tif, ttag_t tag, va_list ap)
+{
+ xtiff *xt = XTIFFDIR(tif);
+ XTIFFDirectory* xd = &xt->xtif_dir;
+
+ switch (tag) {
+ /*
+ * XXX put your extended tags here; replace the implemented
+ * example tags with your own.
+ */
+ case TIFFTAG_EXAMPLE_MULTI:
+ *va_arg(ap, uint16*) = xd->xd_num_multi;
+ *va_arg(ap, double**) = xd->xd_example_multi;
+ break;
+ case TIFFTAG_EXAMPLE_ASCII:
+ *va_arg(ap, char**) = xd->xd_example_ascii;
+ break;
+ case TIFFTAG_EXAMPLE_SINGLE:
+ *va_arg(ap, uint32*) = xd->xd_example_single;
+ break;
+ default:
+ /* return inherited method */
+ return (PARENT(xt,vgetfield))(tif,tag,ap);
+ break;
+ }
+ return (1);
+}
+
+#define CleanupField(member) { \
+ if (xd->member) { \
+ _TIFFfree(xd->member); \
+ xd->member = 0; \
+ } \
+}
+/*
+ * Release storage associated with a directory.
+ */
+static void
+_XTIFFFreeDirectory(xtiff* xt)
+{
+ XTIFFDirectory* xd = &xt->xtif_dir;
+
+ /*
+ * XXX - Purge all Your allocated memory except
+ * for the xtiff directory itself. This includes
+ * all fields that require a _TIFFsetXXX call in
+ * _XTIFFVSetField().
+ */
+
+ CleanupField(xd_example_multi);
+ CleanupField(xd_example_ascii);
+
+}
+#undef CleanupField
+
+static void _XTIFFLocalDefaultDirectory(TIFF *tif)
+{
+ xtiff *xt = XTIFFDIR(tif);
+ XTIFFDirectory* xd = &xt->xtif_dir;
+
+ /* Install the extended Tag field info */
+ _TIFFMergeFieldInfo(tif, xtiffFieldInfo, N(xtiffFieldInfo));
+
+ /*
+ * free up any dynamically allocated arrays
+ * before the new directory is read in.
+ */
+
+ _XTIFFFreeDirectory(xt);
+ _TIFFmemset(xt,0,sizeof(xtiff));
+
+ /* Override the tag access methods */
+
+ PARENT(xt,vsetfield) = TIFFMEMBER(tif,vsetfield);
+ TIFFMEMBER(tif,vsetfield) = _XTIFFVSetField;
+ PARENT(xt,vgetfield) = TIFFMEMBER(tif,vgetfield);
+ TIFFMEMBER(tif,vgetfield) = _XTIFFVGetField;
+
+ /*
+ * XXX Set up any default values here.
+ */
+
+ xd->xd_example_single = 234;
+}
+
+
+
+/**********************************************************************
+ * Nothing below this line should need to be changed.
+ **********************************************************************/
+
+static TIFFExtendProc _ParentExtender;
+
+/*
+ * This is the callback procedure, and is
+ * called by the DefaultDirectory method
+ * every time a new TIFF directory is opened.
+ */
+
+static void
+_XTIFFDefaultDirectory(TIFF *tif)
+{
+ xtiff *xt;
+
+ /* Allocate Directory Structure if first time, and install it */
+ if (!(tif->tif_flags & XTIFF_INITIALIZED))
+ {
+ xt = _TIFFmalloc(sizeof(xtiff));
+ if (!xt)
+ {
+ /* handle memory allocation failure here ! */
+ return;
+ }
+ _TIFFmemset(xt,0,sizeof(xtiff));
+ /*
+ * Install into TIFF structure.
+ */
+ TIFFMEMBER(tif,clientdir) = (tidata_t)xt;
+ tif->tif_flags |= XTIFF_INITIALIZED; /* dont do this again! */
+ }
+
+ /* set up our own defaults */
+ _XTIFFLocalDefaultDirectory(tif);
+
+ /* Since an XTIFF client module may have overridden
+ * the default directory method, we call it now to
+ * allow it to set up the rest of its own methods.
+ */
+
+ if (_ParentExtender)
+ (*_ParentExtender)(tif);
+
+}
+
+/*
+ * XTIFF Initializer -- sets up the callback
+ * procedure for the TIFF module.
+ */
+
+static
+void _XTIFFInitialize(void)
+{
+ static first_time=1;
+
+ if (! first_time) return; /* Been there. Done that. */
+ first_time = 0;
+
+ /* Grab the inherited method and install */
+ _ParentExtender = TIFFSetTagExtender(_XTIFFDefaultDirectory);
+}
+
+
+/*
+ * Public File I/O Routines.
+ */
+TIFF*
+XTIFFOpen(const char* name, const char* mode)
+{
+ /* Set up the callback */
+ _XTIFFInitialize();
+
+ /* Open the file; the callback will set everything up
+ */
+ return TIFFOpen(name, mode);
+}
+
+TIFF*
+XTIFFFdOpen(int fd, const char* name, const char* mode)
+{
+ /* Set up the callback */
+ _XTIFFInitialize();
+
+ /* Open the file; the callback will set everything up
+ */
+ return TIFFFdOpen(fd, name, mode);
+}
+
+
+void
+XTIFFClose(TIFF *tif)
+{
+ xtiff *xt = XTIFFDIR(tif);
+
+ /* call inherited function first */
+ TIFFClose(tif);
+
+ /* Free up extended allocated memory */
+ _XTIFFFreeDirectory(xt);
+ _TIFFfree(xt);
+}
diff --git a/contrib/tags/xtiffio.h b/contrib/tags/xtiffio.h
new file mode 100644
index 00000000..2aea724d
--- /dev/null
+++ b/contrib/tags/xtiffio.h
@@ -0,0 +1,52 @@
+/*
+ * xtiffio.h -- Public interface to Extended TIFF tags
+ *
+ * This is a template for defining a client module
+ * which supports tag extensions to the standard libtiff
+ * set. Only portions of the code marked "XXX" need to
+ * be changed to support your tag set.
+ *
+ * written by: Niles D. Ritter
+ */
+
+#ifndef __xtiffio_h
+#define __xtiffio_h
+
+#include "tiffio.h"
+
+/*
+ * XXX Define your private Tag names and values here
+ */
+
+/* These tags are not valid, but are provided for example */
+#define TIFFTAG_EXAMPLE_MULTI 61234
+#define TIFFTAG_EXAMPLE_SINGLE 61235
+#define TIFFTAG_EXAMPLE_ASCII 61236
+
+/*
+ * XXX Define Printing method flags. These
+ * flags may be passed in to TIFFPrintDirectory() to
+ * indicate that those particular field values should
+ * be printed out in full, rather than just an indicator
+ * of whether they are present or not.
+ */
+#define TIFFPRINT_MYMULTIDOUBLES 0x80000000
+
+/**********************************************************************
+ * Nothing below this line should need to be changed by the user.
+ **********************************************************************/
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+extern TIFF* XTIFFOpen(const char* name, const char* mode);
+extern TIFF* XTIFFFdOpen(int fd, const char* name, const char* mode);
+extern void XTIFFClose(TIFF *tif);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif /* __xtiffio_h */
+
diff --git a/contrib/tags/xtiffiop.h b/contrib/tags/xtiffiop.h
new file mode 100644
index 00000000..0d3f1f2c
--- /dev/null
+++ b/contrib/tags/xtiffiop.h
@@ -0,0 +1,65 @@
+/*
+ * Private Extended TIFF library interface.
+ *
+ * uses private LIBTIFF interface.
+ *
+ * The portions of this module marked "XXX" should be
+ * modified to support your tags instead.
+ *
+ * written by: Niles D. Ritter
+ *
+ */
+
+#ifndef __xtiffiop_h
+#define __xtiffiop_h
+
+#include "tiffiop.h"
+#include "xtiffio.h"
+
+/**********************************************************************
+ * User Configuration
+ **********************************************************************/
+
+/* XXX - Define number of your extended tags here */
+#define NUM_XFIELD 3
+#define XFIELD_BASE (FIELD_LAST-NUM_XFIELD)
+
+/* XXX - Define your Tag Fields here */
+#define FIELD_EXAMPLE_MULTI (XFIELD_BASE+0)
+#define FIELD_EXAMPLE_SINGLE (XFIELD_BASE+1)
+#define FIELD_EXAMPLE_ASCII (XFIELD_BASE+2)
+
+
+/* XXX - Define Private directory tag structure here */
+struct XTIFFDirectory {
+ uint16 xd_num_multi; /* dir-count for the multi tag */
+ double* xd_example_multi;
+ uint32 xd_example_single;
+ char* xd_example_ascii;
+};
+typedef struct XTIFFDirectory XTIFFDirectory;
+
+/**********************************************************************
+ * Nothing below this line should need to be changed by the user.
+ **********************************************************************/
+
+struct xtiff {
+ TIFF *xtif_tif; /* parent TIFF pointer */
+ uint32 xtif_flags;
+#define XTIFFP_PRINT 0x00000001
+ XTIFFDirectory xtif_dir; /* internal rep of current directory */
+ TIFFVSetMethod xtif_vsetfield; /* inherited tag set routine */
+ TIFFVGetMethod xtif_vgetfield; /* inherited tag get routine */
+ TIFFPrintMethod xtif_printdir; /* inherited dir print method */
+};
+typedef struct xtiff xtiff;
+
+
+#define PARENT(xt,pmember) ((xt)->xtif_ ## pmember)
+#define TIFFMEMBER(tf,pmember) ((tf)->tif_ ## pmember)
+#define XTIFFDIR(tif) ((xtiff *)TIFFMEMBER(tif,clientdir))
+
+/* Extended TIFF flags */
+#define XTIFF_INITIALIZED 0x80000000
+
+#endif /* __xtiffiop_h */
diff --git a/contrib/vms/CVS/Entries b/contrib/vms/CVS/Entries
deleted file mode 100644
index 540f0771..00000000
--- a/contrib/vms/CVS/Entries
+++ /dev/null
@@ -1,2 +0,0 @@
-D/libtiff////
-D/tools////
diff --git a/contrib/vms/CVS/Repository b/contrib/vms/CVS/Repository
deleted file mode 100644
index ccd0675e..00000000
--- a/contrib/vms/CVS/Repository
+++ /dev/null
@@ -1 +0,0 @@
-/usr/local/cvs/internal/libtiff/contrib/vms
diff --git a/contrib/vms/CVS/Root b/contrib/vms/CVS/Root
deleted file mode 100644
index 8dff0f68..00000000
--- a/contrib/vms/CVS/Root
+++ /dev/null
@@ -1 +0,0 @@
-/usr/local/cvs
diff --git a/contrib/vms/libtiff/CVS/Entries b/contrib/vms/libtiff/CVS/Entries
deleted file mode 100644
index 4a16a0fa..00000000
--- a/contrib/vms/libtiff/CVS/Entries
+++ /dev/null
@@ -1,6 +0,0 @@
-/makevms.com/1.1.1.1/Tue Jul 27 21:50:27 1999//
-/tiff.opt/1.1.1.1/Tue Jul 27 21:50:27 1999//
-/tiffshraxp.opt/1.1.1.1/Tue Jul 27 21:50:27 1999//
-/tiffshrvax.opt/1.1.1.1/Tue Jul 27 21:50:27 1999//
-/tiffvec.mar/1.1.1.1/Tue Jul 27 21:50:27 1999//
-D
diff --git a/contrib/vms/libtiff/CVS/Repository b/contrib/vms/libtiff/CVS/Repository
deleted file mode 100644
index 021401ed..00000000
--- a/contrib/vms/libtiff/CVS/Repository
+++ /dev/null
@@ -1 +0,0 @@
-/usr/local/cvs/internal/libtiff/contrib/vms/libtiff
diff --git a/contrib/vms/libtiff/CVS/Root b/contrib/vms/libtiff/CVS/Root
deleted file mode 100644
index 8dff0f68..00000000
--- a/contrib/vms/libtiff/CVS/Root
+++ /dev/null
@@ -1 +0,0 @@
-/usr/local/cvs
diff --git a/contrib/vms/tools/CVS/Entries b/contrib/vms/tools/CVS/Entries
deleted file mode 100644
index f84e7ebd..00000000
--- a/contrib/vms/tools/CVS/Entries
+++ /dev/null
@@ -1,2 +0,0 @@
-/makevms.com/1.1.1.1/Tue Jul 27 21:50:27 1999//
-D
diff --git a/contrib/vms/tools/CVS/Repository b/contrib/vms/tools/CVS/Repository
deleted file mode 100644
index 2f2c65ec..00000000
--- a/contrib/vms/tools/CVS/Repository
+++ /dev/null
@@ -1 +0,0 @@
-/usr/local/cvs/internal/libtiff/contrib/vms/tools
diff --git a/contrib/vms/tools/CVS/Root b/contrib/vms/tools/CVS/Root
deleted file mode 100644
index 8dff0f68..00000000
--- a/contrib/vms/tools/CVS/Root
+++ /dev/null
@@ -1 +0,0 @@
-/usr/local/cvs
diff --git a/contrib/win32/CVS/Entries b/contrib/win32/CVS/Entries
deleted file mode 100644
index e209d194..00000000
--- a/contrib/win32/CVS/Entries
+++ /dev/null
@@ -1,4 +0,0 @@
-/README/1.1.1.1/Tue Jul 27 21:50:27 1999//
-/dllshell.c/1.1.1.1/Tue Jul 27 21:50:27 1999//
-/libtiff.def/1.1.1.1/Tue Jul 27 21:50:27 1999//
-D
diff --git a/contrib/win32/CVS/Repository b/contrib/win32/CVS/Repository
deleted file mode 100644
index c07e506e..00000000
--- a/contrib/win32/CVS/Repository
+++ /dev/null
@@ -1 +0,0 @@
-/usr/local/cvs/internal/libtiff/contrib/win32
diff --git a/contrib/win32/CVS/Root b/contrib/win32/CVS/Root
deleted file mode 100644
index 8dff0f68..00000000
--- a/contrib/win32/CVS/Root
+++ /dev/null
@@ -1 +0,0 @@
-/usr/local/cvs
diff --git a/contrib/win95/CVS/Entries b/contrib/win95/CVS/Entries
deleted file mode 100644
index cffcfd66..00000000
--- a/contrib/win95/CVS/Entries
+++ /dev/null
@@ -1,4 +0,0 @@
-/Makefile.w95/1.1.1.1/Tue Jul 27 21:50:27 1999//
-/README/1.1.1.1/Tue Jul 27 21:50:27 1999//
-/tiff2dib.c/1.1.1.1/Tue Jul 27 21:50:27 1999//
-D
diff --git a/contrib/win95/CVS/Repository b/contrib/win95/CVS/Repository
deleted file mode 100644
index 5f4497be..00000000
--- a/contrib/win95/CVS/Repository
+++ /dev/null
@@ -1 +0,0 @@
-/usr/local/cvs/internal/libtiff/contrib/win95
diff --git a/contrib/win95/CVS/Root b/contrib/win95/CVS/Root
deleted file mode 100644
index 8dff0f68..00000000
--- a/contrib/win95/CVS/Root
+++ /dev/null
@@ -1 +0,0 @@
-/usr/local/cvs
diff --git a/contrib/winnt/CVS/Entries b/contrib/winnt/CVS/Entries
deleted file mode 100644
index 49cb459b..00000000
--- a/contrib/winnt/CVS/Entries
+++ /dev/null
@@ -1,8 +0,0 @@
-/README/1.1.1.1/Tue Jul 27 21:50:27 1999//
-/README.console/1.1.1.1/Tue Jul 27 21:50:27 1999//
-/fax3sm.c/1.1.1.1/Tue Jul 27 21:50:27 1999//
-/libtiff.def/1.1.1.1/Tue Jul 27 21:50:27 1999//
-/libtiff.mak/1.1.1.1/Tue Jul 27 21:50:27 1999//
-/libtiff.vcp/1.1.1.1/Tue Jul 27 21:50:27 1999//
-/version.h/1.1.1.1/Tue Jul 27 21:50:27 1999//
-D
diff --git a/contrib/winnt/CVS/Repository b/contrib/winnt/CVS/Repository
deleted file mode 100644
index fcc202e5..00000000
--- a/contrib/winnt/CVS/Repository
+++ /dev/null
@@ -1 +0,0 @@
-/usr/local/cvs/internal/libtiff/contrib/winnt
diff --git a/contrib/winnt/CVS/Root b/contrib/winnt/CVS/Root
deleted file mode 100644
index 8dff0f68..00000000
--- a/contrib/winnt/CVS/Root
+++ /dev/null
@@ -1 +0,0 @@
-/usr/local/cvs