Changeset 14006
- Timestamp:
- 03/14/08 09:42:25 (2 months ago)
- Files:
-
- trunk/gdal/frmts/gtiff/libtiff/tif_aux.c (modified) (2 diffs)
- trunk/gdal/frmts/gtiff/libtiff/tif_dirinfo.c (modified) (2 diffs)
- trunk/gdal/frmts/gtiff/libtiff/tif_dirwrite.c (modified) (42 diffs)
- trunk/gdal/frmts/gtiff/libtiff/tif_flush.c (modified) (2 diffs)
- trunk/gdal/frmts/gtiff/libtiff/tif_getimage.c (modified) (5 diffs)
- trunk/gdal/frmts/gtiff/libtiff/tif_jpeg.c (modified) (2 diffs)
- trunk/gdal/frmts/gtiff/libtiff/tif_next.c (modified) (2 diffs)
- trunk/gdal/frmts/gtiff/libtiff/tif_ojpeg.c (modified) (3 diffs)
- trunk/gdal/frmts/gtiff/libtiff/tif_pixarlog.c (modified) (1 diff)
- trunk/gdal/frmts/gtiff/libtiff/tif_predict.c (modified) (2 diffs)
- trunk/gdal/frmts/gtiff/libtiff/tif_write.c (modified) (7 diffs)
- trunk/gdal/frmts/gtiff/libtiff/tif_zip.c (modified) (1 diff)
- trunk/gdal/frmts/gtiff/libtiff/tiffio.h (modified) (2 diffs)
- trunk/gdal/frmts/gtiff/libtiff/tiffiop.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/gdal/frmts/gtiff/libtiff/tif_aux.c
r11957 r14006 1 /* $Id: tif_aux.c,v 1.2 2 2007/07/19 13:11:59 dronExp $ */1 /* $Id: tif_aux.c,v 1.23 2008/01/01 15:41:22 fwarmerdam Exp $ */ 2 2 3 3 /* … … 70 70 return 0; 71 71 72 n = 1<<td->td_bitspersample;72 n = ((tmsize_t)1)<<td->td_bitspersample; 73 73 nbytes = n * sizeof (uint16); 74 74 if (!(tf[0] = (uint16 *)_TIFFmalloc(nbytes))) trunk/gdal/frmts/gtiff/libtiff/tif_dirinfo.c
r12610 r14006 99 99 { TIFFTAG_INKSET, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "InkSet", NULL }, 100 100 { 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_U NDEFINED, 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 }, 102 102 { TIFFTAG_DOTRANGE, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_UINT16_PAIR, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "DotRange", NULL }, 103 103 { TIFFTAG_TARGETPRINTER, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "TargetPrinter", NULL }, … … 124 124 { TIFFTAG_PIXAR_IMAGEFULLWIDTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ImageFullWidth", NULL }, 125 125 { 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 }, 128 128 { TIFFTAG_PIXAR_FOVCOT, 1, 1, TIFF_FLOAT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FieldOfViewCotangent", NULL }, 129 129 { 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.6 2 2007/11/23 20:49:43fwarmerdam Exp $ */1 /* $Id: tif_dirwrite.c,v 1.65 2008/01/07 15:50:02 fwarmerdam Exp $ */ 2 2 3 3 /* … … 46 46 static int TIFFWriteDirectoryTagAscii(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, char* value); 47 47 static int TIFFWriteDirectoryTagUndefinedArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint8* value); 48 #ifdef notdef 48 49 static int TIFFWriteDirectoryTagByte(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint8 value); 50 #endif 49 51 static int TIFFWriteDirectoryTagByteArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint8* value); 50 52 static int TIFFWriteDirectoryTagBytePerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint8 value); 53 #ifdef notdef 51 54 static int TIFFWriteDirectoryTagSbyte(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int8 value); 55 #endif 52 56 static int TIFFWriteDirectoryTagSbyteArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int8* value); 53 57 static int TIFFWriteDirectoryTagSbytePerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int8 value); … … 55 59 static int TIFFWriteDirectoryTagShortArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint16* value); 56 60 static int TIFFWriteDirectoryTagShortPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint16 value); 61 #ifdef notdef 57 62 static int TIFFWriteDirectoryTagSshort(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int16 value); 63 #endif 58 64 static int TIFFWriteDirectoryTagSshortArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int16* value); 59 65 static int TIFFWriteDirectoryTagSshortPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int16 value); … … 61 67 static int TIFFWriteDirectoryTagLongArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint32* value); 62 68 static int TIFFWriteDirectoryTagLongPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 value); 69 #ifdef notdef 63 70 static int TIFFWriteDirectoryTagSlong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int32 value); 71 #endif 64 72 static int TIFFWriteDirectoryTagSlongArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int32* value); 65 73 static int TIFFWriteDirectoryTagSlongPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int32 value); 74 #ifdef notdef 66 75 static int TIFFWriteDirectoryTagLong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint64 value); 76 #endif 67 77 static int TIFFWriteDirectoryTagLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value); 78 #ifdef notdef 68 79 static int TIFFWriteDirectoryTagSlong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int64 value); 80 #endif 69 81 static int TIFFWriteDirectoryTagSlong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int64* value); 70 82 static int TIFFWriteDirectoryTagRational(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value); 71 83 static int TIFFWriteDirectoryTagRationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value); 72 84 static int TIFFWriteDirectoryTagSrationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value); 85 #ifdef notdef 73 86 static int TIFFWriteDirectoryTagFloat(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, float value); 87 #endif 74 88 static int TIFFWriteDirectoryTagFloatArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value); 75 89 static int TIFFWriteDirectoryTagFloatPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, float value); 90 #ifdef notdef 76 91 static int TIFFWriteDirectoryTagDouble(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value); 92 #endif 77 93 static int TIFFWriteDirectoryTagDoubleArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, double* value); 78 94 static int TIFFWriteDirectoryTagDoublePerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value); … … 81 97 static int TIFFWriteDirectoryTagShortLong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 value); 82 98 static int TIFFWriteDirectoryTagLongLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value); 99 #ifdef notdef 83 100 static int TIFFWriteDirectoryTagShortLongLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value); 101 #endif 84 102 static int TIFFWriteDirectoryTagColormap(TIFF* tif, uint32* ndir, TIFFDirEntry* dir); 85 103 static int TIFFWriteDirectoryTagTransferfunction(TIFF* tif, uint32* ndir, TIFFDirEntry* dir); … … 88 106 static int TIFFWriteDirectoryTagCheckedAscii(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, char* value); 89 107 static int TIFFWriteDirectoryTagCheckedUndefinedArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint8* value); 108 #ifdef notdef 90 109 static int TIFFWriteDirectoryTagCheckedByte(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint8 value); 110 #endif 91 111 static int TIFFWriteDirectoryTagCheckedByteArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint8* value); 112 #ifdef notdef 92 113 static int TIFFWriteDirectoryTagCheckedSbyte(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int8 value); 114 #endif 93 115 static int TIFFWriteDirectoryTagCheckedSbyteArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int8* value); 94 116 static int TIFFWriteDirectoryTagCheckedShort(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint16 value); 95 117 static int TIFFWriteDirectoryTagCheckedShortArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint16* value); 118 #ifdef notdef 96 119 static int TIFFWriteDirectoryTagCheckedSshort(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int16 value); 120 #endif 97 121 static int TIFFWriteDirectoryTagCheckedSshortArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int16* value); 98 122 static int TIFFWriteDirectoryTagCheckedLong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 value); 99 123 static int TIFFWriteDirectoryTagCheckedLongArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint32* value); 124 #ifdef notdef 100 125 static int TIFFWriteDirectoryTagCheckedSlong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int32 value); 126 #endif 101 127 static int TIFFWriteDirectoryTagCheckedSlongArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int32* value); 128 #ifdef notdef 102 129 static int TIFFWriteDirectoryTagCheckedLong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint64 value); 130 #endif 103 131 static int TIFFWriteDirectoryTagCheckedLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value); 132 #ifdef notdef 104 133 static int TIFFWriteDirectoryTagCheckedSlong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int64 value); 134 #endif 105 135 static int TIFFWriteDirectoryTagCheckedSlong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int64* value); 106 136 static int TIFFWriteDirectoryTagCheckedRational(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value); 107 137 static int TIFFWriteDirectoryTagCheckedRationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value); 108 138 static int TIFFWriteDirectoryTagCheckedSrationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value); 139 #ifdef notdef 109 140 static int TIFFWriteDirectoryTagCheckedFloat(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, float value); 141 #endif 110 142 static int TIFFWriteDirectoryTagCheckedFloatArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value); 143 #ifdef notdef 111 144 static int TIFFWriteDirectoryTagCheckedDouble(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value); 145 #endif 112 146 static int TIFFWriteDirectoryTagCheckedDoubleArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, double* value); 113 147 static int TIFFWriteDirectoryTagCheckedIfdArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint32* value); … … 835 869 { 836 870 TIFFFreeDirectory(tif); 837 tif->tif_flags&=~TIFF_DIRTYDIRECT; 871 tif->tif_flags &= ~TIFF_DIRTYDIRECT; 872 tif->tif_flags &= ~TIFF_DIRTYSTRIP; 838 873 (*tif->tif_cleanup)(tif); 839 874 /* … … 903 938 } 904 939 940 #ifdef notdef 905 941 static int 906 942 TIFFWriteDirectoryTagByte(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint8 value) … … 913 949 return(TIFFWriteDirectoryTagCheckedByte(tif,ndir,dir,tag,value)); 914 950 } 951 #endif 915 952 916 953 static int … … 951 988 } 952 989 990 #ifdef notdef 953 991 static int 954 992 TIFFWriteDirectoryTagSbyte(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int8 value) … … 961 999 return(TIFFWriteDirectoryTagCheckedSbyte(tif,ndir,dir,tag,value)); 962 1000 } 1001 #endif 963 1002 964 1003 static int … … 1047 1086 } 1048 1087 1088 #ifdef notdef 1049 1089 static int 1050 1090 TIFFWriteDirectoryTagSshort(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int16 value) … … 1057 1097 return(TIFFWriteDirectoryTagCheckedSshort(tif,ndir,dir,tag,value)); 1058 1098 } 1099 #endif 1059 1100 1060 1101 static int … … 1143 1184 } 1144 1185 1186 #ifdef notdef 1145 1187 static int 1146 1188 TIFFWriteDirectoryTagSlong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int32 value) … … 1153 1195 return(TIFFWriteDirectoryTagCheckedSlong(tif,ndir,dir,tag,value)); 1154 1196 } 1197 #endif 1155 1198 1156 1199 static int … … 1191 1234 } 1192 1235 1236 #ifdef notdef 1193 1237 static int 1194 1238 TIFFWriteDirectoryTagLong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint64 value) … … 1201 1245 return(TIFFWriteDirectoryTagCheckedLong8(tif,ndir,dir,tag,value)); 1202 1246 } 1247 #endif 1203 1248 1204 1249 static int … … 1213 1258 } 1214 1259 1260 #ifdef notdef 1215 1261 static int 1216 1262 TIFFWriteDirectoryTagSlong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int64 value) … … 1223 1269 return(TIFFWriteDirectoryTagCheckedSlong8(tif,ndir,dir,tag,value)); 1224 1270 } 1271 #endif 1225 1272 1226 1273 static int … … 1268 1315 } 1269 1316 1317 #ifdef notdef 1270 1318 static int TIFFWriteDirectoryTagFloat(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, float value) 1271 1319 { … … 1277 1325 return(TIFFWriteDirectoryTagCheckedFloat(tif,ndir,dir,tag,value)); 1278 1326 } 1327 #endif 1279 1328 1280 1329 static int TIFFWriteDirectoryTagFloatArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value) … … 1313 1362 } 1314 1363 1364 #ifdef notdef 1315 1365 static int TIFFWriteDirectoryTagDouble(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value) 1316 1366 { … … 1322 1372 return(TIFFWriteDirectoryTagCheckedDouble(tif,ndir,dir,tag,value)); 1323 1373 } 1374 #endif 1324 1375 1325 1376 static int TIFFWriteDirectoryTagDoubleArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, double* value) … … 1453 1504 } 1454 1505 1506 #ifdef notdef 1455 1507 static int 1456 1508 TIFFWriteDirectoryTagShortLongLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value) … … 1514 1566 return(o); 1515 1567 } 1516 1568 #endif 1517 1569 static int 1518 1570 TIFFWriteDirectoryTagColormap(TIFF* tif, uint32* ndir, TIFFDirEntry* dir) … … 1664 1716 } 1665 1717 1718 #ifdef notdef 1666 1719 static int 1667 1720 TIFFWriteDirectoryTagCheckedByte(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint8 value) … … 1670 1723 return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_BYTE,1,1,&value)); 1671 1724 } 1725 #endif 1672 1726 1673 1727 static int … … 1678 1732 } 1679 1733 1734 #ifdef notdef 1680 1735 static int 1681 1736 TIFFWriteDirectoryTagCheckedSbyte(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int8 value) … … 1684 1739 return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SBYTE,1,1,&value)); 1685 1740 } 1741 #endif 1686 1742 1687 1743 static int … … 1713 1769 } 1714 1770 1771 #ifdef notdef 1715 1772 static int 1716 1773 TIFFWriteDirectoryTagCheckedSshort(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int16 value) … … 1723 1780 return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SSHORT,1,2,&m)); 1724 1781 } 1782 #endif 1725 1783 1726 1784 static int … … 1755 1813 } 1756 1814 1815 #ifdef notdef 1757 1816 static int 1758 1817 TIFFWriteDirectoryTagCheckedSlong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int32 value) … … 1765 1824 return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SLONG,1,4,&m)); 1766 1825 } 1826 #endif 1767 1827 1768 1828 static int … … 1776 1836 } 1777 1837 1838 #ifdef notdef 1778 1839 static int 1779 1840 TIFFWriteDirectoryTagCheckedLong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint64 value) … … 1787 1848 return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_LONG8,1,8,&m)); 1788 1849 } 1850 #endif 1789 1851 1790 1852 static int … … 1799 1861 } 1800 1862 1863 #ifdef notdef 1801 1864 static int 1802 1865 TIFFWriteDirectoryTagCheckedSlong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int64 value) … … 1810 1873 return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SLONG8,1,8,&m)); 1811 1874 } 1875 #endif 1812 1876 1813 1877 static int … … 1964 2028 } 1965 2029 2030 #ifdef notdef 1966 2031 static int 1967 2032 TIFFWriteDirectoryTagCheckedFloat(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, float value) … … 1975 2040 return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_FLOAT,1,4,&m)); 1976 2041 } 2042 #endif 1977 2043 1978 2044 static int … … 1987 2053 } 1988 2054 2055 #ifdef notdef 1989 2056 static int 1990 2057 TIFFWriteDirectoryTagCheckedDouble(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value) … … 1998 2065 return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_DOUBLE,1,8,&m)); 1999 2066 } 2067 #endif 2000 2068 2001 2069 static int … … 2293 2361 } 2294 2362 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 2376 int 2377 TIFFRewriteField(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 } 2295 2709 /* 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 warmerdaExp $ */1 /* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_flush.c,v 1.4 2007/12/31 21:52:16 fwarmerdam Exp $ */ 2 2 3 3 /* … … 33 33 TIFFFlush(TIFF* tif) 34 34 { 35 if( tif->tif_mode == O_RDONLY ) 36 return 1; 35 37 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); 44 85 } 45 86 trunk/gdal/frmts/gtiff/libtiff/tif_getimage.c
r11957 r14006 1 /* $Id: tif_getimage.c,v 1.6 8 2007/08/10 10:19:57 jorisExp $ */1 /* $Id: tif_getimage.c,v 1.69 2008/01/01 15:41:49 fwarmerdam Exp $ */ 2 2 3 3 /* … … 802 802 tileContigRoutine put = img->put.contig; 803 803 uint32 row, y, nrow, nrowsub, rowstoread; 804 uint32pos;804 tmsize_t pos; 805 805 unsigned char* buf; 806 806 uint32 rowsperstrip; … … 887 887 unsigned char *p0, *p1, *p2, *pa; 888 888 uint32 row, y, nrow, rowstoread; 889 uint32pos;889 tmsize_t pos; 890 890 tmsize_t scanline; 891 891 uint32 rowsperstrip, offset_row; … … 2560 2560 if (img->UaToAa==NULL) 2561 2561 { 2562 TIFFErrorExt(img->tif ,module,"Out of memory");2562 TIFFErrorExt(img->tif->tif_clientdata,module,"Out of memory"); 2563 2563 return(0); 2564 2564 } … … 2582 2582 if (img->Bitdepth16To8==NULL) 2583 2583 { 2584 TIFFErrorExt(img->tif ,module,"Out of memory");2584 TIFFErrorExt(img->tif->tif_clientdata,module,"Out of memory"); 2585 2585 return(0); 2586 2586 } trunk/gdal/frmts/gtiff/libtiff/tif_jpeg.c
r13310 r14006 1 /* $Id: tif_jpeg.c,v 1.7 5 2007/12/10 19:58:41fwarmerdam Exp $ */1 /* $Id: tif_jpeg.c,v 1.76 2008/02/01 21:50:24 fwarmerdam Exp $ */ 2 2 3 3 /* … … 682 682 static const char module[] = "JPEGFixupTagsSubsampling"; 683 683 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 684 694 m.tif=tif; 685 695 m.buffersize=2048; trunk/gdal/frmts/gtiff/libtiff/tif_next.c
r11957 r14006 1 /* $Id: tif_next.c,v 1.1 1 2007/04/10 02:56:33 jorisExp $ */1 /* $Id: tif_next.c,v 1.12 2008/01/01 15:41:22 fwarmerdam Exp $ */ 2 2 3 3 /* … … 112 112 op = row; 113 113 for (;;) { 114 grey = ( n>>6) & 0x3;114 grey = (uint32)((n>>6) & 0x3); 115 115 n &= 0x3f; 116 116 /* trunk/gdal/frmts/gtiff/libtiff/tif_ojpeg.c
r13365 r14006 583 583 assert(sp!=NULL); 584 584 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); 587 586 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); 589 588 if (TIFFFieldSet(tif,FIELD_OJPEG_JPEGQTABLES)) 590 589 { 591 590 fprintf(fd," JpegQTables:"); 592 591 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]); 594 593 fprintf(fd,"\n"); 595 594 } … … 598 597 fprintf(fd," JpegDcTables:"); 599 598 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]); 601 600 fprintf(fd,"\n"); 602 601 } … … 605 604 &
