Changeset 14006

Show
Ignore:
Timestamp:
03/14/08 09:42:25 (2 months ago)
Author:
warmerdam
Message:

refresh from upstream

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/gdal/frmts/gtiff/libtiff/tif_aux.c

    r11957 r14006  
    1 /* $Id: tif_aux.c,v 1.22 2007/07/19 13:11:59 dron Exp $ */ 
     1/* $Id: tif_aux.c,v 1.23 2008/01/01 15:41:22 fwarmerdam Exp $ */ 
    22 
    33/* 
     
    7070                return 0; 
    7171 
    72         n = 1<<td->td_bitspersample; 
     72        n = ((tmsize_t)1)<<td->td_bitspersample; 
    7373        nbytes = n * sizeof (uint16); 
    7474        if (!(tf[0] = (uint16 *)_TIFFmalloc(nbytes))) 
  • trunk/gdal/frmts/gtiff/libtiff/tif_dirinfo.c

    r12610 r14006  
    9999        { TIFFTAG_INKSET, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "InkSet", NULL }, 
    100100        { TIFFTAG_INKNAMES, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_C16_ASCII, TIFF_SETGET_UNDEFINED, FIELD_INKNAMES, 1, 1, "InkNames", NULL }, 
    101         { TIFFTAG_NUMBEROFINKS, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "NumberOfInks", NULL }, 
     101        { TIFFTAG_NUMBEROFINKS, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "NumberOfInks", NULL }, 
    102102        { TIFFTAG_DOTRANGE, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_UINT16_PAIR, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "DotRange", NULL }, 
    103103        { TIFFTAG_TARGETPRINTER, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "TargetPrinter", NULL }, 
     
    124124        { TIFFTAG_PIXAR_IMAGEFULLWIDTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ImageFullWidth", NULL }, 
    125125        { TIFFTAG_PIXAR_IMAGEFULLLENGTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ImageFullLength", NULL }, 
    126         { TIFFTAG_PIXAR_TEXTUREFORMAT, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "TextureFormat", NULL }, 
    127         { TIFFTAG_PIXAR_WRAPMODES, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "TextureWrapModes", NULL }, 
     126        { TIFFTAG_PIXAR_TEXTUREFORMAT, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "TextureFormat", NULL }, 
     127        { TIFFTAG_PIXAR_WRAPMODES, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "TextureWrapModes", NULL }, 
    128128        { TIFFTAG_PIXAR_FOVCOT, 1, 1, TIFF_FLOAT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FieldOfViewCotangent", NULL }, 
    129129        { TIFFTAG_PIXAR_MATRIX_WORLDTOSCREEN, 16, 16, TIFF_FLOAT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "MatrixWorldToScreen", NULL }, 
  • trunk/gdal/frmts/gtiff/libtiff/tif_dirwrite.c

    r12954 r14006  
    1 /* $Id: tif_dirwrite.c,v 1.62 2007/11/23 20:49:43 fwarmerdam Exp $ */ 
     1/* $Id: tif_dirwrite.c,v 1.65 2008/01/07 15:50:02 fwarmerdam Exp $ */ 
    22 
    33/* 
     
    4646static int TIFFWriteDirectoryTagAscii(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, char* value); 
    4747static int TIFFWriteDirectoryTagUndefinedArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint8* value); 
     48#ifdef notdef 
    4849static int TIFFWriteDirectoryTagByte(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint8 value); 
     50#endif 
    4951static int TIFFWriteDirectoryTagByteArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint8* value); 
    5052static int TIFFWriteDirectoryTagBytePerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint8 value); 
     53#ifdef notdef 
    5154static int TIFFWriteDirectoryTagSbyte(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int8 value); 
     55#endif 
    5256static int TIFFWriteDirectoryTagSbyteArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int8* value); 
    5357static int TIFFWriteDirectoryTagSbytePerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int8 value); 
     
    5559static int TIFFWriteDirectoryTagShortArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint16* value); 
    5660static int TIFFWriteDirectoryTagShortPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint16 value); 
     61#ifdef notdef 
    5762static int TIFFWriteDirectoryTagSshort(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int16 value); 
     63#endif 
    5864static int TIFFWriteDirectoryTagSshortArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int16* value); 
    5965static int TIFFWriteDirectoryTagSshortPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int16 value); 
     
    6167static int TIFFWriteDirectoryTagLongArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint32* value); 
    6268static int TIFFWriteDirectoryTagLongPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 value); 
     69#ifdef notdef 
    6370static int TIFFWriteDirectoryTagSlong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int32 value); 
     71#endif 
    6472static int TIFFWriteDirectoryTagSlongArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int32* value); 
    6573static int TIFFWriteDirectoryTagSlongPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int32 value); 
     74#ifdef notdef 
    6675static int TIFFWriteDirectoryTagLong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint64 value); 
     76#endif 
    6777static int TIFFWriteDirectoryTagLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value); 
     78#ifdef notdef 
    6879static int TIFFWriteDirectoryTagSlong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int64 value); 
     80#endif 
    6981static int TIFFWriteDirectoryTagSlong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int64* value); 
    7082static int TIFFWriteDirectoryTagRational(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value); 
    7183static int TIFFWriteDirectoryTagRationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value); 
    7284static int TIFFWriteDirectoryTagSrationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value); 
     85#ifdef notdef 
    7386static int TIFFWriteDirectoryTagFloat(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, float value); 
     87#endif 
    7488static int TIFFWriteDirectoryTagFloatArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value); 
    7589static int TIFFWriteDirectoryTagFloatPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, float value); 
     90#ifdef notdef 
    7691static int TIFFWriteDirectoryTagDouble(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value); 
     92#endif 
    7793static int TIFFWriteDirectoryTagDoubleArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, double* value); 
    7894static int TIFFWriteDirectoryTagDoublePerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value); 
     
    8197static int TIFFWriteDirectoryTagShortLong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 value); 
    8298static int TIFFWriteDirectoryTagLongLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value); 
     99#ifdef notdef 
    83100static int TIFFWriteDirectoryTagShortLongLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value); 
     101#endif 
    84102static int TIFFWriteDirectoryTagColormap(TIFF* tif, uint32* ndir, TIFFDirEntry* dir); 
    85103static int TIFFWriteDirectoryTagTransferfunction(TIFF* tif, uint32* ndir, TIFFDirEntry* dir); 
     
    88106static int TIFFWriteDirectoryTagCheckedAscii(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, char* value); 
    89107static int TIFFWriteDirectoryTagCheckedUndefinedArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint8* value); 
     108#ifdef notdef 
    90109static int TIFFWriteDirectoryTagCheckedByte(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint8 value); 
     110#endif 
    91111static int TIFFWriteDirectoryTagCheckedByteArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint8* value); 
     112#ifdef notdef 
    92113static int TIFFWriteDirectoryTagCheckedSbyte(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int8 value); 
     114#endif 
    93115static int TIFFWriteDirectoryTagCheckedSbyteArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int8* value); 
    94116static int TIFFWriteDirectoryTagCheckedShort(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint16 value); 
    95117static int TIFFWriteDirectoryTagCheckedShortArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint16* value); 
     118#ifdef notdef 
    96119static int TIFFWriteDirectoryTagCheckedSshort(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int16 value); 
     120#endif 
    97121static int TIFFWriteDirectoryTagCheckedSshortArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int16* value); 
    98122static int TIFFWriteDirectoryTagCheckedLong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 value); 
    99123static int TIFFWriteDirectoryTagCheckedLongArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint32* value); 
     124#ifdef notdef 
    100125static int TIFFWriteDirectoryTagCheckedSlong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int32 value); 
     126#endif 
    101127static int TIFFWriteDirectoryTagCheckedSlongArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int32* value); 
     128#ifdef notdef 
    102129static int TIFFWriteDirectoryTagCheckedLong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint64 value); 
     130#endif 
    103131static int TIFFWriteDirectoryTagCheckedLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value); 
     132#ifdef notdef 
    104133static int TIFFWriteDirectoryTagCheckedSlong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int64 value); 
     134#endif 
    105135static int TIFFWriteDirectoryTagCheckedSlong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int64* value); 
    106136static int TIFFWriteDirectoryTagCheckedRational(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value); 
    107137static int TIFFWriteDirectoryTagCheckedRationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value); 
    108138static int TIFFWriteDirectoryTagCheckedSrationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value); 
     139#ifdef notdef 
    109140static int TIFFWriteDirectoryTagCheckedFloat(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, float value); 
     141#endif 
    110142static int TIFFWriteDirectoryTagCheckedFloatArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value); 
     143#ifdef notdef 
    111144static int TIFFWriteDirectoryTagCheckedDouble(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value); 
     145#endif 
    112146static int TIFFWriteDirectoryTagCheckedDoubleArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, double* value); 
    113147static int TIFFWriteDirectoryTagCheckedIfdArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint32* value); 
     
    835869        { 
    836870                TIFFFreeDirectory(tif); 
    837                 tif->tif_flags&=~TIFF_DIRTYDIRECT; 
     871                tif->tif_flags &= ~TIFF_DIRTYDIRECT; 
     872                tif->tif_flags &= ~TIFF_DIRTYSTRIP; 
    838873                (*tif->tif_cleanup)(tif); 
    839874                /* 
     
    903938} 
    904939 
     940#ifdef notdef 
    905941static int 
    906942TIFFWriteDirectoryTagByte(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint8 value) 
     
    913949        return(TIFFWriteDirectoryTagCheckedByte(tif,ndir,dir,tag,value)); 
    914950} 
     951#endif 
    915952 
    916953static int 
     
    951988} 
    952989 
     990#ifdef notdef 
    953991static int 
    954992TIFFWriteDirectoryTagSbyte(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int8 value) 
     
    961999        return(TIFFWriteDirectoryTagCheckedSbyte(tif,ndir,dir,tag,value)); 
    9621000} 
     1001#endif 
    9631002 
    9641003static int 
     
    10471086} 
    10481087 
     1088#ifdef notdef 
    10491089static int 
    10501090TIFFWriteDirectoryTagSshort(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int16 value) 
     
    10571097        return(TIFFWriteDirectoryTagCheckedSshort(tif,ndir,dir,tag,value)); 
    10581098} 
     1099#endif 
    10591100 
    10601101static int 
     
    11431184} 
    11441185 
     1186#ifdef notdef 
    11451187static int 
    11461188TIFFWriteDirectoryTagSlong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int32 value) 
     
    11531195        return(TIFFWriteDirectoryTagCheckedSlong(tif,ndir,dir,tag,value)); 
    11541196} 
     1197#endif 
    11551198 
    11561199static int 
     
    11911234} 
    11921235 
     1236#ifdef notdef 
    11931237static int 
    11941238TIFFWriteDirectoryTagLong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint64 value) 
     
    12011245        return(TIFFWriteDirectoryTagCheckedLong8(tif,ndir,dir,tag,value)); 
    12021246} 
     1247#endif 
    12031248 
    12041249static int 
     
    12131258} 
    12141259 
     1260#ifdef notdef 
    12151261static int 
    12161262TIFFWriteDirectoryTagSlong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int64 value) 
     
    12231269        return(TIFFWriteDirectoryTagCheckedSlong8(tif,ndir,dir,tag,value)); 
    12241270} 
     1271#endif 
    12251272 
    12261273static int 
     
    12681315} 
    12691316 
     1317#ifdef notdef 
    12701318static int TIFFWriteDirectoryTagFloat(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, float value) 
    12711319{ 
     
    12771325        return(TIFFWriteDirectoryTagCheckedFloat(tif,ndir,dir,tag,value)); 
    12781326} 
     1327#endif 
    12791328 
    12801329static int TIFFWriteDirectoryTagFloatArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value) 
     
    13131362} 
    13141363 
     1364#ifdef notdef 
    13151365static int TIFFWriteDirectoryTagDouble(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value) 
    13161366{ 
     
    13221372        return(TIFFWriteDirectoryTagCheckedDouble(tif,ndir,dir,tag,value)); 
    13231373} 
     1374#endif 
    13241375 
    13251376static int TIFFWriteDirectoryTagDoubleArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, double* value) 
     
    14531504} 
    14541505 
     1506#ifdef notdef 
    14551507static int 
    14561508TIFFWriteDirectoryTagShortLongLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value) 
     
    15141566        return(o); 
    15151567} 
    1516  
     1568#endif 
    15171569static int 
    15181570TIFFWriteDirectoryTagColormap(TIFF* tif, uint32* ndir, TIFFDirEntry* dir) 
     
    16641716} 
    16651717 
     1718#ifdef notdef 
    16661719static int 
    16671720TIFFWriteDirectoryTagCheckedByte(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint8 value) 
     
    16701723        return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_BYTE,1,1,&value)); 
    16711724} 
     1725#endif 
    16721726 
    16731727static int 
     
    16781732} 
    16791733 
     1734#ifdef notdef 
    16801735static int 
    16811736TIFFWriteDirectoryTagCheckedSbyte(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int8 value) 
     
    16841739        return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SBYTE,1,1,&value)); 
    16851740} 
     1741#endif 
    16861742 
    16871743static int 
     
    17131769} 
    17141770 
     1771#ifdef notdef 
    17151772static int 
    17161773TIFFWriteDirectoryTagCheckedSshort(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int16 value) 
     
    17231780        return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SSHORT,1,2,&m)); 
    17241781} 
     1782#endif 
    17251783 
    17261784static int 
     
    17551813} 
    17561814 
     1815#ifdef notdef 
    17571816static int 
    17581817TIFFWriteDirectoryTagCheckedSlong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int32 value) 
     
    17651824        return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SLONG,1,4,&m)); 
    17661825} 
     1826#endif 
    17671827 
    17681828static int 
     
    17761836} 
    17771837 
     1838#ifdef notdef 
    17781839static int 
    17791840TIFFWriteDirectoryTagCheckedLong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint64 value) 
     
    17871848        return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_LONG8,1,8,&m)); 
    17881849} 
     1850#endif 
    17891851 
    17901852static int 
     
    17991861} 
    18001862 
     1863#ifdef notdef 
    18011864static int 
    18021865TIFFWriteDirectoryTagCheckedSlong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int64 value) 
     
    18101873        return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SLONG8,1,8,&m)); 
    18111874} 
     1875#endif 
    18121876 
    18131877static int 
     
    19642028} 
    19652029 
     2030#ifdef notdef 
    19662031static int 
    19672032TIFFWriteDirectoryTagCheckedFloat(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, float value) 
     
    19752040        return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_FLOAT,1,4,&m)); 
    19762041} 
     2042#endif 
    19772043 
    19782044static int 
     
    19872053} 
    19882054 
     2055#ifdef notdef 
    19892056static int 
    19902057TIFFWriteDirectoryTagCheckedDouble(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value) 
     
    19982065        return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_DOUBLE,1,8,&m)); 
    19992066} 
     2067#endif 
    20002068 
    20012069static int 
     
    22932361} 
    22942362 
     2363/************************************************************************/ 
     2364/*                          TIFFRewriteField()                          */ 
     2365/*                                                                      */ 
     2366/*      Rewrite a field in the directory on disk without regard to      */ 
     2367/*      updating the TIFF directory structure in memory.  Currently     */ 
     2368/*      only supported for field that already exist in the on-disk      */ 
     2369/*      directory.  Mainly used for updating stripoffset /              */ 
     2370/*      stripbytecount values after the directory is already on         */ 
     2371/*      disk.                                                           */ 
     2372/*                                                                      */ 
     2373/*      Returns zero on failure, and one on success.                    */ 
     2374/************************************************************************/ 
     2375 
     2376int 
     2377TIFFRewriteField(TIFF* tif, uint16 tag, TIFFDataType in_datatype,  
     2378                 uint32 count, void* data) 
     2379{ 
     2380    static const char module[] = "TIFFResetField"; 
     2381    const TIFFField* fip = NULL; 
     2382    uint16 dircount; 
     2383    uint32 dirsize; 
     2384    uint8 direntry_raw[20]; 
     2385    uint16 entry_tag = 0; 
     2386    uint16 entry_type = 0; 
     2387    uint64 entry_count = 0; 
     2388    uint64 entry_offset = 0; 
     2389    int    value_in_entry = 0; 
     2390    uint32 i; 
     2391    uint64 read_offset; 
     2392    uint8 *buf_to_write = NULL; 
     2393    TIFFDataType datatype; 
     2394 
     2395/* -------------------------------------------------------------------- */ 
     2396/*      Find field definition.                                          */ 
     2397/* -------------------------------------------------------------------- */ 
     2398    fip = TIFFFindField(tif, tag, TIFF_ANY); 
     2399 
     2400/* -------------------------------------------------------------------- */ 
     2401/*      Do some checking this is a straight forward case.               */ 
     2402/* -------------------------------------------------------------------- */ 
     2403    if( isMapped(tif) ) 
     2404    { 
     2405        TIFFErrorExt( tif->tif_clientdata, module,  
     2406                      "Memory mapped files not currently supported for this operation." ); 
     2407        return 0; 
     2408    } 
     2409 
     2410    if( tif->tif_diroff == 0 ) 
     2411    { 
     2412        TIFFErrorExt( tif->tif_clientdata, module,  
     2413                      "Attempt to reset field on directory not already on disk." ); 
     2414        return 0; 
     2415    } 
     2416 
     2417/* -------------------------------------------------------------------- */ 
     2418/*      Read the directory entry count.                                 */ 
     2419/* -------------------------------------------------------------------- */ 
     2420    if (!SeekOK(tif, tif->tif_diroff)) { 
     2421        TIFFErrorExt(tif->tif_clientdata, module, 
     2422                     "%s: Seek error accessing TIFF directory", 
     2423                     tif->tif_name); 
     2424        return 0; 
     2425    } 
     2426 
     2427    read_offset = tif->tif_diroff; 
     2428 
     2429    if (!(tif->tif_flags&TIFF_BIGTIFF)) 
     2430    { 
     2431        if (!ReadOK(tif, &dircount, sizeof (uint16))) { 
     2432            TIFFErrorExt(tif->tif_clientdata, module, 
     2433                         "%s: Can not read TIFF directory count", 
     2434                         tif->tif_name); 
     2435            return 0; 
     2436        } 
     2437        if (tif->tif_flags & TIFF_SWAB) 
     2438            TIFFSwabShort(&dircount); 
     2439        dirsize = 12; 
     2440        read_offset += 2; 
     2441    } else { 
     2442        uint64 dircount64; 
     2443        if (!ReadOK(tif, &dircount64, sizeof (uint64))) { 
     2444            TIFFErrorExt(tif->tif_clientdata, module, 
     2445                         "%s: Can not read TIFF directory count", 
     2446                         tif->tif_name); 
     2447            return 0; 
     2448        } 
     2449        if (tif->tif_flags & TIFF_SWAB) 
     2450            TIFFSwabLong8(&dircount64); 
     2451        dircount = (uint16)dircount64; 
     2452        dirsize = 20; 
     2453        read_offset += 8; 
     2454    } 
     2455 
     2456/* -------------------------------------------------------------------- */ 
     2457/*      Read through directory to find target tag.                      */ 
     2458/* -------------------------------------------------------------------- */ 
     2459    while( dircount > 0 ) 
     2460    { 
     2461        if (!ReadOK(tif, direntry_raw, dirsize)) { 
     2462            TIFFErrorExt(tif->tif_clientdata, module, 
     2463                         "%s: Can not read TIFF directory entry.", 
     2464                         tif->tif_name); 
     2465            return 0; 
     2466        } 
     2467 
     2468        memcpy( &entry_tag, direntry_raw + 0, sizeof(uint16) ); 
     2469        if (tif->tif_flags&TIFF_SWAB) 
     2470            TIFFSwabShort( &entry_tag ); 
     2471 
     2472        if( entry_tag == tag ) 
     2473            break; 
     2474 
     2475        read_offset += dirsize; 
     2476    } 
     2477 
     2478    if( entry_tag != tag ) 
     2479    { 
     2480        TIFFErrorExt(tif->tif_clientdata, module, 
     2481                     "%s: Could not find tag %d.", 
     2482                     tif->tif_name, tag ); 
     2483        return 0; 
     2484    } 
     2485 
     2486/* -------------------------------------------------------------------- */ 
     2487/*      Extract the type, count and offset for this entry.              */ 
     2488/* -------------------------------------------------------------------- */ 
     2489    memcpy( &entry_type, direntry_raw + 2, sizeof(uint16) ); 
     2490    if (tif->tif_flags&TIFF_SWAB) 
     2491        TIFFSwabShort( &entry_type ); 
     2492 
     2493    if (!(tif->tif_flags&TIFF_BIGTIFF)) 
     2494    { 
     2495        uint32 value; 
     2496         
     2497        memcpy( &value, direntry_raw + 4, sizeof(uint32) ); 
     2498        if (tif->tif_flags&TIFF_SWAB) 
     2499            TIFFSwabLong( &value ); 
     2500        entry_count = value; 
     2501 
     2502        memcpy( &value, direntry_raw + 8, sizeof(uint32) ); 
     2503        if (tif->tif_flags&TIFF_SWAB) 
     2504            TIFFSwabLong( &value ); 
     2505        entry_offset = value; 
     2506    } 
     2507    else 
     2508    { 
     2509        memcpy( &entry_count, direntry_raw + 4, sizeof(uint64) ); 
     2510        if (tif->tif_flags&TIFF_SWAB) 
     2511            TIFFSwabLong8( &entry_count ); 
     2512 
     2513        memcpy( &entry_offset, direntry_raw + 12, sizeof(uint64) ); 
     2514        if (tif->tif_flags&TIFF_SWAB) 
     2515            TIFFSwabLong8( &entry_offset ); 
     2516    } 
     2517 
     2518/* -------------------------------------------------------------------- */ 
     2519/*      What data type do we want to write this as?                     */ 
     2520/* -------------------------------------------------------------------- */ 
     2521    if( TIFFDataWidth(in_datatype) == 8 && !(tif->tif_flags&TIFF_BIGTIFF) ) 
     2522    { 
     2523        if( in_datatype == TIFF_LONG8 ) 
     2524            datatype = TIFF_LONG; 
     2525        else if( in_datatype == TIFF_SLONG8 ) 
     2526            datatype = TIFF_SLONG; 
     2527        else if( in_datatype == TIFF_IFD8 ) 
     2528            datatype = TIFF_IFD; 
     2529        else 
     2530            datatype = in_datatype; 
     2531    } 
     2532    else  
     2533        datatype = in_datatype; 
     2534 
     2535/* -------------------------------------------------------------------- */ 
     2536/*      Prepare buffer of actual data to write.  This includes          */ 
     2537/*      swabbing as needed.                                             */ 
     2538/* -------------------------------------------------------------------- */ 
     2539    buf_to_write = (uint8 *) _TIFFmalloc(count * TIFFDataWidth(datatype)); 
     2540    if( buf_to_write == NULL ) 
     2541    { 
     2542        TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); 
     2543        return 0; 
     2544    } 
     2545 
     2546    if( datatype == in_datatype ) 
     2547        memcpy( buf_to_write, data, count * TIFFDataWidth(datatype) ); 
     2548    else if( datatype == TIFF_SLONG && in_datatype == TIFF_SLONG8 ) 
     2549    { 
     2550        for( i = 0; i < count; i++ ) 
     2551        { 
     2552            ((int32 *) buf_to_write)[i] =  
     2553                (int32) ((int64 *) data)[i]; 
     2554            if( (int64) ((int32 *) buf_to_write)[i] != ((int64 *) data)[i] ) 
     2555            { 
     2556                _TIFFfree( buf_to_write ); 
     2557                TIFFErrorExt( tif->tif_clientdata, module,  
     2558                              "Value exceeds 32bit range of output type." ); 
     2559                return 0; 
     2560            } 
     2561        } 
     2562    } 
     2563    else if( (datatype == TIFF_LONG && in_datatype == TIFF_LONG8) 
     2564             || (datatype == TIFF_IFD && in_datatype == TIFF_IFD8) ) 
     2565    { 
     2566        for( i = 0; i < count; i++ ) 
     2567        { 
     2568            ((uint32 *) buf_to_write)[i] =  
     2569                (uint32) ((uint64 *) data)[i]; 
     2570            if( (uint64) ((uint32 *) buf_to_write)[i] != ((uint64 *) data)[i] ) 
     2571            { 
     2572                _TIFFfree( buf_to_write ); 
     2573                TIFFErrorExt( tif->tif_clientdata, module,  
     2574                              "Value exceeds 32bit range of output type." ); 
     2575                return 0; 
     2576            } 
     2577        } 
     2578    } 
     2579 
     2580    if( TIFFDataWidth(datatype) > 1 && (tif->tif_flags&TIFF_SWAB) ) 
     2581    { 
     2582        if( TIFFDataWidth(datatype) == 2 ) 
     2583            TIFFSwabArrayOfShort( (uint16 *) buf_to_write, count ); 
     2584        else if( TIFFDataWidth(datatype) == 4 ) 
     2585            TIFFSwabArrayOfLong( (uint32 *) buf_to_write, count ); 
     2586        else if( TIFFDataWidth(datatype) == 8 ) 
     2587            TIFFSwabArrayOfLong8( (uint64 *) buf_to_write, count ); 
     2588    } 
     2589 
     2590/* -------------------------------------------------------------------- */ 
     2591/*      Is this a value that fits into the directory entry?             */ 
     2592/* -------------------------------------------------------------------- */ 
     2593    if (!(tif->tif_flags&TIFF_BIGTIFF)) 
     2594    { 
     2595        if( TIFFDataWidth(datatype) * count <= 4 ) 
     2596        { 
     2597            entry_offset = read_offset + 8; 
     2598            value_in_entry = 1; 
     2599        } 
     2600    } 
     2601    else 
     2602    { 
     2603        if( TIFFDataWidth(datatype) * count <= 8 ) 
     2604        { 
     2605            entry_offset = read_offset + 12; 
     2606            value_in_entry = 1; 
     2607        } 
     2608    } 
     2609 
     2610/* -------------------------------------------------------------------- */ 
     2611/*      If the tag type, and count match, then we just write it out     */ 
     2612/*      over the old values without altering the directory entry at     */ 
     2613/*      all.                                                            */ 
     2614/* -------------------------------------------------------------------- */ 
     2615    if( entry_count == count && entry_type == (uint16) datatype ) 
     2616    { 
     2617        if (!SeekOK(tif, entry_offset)) { 
     2618            _TIFFfree( buf_to_write ); 
     2619            TIFFErrorExt(tif->tif_clientdata, module, 
     2620                         "%s: Seek error accessing TIFF directory", 
     2621                         tif->tif_name); 
     2622            return 0; 
     2623        } 
     2624        if (!WriteOK(tif, buf_to_write, count*TIFFDataWidth(datatype))) { 
     2625            _TIFFfree( buf_to_write ); 
     2626            TIFFErrorExt(tif->tif_clientdata, module, 
     2627                         "Error writing directory link"); 
     2628            return (0); 
     2629        } 
     2630 
     2631        _TIFFfree( buf_to_write ); 
     2632        return 1; 
     2633    } 
     2634 
     2635/* -------------------------------------------------------------------- */ 
     2636/*      Otherwise, we write the new tag data at the end of the file.    */ 
     2637/* -------------------------------------------------------------------- */ 
     2638    if( !value_in_entry ) 
     2639    { 
     2640        entry_offset = TIFFSeekFile(tif,0,SEEK_END); 
     2641         
     2642        if (!WriteOK(tif, buf_to_write, count*TIFFDataWidth(datatype))) { 
     2643            _TIFFfree( buf_to_write ); 
     2644            TIFFErrorExt(tif->tif_clientdata, module, 
     2645                         "Error writing directory link"); 
     2646            return (0); 
     2647        } 
     2648         
     2649        _TIFFfree( buf_to_write ); 
     2650    } 
     2651    else 
     2652    { 
     2653        memcpy( &entry_offset, buf_to_write, count*TIFFDataWidth(datatype)); 
     2654    } 
     2655 
     2656/* -------------------------------------------------------------------- */ 
     2657/*      Adjust the directory entry.                                     */ 
     2658/* -------------------------------------------------------------------- */ 
     2659    entry_type = datatype; 
     2660    memcpy( direntry_raw + 2, &entry_type, sizeof(uint16) ); 
     2661    if (tif->tif_flags&TIFF_SWAB) 
     2662        TIFFSwabShort( (uint16 *) (direntry_raw + 2) ); 
     2663 
     2664    if (!(tif->tif_flags&TIFF_BIGTIFF)) 
     2665    { 
     2666        uint32 value; 
     2667 
     2668        value = (uint32) entry_count; 
     2669        memcpy( direntry_raw + 4, &value, sizeof(uint32) ); 
     2670        if (tif->tif_flags&TIFF_SWAB) 
     2671            TIFFSwabLong( (uint32 *) (direntry_raw + 4) ); 
     2672 
     2673        value = (uint32) entry_offset; 
     2674        memcpy( direntry_raw + 8, &value, sizeof(uint32) ); 
     2675        if (tif->tif_flags&TIFF_SWAB) 
     2676            TIFFSwabLong( (uint32 *) (direntry_raw + 8) ); 
     2677    } 
     2678    else 
     2679    { 
     2680        memcpy( direntry_raw + 4, &entry_count, sizeof(uint64) ); 
     2681        if (tif->tif_flags&TIFF_SWAB) 
     2682            TIFFSwabLong8( (uint64 *) (direntry_raw + 4) ); 
     2683 
     2684        memcpy( direntry_raw + 12, &entry_offset, sizeof(uint64) ); 
     2685        if (tif->tif_flags&TIFF_SWAB) 
     2686            TIFFSwabLong8( (uint64 *) (direntry_raw + 12) ); 
     2687    } 
     2688 
     2689/* -------------------------------------------------------------------- */ 
     2690/*      Write the directory entry out to disk.                          */ 
     2691/* -------------------------------------------------------------------- */ 
     2692    if (!SeekOK(tif, read_offset )) { 
     2693        TIFFErrorExt(tif->tif_clientdata, module, 
     2694                     "%s: Seek error accessing TIFF directory", 
     2695                     tif->tif_name); 
     2696        return 0; 
     2697    } 
     2698 
     2699    if (!WriteOK(tif, direntry_raw,dirsize)) 
     2700    { 
     2701        TIFFErrorExt(tif->tif_clientdata, module, 
     2702                     "%s: Can not write TIFF directory entry.", 
     2703                     tif->tif_name); 
     2704        return 0; 
     2705    } 
     2706     
     2707    return 1; 
     2708} 
    22952709/* vim: set ts=8 sts=8 sw=8 noet: */ 
  • trunk/gdal/frmts/gtiff/libtiff/tif_flush.c

    r6708 r14006  
    1 /* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_flush.c,v 1.3 2000/09/15 20:52:42 warmerda Exp $ */ 
     1/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_flush.c,v 1.4 2007/12/31 21:52:16 fwarmerdam Exp $ */ 
    22 
    33/* 
     
    3333TIFFFlush(TIFF* tif) 
    3434{ 
     35    if( tif->tif_mode == O_RDONLY ) 
     36        return 1; 
    3537 
    36         if (tif->tif_mode != O_RDONLY) { 
    37                 if (!TIFFFlushData(tif)) 
    38                         return (0); 
    39                 if ((tif->tif_flags & TIFF_DIRTYDIRECT) && 
    40                     !TIFFWriteDirectory(tif)) 
    41                         return (0); 
    42         } 
    43         return (1); 
     38    if (!TIFFFlushData(tif)) 
     39        return (0); 
     40                 
     41    /* In update (r+) mode we try to detect the case where  
     42       only the strip/tile map has been altered, and we try to  
     43       rewrite only that portion of the directory without  
     44       making any other changes */ 
     45                 
     46    if( (tif->tif_flags & TIFF_DIRTYSTRIP) 
     47        && !(tif->tif_flags & TIFF_DIRTYDIRECT)  
     48        && tif->tif_mode == O_RDWR ) 
     49    { 
     50        uint64  *offsets=NULL, *sizes=NULL; 
     51 
     52        if( TIFFIsTiled(tif) ) 
     53        { 
     54            if( TIFFGetField( tif, TIFFTAG_TILEOFFSETS, &offsets )  
     55                && TIFFGetField( tif, TIFFTAG_TILEBYTECOUNTS, &sizes )  
     56                && TIFFRewriteField( tif, TIFFTAG_TILEOFFSETS, TIFF_LONG8,  
     57                                     tif->tif_dir.td_nstrips, offsets ) 
     58                && TIFFRewriteField( tif, TIFFTAG_TILEBYTECOUNTS, TIFF_LONG8,  
     59                                     tif->tif_dir.td_nstrips, sizes ) ) 
     60            { 
     61                tif->tif_flags &= ~TIFF_DIRTYSTRIP; 
     62                return 1; 
     63            } 
     64        } 
     65        else 
     66        { 
     67            if( TIFFGetField( tif, TIFFTAG_STRIPOFFSETS, &offsets )  
     68                && TIFFGetField( tif, TIFFTAG_STRIPBYTECOUNTS, &sizes )  
     69                && TIFFRewriteField( tif, TIFFTAG_STRIPOFFSETS, TIFF_LONG8,  
     70                                     tif->tif_dir.td_nstrips, offsets ) 
     71                && TIFFRewriteField( tif, TIFFTAG_STRIPBYTECOUNTS, TIFF_LONG8,  
     72                                     tif->tif_dir.td_nstrips, sizes ) ) 
     73            { 
     74                tif->tif_flags &= ~TIFF_DIRTYSTRIP; 
     75                return 1; 
     76            } 
     77        } 
     78    } 
     79 
     80    if ((tif->tif_flags & (TIFF_DIRTYDIRECT|TIFF_DIRTYSTRIP))  
     81        && !TIFFWriteDirectory(tif)) 
     82        return (0); 
     83 
     84    return (1); 
    4485} 
    4586 
  • trunk/gdal/frmts/gtiff/libtiff/tif_getimage.c

    r11957 r14006  
    1 /* $Id: tif_getimage.c,v 1.68 2007/08/10 10:19:57 joris Exp $ */ 
     1/* $Id: tif_getimage.c,v 1.69 2008/01/01 15:41:49 fwarmerdam Exp $ */ 
    22 
    33/* 
     
    802802        tileContigRoutine put = img->put.contig; 
    803803        uint32 row, y, nrow, nrowsub, rowstoread; 
    804         uint32 pos; 
     804        tmsize_t pos; 
    805805        unsigned char* buf; 
    806806        uint32 rowsperstrip; 
     
    887887        unsigned char *p0, *p1, *p2, *pa; 
    888888        uint32 row, y, nrow, rowstoread; 
    889         uint32 pos; 
     889        tmsize_t pos; 
    890890        tmsize_t scanline; 
    891891        uint32 rowsperstrip, offset_row; 
     
    25602560        if (img->UaToAa==NULL) 
    25612561        { 
    2562                 TIFFErrorExt(img->tif,module,"Out of memory"); 
     2562                TIFFErrorExt(img->tif->tif_clientdata,module,"Out of memory"); 
    25632563                return(0); 
    25642564        } 
     
    25822582        if (img->Bitdepth16To8==NULL) 
    25832583        { 
    2584                 TIFFErrorExt(img->tif,module,"Out of memory"); 
     2584                TIFFErrorExt(img->tif->tif_clientdata,module,"Out of memory"); 
    25852585                return(0); 
    25862586        } 
  • trunk/gdal/frmts/gtiff/libtiff/tif_jpeg.c

    r13310 r14006  
    1 /* $Id: tif_jpeg.c,v 1.75 2007/12/10 19:58:41 fwarmerdam Exp $ */ 
     1/* $Id: tif_jpeg.c,v 1.76 2008/02/01 21:50:24 fwarmerdam Exp $ */ 
    22 
    33/* 
     
    682682        static const char module[] = "JPEGFixupTagsSubsampling"; 
    683683        struct JPEGFixupTagsSubsamplingData m; 
     684 
     685        if( tif->tif_dir.td_stripbytecount == NULL 
     686            || tif->tif_dir.td_stripbytecount[0] == 0 ) 
     687        { 
     688            /* Do not even try to check if the first strip/tile does not 
     689               yet exist, as occurs when GDAL has created a new NULL file 
     690               for instance. */ 
     691            return; 
     692        } 
     693 
    684694        m.tif=tif; 
    685695        m.buffersize=2048; 
  • trunk/gdal/frmts/gtiff/libtiff/tif_next.c

    r11957 r14006  
    1 /* $Id: tif_next.c,v 1.11 2007/04/10 02:56:33 joris Exp $ */ 
     1/* $Id: tif_next.c,v 1.12 2008/01/01 15:41:22 fwarmerdam Exp $ */ 
    22 
    33/* 
     
    112112                        op = row; 
    113113                        for (;;) { 
    114                                 grey = (n>>6) & 0x3
     114                                grey = (uint32)((n>>6) & 0x3)
    115115                                n &= 0x3f; 
    116116                                /* 
  • trunk/gdal/frmts/gtiff/libtiff/tif_ojpeg.c

    r13365 r14006  
    583583        assert(sp!=NULL); 
    584584        if (TIFFFieldSet(tif,FIELD_OJPEG_JPEGINTERCHANGEFORMAT)) 
    585                 fprintf(fd,"  JpegInterchangeFormat: %llu\n", 
    586                         (TIFF_UINT64_T)sp->jpeg_interchange_format);   
     585                fprintf(fd,"  JpegInterchangeFormat: %llu\n",(unsigned long long)sp->jpeg_interchange_format);   
    587586        if (TIFFFieldSet(tif,FIELD_OJPEG_JPEGINTERCHANGEFORMATLENGTH)) 
    588                 fprintf(fd,"  JpegInterchangeFormatLength: %llu\n",(TIFF_UINT64_T)sp->jpeg_interchange_format_length);   
     587                fprintf(fd,"  JpegInterchangeFormatLength: %llu\n",(unsigned long long)sp->jpeg_interchange_format_length);   
    589588        if (TIFFFieldSet(tif,FIELD_OJPEG_JPEGQTABLES)) 
    590589        { 
    591590                fprintf(fd,"  JpegQTables:"); 
    592591                for (m=0; m<sp->qtable_offset_count; m++) 
    593                         fprintf(fd," %llu",(TIFF_UINT64_T)sp->qtable_offset[m]); 
     592                        fprintf(fd," %llu",(unsigned long long)sp->qtable_offset[m]); 
    594593                fprintf(fd,"\n"); 
    595594        } 
     
    598597                fprintf(fd,"  JpegDcTables:"); 
    599598                for (m=0; m<sp->dctable_offset_count; m++) 
    600                         fprintf(fd," %llu",(TIFF_UINT64_T)sp->dctable_offset[m]); 
     599                        fprintf(fd," %llu",(unsigned long long)sp->dctable_offset[m]); 
    601600                fprintf(fd,"\n"); 
    602601        } 
     
    605604  &