ReactOS  0.4.15-dev-1177-g6cb3b62
tif_dirwrite.c File Reference
#include <precomp.h>
#include <float.h>
Include dependency graph for tif_dirwrite.c:

Go to the source code of this file.

Functions

void TIFFCvtNativeToIEEEFloat (TIFF *tif, uint32 n, float *fp)
 
void TIFFCvtNativeToIEEEDouble (TIFF *tif, uint32 n, double *dp)
 
static int TIFFWriteDirectorySec (TIFF *tif, int isimage, int imagedone, uint64 *pdiroff)
 
static int TIFFWriteDirectoryTagSampleformatArray (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, double *value)
 
static int TIFFWriteDirectoryTagAscii (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, char *value)
 
static int TIFFWriteDirectoryTagUndefinedArray (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint8 *value)
 
static int TIFFWriteDirectoryTagByteArray (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint8 *value)
 
static int TIFFWriteDirectoryTagSbyteArray (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, int8 *value)
 
static int TIFFWriteDirectoryTagShort (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 value)
 
static int TIFFWriteDirectoryTagShortArray (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint16 *value)
 
static int TIFFWriteDirectoryTagShortPerSample (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 value)
 
static int TIFFWriteDirectoryTagSshortArray (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, int16 *value)
 
static int TIFFWriteDirectoryTagLong (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 value)
 
static int TIFFWriteDirectoryTagLongArray (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint32 *value)
 
static int TIFFWriteDirectoryTagSlongArray (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, int32 *value)
 
static int TIFFWriteDirectoryTagLong8Array (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint64 *value)
 
static int TIFFWriteDirectoryTagSlong8Array (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, int64 *value)
 
static int TIFFWriteDirectoryTagRational (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, double value)
 
static int TIFFWriteDirectoryTagRationalArray (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, float *value)
 
static int TIFFWriteDirectoryTagSrationalArray (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, float *value)
 
static int TIFFWriteDirectoryTagFloatArray (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, float *value)
 
static int TIFFWriteDirectoryTagDoubleArray (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, double *value)
 
static int TIFFWriteDirectoryTagIfdArray (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint32 *value)
 
static int TIFFWriteDirectoryTagShortLong (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 value)
 
static int TIFFWriteDirectoryTagLongLong8Array (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint64 *value)
 
static int TIFFWriteDirectoryTagIfdIfd8Array (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint64 *value)
 
static int TIFFWriteDirectoryTagColormap (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir)
 
static int TIFFWriteDirectoryTagTransferfunction (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir)
 
static int TIFFWriteDirectoryTagSubifd (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir)
 
static int TIFFWriteDirectoryTagCheckedAscii (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, char *value)
 
static int TIFFWriteDirectoryTagCheckedUndefinedArray (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint8 *value)
 
static int TIFFWriteDirectoryTagCheckedByteArray (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint8 *value)
 
static int TIFFWriteDirectoryTagCheckedSbyteArray (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, int8 *value)
 
static int TIFFWriteDirectoryTagCheckedShort (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 value)
 
static int TIFFWriteDirectoryTagCheckedShortArray (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint16 *value)
 
static int TIFFWriteDirectoryTagCheckedSshortArray (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, int16 *value)
 
static int TIFFWriteDirectoryTagCheckedLong (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 value)
 
static int TIFFWriteDirectoryTagCheckedLongArray (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint32 *value)
 
static int TIFFWriteDirectoryTagCheckedSlongArray (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, int32 *value)
 
static int TIFFWriteDirectoryTagCheckedLong8Array (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint64 *value)
 
static int TIFFWriteDirectoryTagCheckedSlong8Array (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, int64 *value)
 
static int TIFFWriteDirectoryTagCheckedRational (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, double value)
 
static int TIFFWriteDirectoryTagCheckedRationalArray (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, float *value)
 
static int TIFFWriteDirectoryTagCheckedSrationalArray (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, float *value)
 
static int TIFFWriteDirectoryTagCheckedFloatArray (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, float *value)
 
static int TIFFWriteDirectoryTagCheckedDoubleArray (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, double *value)
 
static int TIFFWriteDirectoryTagCheckedIfdArray (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint32 *value)
 
static int TIFFWriteDirectoryTagCheckedIfd8Array (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint64 *value)
 
static int TIFFWriteDirectoryTagData (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 datatype, uint32 count, uint32 datalength, void *data)
 
static int TIFFLinkDirectory (TIFF *)
 
int TIFFWriteDirectory (TIFF *tif)
 
int TIFFDeferStrileArrayWriting (TIFF *tif)
 
int TIFFCheckpointDirectory (TIFF *tif)
 
int TIFFWriteCustomDirectory (TIFF *tif, uint64 *pdiroff)
 
int TIFFRewriteDirectory (TIFF *tif)
 
static int8 TIFFClampDoubleToInt8 (double val)
 
static int16 TIFFClampDoubleToInt16 (double val)
 
static int32 TIFFClampDoubleToInt32 (double val)
 
static uint8 TIFFClampDoubleToUInt8 (double val)
 
static uint16 TIFFClampDoubleToUInt16 (double val)
 
static uint32 TIFFClampDoubleToUInt32 (double val)
 
static int _WriteAsType (TIFF *tif, uint64 strile_size, uint64 uncompressed_threshold)
 
static int WriteAsLong8 (TIFF *tif, uint64 strile_size)
 
static int WriteAsLong4 (TIFF *tif, uint64 strile_size)
 
int _TIFFRewriteField (TIFF *tif, uint16 tag, TIFFDataType in_datatype, tmsize_t count, void *data)
 

Function Documentation

◆ _TIFFRewriteField()

int _TIFFRewriteField ( TIFF tif,
uint16  tag,
TIFFDataType  in_datatype,
tmsize_t  count,
void data 
)

Definition at line 2824 of file tif_dirwrite.c.

2826 {
2827  static const char module[] = "TIFFResetField";
2828  /* const TIFFField* fip = NULL; */
2829  uint16 dircount;
2830  tmsize_t dirsize;
2831  uint8 direntry_raw[20];
2832  uint16 entry_tag = 0;
2833  uint16 entry_type = 0;
2834  uint64 entry_count = 0;
2835  uint64 entry_offset = 0;
2836  int value_in_entry = 0;
2837  uint64 read_offset;
2838  uint8 *buf_to_write = NULL;
2839  TIFFDataType datatype;
2840 
2841 /* -------------------------------------------------------------------- */
2842 /* Find field definition. */
2843 /* -------------------------------------------------------------------- */
2844  /*fip =*/ TIFFFindField(tif, tag, TIFF_ANY);
2845 
2846 /* -------------------------------------------------------------------- */
2847 /* Do some checking this is a straight forward case. */
2848 /* -------------------------------------------------------------------- */
2849  if( isMapped(tif) )
2850  {
2852  "Memory mapped files not currently supported for this operation." );
2853  return 0;
2854  }
2855 
2856  if( tif->tif_diroff == 0 )
2857  {
2859  "Attempt to reset field on directory not already on disk." );
2860  return 0;
2861  }
2862 
2863 /* -------------------------------------------------------------------- */
2864 /* Read the directory entry count. */
2865 /* -------------------------------------------------------------------- */
2866  if (!SeekOK(tif, tif->tif_diroff)) {
2868  "%s: Seek error accessing TIFF directory",
2869  tif->tif_name);
2870  return 0;
2871  }
2872 
2873  read_offset = tif->tif_diroff;
2874 
2875  if (!(tif->tif_flags&TIFF_BIGTIFF))
2876  {
2877  if (!ReadOK(tif, &dircount, sizeof (uint16))) {
2879  "%s: Can not read TIFF directory count",
2880  tif->tif_name);
2881  return 0;
2882  }
2883  if (tif->tif_flags & TIFF_SWAB)
2884  TIFFSwabShort(&dircount);
2885  dirsize = 12;
2886  read_offset += 2;
2887  } else {
2888  uint64 dircount64;
2889  if (!ReadOK(tif, &dircount64, sizeof (uint64))) {
2891  "%s: Can not read TIFF directory count",
2892  tif->tif_name);
2893  return 0;
2894  }
2895  if (tif->tif_flags & TIFF_SWAB)
2896  TIFFSwabLong8(&dircount64);
2897  dircount = (uint16)dircount64;
2898  dirsize = 20;
2899  read_offset += 8;
2900  }
2901 
2902 /* -------------------------------------------------------------------- */
2903 /* Read through directory to find target tag. */
2904 /* -------------------------------------------------------------------- */
2905  while( dircount > 0 )
2906  {
2907  if (!ReadOK(tif, direntry_raw, dirsize)) {
2909  "%s: Can not read TIFF directory entry.",
2910  tif->tif_name);
2911  return 0;
2912  }
2913 
2914  memcpy( &entry_tag, direntry_raw + 0, sizeof(uint16) );
2915  if (tif->tif_flags&TIFF_SWAB)
2916  TIFFSwabShort( &entry_tag );
2917 
2918  if( entry_tag == tag )
2919  break;
2920 
2921  read_offset += dirsize;
2922  }
2923 
2924  if( entry_tag != tag )
2925  {
2927  "%s: Could not find tag %d.",
2928  tif->tif_name, tag );
2929  return 0;
2930  }
2931 
2932 /* -------------------------------------------------------------------- */
2933 /* Extract the type, count and offset for this entry. */
2934 /* -------------------------------------------------------------------- */
2935  memcpy( &entry_type, direntry_raw + 2, sizeof(uint16) );
2936  if (tif->tif_flags&TIFF_SWAB)
2937  TIFFSwabShort( &entry_type );
2938 
2939  if (!(tif->tif_flags&TIFF_BIGTIFF))
2940  {
2941  uint32 value;
2942 
2943  memcpy( &value, direntry_raw + 4, sizeof(uint32) );
2944  if (tif->tif_flags&TIFF_SWAB)
2945  TIFFSwabLong( &value );
2946  entry_count = value;
2947 
2948  memcpy( &value, direntry_raw + 8, sizeof(uint32) );
2949  if (tif->tif_flags&TIFF_SWAB)
2950  TIFFSwabLong( &value );
2951  entry_offset = value;
2952  }
2953  else
2954  {
2955  memcpy( &entry_count, direntry_raw + 4, sizeof(uint64) );
2956  if (tif->tif_flags&TIFF_SWAB)
2957  TIFFSwabLong8( &entry_count );
2958 
2959  memcpy( &entry_offset, direntry_raw + 12, sizeof(uint64) );
2960  if (tif->tif_flags&TIFF_SWAB)
2961  TIFFSwabLong8( &entry_offset );
2962  }
2963 
2964 /* -------------------------------------------------------------------- */
2965 /* When a dummy tag was written due to TIFFDeferStrileArrayWriting() */
2966 /* -------------------------------------------------------------------- */
2967  if( entry_offset == 0 && entry_count == 0 && entry_type == 0 )
2968  {
2970  {
2971  entry_type = (tif->tif_flags&TIFF_BIGTIFF) ? TIFF_LONG8 : TIFF_LONG;
2972  }
2973  else
2974  {
2975  int write_aslong8 = 1;
2976  if( count > 1 && tag == TIFFTAG_STRIPBYTECOUNTS )
2977  {
2978  write_aslong8 = WriteAsLong8(tif, TIFFStripSize64(tif));
2979  }
2980  else if( count > 1 && tag == TIFFTAG_TILEBYTECOUNTS )
2981  {
2982  write_aslong8 = WriteAsLong8(tif, TIFFTileSize64(tif));
2983  }
2984  if( write_aslong8 )
2985  {
2986  entry_type = TIFF_LONG8;
2987  }
2988  else
2989  {
2990  int write_aslong4 = 1;
2991  if( count > 1 && tag == TIFFTAG_STRIPBYTECOUNTS )
2992  {
2993  write_aslong4 = WriteAsLong4(tif, TIFFStripSize64(tif));
2994  }
2995  else if( count > 1 && tag == TIFFTAG_TILEBYTECOUNTS )
2996  {
2997  write_aslong4 = WriteAsLong4(tif, TIFFTileSize64(tif));
2998  }
2999  if( write_aslong4 )
3000  {
3001  entry_type = TIFF_LONG;
3002  }
3003  else
3004  {
3005  entry_type = TIFF_SHORT;
3006  }
3007  }
3008  }
3009  }
3010 
3011 /* -------------------------------------------------------------------- */
3012 /* What data type do we want to write this as? */
3013 /* -------------------------------------------------------------------- */
3014  if( TIFFDataWidth(in_datatype) == 8 && !(tif->tif_flags&TIFF_BIGTIFF) )
3015  {
3016  if( in_datatype == TIFF_LONG8 )
3017  datatype = entry_type == TIFF_SHORT ? TIFF_SHORT : TIFF_LONG;
3018  else if( in_datatype == TIFF_SLONG8 )
3019  datatype = TIFF_SLONG;
3020  else if( in_datatype == TIFF_IFD8 )
3021  datatype = TIFF_IFD;
3022  else
3023  datatype = in_datatype;
3024  }
3025  else
3026  {
3027  if( in_datatype == TIFF_LONG8 &&
3028  (entry_type == TIFF_SHORT || entry_type == TIFF_LONG ||
3029  entry_type == TIFF_LONG8 ) )
3030  datatype = entry_type;
3031  else if( in_datatype == TIFF_SLONG8 &&
3032  (entry_type == TIFF_SLONG || entry_type == TIFF_SLONG8 ) )
3033  datatype = entry_type;
3034  else if( in_datatype == TIFF_IFD8 &&
3035  (entry_type == TIFF_IFD || entry_type == TIFF_IFD8 ) )
3036  datatype = entry_type;
3037  else
3038  datatype = in_datatype;
3039  }
3040 
3041 /* -------------------------------------------------------------------- */
3042 /* Prepare buffer of actual data to write. This includes */
3043 /* swabbing as needed. */
3044 /* -------------------------------------------------------------------- */
3045  buf_to_write =
3046  (uint8 *)_TIFFCheckMalloc(tif, count, TIFFDataWidth(datatype),
3047  "for field buffer.");
3048  if (!buf_to_write)
3049  return 0;
3050 
3051  if( datatype == in_datatype )
3052  memcpy( buf_to_write, data, count * TIFFDataWidth(datatype) );
3053  else if( datatype == TIFF_SLONG && in_datatype == TIFF_SLONG8 )
3054  {
3055  tmsize_t i;
3056 
3057  for( i = 0; i < count; i++ )
3058  {
3059  ((int32 *) buf_to_write)[i] =
3060  (int32) ((int64 *) data)[i];
3061  if( (int64) ((int32 *) buf_to_write)[i] != ((int64 *) data)[i] )
3062  {
3063  _TIFFfree( buf_to_write );
3065  "Value exceeds 32bit range of output type." );
3066  return 0;
3067  }
3068  }
3069  }
3070  else if( (datatype == TIFF_LONG && in_datatype == TIFF_LONG8)
3071  || (datatype == TIFF_IFD && in_datatype == TIFF_IFD8) )
3072  {
3073  tmsize_t i;
3074 
3075  for( i = 0; i < count; i++ )
3076  {
3077  ((uint32 *) buf_to_write)[i] =
3078  (uint32) ((uint64 *) data)[i];
3079  if( (uint64) ((uint32 *) buf_to_write)[i] != ((uint64 *) data)[i] )
3080  {
3081  _TIFFfree( buf_to_write );
3083  "Value exceeds 32bit range of output type." );
3084  return 0;
3085  }
3086  }
3087  }
3088  else if( datatype == TIFF_SHORT && in_datatype == TIFF_LONG8 )
3089  {
3090  tmsize_t i;
3091 
3092  for( i = 0; i < count; i++ )
3093  {
3094  ((uint16 *) buf_to_write)[i] =
3095  (uint16) ((uint64 *) data)[i];
3096  if( (uint64) ((uint16 *) buf_to_write)[i] != ((uint64 *) data)[i] )
3097  {
3098  _TIFFfree( buf_to_write );
3100  "Value exceeds 16bit range of output type." );
3101  return 0;
3102  }
3103  }
3104  }
3105  else
3106  {
3108  "Unhandled type conversion." );
3109  return 0;
3110  }
3111 
3112  if( TIFFDataWidth(datatype) > 1 && (tif->tif_flags&TIFF_SWAB) )
3113  {
3114  if( TIFFDataWidth(datatype) == 2 )
3115  TIFFSwabArrayOfShort( (uint16 *) buf_to_write, count );
3116  else if( TIFFDataWidth(datatype) == 4 )
3117  TIFFSwabArrayOfLong( (uint32 *) buf_to_write, count );
3118  else if( TIFFDataWidth(datatype) == 8 )
3119  TIFFSwabArrayOfLong8( (uint64 *) buf_to_write, count );
3120  }
3121 
3122 /* -------------------------------------------------------------------- */
3123 /* Is this a value that fits into the directory entry? */
3124 /* -------------------------------------------------------------------- */
3125  if (!(tif->tif_flags&TIFF_BIGTIFF))
3126  {
3127  if( TIFFDataWidth(datatype) * count <= 4 )
3128  {
3129  entry_offset = read_offset + 8;
3130  value_in_entry = 1;
3131  }
3132  }
3133  else
3134  {
3135  if( TIFFDataWidth(datatype) * count <= 8 )
3136  {
3137  entry_offset = read_offset + 12;
3138  value_in_entry = 1;
3139  }
3140  }
3141 
3146  {
3147  tif->tif_dir.td_stripoffset_entry.tdir_type = datatype;
3149  }
3150  else if( (tag == TIFFTAG_TILEBYTECOUNTS || tag == TIFFTAG_STRIPBYTECOUNTS) &&
3154  {
3155  tif->tif_dir.td_stripbytecount_entry.tdir_type = datatype;
3157  }
3158 
3159 /* -------------------------------------------------------------------- */
3160 /* If the tag type, and count match, then we just write it out */
3161 /* over the old values without altering the directory entry at */
3162 /* all. */
3163 /* -------------------------------------------------------------------- */
3164  if( entry_count == (uint64)count && entry_type == (uint16) datatype )
3165  {
3166  if (!SeekOK(tif, entry_offset)) {
3167  _TIFFfree( buf_to_write );
3169  "%s: Seek error accessing TIFF directory",
3170  tif->tif_name);
3171  return 0;
3172  }
3173  if (!WriteOK(tif, buf_to_write, count*TIFFDataWidth(datatype))) {
3174  _TIFFfree( buf_to_write );
3176  "Error writing directory link");
3177  return (0);
3178  }
3179 
3180  _TIFFfree( buf_to_write );
3181  return 1;
3182  }
3183 
3184 /* -------------------------------------------------------------------- */
3185 /* Otherwise, we write the new tag data at the end of the file. */
3186 /* -------------------------------------------------------------------- */
3187  if( !value_in_entry )
3188  {
3189  entry_offset = TIFFSeekFile(tif,0,SEEK_END);
3190 
3191  if (!WriteOK(tif, buf_to_write, count*TIFFDataWidth(datatype))) {
3192  _TIFFfree( buf_to_write );
3194  "Error writing directory link");
3195  return (0);
3196  }
3197  }
3198  else
3199  {
3200  memcpy( &entry_offset, buf_to_write, count*TIFFDataWidth(datatype));
3201  }
3202 
3203  _TIFFfree( buf_to_write );
3204  buf_to_write = 0;
3205 
3206 /* -------------------------------------------------------------------- */
3207 /* Adjust the directory entry. */
3208 /* -------------------------------------------------------------------- */
3209  entry_type = datatype;
3210  entry_count = (uint64)count;
3211  memcpy( direntry_raw + 2, &entry_type, sizeof(uint16) );
3212  if (tif->tif_flags&TIFF_SWAB)
3213  TIFFSwabShort( (uint16 *) (direntry_raw + 2) );
3214 
3215  if (!(tif->tif_flags&TIFF_BIGTIFF))
3216  {
3217  uint32 value;
3218 
3219  value = (uint32) entry_count;
3220  memcpy( direntry_raw + 4, &value, sizeof(uint32) );
3221  if (tif->tif_flags&TIFF_SWAB)
3222  TIFFSwabLong( (uint32 *) (direntry_raw + 4) );
3223 
3224  value = (uint32) entry_offset;
3225  memcpy( direntry_raw + 8, &value, sizeof(uint32) );
3226  if (tif->tif_flags&TIFF_SWAB)
3227  TIFFSwabLong( (uint32 *) (direntry_raw + 8) );
3228  }
3229  else
3230  {
3231  memcpy( direntry_raw + 4, &entry_count, sizeof(uint64) );
3232  if (tif->tif_flags&TIFF_SWAB)
3233  TIFFSwabLong8( (uint64 *) (direntry_raw + 4) );
3234 
3235  memcpy( direntry_raw + 12, &entry_offset, sizeof(uint64) );
3236  if (tif->tif_flags&TIFF_SWAB)
3237  TIFFSwabLong8( (uint64 *) (direntry_raw + 12) );
3238  }
3239 
3240 /* -------------------------------------------------------------------- */
3241 /* Write the directory entry out to disk. */
3242 /* -------------------------------------------------------------------- */
3243  if (!SeekOK(tif, read_offset )) {
3245  "%s: Seek error accessing TIFF directory",
3246  tif->tif_name);
3247  return 0;
3248  }
3249 
3250  if (!WriteOK(tif, direntry_raw,dirsize))
3251  {
3253  "%s: Can not write TIFF directory entry.",
3254  tif->tif_name);
3255  return 0;
3256  }
3257 
3258  return 1;
3259 }
unsigned long long uint64
Definition: platform.h:18
#define TIFF_ANY
Definition: tiffio.h:307
void TIFFSwabArrayOfShort(register uint16 *wp, tmsize_t n)
Definition: tif_swab.c:71
#define TIFFTAG_STRIPBYTECOUNTS
Definition: tiff.h:234
#define WriteOK(tif, buf, size)
Definition: tiffiop.h:259
GLuint GLuint GLsizei count
Definition: gl.h:1545
unsigned int uint32
Definition: types.h:32
#define TIFFSeekFile(tif, off, whence)
Definition: tiffiop.h:237
Definition: ecma_167.h:138
#define TIFFTAG_STRIPOFFSETS
Definition: tiff.h:222
thandle_t tif_clientdata
Definition: tiffiop.h:207
long long int64
Definition: platform.h:13
char * tif_name
Definition: tiffiop.h:116
#define TIFFTAG_TILEBYTECOUNTS
Definition: tiff.h:289
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define TIFF_BIGTIFF
Definition: tiffiop.h:138
#define TIFF_SWAB
Definition: tiffiop.h:126
TIFF_SSIZE_T tmsize_t
Definition: tiffio.h:65
TIFFDirEntry td_stripbytecount_entry
Definition: tif_dir.h:108
void * _TIFFCheckMalloc(TIFF *tif, tmsize_t nmemb, tmsize_t elem_size, const char *what)
Definition: tif_aux.c:121
uint32 tif_flags
Definition: tiffiop.h:119
smooth NULL
Definition: ftsmooth.c:416
#define TIFFTAG_TILEOFFSETS
Definition: tiff.h:288
#define isMapped(tif)
Definition: tiffiop.h:230
static int WriteAsLong4(TIFF *tif, uint64 strile_size)
void TIFFSwabShort(uint16 *wp)
Definition: tif_swab.c:34
unsigned char uint8
Definition: types.h:28
void TIFFSwabArrayOfLong(register uint32 *lp, tmsize_t n)
Definition: tif_swab.c:103
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
uint64 TIFFTileSize64(TIFF *tif)
Definition: tif_tile.c:252
uint64 tdir_count
Definition: tif_dir.h:55
uint64 tif_diroff
Definition: tiffiop.h:146
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
union TIFFDirEntry::@3425 tdir_offset
GLsizei const GLfloat * value
Definition: glext.h:6069
int TIFFDataWidth(TIFFDataType type)
Definition: tif_dirinfo.c:438
uint64 TIFFStripSize64(TIFF *tif)
Definition: tif_strip.c:193
void TIFFSwabLong(uint32 *lp)
Definition: tif_swab.c:45
unsigned short uint16
Definition: types.h:30
TIFFDirectory tif_dir
Definition: tiffiop.h:151
TIFFDirEntry td_stripoffset_entry
Definition: tif_dir.h:107
void TIFFSwabArrayOfLong8(register uint64 *lp, tmsize_t n)
Definition: tif_swab.c:120
#define SeekOK(tif, off)
Definition: tiffiop.h:256
long int32
Definition: platform.h:12
#define ReadOK(tif, buf, size)
Definition: tiffiop.h:252
const TIFFField * TIFFFindField(TIFF *tif, uint32 tag, TIFFDataType dt)
Definition: tif_dirinfo.c:506
#define SEEK_END
Definition: cabinet.c:27
static int WriteAsLong8(TIFF *tif, uint64 strile_size)
Definition: tiff.h:137
void _TIFFfree(void *p)
Definition: tif_unix.c:326
uint64 toff_long8
Definition: tif_dir.h:59
TIFFDataType
Definition: tiff.h:123
void TIFFSwabLong8(uint64 *lp)
Definition: tif_swab.c:57
uint16 tdir_type
Definition: tif_dir.h:54

Referenced by TIFFForceStrileArrayWriting().

◆ _WriteAsType()

static int _WriteAsType ( TIFF tif,
uint64  strile_size,
uint64  uncompressed_threshold 
)
static

Definition at line 1700 of file tif_dirwrite.c.

1701 {
1703  if ( compression == COMPRESSION_NONE )
1704  {
1705  return strile_size > uncompressed_threshold;
1706  }
1707  else if ( compression == COMPRESSION_JPEG ||
1714  {
1715  /* For a few select compression types, we assume that in the worst */
1716  /* case the compressed size will be 10 times the uncompressed size */
1717  /* This is overly pessismistic ! */
1718  return strile_size >= uncompressed_threshold / 10;
1719  }
1720  return 1;
1721 }
#define COMPRESSION_WEBP
Definition: tiff.h:194
#define COMPRESSION_LERC
Definition: tiff.h:190
#define COMPRESSION_LZMA
Definition: tiff.h:192
#define COMPRESSION_NONE
Definition: tiff.h:158
#define COMPRESSION_JPEG
Definition: tiff.h:166
_In_ fcb _In_ chunk _In_ uint64_t _In_ uint64_t _In_ bool _In_opt_ void _In_opt_ PIRP _In_ LIST_ENTRY _In_ uint8_t compression
Definition: btrfs_drv.h:1357
#define COMPRESSION_ADOBE_DEFLATE
Definition: tiff.h:182
unsigned short uint16
Definition: types.h:30
TIFFDirectory tif_dir
Definition: tiffiop.h:151
#define COMPRESSION_ZSTD
Definition: tiff.h:193
uint16 td_compression
Definition: tif_dir.h:77
#define COMPRESSION_LZW
Definition: tiff.h:164

Referenced by WriteAsLong4(), and WriteAsLong8().

◆ TIFFCheckpointDirectory()

int TIFFCheckpointDirectory ( TIFF tif)

Definition at line 237 of file tif_dirwrite.c.

238 {
239  int rc;
240  /* Setup the strips arrays, if they haven't already been. */
241  if (tif->tif_dir.td_stripoffset_p == NULL)
242  (void) TIFFSetupStrips(tif);
244  (void) TIFFSetWriteOffset(tif, TIFFSeekFile(tif, 0, SEEK_END));
245  return rc;
246 }
static int TIFFWriteDirectorySec(TIFF *tif, int isimage, int imagedone, uint64 *pdiroff)
Definition: tif_dirwrite.c:407
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
int TIFFSetupStrips(TIFF *tif)
Definition: tif_write.c:523
#define TRUE
Definition: types.h:120
#define TIFFSeekFile(tif, off, whence)
Definition: tiffiop.h:237
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:416
void TIFFSetWriteOffset(TIFF *tif, toff_t off)
Definition: tif_write.c:834
TIFFDirectory tif_dir
Definition: tiffiop.h:151
uint64 * td_stripoffset_p
Definition: tif_dir.h:101
#define SEEK_END
Definition: cabinet.c:27

◆ TIFFClampDoubleToInt16()

static int16 TIFFClampDoubleToInt16 ( double  val)
static

Definition at line 1003 of file tif_dirwrite.c.

1004 {
1005  if( val > 32767 )
1006  return 32767;
1007  if( val < -32768 || val != val )
1008  return -32768;
1009  return (int16)val;
1010 }
GLuint GLfloat * val
Definition: glext.h:7180
short int16
Definition: platform.h:11

Referenced by TIFFWriteDirectoryTagSampleformatArray().

◆ TIFFClampDoubleToInt32()

static int32 TIFFClampDoubleToInt32 ( double  val)
static

Definition at line 1012 of file tif_dirwrite.c.

1013 {
1014  if( val > 0x7FFFFFFF )
1015  return 0x7FFFFFFF;
1016  if( val < -0x7FFFFFFF-1 || val != val )
1017  return -0x7FFFFFFF-1;
1018  return (int32)val;
1019 }
GLuint GLfloat * val
Definition: glext.h:7180
long int32
Definition: platform.h:12

Referenced by TIFFWriteDirectoryTagSampleformatArray().

◆ TIFFClampDoubleToInt8()

static int8 TIFFClampDoubleToInt8 ( double  val)
static

Definition at line 994 of file tif_dirwrite.c.

995 {
996  if( val > 127 )
997  return 127;
998  if( val < -128 || val != val )
999  return -128;
1000  return (int8)val;
1001 }
GLuint GLfloat * val
Definition: glext.h:7180
char int8
Definition: platform.h:10

Referenced by TIFFWriteDirectoryTagSampleformatArray().

◆ TIFFClampDoubleToUInt16()

static uint16 TIFFClampDoubleToUInt16 ( double  val)
static

Definition at line 1030 of file tif_dirwrite.c.

1031 {
1032  if( val < 0 )
1033  return 0;
1034  if( val > 65535 || val != val )
1035  return 65535;
1036  return (uint16)val;
1037 }
GLuint GLfloat * val
Definition: glext.h:7180
unsigned short uint16
Definition: types.h:30

Referenced by TIFFWriteDirectoryTagSampleformatArray().

◆ TIFFClampDoubleToUInt32()

static uint32 TIFFClampDoubleToUInt32 ( double  val)
static

Definition at line 1039 of file tif_dirwrite.c.

1040 {
1041  if( val < 0 )
1042  return 0;
1043  if( val > 0xFFFFFFFFU || val != val )
1044  return 0xFFFFFFFFU;
1045  return (uint32)val;
1046 }
unsigned int uint32
Definition: types.h:32
#define U(x)
Definition: wordpad.c:45
GLuint GLfloat * val
Definition: glext.h:7180

Referenced by TIFFWriteDirectoryTagSampleformatArray().

◆ TIFFClampDoubleToUInt8()

static uint8 TIFFClampDoubleToUInt8 ( double  val)
static

Definition at line 1021 of file tif_dirwrite.c.

1022 {
1023  if( val < 0 )
1024  return 0;
1025  if( val > 255 || val != val )
1026  return 255;
1027  return (uint8)val;
1028 }
GLuint GLfloat * val
Definition: glext.h:7180
unsigned char uint8
Definition: types.h:28

Referenced by TIFFWriteDirectoryTagSampleformatArray().

◆ TIFFCvtNativeToIEEEDouble()

void TIFFCvtNativeToIEEEDouble ( TIFF tif,
uint32  n,
double dp 
)

◆ TIFFCvtNativeToIEEEFloat()

void TIFFCvtNativeToIEEEFloat ( TIFF tif,
uint32  n,
float fp 
)

◆ TIFFDeferStrileArrayWriting()

int TIFFDeferStrileArrayWriting ( TIFF tif)

Definition at line 210 of file tif_dirwrite.c.

211 {
212  static const char module[] = "TIFFDeferStrileArrayWriting";
213  if (tif->tif_mode == O_RDONLY)
214  {
216  "File opened in read-only mode");
217  return 0;
218  }
219  if( tif->tif_diroff != 0 )
220  {
222  "Directory has already been written");
223  return 0;
224  }
225 
227  return 1;
228 }
#define TRUE
Definition: types.h:120
thandle_t tif_clientdata
Definition: tiffiop.h:207
char * tif_name
Definition: tiffiop.h:116
int tif_mode
Definition: tiffiop.h:118
unsigned char td_deferstrilearraywriting
Definition: tif_dir.h:124
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
uint64 tif_diroff
Definition: tiffiop.h:146
TIFFDirectory tif_dir
Definition: tiffiop.h:151
#define O_RDONLY
Definition: acwin.h:108

◆ TIFFLinkDirectory()

static int TIFFLinkDirectory ( TIFF tif)
static

Definition at line 2622 of file tif_dirwrite.c.

2623 {
2624  static const char module[] = "TIFFLinkDirectory";
2625 
2626  tif->tif_diroff = (TIFFSeekFile(tif,0,SEEK_END)+1) & (~((toff_t)1));
2627 
2628  /*
2629  * Handle SubIFDs
2630  */
2631  if (tif->tif_flags & TIFF_INSUBIFD)
2632  {
2633  if (!(tif->tif_flags&TIFF_BIGTIFF))
2634  {
2635  uint32 m;
2636  m = (uint32)tif->tif_diroff;
2637  if (tif->tif_flags & TIFF_SWAB)
2638  TIFFSwabLong(&m);
2639  (void) TIFFSeekFile(tif, tif->tif_subifdoff, SEEK_SET);
2640  if (!WriteOK(tif, &m, 4)) {
2642  "Error writing SubIFD directory link");
2643  return (0);
2644  }
2645  /*
2646  * Advance to the next SubIFD or, if this is
2647  * the last one configured, revert back to the
2648  * normal directory linkage.
2649  */
2650  if (--tif->tif_nsubifd)
2651  tif->tif_subifdoff += 4;
2652  else
2653  tif->tif_flags &= ~TIFF_INSUBIFD;
2654  return (1);
2655  }
2656  else
2657  {
2658  uint64 m;
2659  m = tif->tif_diroff;
2660  if (tif->tif_flags & TIFF_SWAB)
2661  TIFFSwabLong8(&m);
2662  (void) TIFFSeekFile(tif, tif->tif_subifdoff, SEEK_SET);
2663  if (!WriteOK(tif, &m, 8)) {
2665  "Error writing SubIFD directory link");
2666  return (0);
2667  }
2668  /*
2669  * Advance to the next SubIFD or, if this is
2670  * the last one configured, revert back to the
2671  * normal directory linkage.
2672  */
2673  if (--tif->tif_nsubifd)
2674  tif->tif_subifdoff += 8;
2675  else
2676  tif->tif_flags &= ~TIFF_INSUBIFD;
2677  return (1);
2678  }
2679  }
2680 
2681  if (!(tif->tif_flags&TIFF_BIGTIFF))
2682  {
2683  uint32 m;
2684  uint32 nextdir;
2685  m = (uint32)(tif->tif_diroff);
2686  if (tif->tif_flags & TIFF_SWAB)
2687  TIFFSwabLong(&m);
2688  if (tif->tif_header.classic.tiff_diroff == 0) {
2689  /*
2690  * First directory, overwrite offset in header.
2691  */
2693  (void) TIFFSeekFile(tif,4, SEEK_SET);
2694  if (!WriteOK(tif, &m, 4)) {
2696  "Error writing TIFF header");
2697  return (0);
2698  }
2699  return (1);
2700  }
2701  /*
2702  * Not the first directory, search to the last and append.
2703  */
2704  nextdir = tif->tif_header.classic.tiff_diroff;
2705  while(1) {
2706  uint16 dircount;
2707  uint32 nextnextdir;
2708 
2709  if (!SeekOK(tif, nextdir) ||
2710  !ReadOK(tif, &dircount, 2)) {
2712  "Error fetching directory count");
2713  return (0);
2714  }
2715  if (tif->tif_flags & TIFF_SWAB)
2716  TIFFSwabShort(&dircount);
2717  (void) TIFFSeekFile(tif,
2718  nextdir+2+dircount*12, SEEK_SET);
2719  if (!ReadOK(tif, &nextnextdir, 4)) {
2721  "Error fetching directory link");
2722  return (0);
2723  }
2724  if (tif->tif_flags & TIFF_SWAB)
2725  TIFFSwabLong(&nextnextdir);
2726  if (nextnextdir==0)
2727  {
2728  (void) TIFFSeekFile(tif,
2729  nextdir+2+dircount*12, SEEK_SET);
2730  if (!WriteOK(tif, &m, 4)) {
2732  "Error writing directory link");
2733  return (0);
2734  }
2735  break;
2736  }
2737  nextdir=nextnextdir;
2738  }
2739  }
2740  else
2741  {
2742  uint64 m;
2743  uint64 nextdir;
2744  m = tif->tif_diroff;
2745  if (tif->tif_flags & TIFF_SWAB)
2746  TIFFSwabLong8(&m);
2747  if (tif->tif_header.big.tiff_diroff == 0) {
2748  /*
2749  * First directory, overwrite offset in header.
2750  */
2751  tif->tif_header.big.tiff_diroff = tif->tif_diroff;
2752  (void) TIFFSeekFile(tif,8, SEEK_SET);
2753  if (!WriteOK(tif, &m, 8)) {
2755  "Error writing TIFF header");
2756  return (0);
2757  }
2758  return (1);
2759  }
2760  /*
2761  * Not the first directory, search to the last and append.
2762  */
2763  nextdir = tif->tif_header.big.tiff_diroff;
2764  while(1) {
2765  uint64 dircount64;
2766  uint16 dircount;
2767  uint64 nextnextdir;
2768 
2769  if (!SeekOK(tif, nextdir) ||
2770  !ReadOK(tif, &dircount64, 8)) {
2772  "Error fetching directory count");
2773  return (0);
2774  }
2775  if (tif->tif_flags & TIFF_SWAB)
2776  TIFFSwabLong8(&dircount64);
2777  if (dircount64>0xFFFF)
2778  {
2780  "Sanity check on tag count failed, likely corrupt TIFF");
2781  return (0);
2782  }
2783  dircount=(uint16)dircount64;
2784  (void) TIFFSeekFile(tif,
2785  nextdir+8+dircount*20, SEEK_SET);
2786  if (!ReadOK(tif, &nextnextdir, 8)) {
2788  "Error fetching directory link");
2789  return (0);
2790  }
2791  if (tif->tif_flags & TIFF_SWAB)
2792  TIFFSwabLong8(&nextnextdir);
2793  if (nextnextdir==0)
2794  {
2795  (void) TIFFSeekFile(tif,
2796  nextdir+8+dircount*20, SEEK_SET);
2797  if (!WriteOK(tif, &m, 8)) {
2799  "Error writing directory link");
2800  return (0);
2801  }
2802  break;
2803  }
2804  nextdir=nextnextdir;
2805  }
2806  }
2807  return (1);
2808 }
unsigned long long uint64
Definition: platform.h:18
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
union tiff::@3427 tif_header
#define WriteOK(tif, buf, size)
Definition: tiffiop.h:259
unsigned int uint32
Definition: types.h:32
#define TIFFSeekFile(tif, off, whence)
Definition: tiffiop.h:237
uint64 toff_t
Definition: tiffio.h:66
thandle_t tif_clientdata
Definition: tiffiop.h:207
char * tif_name
Definition: tiffiop.h:116
const GLfloat * m
Definition: glext.h:10848
#define TIFF_BIGTIFF
Definition: tiffiop.h:138
#define TIFF_SWAB
Definition: tiffiop.h:126
uint16 tif_nsubifd
Definition: tiffiop.h:165
uint32 tif_flags
Definition: tiffiop.h:119
#define SEEK_SET
Definition: jmemansi.c:26
void TIFFSwabShort(uint16 *wp)
Definition: tif_swab.c:34
uint32 tiff_diroff
Definition: tiff.h:98
if(!(yy_init))
Definition: macro.lex.yy.c:714
uint64 tif_subifdoff
Definition: tiffiop.h:166
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
uint64 tif_diroff
Definition: tiffiop.h:146
TIFFHeaderBig big
Definition: tiffiop.h:156
void TIFFSwabLong(uint32 *lp)
Definition: tif_swab.c:45
unsigned short uint16
Definition: types.h:30
#define SeekOK(tif, off)
Definition: tiffiop.h:256
#define ReadOK(tif, buf, size)
Definition: tiffiop.h:252
#define SEEK_END
Definition: cabinet.c:27
uint64 tiff_diroff
Definition: tiff.h:105
TIFFHeaderClassic classic
Definition: tiffiop.h:155
#define TIFF_INSUBIFD
Definition: tiffiop.h:132
void TIFFSwabLong8(uint64 *lp)
Definition: tif_swab.c:57

Referenced by TIFFWriteDirectorySec().

◆ TIFFRewriteDirectory()

int TIFFRewriteDirectory ( TIFF tif)

Definition at line 261 of file tif_dirwrite.c.

262 {
263  static const char module[] = "TIFFRewriteDirectory";
264 
265  /* We don't need to do anything special if it hasn't been written. */
266  if( tif->tif_diroff == 0 )
267  return TIFFWriteDirectory( tif );
268 
269  /*
270  * Find and zero the pointer to this directory, so that TIFFLinkDirectory
271  * will cause it to be added after this directories current pre-link.
272  */
273 
274  if (!(tif->tif_flags&TIFF_BIGTIFF))
275  {
276  if (tif->tif_header.classic.tiff_diroff == tif->tif_diroff)
277  {
278  tif->tif_header.classic.tiff_diroff = 0;
279  tif->tif_diroff = 0;
280 
281  TIFFSeekFile(tif,4,SEEK_SET);
282  if (!WriteOK(tif, &(tif->tif_header.classic.tiff_diroff),4))
283  {
285  "Error updating TIFF header");
286  return (0);
287  }
288  }
289  else
290  {
291  uint32 nextdir;
292  nextdir = tif->tif_header.classic.tiff_diroff;
293  while(1) {
294  uint16 dircount;
295  uint32 nextnextdir;
296 
297  if (!SeekOK(tif, nextdir) ||
298  !ReadOK(tif, &dircount, 2)) {
300  "Error fetching directory count");
301  return (0);
302  }
303  if (tif->tif_flags & TIFF_SWAB)
304  TIFFSwabShort(&dircount);
305  (void) TIFFSeekFile(tif,
306  nextdir+2+dircount*12, SEEK_SET);
307  if (!ReadOK(tif, &nextnextdir, 4)) {
309  "Error fetching directory link");
310  return (0);
311  }
312  if (tif->tif_flags & TIFF_SWAB)
313  TIFFSwabLong(&nextnextdir);
314  if (nextnextdir==tif->tif_diroff)
315  {
316  uint32 m;
317  m=0;
318  (void) TIFFSeekFile(tif,
319  nextdir+2+dircount*12, SEEK_SET);
320  if (!WriteOK(tif, &m, 4)) {
322  "Error writing directory link");
323  return (0);
324  }
325  tif->tif_diroff=0;
326  break;
327  }
328  nextdir=nextnextdir;
329  }
330  }
331  }
332  else
333  {
334  if (tif->tif_header.big.tiff_diroff == tif->tif_diroff)
335  {
336  tif->tif_header.big.tiff_diroff = 0;
337  tif->tif_diroff = 0;
338 
339  TIFFSeekFile(tif,8,SEEK_SET);
340  if (!WriteOK(tif, &(tif->tif_header.big.tiff_diroff),8))
341  {
343  "Error updating TIFF header");
344  return (0);
345  }
346  }
347  else
348  {
349  uint64 nextdir;
350  nextdir = tif->tif_header.big.tiff_diroff;
351  while(1) {
352  uint64 dircount64;
353  uint16 dircount;
354  uint64 nextnextdir;
355 
356  if (!SeekOK(tif, nextdir) ||
357  !ReadOK(tif, &dircount64, 8)) {
359  "Error fetching directory count");
360  return (0);
361  }
362  if (tif->tif_flags & TIFF_SWAB)
363  TIFFSwabLong8(&dircount64);
364  if (dircount64>0xFFFF)
365  {
367  "Sanity check on tag count failed, likely corrupt TIFF");
368  return (0);
369  }
370  dircount=(uint16)dircount64;
371  (void) TIFFSeekFile(tif,
372  nextdir+8+dircount*20, SEEK_SET);
373  if (!ReadOK(tif, &nextnextdir, 8)) {
375  "Error fetching directory link");
376  return (0);
377  }
378  if (tif->tif_flags & TIFF_SWAB)
379  TIFFSwabLong8(&nextnextdir);
380  if (nextnextdir==tif->tif_diroff)
381  {
382  uint64 m;
383  m=0;
384  (void) TIFFSeekFile(tif,
385  nextdir+8+dircount*20, SEEK_SET);
386  if (!WriteOK(tif, &m, 8)) {
388  "Error writing directory link");
389  return (0);
390  }
391  tif->tif_diroff=0;
392  break;
393  }
394  nextdir=nextnextdir;
395  }
396  }
397  }
398 
399  /*
400  * Now use TIFFWriteDirectory() normally.
401  */
402 
403  return TIFFWriteDirectory( tif );
404 }
unsigned long long uint64
Definition: platform.h:18
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
union tiff::@3427 tif_header
#define WriteOK(tif, buf, size)
Definition: tiffiop.h:259
unsigned int uint32
Definition: types.h:32
#define TIFFSeekFile(tif, off, whence)
Definition: tiffiop.h:237
thandle_t tif_clientdata
Definition: tiffiop.h:207
char * tif_name
Definition: tiffiop.h:116
const GLfloat * m
Definition: glext.h:10848
#define TIFF_BIGTIFF
Definition: tiffiop.h:138
#define TIFF_SWAB
Definition: tiffiop.h:126
int TIFFWriteDirectory(TIFF *tif)
Definition: tif_dirwrite.c:180
uint32 tif_flags
Definition: tiffiop.h:119
#define SEEK_SET
Definition: jmemansi.c:26
void TIFFSwabShort(uint16 *wp)
Definition: tif_swab.c:34
uint32 tiff_diroff
Definition: tiff.h:98
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
uint64 tif_diroff
Definition: tiffiop.h:146
TIFFHeaderBig big
Definition: tiffiop.h:156
void TIFFSwabLong(uint32 *lp)
Definition: tif_swab.c:45
unsigned short uint16
Definition: types.h:30
#define SeekOK(tif, off)
Definition: tiffiop.h:256
#define ReadOK(tif, buf, size)
Definition: tiffiop.h:252
uint64 tiff_diroff
Definition: tiff.h:105
TIFFHeaderClassic classic
Definition: tiffiop.h:155
void TIFFSwabLong8(uint64 *lp)
Definition: tif_swab.c:57

Referenced by TIFFFlush().

◆ TIFFWriteCustomDirectory()

int TIFFWriteCustomDirectory ( TIFF tif,
uint64 pdiroff 
)

Definition at line 249 of file tif_dirwrite.c.

250 {
251  return TIFFWriteDirectorySec(tif,FALSE,FALSE,pdiroff);
252 }
static int TIFFWriteDirectorySec(TIFF *tif, int isimage, int imagedone, uint64 *pdiroff)
Definition: tif_dirwrite.c:407
#define FALSE
Definition: types.h:117

◆ TIFFWriteDirectory()

int TIFFWriteDirectory ( TIFF tif)

Definition at line 180 of file tif_dirwrite.c.

181 {
182  return TIFFWriteDirectorySec(tif,TRUE,TRUE,NULL);
183 }
static int TIFFWriteDirectorySec(TIFF *tif, int isimage, int imagedone, uint64 *pdiroff)
Definition: tif_dirwrite.c:407
#define TRUE
Definition: types.h:120
smooth NULL
Definition: ftsmooth.c:416

Referenced by TIFFRewriteDirectory().

◆ TIFFWriteDirectorySec()

static int TIFFWriteDirectorySec ( TIFF tif,
int  isimage,
int  imagedone,
uint64 pdiroff 
)
static

Definition at line 407 of file tif_dirwrite.c.

408 {
409  static const char module[] = "TIFFWriteDirectorySec";
410  uint32 ndir;
411  TIFFDirEntry* dir;
412  uint32 dirsize;
413  void* dirmem;
414  uint32 m;
415  if (tif->tif_mode == O_RDONLY)
416  return (1);
417 
418  _TIFFFillStriles( tif );
419 
420  /*
421  * Clear write state so that subsequent images with
422  * different characteristics get the right buffers
423  * setup for them.
424  */
425  if (imagedone)
426  {
427  if (tif->tif_flags & TIFF_POSTENCODE)
428  {
429  tif->tif_flags &= ~TIFF_POSTENCODE;
430  if (!(*tif->tif_postencode)(tif))
431  {
433  "Error post-encoding before directory write");
434  return (0);
435  }
436  }
437  (*tif->tif_close)(tif); /* shutdown encoder */
438  /*
439  * Flush any data that might have been written
440  * by the compression close+cleanup routines. But
441  * be careful not to write stuff if we didn't add data
442  * in the previous steps as the "rawcc" data may well be
443  * a previously read tile/strip in mixed read/write mode.
444  */
445  if (tif->tif_rawcc > 0
446  && (tif->tif_flags & TIFF_BEENWRITING) != 0 )
447  {
448  if( !TIFFFlushData1(tif) )
449  {
451  "Error flushing data before directory write");
452  return (0);
453  }
454  }
455  if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata)
456  {
457  _TIFFfree(tif->tif_rawdata);
458  tif->tif_rawdata = NULL;
459  tif->tif_rawcc = 0;
460  tif->tif_rawdatasize = 0;
461  tif->tif_rawdataoff = 0;
462  tif->tif_rawdataloaded = 0;
463  }
465  }
466  dir=NULL;
467  dirmem=NULL;
468  dirsize=0;
469  while (1)
470  {
471  ndir=0;
472  if (isimage)
473  {
475  {
477  goto bad;
479  goto bad;
480  }
482  {
484  goto bad;
486  goto bad;
487  }
489  {
491  goto bad;
493  goto bad;
494  }
495  if (TIFFFieldSet(tif,FIELD_POSITION))
496  {
498  goto bad;
500  goto bad;
501  }
503  {
505  goto bad;
506  }
508  {
510  goto bad;
511  }
513  {
515  goto bad;
516  }
518  {
520  goto bad;
521  }
523  {
525  goto bad;
526  }
527  if (TIFFFieldSet(tif,FIELD_FILLORDER))
528  {
530  goto bad;
531  }
533  {
535  goto bad;
536  }
538  {
540  goto bad;
541  }
543  {
545  goto bad;
546  }
548  {
550  goto bad;
551  }
553  {
555  goto bad;
556  }
558  {
560  goto bad;
561  }
563  {
565  goto bad;
566  }
568  {
570  goto bad;
571  }
573  {
574  if (!isTiled(tif))
575  {
577  goto bad;
578  }
579  else
580  {
582  goto bad;
583  }
584  }
586  {
587  if (!isTiled(tif))
588  {
589  /* td_stripoffset_p might be NULL in an odd OJPEG case. See
590  * tif_dirread.c around line 3634.
591  * XXX: OJPEG hack.
592  * If a) compression is OJPEG, b) it's not a tiled TIFF,
593  * and c) the number of strips is 1,
594  * then we tolerate the absence of stripoffsets tag,
595  * because, presumably, all required data is in the
596  * JpegInterchangeFormat stream.
597  * We can get here when using tiffset on such a file.
598  * See http://bugzilla.maptools.org/show_bug.cgi?id=2500
599  */
600  if (tif->tif_dir.td_stripoffset_p != NULL &&
602  goto bad;
603  }
604  else
605  {
607  goto bad;
608  }
609  }
610  if (TIFFFieldSet(tif,FIELD_COLORMAP))
611  {
612  if (!TIFFWriteDirectoryTagColormap(tif,&ndir,dir))
613  goto bad;
614  }
616  {
617  if (tif->tif_dir.td_extrasamples)
618  {
619  uint16 na;
620  uint16* nb;
623  goto bad;
624  }
625  }
627  {
629  goto bad;
630  }
632  {
634  goto bad;
635  }
637  {
639  goto bad;
640  }
642  {
644  goto bad;
645  }
646  if (TIFFFieldSet(tif,FIELD_TILEDEPTH))
647  {
649  goto bad;
650  }
652  {
654  goto bad;
655  }
657  {
659  goto bad;
660  }
662  {
664  goto bad;
665  }
667  {
669  goto bad;
670  }
672  {
674  goto bad;
675  }
676  if (TIFFFieldSet(tif,FIELD_INKNAMES))
677  {
679  goto bad;
680  }
681  if (TIFFFieldSet(tif,FIELD_SUBIFD))
682  {
683  if (!TIFFWriteDirectoryTagSubifd(tif,&ndir,dir))
684  goto bad;
685  }
686  {
687  uint32 n;
688  for (n=0; n<tif->tif_nfields; n++) {
689  const TIFFField* o;
690  o = tif->tif_fields[n];
691  if ((o->field_bit>=FIELD_CODEC)&&(TIFFFieldSet(tif,o->field_bit)))
692  {
693  switch (o->get_field_type)
694  {
695  case TIFF_SETGET_ASCII:
696  {
697  uint32 pa;
698  char* pb;
701  assert(o->field_passcount==0);
702  TIFFGetField(tif,o->field_tag,&pb);
703  pa=(uint32)(strlen(pb));
704  if (!TIFFWriteDirectoryTagAscii(tif,&ndir,dir,(uint16)o->field_tag,pa,pb))
705  goto bad;
706  }
707  break;
708  case TIFF_SETGET_UINT16:
709  {
710  uint16 p;
712  assert(o->field_readcount==1);
713  assert(o->field_passcount==0);
714  TIFFGetField(tif,o->field_tag,&p);
715  if (!TIFFWriteDirectoryTagShort(tif,&ndir,dir,(uint16)o->field_tag,p))
716  goto bad;
717  }
718  break;
719  case TIFF_SETGET_UINT32:
720  {
721  uint32 p;
723  assert(o->field_readcount==1);
724  assert(o->field_passcount==0);
725  TIFFGetField(tif,o->field_tag,&p);
726  if (!TIFFWriteDirectoryTagLong(tif,&ndir,dir,(uint16)o->field_tag,p))
727  goto bad;
728  }
729  break;
731  {
732  uint32 pa;
733  void* pb;
736  assert(o->field_passcount==1);
737  TIFFGetField(tif,o->field_tag,&pa,&pb);
739  goto bad;
740  }
741  break;
742  default:
744  "Cannot write tag %d (%s)",
745  TIFFFieldTag(o),
746  o->field_name ? o->field_name : "unknown");
747  goto bad;
748  }
749  }
750  }
751  }
752  }
753  for (m=0; m<(uint32)(tif->tif_dir.td_customValueCount); m++)
754  {
758  {
759  case TIFF_ASCII:
761  goto bad;
762  break;
763  case TIFF_UNDEFINED:
765  goto bad;
766  break;
767  case TIFF_BYTE:
769  goto bad;
770  break;
771  case TIFF_SBYTE:
773  goto bad;
774  break;
775  case TIFF_SHORT:
777  goto bad;
778  break;
779  case TIFF_SSHORT:
781  goto bad;
782  break;
783  case TIFF_LONG:
785  goto bad;
786  break;
787  case TIFF_SLONG:
789  goto bad;
790  break;
791  case TIFF_LONG8:
793  goto bad;
794  break;
795  case TIFF_SLONG8:
797  goto bad;
798  break;
799  case TIFF_RATIONAL:
801  goto bad;
802  break;
803  case TIFF_SRATIONAL:
805  goto bad;
806  break;
807  case TIFF_FLOAT:
809  goto bad;
810  break;
811  case TIFF_DOUBLE:
813  goto bad;
814  break;
815  case TIFF_IFD:
817  goto bad;
818  break;
819  case TIFF_IFD8:
821  goto bad;
822  break;
823  default:
824  assert(0); /* we should never get here */
825  break;
826  }
827  }
828  if (dir!=NULL)
829  break;
830  dir=_TIFFmalloc(ndir*sizeof(TIFFDirEntry));
831  if (dir==NULL)
832  {
833  TIFFErrorExt(tif->tif_clientdata,module,"Out of memory");
834  goto bad;
835  }
836  if (isimage)
837  {
838  if ((tif->tif_diroff==0)&&(!TIFFLinkDirectory(tif)))
839  goto bad;
840  }
841  else
842  tif->tif_diroff=(TIFFSeekFile(tif,0,SEEK_END)+1)&(~((toff_t)1));
843  if (pdiroff!=NULL)
844  *pdiroff=tif->tif_diroff;
845  if (!(tif->tif_flags&TIFF_BIGTIFF))
846  dirsize=2+ndir*12+4;
847  else
848  dirsize=8+ndir*20+8;
849  tif->tif_dataoff=tif->tif_diroff+dirsize;
850  if (!(tif->tif_flags&TIFF_BIGTIFF))
851  tif->tif_dataoff=(uint32)tif->tif_dataoff;
852  if ((tif->tif_dataoff<tif->tif_diroff)||(tif->tif_dataoff<(uint64)dirsize))
853  {
854  TIFFErrorExt(tif->tif_clientdata,module,"Maximum TIFF file size exceeded");
855  goto bad;
856  }
857  if (tif->tif_dataoff&1)
858  tif->tif_dataoff++;
859  if (isimage)
860  tif->tif_curdir++;
861  }
862  if (isimage)
863  {
864  if (TIFFFieldSet(tif,FIELD_SUBIFD)&&(tif->tif_subifdoff==0))
865  {
866  uint32 na;
867  TIFFDirEntry* nb;
868  for (na=0, nb=dir; ; na++, nb++)
869  {
870  if( na == ndir )
871  {
873  "Cannot find SubIFD tag");
874  goto bad;
875  }
876  if (nb->tdir_tag==TIFFTAG_SUBIFD)
877  break;
878  }
879  if (!(tif->tif_flags&TIFF_BIGTIFF))
880  tif->tif_subifdoff=tif->tif_diroff+2+na*12+8;
881  else
882  tif->tif_subifdoff=tif->tif_diroff+8+na*20+12;
883  }
884  }
885  dirmem=_TIFFmalloc(dirsize);
886  if (dirmem==NULL)
887  {
888  TIFFErrorExt(tif->tif_clientdata,module,"Out of memory");
889  goto bad;
890  }
891  if (!(tif->tif_flags&TIFF_BIGTIFF))
892  {
893  uint8* n;
894  uint32 nTmp;
895  TIFFDirEntry* o;
896  n=dirmem;
897  *(uint16*)n=(uint16)ndir;
898  if (tif->tif_flags&TIFF_SWAB)
900  n+=2;
901  o=dir;
902  for (m=0; m<ndir; m++)
903  {
904  *(uint16*)n=o->tdir_tag;
905  if (tif->tif_flags&TIFF_SWAB)
907  n+=2;
908  *(uint16*)n=o->tdir_type;
909  if (tif->tif_flags&TIFF_SWAB)
911  n+=2;
912  nTmp = (uint32)o->tdir_count;
913  _TIFFmemcpy(n,&nTmp,4);
914  if (tif->tif_flags&TIFF_SWAB)
915  TIFFSwabLong((uint32*)n);
916  n+=4;
917  /* This is correct. The data has been */
918  /* swabbed previously in TIFFWriteDirectoryTagData */
919  _TIFFmemcpy(n,&o->tdir_offset,4);
920  n+=4;
921  o++;
922  }
923  nTmp = (uint32)tif->tif_nextdiroff;
924  if (tif->tif_flags&TIFF_SWAB)
925  TIFFSwabLong(&nTmp);
926  _TIFFmemcpy(n,&nTmp,4);
927  }
928  else
929  {
930  uint8* n;
931  TIFFDirEntry* o;
932  n=dirmem;
933  *(uint64*)n=ndir;
934  if (tif->tif_flags&TIFF_SWAB)
936  n+=8;
937  o=dir;
938  for (m=0; m<ndir; m++)
939  {
940  *(uint16*)n=o->tdir_tag;
941  if (tif->tif_flags&TIFF_SWAB)
943  n+=2;
944  *(uint16*)n=o->tdir_type;
945  if (tif->tif_flags&TIFF_SWAB)
947  n+=2;
948  _TIFFmemcpy(n,&o->tdir_count,8);
949  if (tif->tif_flags&TIFF_SWAB)
951  n+=8;
952  _TIFFmemcpy(n,&o->tdir_offset,8);
953  n+=8;
954  o++;
955  }
956  _TIFFmemcpy(n,&tif->tif_nextdiroff,8);
957  if (tif->tif_flags&TIFF_SWAB)
959  }
960  _TIFFfree(dir);
961  dir=NULL;
962  if (!SeekOK(tif,tif->tif_diroff))
963  {
964  TIFFErrorExt(tif->tif_clientdata,module,"IO error writing directory");
965  goto bad;
966  }
967  if (!WriteOK(tif,dirmem,(tmsize_t)dirsize))
968  {
969  TIFFErrorExt(tif->tif_clientdata,module,"IO error writing directory");
970  goto bad;
971  }
972  _TIFFfree(dirmem);
973  if (imagedone)
974  {
975  TIFFFreeDirectory(tif);
976  tif->tif_flags &= ~TIFF_DIRTYDIRECT;
977  tif->tif_flags &= ~TIFF_DIRTYSTRIP;
978  (*tif->tif_cleanup)(tif);
979  /*
980  * Reset directory-related state for subsequent
981  * directories.
982  */
983  TIFFCreateDirectory(tif);
984  }
985  return(1);
986 bad:
987  if (dir!=NULL)
988  _TIFFfree(dir);
989  if (dirmem!=NULL)
990  _TIFFfree(dirmem);
991  return(0);
992 }
unsigned long long uint64
Definition: platform.h:18
static int TIFFWriteDirectoryTagTransferfunction(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir)
#define TIFFTAG_SUBFILETYPE
Definition: tiff.h:146
#define TIFF_BEENWRITING
Definition: tiffiop.h:125
#define TIFF_VARIABLE
Definition: tiffio.h:308
static int TIFFWriteDirectoryTagShortLong(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 value)
uint16 td_ycbcrpositioning
Definition: tif_dir.h:113
uint32 TIFFFieldTag(const TIFFField *fip)
Definition: tif_dirinfo.c:582
float td_yposition
Definition: tif_dir.h:90
uint16 td_bitspersample
Definition: tif_dir.h:75
uint32 td_tiledepth
Definition: tif_dir.h:73
#define FIELD_MINSAMPLEVALUE
Definition: tif_dir.h:156
#define FIELD_RESOLUTION
Definition: tif_dir.h:143
#define TIFFTAG_BITSPERSAMPLE
Definition: tiff.h:156
#define TIFFTAG_ROWSPERSTRIP
Definition: tiff.h:233
char * td_inknames
Definition: tif_dir.h:119
int td_inknameslen
Definition: tif_dir.h:118
#define FIELD_STRIPOFFSETS
Definition: tif_dir.h:162
#define TIFFTAG_STRIPBYTECOUNTS
Definition: tiff.h:234
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define TIFFTAG_EXTRASAMPLES
Definition: tiff.h:304
#define WriteOK(tif, buf, size)
Definition: tiffiop.h:259
#define TIFFTAG_ORIENTATION
Definition: tiff.h:223
#define FIELD_IMAGEDIMENSIONS
Definition: tif_dir.h:141
GLuint GLuint GLsizei count
Definition: gl.h:1545
unsigned int uint32
Definition: types.h:32
#define TIFFSeekFile(tif, off, whence)
Definition: tiffiop.h:237
#define TIFFTAG_IMAGEWIDTH
Definition: tiff.h:154
#define FIELD_THRESHHOLDING
Definition: tif_dir.h:151
#define TIFFTAG_YRESOLUTION
Definition: tiff.h:238
#define TIFFTAG_MINSAMPLEVALUE
Definition: tiff.h:235
#define TIFFTAG_INKNAMES
Definition: tiff.h:300
#define TIFFTAG_FILLORDER
Definition: tiff.h:215
uint64 toff_t
Definition: tiffio.h:66
TIFFTagValue * td_customValues
Definition: tif_dir.h:122
uint16 td_halftonehints[2]
Definition: tif_dir.h:93
GLdouble n
Definition: glext.h:7729
static int TIFFWriteDirectoryTagRationalArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, float *value)
uint64 * td_stripbytecount_p
Definition: tif_dir.h:102
int count
Definition: tif_dir.h:37
#define assert(x)
Definition: debug.h:53
Definition: ecma_167.h:138
#define FIELD_HALFTONEHINTS
Definition: tif_dir.h:170
TIFFVoidMethod tif_close
Definition: tiffiop.h:186
uint8 * tif_rawdata
Definition: tiffiop.h:195
uint32 td_imagedepth
Definition: tif_dir.h:72
int td_customValueCount
Definition: tif_dir.h:121
#define TIFFTAG_STRIPOFFSETS
Definition: tiff.h:222
#define TIFFTAG_SUBIFD
Definition: tiff.h:296
#define TIFFTAG_THRESHHOLDING
Definition: tiff.h:209
#define TIFFTAG_YCBCRSUBSAMPLING
Definition: tiff.h:367
thandle_t tif_clientdata
Definition: tiffiop.h:207
tmsize_t tif_rawdataoff
Definition: tiffiop.h:197
#define FIELD_RESOLUTIONUNIT
Definition: tif_dir.h:159
#define TIFFTAG_YPOSITION
Definition: tiff.h:244
#define TIFFTAG_SMINSAMPLEVALUE
Definition: tiff.h:315
#define TIFFTAG_REFERENCEBLACKWHITE
Definition: tiff.h:371
tmsize_t tif_rawcc
Definition: tiffiop.h:200
uint16 tif_curdir
Definition: tiffiop.h:160
#define TIFFTAG_PLANARCONFIG
Definition: tiff.h:239
#define TIFF_DIRTYDIRECT
Definition: tiffiop.h:122
const GLfloat * m
Definition: glext.h:10848
static int TIFFWriteDirectoryTagSrationalArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, float *value)
#define FIELD_YCBCRSUBSAMPLING
Definition: tif_dir.h:171
#define FIELD_SMAXSAMPLEVALUE
Definition: tif_dir.h:167
float td_xresolution
Definition: tif_dir.h:87
#define TIFFTAG_TILEBYTECOUNTS
Definition: tiff.h:289
uint32 td_tilelength
Definition: tif_dir.h:73
unsigned short field_bit
Definition: tif_dir.h:290
#define FIELD_SUBIFD
Definition: tif_dir.h:176
#define FIELD_TRANSFERFUNCTION
Definition: tif_dir.h:174
#define FIELD_FILLORDER
Definition: tif_dir.h:152
static int TIFFWriteDirectoryTagShort(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 value)
#define FIELD_MAXSAMPLEVALUE
Definition: tif_dir.h:157
int TIFFGetField(TIFF *tif, uint32 tag,...)
Definition: tif_dir.c:1232
static int TIFFWriteDirectoryTagShortArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint16 *value)
static int TIFFWriteDirectoryTagLongLong8Array(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint64 *value)
float td_xposition
Definition: tif_dir.h:90
#define FIELD_BITSPERSAMPLE
Definition: tif_dir.h:148
#define TIFF_BIGTIFF
Definition: tiffiop.h:138
#define TIFF_SWAB
Definition: tiffiop.h:126
#define TIFFTAG_YCBCRPOSITIONING
Definition: tiff.h:368
#define TIFFTAG_TILEWIDTH
Definition: tiff.h:286
char * field_name
Definition: tif_dir.h:293
#define FIELD_STRIPBYTECOUNTS
Definition: tif_dir.h:161
uint32 td_subfiletype
Definition: tif_dir.h:74
TIFF_SSIZE_T tmsize_t
Definition: tiffio.h:65
uint16 td_resolutionunit
Definition: tif_dir.h:88
#define TIFFTAG_TILELENGTH
Definition: tiff.h:287
int tif_mode
Definition: tiffiop.h:118
uint32 tif_flags
Definition: tiffiop.h:119
smooth NULL
Definition: ftsmooth.c:416
static int TIFFWriteDirectoryTagIfdIfd8Array(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint64 *value)
#define TIFFTAG_IMAGELENGTH
Definition: tiff.h:155
#define FIELD_PLANARCONFIG
Definition: tif_dir.h:158
size_t tif_nfields
Definition: tiffiop.h:217
#define TIFFTAG_TILEOFFSETS
Definition: tiff.h:288
#define TIFFTAG_SAMPLESPERPIXEL
Definition: tiff.h:232
uint16 td_planarconfig
Definition: tif_dir.h:89
switch(r->id)
Definition: btrfs.c:2980
unsigned int dir
Definition: maze.c:112
double * td_sminsamplevalue
Definition: tif_dir.h:85
uint64 tif_nextdiroff
Definition: tiffiop.h:147
#define TIFF_POSTENCODE
Definition: tiffiop.h:131
static int TIFFWriteDirectoryTagSshortArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, int16 *value)
static int TIFFWriteDirectoryTagSubifd(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir)
uint16 td_orientation
Definition: tif_dir.h:81
uint16 td_minsamplevalue
Definition: tif_dir.h:84
void * _TIFFmalloc(tmsize_t s)
Definition: tif_unix.c:309
TIFFSetGetFieldType get_field_type
Definition: tif_dir.h:289
void TIFFFreeDirectory(TIFF *tif)
Definition: tif_dir.c:1268
unsigned char field_passcount
Definition: tif_dir.h:292
static int ** pa
Definition: server.c:126
uint32 td_nstrips
Definition: tif_dir.h:100
static int TIFFWriteDirectoryTagByteArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint8 *value)
void TIFFSwabShort(uint16 *wp)
Definition: tif_swab.c:34
int TIFFGetFieldDefaulted(TIFF *tif, uint32 tag,...)
Definition: tif_aux.c:345
TIFFBoolMethod tif_postencode
Definition: tiffiop.h:179
const TIFFField * info
Definition: tif_dir.h:36
if(!(yy_init))
Definition: macro.lex.yy.c:714
uint16 td_extrasamples
Definition: tif_dir.h:94
uint32 td_imagelength
Definition: tif_dir.h:72
uint32 field_tag
Definition: tif_dir.h:283
#define TIFFTAG_XPOSITION
Definition: tiff.h:243
uint16 td_photometric
Definition: tif_dir.h:78
uint16 tdir_tag
Definition: tif_dir.h:53
#define TIFFTAG_HALFTONEHINTS
Definition: tiff.h:285
uint64 tif_subifdoff
Definition: tiffiop.h:166
unsigned char uint8
Definition: types.h:28
#define FIELD_PHOTOMETRIC
Definition: tif_dir.h:150
uint64 tif_dataoff
Definition: tiffiop.h:163
static int TIFFWriteDirectoryTagShortPerSample(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 value)
static int TIFFWriteDirectoryTagLong(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 value)
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
static int TIFFLinkDirectory(TIFF *)
double * td_smaxsamplevalue
Definition: tif_dir.h:86
#define TIFFTAG_PHOTOMETRIC
Definition: tiff.h:195
tmsize_t tif_rawdatasize
Definition: tiffiop.h:196
#define TIFFFieldSet(tif, field)
Definition: tif_dir.h:196
uint16 td_fillorder
Definition: tif_dir.h:80
#define TIFFTAG_PAGENUMBER
Definition: tiff.h:266
static int TIFFWriteDirectoryTagIfdArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint32 *value)
#define FIELD_COMPRESSION
Definition: tif_dir.h:149
#define FIELD_SMINSAMPLEVALUE
Definition: tif_dir.h:166
#define FIELD_ROWSPERSTRIP
Definition: tif_dir.h:155
uint64 tdir_count
Definition: tif_dir.h:55
#define TIFF_DIRTYSTRIP
Definition: tiffiop.h:140
tmsize_t tif_rawdataloaded
Definition: tiffiop.h:198
static int TIFFWriteDirectoryTagLong8Array(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint64 *value)
#define FIELD_INKNAMES
Definition: tif_dir.h:175
uint64 tif_diroff
Definition: tiffiop.h:146
#define TIFFTAG_COMPRESSION
Definition: tiff.h:157
uint32 td_tilewidth
Definition: tif_dir.h:73
#define FIELD_ORIENTATION
Definition: tif_dir.h:153
uint16 td_sampleformat
Definition: tif_dir.h:76
uint16 td_threshholding
Definition: tif_dir.h:79
union TIFFDirEntry::@3425 tdir_offset
TIFFVoidMethod tif_cleanup
Definition: tiffiop.h:188
uint16 td_pagenumber[2]
Definition: tif_dir.h:91
static int TIFFWriteDirectoryTagRational(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, double value)
#define FIELD_IMAGEDEPTH
Definition: tif_dir.h:168
static int TIFFWriteDirectoryTagFloatArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, float *value)
#define isTiled(tif)
Definition: tiffiop.h:229
#define TIFFTAG_SMAXSAMPLEVALUE
Definition: tiff.h:316
#define TIFF_BUFFERSETUP
Definition: tiffiop.h:123
#define FIELD_YCBCRPOSITIONING
Definition: tif_dir.h:172
TIFFField ** tif_fields
Definition: tiffiop.h:216
#define FIELD_CODEC
Definition: tif_dir.h:179
#define FIELD_EXTRASAMPLES
Definition: tif_dir.h:164
#define TIFF_VARIABLE2
Definition: tiffio.h:310
uint16 td_maxsamplevalue
Definition: tif_dir.h:84
void * value
Definition: tif_dir.h:38
uint32 td_rowsperstrip
Definition: tif_dir.h:83
TIFFDataType field_type
Definition: tif_dir.h:286
#define TIFFTAG_TILEDEPTH
Definition: tiff.h:387
#define TIFFTAG_IMAGEDEPTH
Definition: tiff.h:386
#define TIFFTAG_RESOLUTIONUNIT
Definition: tiff.h:262
static int TIFFWriteDirectoryTagLongArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint32 *value)
void TIFFSwabLong(uint32 *lp)
Definition: tif_swab.c:45
uint16 td_ycbcrsubsampling[2]
Definition: tif_dir.h:112
#define TIFFTAG_XRESOLUTION
Definition: tiff.h:237
unsigned short uint16
Definition: types.h:30
#define FIELD_POSITION
Definition: tif_dir.h:144
TIFFDirectory tif_dir
Definition: tiffiop.h:151
static int TIFFWriteDirectoryTagAscii(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, char *value)
#define FIELD_PAGENUMBER
Definition: tif_dir.h:160
#define FIELD_TILEDEPTH
Definition: tif_dir.h:169
static int TIFFWriteDirectoryTagSbyteArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, int8 *value)
#define FIELD_TILEDIMENSIONS
Definition: tif_dir.h:142
#define SeekOK(tif, off)
Definition: tiffiop.h:256
float * td_refblackwhite
Definition: tif_dir.h:116
static int TIFFWriteDirectoryTagColormap(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir)
uint64 * td_stripoffset_p
Definition: tif_dir.h:101
static int TIFFWriteDirectoryTagSlong8Array(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, int64 *value)
#define FIELD_COLORMAP
Definition: tif_dir.h:163
#define FIELD_SAMPLESPERPIXEL
Definition: tif_dir.h:154
float td_yresolution
Definition: tif_dir.h:87
#define SEEK_END
Definition: cabinet.c:27
uint16 td_samplesperpixel
Definition: tif_dir.h:82
static int TIFFWriteDirectoryTagSampleformatArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, double *value)
#define FIELD_REFBLACKWHITE
Definition: tif_dir.h:173
Definition: tiff.h:137
int TIFFCreateDirectory(TIFF *tif)
Definition: tif_dir.c:1327
uint16 td_compression
Definition: tif_dir.h:77
void _TIFFfree(void *p)
Definition: tif_unix.c:326
#define TIFFTAG_SAMPLEFORMAT
Definition: tiff.h:308
GLfloat GLfloat p
Definition: glext.h:8902
#define FIELD_SAMPLEFORMAT
Definition: tif_dir.h:165
uint32 td_imagewidth
Definition: tif_dir.h:72
int TIFFFlushData1(TIFF *tif)
Definition: tif_write.c:803
void _TIFFmemcpy(void *d, const void *s, tmsize_t c)
Definition: tif_unix.c:344
#define TIFFTAG_MAXSAMPLEVALUE
Definition: tiff.h:236
#define TIFF_MYBUFFER
Definition: tiffiop.h:128
static int TIFFWriteDirectoryTagUndefinedArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint8 *value)
void TIFFSwabLong8(uint64 *lp)
Definition: tif_swab.c:57
int _TIFFFillStriles(TIFF *tif)
Definition: tif_dirread.c:6320
#define FIELD_SUBFILETYPE
Definition: tif_dir.h:147
static int TIFFWriteDirectoryTagDoubleArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, double *value)
uint16 tdir_type
Definition: tif_dir.h:54
short field_readcount
Definition: tif_dir.h:284
#define O_RDONLY
Definition: acwin.h:108
static int TIFFWriteDirectoryTagSlongArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, int32 *value)

Referenced by TIFFCheckpointDirectory(), TIFFWriteCustomDirectory(), and TIFFWriteDirectory().

◆ TIFFWriteDirectoryTagAscii()

static int TIFFWriteDirectoryTagAscii ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
char value 
)
static

Definition at line 1156 of file tif_dirwrite.c.

1157 {
1158  if (dir==NULL)
1159  {
1160  (*ndir)++;
1161  return(1);
1162  }
1164 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
Definition: ecma_167.h:138
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112
static int TIFFWriteDirectoryTagCheckedAscii(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, char *value)

Referenced by TIFFWriteDirectorySec().

◆ TIFFWriteDirectoryTagByteArray()

static int TIFFWriteDirectoryTagByteArray ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
uint8 value 
)
static

Definition at line 1191 of file tif_dirwrite.c.

1192 {
1193  if (dir==NULL)
1194  {
1195  (*ndir)++;
1196  return(1);
1197  }
1199 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
Definition: ecma_167.h:138
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112
static int TIFFWriteDirectoryTagCheckedByteArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint8 *value)

Referenced by TIFFWriteDirectorySec(), and TIFFWriteDirectoryTagSampleformatArray().

◆ TIFFWriteDirectoryTagCheckedAscii()

static int TIFFWriteDirectoryTagCheckedAscii ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
char value 
)
static

Definition at line 2124 of file tif_dirwrite.c.

2125 {
2126  assert(sizeof(char)==1);
2128 }
static int TIFFWriteDirectoryTagData(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 datatype, uint32 count, uint32 datalength, void *data)
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define assert(x)
Definition: debug.h:53
Definition: ecma_167.h:138
unsigned int dir
Definition: maze.c:112

Referenced by TIFFWriteDirectoryTagAscii().

◆ TIFFWriteDirectoryTagCheckedByteArray()

static int TIFFWriteDirectoryTagCheckedByteArray ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
uint8 value 
)
static

Definition at line 2147 of file tif_dirwrite.c.

2148 {
2149  assert(sizeof(uint8)==1);
2151 }
static int TIFFWriteDirectoryTagData(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 datatype, uint32 count, uint32 datalength, void *data)
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define assert(x)
Definition: debug.h:53
Definition: ecma_167.h:138
unsigned int dir
Definition: maze.c:112
unsigned char uint8
Definition: types.h:28

Referenced by TIFFWriteDirectoryTagByteArray().

◆ TIFFWriteDirectoryTagCheckedDoubleArray()

static int TIFFWriteDirectoryTagCheckedDoubleArray ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
double value 
)
static

Definition at line 2512 of file tif_dirwrite.c.

2513 {
2514  assert(count<0x20000000);
2515  assert(sizeof(double)==8);
2517  if (tif->tif_flags&TIFF_SWAB)
2520 }
static int TIFFWriteDirectoryTagData(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 datatype, uint32 count, uint32 datalength, void *data)
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define assert(x)
Definition: debug.h:53
Definition: ecma_167.h:138
#define TIFF_SWAB
Definition: tiffiop.h:126
uint32 tif_flags
Definition: tiffiop.h:119
unsigned int dir
Definition: maze.c:112
void TIFFCvtNativeToIEEEDouble(TIFF *tif, uint32 n, double *dp)
void TIFFSwabArrayOfDouble(double *dp, tmsize_t n)
Definition: tif_swab.c:182

Referenced by TIFFWriteDirectoryTagDoubleArray().

◆ TIFFWriteDirectoryTagCheckedFloatArray()

static int TIFFWriteDirectoryTagCheckedFloatArray ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
float value 
)
static

Definition at line 2487 of file tif_dirwrite.c.

2488 {
2489  assert(count<0x40000000);
2490  assert(sizeof(float)==4);
2492  if (tif->tif_flags&TIFF_SWAB)
2495 }
static int TIFFWriteDirectoryTagData(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 datatype, uint32 count, uint32 datalength, void *data)
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define assert(x)
Definition: debug.h:53
Definition: ecma_167.h:138
void TIFFSwabArrayOfFloat(register float *fp, tmsize_t n)
Definition: tif_swab.c:151
#define TIFF_SWAB
Definition: tiffiop.h:126
uint32 tif_flags
Definition: tiffiop.h:119
unsigned int dir
Definition: maze.c:112
void TIFFCvtNativeToIEEEFloat(TIFF *tif, uint32 n, float *fp)

Referenced by TIFFWriteDirectoryTagFloatArray().

◆ TIFFWriteDirectoryTagCheckedIfd8Array()

static int TIFFWriteDirectoryTagCheckedIfd8Array ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
uint64 value 
)
static

Definition at line 2533 of file tif_dirwrite.c.

2534 {
2535  assert(count<0x20000000);
2536  assert(sizeof(uint64)==8);
2538  if (tif->tif_flags&TIFF_SWAB)
2541 }
unsigned long long uint64
Definition: platform.h:18
static int TIFFWriteDirectoryTagData(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 datatype, uint32 count, uint32 datalength, void *data)
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define assert(x)
Definition: debug.h:53
Definition: ecma_167.h:138
#define TIFF_BIGTIFF
Definition: tiffiop.h:138
#define TIFF_SWAB
Definition: tiffiop.h:126
uint32 tif_flags
Definition: tiffiop.h:119
unsigned int dir
Definition: maze.c:112
void TIFFSwabArrayOfLong8(register uint64 *lp, tmsize_t n)
Definition: tif_swab.c:120

Referenced by TIFFWriteDirectoryTagIfdIfd8Array(), and TIFFWriteDirectoryTagSubifd().

◆ TIFFWriteDirectoryTagCheckedIfdArray()

static int TIFFWriteDirectoryTagCheckedIfdArray ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
uint32 value 
)
static

Definition at line 2523 of file tif_dirwrite.c.

2524 {
2525  assert(count<0x40000000);
2526  assert(sizeof(uint32)==4);
2527  if (tif->tif_flags&TIFF_SWAB)
2530 }
static int TIFFWriteDirectoryTagData(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 datatype, uint32 count, uint32 datalength, void *data)
GLuint GLuint GLsizei count
Definition: gl.h:1545
unsigned int uint32
Definition: types.h:32
#define assert(x)
Definition: debug.h:53
Definition: ecma_167.h:138
#define TIFF_SWAB
Definition: tiffiop.h:126
uint32 tif_flags
Definition: tiffiop.h:119
unsigned int dir
Definition: maze.c:112
void TIFFSwabArrayOfLong(register uint32 *lp, tmsize_t n)
Definition: tif_swab.c:103
Definition: tiff.h:137

Referenced by TIFFWriteDirectoryTagIfdArray(), TIFFWriteDirectoryTagIfdIfd8Array(), and TIFFWriteDirectoryTagSubifd().

◆ TIFFWriteDirectoryTagCheckedLong()

static int TIFFWriteDirectoryTagCheckedLong ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  value 
)
static

Definition at line 2214 of file tif_dirwrite.c.

2215 {
2216  uint32 m;
2217  assert(sizeof(uint32)==4);
2218  m=value;
2219  if (tif->tif_flags&TIFF_SWAB)
2220  TIFFSwabLong(&m);
2221  return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_LONG,1,4,&m));
2222 }
static int TIFFWriteDirectoryTagData(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 datatype, uint32 count, uint32 datalength, void *data)
unsigned int uint32
Definition: types.h:32
#define assert(x)
Definition: debug.h:53
Definition: ecma_167.h:138
const GLfloat * m
Definition: glext.h:10848
#define TIFF_SWAB
Definition: tiffiop.h:126
uint32 tif_flags
Definition: tiffiop.h:119
unsigned int dir
Definition: maze.c:112
GLsizei const GLfloat * value
Definition: glext.h:6069
void TIFFSwabLong(uint32 *lp)
Definition: tif_swab.c:45

Referenced by TIFFWriteDirectoryTagLong(), and TIFFWriteDirectoryTagShortLong().

◆ TIFFWriteDirectoryTagCheckedLong8Array()

static int TIFFWriteDirectoryTagCheckedLong8Array ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
uint64 value 
)
static

Definition at line 2275 of file tif_dirwrite.c.

2276 {
2277  assert(count<0x20000000);
2278  assert(sizeof(uint64)==8);
2279  if( !(tif->tif_flags&TIFF_BIGTIFF) ) {
2280  TIFFErrorExt(tif->tif_clientdata,"TIFFWriteDirectoryTagCheckedLong8Array","LONG8 not allowed for ClassicTIFF");
2281  return(0);
2282  }
2283  if (tif->tif_flags&TIFF_SWAB)
2286 }
unsigned long long uint64
Definition: platform.h:18
static int TIFFWriteDirectoryTagData(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 datatype, uint32 count, uint32 datalength, void *data)
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define assert(x)
Definition: debug.h:53
Definition: ecma_167.h:138
thandle_t tif_clientdata
Definition: tiffiop.h:207
#define TIFF_BIGTIFF
Definition: tiffiop.h:138
#define TIFF_SWAB
Definition: tiffiop.h:126
uint32 tif_flags
Definition: tiffiop.h:119
unsigned int dir
Definition: maze.c:112
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
void TIFFSwabArrayOfLong8(register uint64 *lp, tmsize_t n)
Definition: tif_swab.c:120

Referenced by TIFFWriteDirectoryTagLong8Array(), and TIFFWriteDirectoryTagLongLong8Array().

◆ TIFFWriteDirectoryTagCheckedLongArray()

static int TIFFWriteDirectoryTagCheckedLongArray ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
uint32 value 
)
static

Definition at line 2225 of file tif_dirwrite.c.

2226 {
2227  assert(count<0x40000000);
2228  assert(sizeof(uint32)==4);
2229  if (tif->tif_flags&TIFF_SWAB)
2232 }
static int TIFFWriteDirectoryTagData(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 datatype, uint32 count, uint32 datalength, void *data)
GLuint GLuint GLsizei count
Definition: gl.h:1545
unsigned int uint32
Definition: types.h:32
#define assert(x)
Definition: debug.h:53
Definition: ecma_167.h:138
#define TIFF_SWAB
Definition: tiffiop.h:126
uint32 tif_flags
Definition: tiffiop.h:119
unsigned int dir
Definition: maze.c:112
void TIFFSwabArrayOfLong(register uint32 *lp, tmsize_t n)
Definition: tif_swab.c:103

Referenced by TIFFWriteDirectoryTagLongArray(), and TIFFWriteDirectoryTagLongLong8Array().

◆ TIFFWriteDirectoryTagCheckedRational()

static int TIFFWriteDirectoryTagCheckedRational ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
double  value 
)
static

Definition at line 2320 of file tif_dirwrite.c.

2321 {
2322  static const char module[] = "TIFFWriteDirectoryTagCheckedRational";
2323  uint32 m[2];
2324  assert(sizeof(uint32)==4);
2325  if( value < 0 )
2326  {
2327  TIFFErrorExt(tif->tif_clientdata,module,"Negative value is illegal");
2328  return 0;
2329  }
2330  else if( value != value )
2331  {
2332  TIFFErrorExt(tif->tif_clientdata,module,"Not-a-number value is illegal");
2333  return 0;
2334  }
2335  else if (value==0.0)
2336  {
2337  m[0]=0;
2338  m[1]=1;
2339  }
2340  else if (value <= 0xFFFFFFFFU && value==(double)(uint32)value)
2341  {
2342  m[0]=(uint32)value;
2343  m[1]=1;
2344  }
2345  else if (value<1.0)
2346  {
2347  m[0]=(uint32)(value*0xFFFFFFFF);
2348  m[1]=0xFFFFFFFF;
2349  }
2350  else
2351  {
2352  m[0]=0xFFFFFFFF;
2353  m[1]=(uint32)(0xFFFFFFFF/value);
2354  }
2355  if (tif->tif_flags&TIFF_SWAB)
2356  {
2357  TIFFSwabLong(&m[0]);
2358  TIFFSwabLong(&m[1]);
2359  }
2360  return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_RATIONAL,1,8,&m[0]));
2361 }
static int TIFFWriteDirectoryTagData(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 datatype, uint32 count, uint32 datalength, void *data)
unsigned int uint32
Definition: types.h:32
#define assert(x)
Definition: debug.h:53
Definition: ecma_167.h:138
thandle_t tif_clientdata
Definition: tiffiop.h:207
const GLfloat * m
Definition: glext.h:10848
#define TIFF_SWAB
Definition: tiffiop.h:126
uint32 tif_flags
Definition: tiffiop.h:119
unsigned int dir
Definition: maze.c:112
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
void TIFFSwabLong(uint32 *lp)
Definition: tif_swab.c:45

Referenced by TIFFWriteDirectoryTagRational().

◆ TIFFWriteDirectoryTagCheckedRationalArray()

static int TIFFWriteDirectoryTagCheckedRationalArray ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
float value 
)
static

Definition at line 2364 of file tif_dirwrite.c.

2365 {
2366  static const char module[] = "TIFFWriteDirectoryTagCheckedRationalArray";
2367  uint32* m;
2368  float* na;
2369  uint32* nb;
2370  uint32 nc;
2371  int o;
2372  assert(sizeof(uint32)==4);
2373  m=_TIFFmalloc(count*2*sizeof(uint32));
2374  if (m==NULL)
2375  {
2376  TIFFErrorExt(tif->tif_clientdata,module,"Out of memory");
2377  return(0);
2378  }
2379  for (na=value, nb=m, nc=0; nc<count; na++, nb+=2, nc++)
2380  {
2381  if (*na<=0.0 || *na != *na)
2382  {
2383  nb[0]=0;
2384  nb[1]=1;
2385  }
2386  else if (*na >= 0 && *na <= (float)0xFFFFFFFFU &&
2387  *na==(float)(uint32)(*na))
2388  {
2389  nb[0]=(uint32)(*na);
2390  nb[1]=1;
2391  }
2392  else if (*na<1.0)
2393  {
2394  nb[0]=(uint32)((double)(*na)*0xFFFFFFFF);
2395  nb[1]=0xFFFFFFFF;
2396  }
2397  else
2398  {
2399  nb[0]=0xFFFFFFFF;
2400  nb[1]=(uint32)((double)0xFFFFFFFF/(*na));
2401  }
2402  }
2403  if (tif->tif_flags&TIFF_SWAB)
2406  _TIFFfree(m);
2407  return(o);
2408 }
static int TIFFWriteDirectoryTagData(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 datatype, uint32 count, uint32 datalength, void *data)
GLuint GLuint GLsizei count
Definition: gl.h:1545
unsigned int uint32
Definition: types.h:32
#define assert(x)
Definition: debug.h:53
Definition: ecma_167.h:138
thandle_t tif_clientdata
Definition: tiffiop.h:207
const GLfloat * m
Definition: glext.h:10848
#define TIFF_SWAB
Definition: tiffiop.h:126
uint32 tif_flags
Definition: tiffiop.h:119
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112
void * _TIFFmalloc(tmsize_t s)
Definition: tif_unix.c:309
void TIFFSwabArrayOfLong(register uint32 *lp, tmsize_t n)
Definition: tif_swab.c:103
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
void _TIFFfree(void *p)
Definition: tif_unix.c:326

Referenced by TIFFWriteDirectoryTagRationalArray().

◆ TIFFWriteDirectoryTagCheckedSbyteArray()

static int TIFFWriteDirectoryTagCheckedSbyteArray ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
int8 value 
)
static

Definition at line 2163 of file tif_dirwrite.c.

2164 {
2165  assert(sizeof(int8)==1);
2167 }
static int TIFFWriteDirectoryTagData(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 datatype, uint32 count, uint32 datalength, void *data)
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define assert(x)
Definition: debug.h:53
Definition: ecma_167.h:138
unsigned int dir
Definition: maze.c:112
char int8
Definition: platform.h:10

Referenced by TIFFWriteDirectoryTagSbyteArray().

◆ TIFFWriteDirectoryTagCheckedShort()

static int TIFFWriteDirectoryTagCheckedShort ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint16  value 
)
static

Definition at line 2170 of file tif_dirwrite.c.

2171 {
2172  uint16 m;
2173  assert(sizeof(uint16)==2);
2174  m=value;
2175  if (tif->tif_flags&TIFF_SWAB)
2176  TIFFSwabShort(&m);
2177  return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SHORT,1,2,&m));
2178 }
static int TIFFWriteDirectoryTagData(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 datatype, uint32 count, uint32 datalength, void *data)
#define assert(x)
Definition: debug.h:53
Definition: ecma_167.h:138
const GLfloat * m
Definition: glext.h:10848
#define TIFF_SWAB
Definition: tiffiop.h:126
uint32 tif_flags
Definition: tiffiop.h:119
unsigned int dir
Definition: maze.c:112
void TIFFSwabShort(uint16 *wp)
Definition: tif_swab.c:34
GLsizei const GLfloat * value
Definition: glext.h:6069
unsigned short uint16
Definition: types.h:30

Referenced by TIFFWriteDirectoryTagShort(), and TIFFWriteDirectoryTagShortLong().

◆ TIFFWriteDirectoryTagCheckedShortArray()

static int TIFFWriteDirectoryTagCheckedShortArray ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
uint16 value 
)
static

Definition at line 2181 of file tif_dirwrite.c.

2182 {
2183  assert(count<0x80000000);
2184  assert(sizeof(uint16)==2);
2185  if (tif->tif_flags&TIFF_SWAB)
2188 }
static int TIFFWriteDirectoryTagData(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 datatype, uint32 count, uint32 datalength, void *data)
void TIFFSwabArrayOfShort(register uint16 *wp, tmsize_t n)
Definition: tif_swab.c:71
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define assert(x)
Definition: debug.h:53
Definition: ecma_167.h:138
#define TIFF_SWAB
Definition: tiffiop.h:126
uint32 tif_flags
Definition: tiffiop.h:119
unsigned int dir
Definition: maze.c:112
unsigned short uint16
Definition: types.h:30

Referenced by TIFFWriteDirectoryTagColormap(), TIFFWriteDirectoryTagLongLong8Array(), TIFFWriteDirectoryTagShortArray(), TIFFWriteDirectoryTagShortPerSample(), and TIFFWriteDirectoryTagTransferfunction().

◆ TIFFWriteDirectoryTagCheckedSlong8Array()

static int TIFFWriteDirectoryTagCheckedSlong8Array ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
int64 value 
)
static

Definition at line 2306 of file tif_dirwrite.c.

2307 {
2308  assert(count<0x20000000);
2309  assert(sizeof(int64)==8);
2310  if( !(tif->tif_flags&TIFF_BIGTIFF) ) {
2311  TIFFErrorExt(tif->tif_clientdata,"TIFFWriteDirectoryTagCheckedSlong8Array","SLONG8 not allowed for ClassicTIFF");
2312  return(0);
2313  }
2314  if (tif->tif_flags&TIFF_SWAB)
2317 }
unsigned long long uint64
Definition: platform.h:18
static int TIFFWriteDirectoryTagData(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 datatype, uint32 count, uint32 datalength, void *data)
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define assert(x)
Definition: debug.h:53
Definition: ecma_167.h:138
thandle_t tif_clientdata
Definition: tiffiop.h:207
long long int64
Definition: platform.h:13
#define TIFF_BIGTIFF
Definition: tiffiop.h:138
#define TIFF_SWAB
Definition: tiffiop.h:126
uint32 tif_flags
Definition: tiffiop.h:119
unsigned int dir
Definition: maze.c:112
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
void TIFFSwabArrayOfLong8(register uint64 *lp, tmsize_t n)
Definition: tif_swab.c:120

Referenced by TIFFWriteDirectoryTagSlong8Array().

◆ TIFFWriteDirectoryTagCheckedSlongArray()

static int TIFFWriteDirectoryTagCheckedSlongArray ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
int32 value 
)
static

Definition at line 2248 of file tif_dirwrite.c.

2249 {
2250  assert(count<0x40000000);
2251  assert(sizeof(int32)==4);
2252  if (tif->tif_flags&TIFF_SWAB)
2255 }
static int TIFFWriteDirectoryTagData(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 datatype, uint32 count, uint32 datalength, void *data)
GLuint GLuint GLsizei count
Definition: gl.h:1545
unsigned int uint32
Definition: types.h:32
#define assert(x)
Definition: debug.h:53
Definition: ecma_167.h:138
#define TIFF_SWAB
Definition: tiffiop.h:126
uint32 tif_flags
Definition: tiffiop.h:119
unsigned int dir
Definition: maze.c:112
void TIFFSwabArrayOfLong(register uint32 *lp, tmsize_t n)
Definition: tif_swab.c:103
long int32
Definition: platform.h:12

Referenced by TIFFWriteDirectoryTagSlongArray().

◆ TIFFWriteDirectoryTagCheckedSrationalArray()

static int TIFFWriteDirectoryTagCheckedSrationalArray ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
float value 
)
static

Definition at line 2411 of file tif_dirwrite.c.

2412 {
2413  static const char module[] = "TIFFWriteDirectoryTagCheckedSrationalArray";
2414  int32* m;
2415  float* na;
2416  int32* nb;
2417  uint32 nc;
2418  int o;
2419  assert(sizeof(int32)==4);
2420  m=_TIFFmalloc(count*2*sizeof(int32));
2421  if (m==NULL)
2422  {
2423  TIFFErrorExt(tif->tif_clientdata,module,"Out of memory");
2424  return(0);
2425  }
2426  for (na=value, nb=m, nc=0; nc<count; na++, nb+=2, nc++)
2427  {
2428  if (*na<0.0)
2429  {
2430  if (*na==(int32)(*na))
2431  {
2432  nb[0]=(int32)(*na);
2433  nb[1]=1;
2434  }
2435  else if (*na>-1.0)
2436  {
2437  nb[0]=-(int32)((double)(-*na)*0x7FFFFFFF);
2438  nb[1]=0x7FFFFFFF;
2439  }
2440  else
2441  {
2442  nb[0]=-0x7FFFFFFF;
2443  nb[1]=(int32)((double)0x7FFFFFFF/(-*na));
2444  }
2445  }
2446  else
2447  {
2448  if (*na==(int32)(*na))
2449  {
2450  nb[0]=(int32)(*na);
2451  nb[1]=1;
2452  }
2453  else if (*na<1.0)
2454  {
2455  nb[0]=(int32)((double)(*na)*0x7FFFFFFF);
2456  nb[1]=0x7FFFFFFF;
2457  }
2458  else
2459  {
2460  nb[0]=0x7FFFFFFF;
2461  nb[1]=(int32)((double)0x7FFFFFFF/(*na));
2462  }
2463  }
2464  }
2465  if (tif->tif_flags&TIFF_SWAB)
2468  _TIFFfree(m);
2469  return(o);
2470 }
static int TIFFWriteDirectoryTagData(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 datatype, uint32 count, uint32 datalength, void *data)
GLuint GLuint GLsizei count
Definition: gl.h:1545
unsigned int uint32
Definition: types.h:32
#define assert(x)
Definition: debug.h:53
Definition: ecma_167.h:138
thandle_t tif_clientdata
Definition: tiffiop.h:207
const GLfloat * m
Definition: glext.h:10848
#define TIFF_SWAB
Definition: tiffiop.h:126
uint32 tif_flags
Definition: tiffiop.h:119
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112
void * _TIFFmalloc(tmsize_t s)
Definition: tif_unix.c:309
void TIFFSwabArrayOfLong(register uint32 *lp, tmsize_t n)
Definition: tif_swab.c:103
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
long int32
Definition: platform.h:12
void _TIFFfree(void *p)
Definition: tif_unix.c:326

Referenced by TIFFWriteDirectoryTagSrationalArray().

◆ TIFFWriteDirectoryTagCheckedSshortArray()

static int TIFFWriteDirectoryTagCheckedSshortArray ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
int16 value 
)
static

Definition at line 2204 of file tif_dirwrite.c.

2205 {
2206  assert(count<0x80000000);
2207  assert(sizeof(int16)==2);
2208  if (tif->tif_flags&TIFF_SWAB)
2211 }
static int TIFFWriteDirectoryTagData(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 datatype, uint32 count, uint32 datalength, void *data)
void TIFFSwabArrayOfShort(register uint16 *wp, tmsize_t n)
Definition: tif_swab.c:71
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define assert(x)
Definition: debug.h:53
Definition: ecma_167.h:138
#define TIFF_SWAB
Definition: tiffiop.h:126
uint32 tif_flags
Definition: tiffiop.h:119
unsigned int dir
Definition: maze.c:112
unsigned short uint16
Definition: types.h:30
short int16
Definition: platform.h:11

Referenced by TIFFWriteDirectoryTagSshortArray().

◆ TIFFWriteDirectoryTagCheckedUndefinedArray()

static int TIFFWriteDirectoryTagCheckedUndefinedArray ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
uint8 value 
)
static

Definition at line 2131 of file tif_dirwrite.c.

2132 {
2133  assert(sizeof(uint8)==1);
2135 }
static int TIFFWriteDirectoryTagData(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 datatype, uint32 count, uint32 datalength, void *data)
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define assert(x)
Definition: debug.h:53
Definition: ecma_167.h:138
unsigned int dir
Definition: maze.c:112
unsigned char uint8
Definition: types.h:28

Referenced by TIFFWriteDirectoryTagUndefinedArray().

◆ TIFFWriteDirectoryTagColormap()

static int TIFFWriteDirectoryTagColormap ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir 
)
static

Definition at line 1979 of file tif_dirwrite.c.

1980 {
1981  static const char module[] = "TIFFWriteDirectoryTagColormap";
1982  uint32 m;
1983  uint16* n;
1984  int o;
1985  if (dir==NULL)
1986  {
1987  (*ndir)++;
1988  return(1);
1989  }
1990  m=(1<<tif->tif_dir.td_bitspersample);
1991  n=_TIFFmalloc(3*m*sizeof(uint16));
1992  if (n==NULL)
1993  {
1994  TIFFErrorExt(tif->tif_clientdata,module,"Out of memory");
1995  return(0);
1996  }
1997  _TIFFmemcpy(&n[0],tif->tif_dir.td_colormap[0],m*sizeof(uint16));
1998  _TIFFmemcpy(&n[m],tif->tif_dir.td_colormap[1],m*sizeof(uint16));
1999  _TIFFmemcpy(&n[2*m],tif->tif_dir.td_colormap[2],m*sizeof(uint16));
2001  _TIFFfree(n);
2002  return(o);
2003 }
uint16 td_bitspersample
Definition: tif_dir.h:75
#define TIFFTAG_COLORMAP
Definition: tiff.h:284
unsigned int uint32
Definition: types.h:32
GLdouble n
Definition: glext.h:7729
thandle_t tif_clientdata
Definition: tiffiop.h:207
const GLfloat * m
Definition: glext.h:10848
static int TIFFWriteDirectoryTagCheckedShortArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint16 *value)
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112
uint16 * td_colormap[3]
Definition: tif_dir.h:92
void * _TIFFmalloc(tmsize_t s)
Definition: tif_unix.c:309
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
unsigned short uint16
Definition: types.h:30
TIFFDirectory tif_dir
Definition: tiffiop.h:151
void _TIFFfree(void *p)
Definition: tif_unix.c:326
void _TIFFmemcpy(void *d, const void *s, tmsize_t c)
Definition: tif_unix.c:344

Referenced by TIFFWriteDirectorySec().

◆ TIFFWriteDirectoryTagData()

static int TIFFWriteDirectoryTagData ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint16  datatype,
uint32  count,
uint32  datalength,
void data 
)
static

Definition at line 2544 of file tif_dirwrite.c.

2545 {
2546  static const char module[] = "TIFFWriteDirectoryTagData";
2547  uint32 m;
2548  m=0;
2549  while (m<(*ndir))
2550  {
2551  assert(dir[m].tdir_tag!=tag);
2552  if (dir[m].tdir_tag>tag)
2553  break;
2554  m++;
2555  }
2556  if (m<(*ndir))
2557  {
2558  uint32 n;
2559  for (n=*ndir; n>m; n--)
2560  dir[n]=dir[n-1];
2561  }
2562  dir[m].tdir_tag=tag;
2563  dir[m].tdir_type=datatype;
2564  dir[m].tdir_count=count;
2565  dir[m].tdir_offset.toff_long8 = 0;
2566  if (datalength<=((tif->tif_flags&TIFF_BIGTIFF)?0x8U:0x4U))
2567  {
2568  if( data && datalength )
2569  {
2570  _TIFFmemcpy(&dir[m].tdir_offset,data,datalength);
2571  }
2572  }
2573  else
2574  {
2575  uint64 na,nb;
2576  na=tif->tif_dataoff;
2577  nb=na+datalength;
2578  if (!(tif->tif_flags&TIFF_BIGTIFF))
2579  nb=(uint32)nb;
2580  if ((nb<na)||(nb<datalength))
2581  {
2582  TIFFErrorExt(tif->tif_clientdata,module,"Maximum TIFF file size exceeded");
2583  return(0);
2584  }
2585  if (!SeekOK(tif,na))
2586  {
2587  TIFFErrorExt(tif->tif_clientdata,module,"IO error writing tag data");
2588  return(0);
2589  }
2590  assert(datalength<0x80000000UL);
2591  if (!WriteOK(tif,data,(tmsize_t)datalength))
2592  {
2593  TIFFErrorExt(tif->tif_clientdata,module,"IO error writing tag data");
2594  return(0);
2595  }
2596  tif->tif_dataoff=nb;
2597  if (tif->tif_dataoff&1)
2598  tif->tif_dataoff++;
2599  if (!(tif->tif_flags&TIFF_BIGTIFF))
2600  {
2601  uint32 o;
2602  o=(uint32)na;
2603  if (tif->tif_flags&TIFF_SWAB)
2604  TIFFSwabLong(&o);
2605  _TIFFmemcpy(&dir[m].tdir_offset,&o,4);
2606  }
2607  else
2608  {
2609  dir[m].tdir_offset.toff_long8 = na;
2610  if (tif->tif_flags&TIFF_SWAB)
2611  TIFFSwabLong8(&dir[m].tdir_offset.toff_long8);
2612  }
2613  }
2614  (*ndir)++;
2615  return(1);
2616 }
unsigned long long uint64
Definition: platform.h:18
#define WriteOK(tif, buf, size)
Definition: tiffiop.h:259
GLuint GLuint GLsizei count
Definition: gl.h:1545
unsigned int uint32
Definition: types.h:32
GLdouble n
Definition: glext.h:7729
#define assert(x)
Definition: debug.h:53
Definition: ecma_167.h:138
thandle_t tif_clientdata
Definition: tiffiop.h:207
const GLfloat * m
Definition: glext.h:10848
#define TIFF_BIGTIFF
Definition: tiffiop.h:138
#define TIFF_SWAB
Definition: tiffiop.h:126
TIFF_SSIZE_T tmsize_t
Definition: tiffio.h:65
uint32 tif_flags
Definition: tiffiop.h:119
unsigned int dir
Definition: maze.c:112
uint64 tif_dataoff
Definition: tiffiop.h:163
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
void TIFFSwabLong(uint32 *lp)
Definition: tif_swab.c:45
#define SeekOK(tif, off)
Definition: tiffiop.h:256
void _TIFFmemcpy(void *d, const void *s, tmsize_t c)
Definition: tif_unix.c:344
void TIFFSwabLong8(uint64 *lp)
Definition: tif_swab.c:57
char * tag
Definition: main.c:59

Referenced by TIFFWriteDirectoryTagCheckedAscii(), TIFFWriteDirectoryTagCheckedByteArray(), TIFFWriteDirectoryTagCheckedDoubleArray(), TIFFWriteDirectoryTagCheckedFloatArray(), TIFFWriteDirectoryTagCheckedIfd8Array(), TIFFWriteDirectoryTagCheckedIfdArray(), TIFFWriteDirectoryTagCheckedLong(), TIFFWriteDirectoryTagCheckedLong8Array(), TIFFWriteDirectoryTagCheckedLongArray(), TIFFWriteDirectoryTagCheckedRational(), TIFFWriteDirectoryTagCheckedRationalArray(), TIFFWriteDirectoryTagCheckedSbyteArray(), TIFFWriteDirectoryTagCheckedShort(), TIFFWriteDirectoryTagCheckedShortArray(), TIFFWriteDirectoryTagCheckedSlong8Array(), TIFFWriteDirectoryTagCheckedSlongArray(), TIFFWriteDirectoryTagCheckedSrationalArray(), TIFFWriteDirectoryTagCheckedSshortArray(), TIFFWriteDirectoryTagCheckedUndefinedArray(), and TIFFWriteDirectoryTagLongLong8Array().

◆ TIFFWriteDirectoryTagDoubleArray()

static int TIFFWriteDirectoryTagDoubleArray ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
double value 
)
static

Definition at line 1625 of file tif_dirwrite.c.

1626 {
1627  if (dir==NULL)
1628  {
1629  (*ndir)++;
1630  return(1);
1631  }
1633 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
Definition: ecma_167.h:138
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112
static int TIFFWriteDirectoryTagCheckedDoubleArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, double *value)

Referenced by TIFFWriteDirectorySec(), and TIFFWriteDirectoryTagSampleformatArray().

◆ TIFFWriteDirectoryTagFloatArray()

static int TIFFWriteDirectoryTagFloatArray ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
float value 
)
static

Definition at line 1576 of file tif_dirwrite.c.

1577 {
1578  if (dir==NULL)
1579  {
1580  (*ndir)++;
1581  return(1);
1582  }
1584 }
static int TIFFWriteDirectoryTagCheckedFloatArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, float *value)
GLuint GLuint GLsizei count
Definition: gl.h:1545
Definition: ecma_167.h:138
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112

Referenced by TIFFWriteDirectorySec(), and TIFFWriteDirectoryTagSampleformatArray().

◆ TIFFWriteDirectoryTagIfdArray()

static int TIFFWriteDirectoryTagIfdArray ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
uint32 value 
)
static

Definition at line 1663 of file tif_dirwrite.c.

1664 {
1665  if (dir==NULL)
1666  {
1667  (*ndir)++;
1668  return(1);
1669  }
1671 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
Definition: ecma_167.h:138
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112
static int TIFFWriteDirectoryTagCheckedIfdArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint32 *value)

Referenced by TIFFWriteDirectorySec().

◆ TIFFWriteDirectoryTagIfdIfd8Array()

static int TIFFWriteDirectoryTagIfdIfd8Array ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
uint64 value 
)
static

Definition at line 1864 of file tif_dirwrite.c.

1865 {
1866  static const char module[] = "TIFFWriteDirectoryTagIfdIfd8Array";
1867  uint64* ma;
1868  uint32 mb;
1869  uint32* p;
1870  uint32* q;
1871  int o;
1872 
1873  /* is this just a counting pass? */
1874  if (dir==NULL)
1875  {
1876  (*ndir)++;
1877  return(1);
1878  }
1879 
1880  /* We always write IFD8 for BigTIFF, no checking needed. */
1881  if( tif->tif_flags&TIFF_BIGTIFF )
1883  tag,count,value);
1884 
1885  /*
1886  ** For classic tiff we want to verify everything is in range for IFD
1887  ** and convert to long format.
1888  */
1889 
1890  p = _TIFFmalloc(count*sizeof(uint32));
1891  if (p==NULL)
1892  {
1893  TIFFErrorExt(tif->tif_clientdata,module,"Out of memory");
1894  return(0);
1895  }
1896 
1897  for (q=p, ma=value, mb=0; mb<count; ma++, mb++, q++)
1898  {
1899  if (*ma>0xFFFFFFFF)
1900  {
1902  "Attempt to write value larger than 0xFFFFFFFF in Classic TIFF file.");
1903  _TIFFfree(p);
1904  return(0);
1905  }
1906  *q= (uint32)(*ma);
1907  }
1908 
1910  _TIFFfree(p);
1911 
1912  return(o);
1913 }
unsigned long long uint64
Definition: platform.h:18
GLuint GLuint GLsizei count
Definition: gl.h:1545
unsigned int uint32
Definition: types.h:32
Definition: ecma_167.h:138
thandle_t tif_clientdata
Definition: tiffiop.h:207
#define TIFF_BIGTIFF
Definition: tiffiop.h:138
static int TIFFWriteDirectoryTagCheckedIfd8Array(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint64 *value)
uint32 tif_flags
Definition: tiffiop.h:119
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112
void * _TIFFmalloc(tmsize_t s)
Definition: tif_unix.c:309
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
static int TIFFWriteDirectoryTagCheckedIfdArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint32 *value)
void _TIFFfree(void *p)
Definition: tif_unix.c:326
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by TIFFWriteDirectorySec().

◆ TIFFWriteDirectoryTagLong()

static int TIFFWriteDirectoryTagLong ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  value 
)
static

Definition at line 1382 of file tif_dirwrite.c.

1383 {
1384  if (dir==NULL)
1385  {
1386  (*ndir)++;
1387  return(1);
1388  }
1389  return(TIFFWriteDirectoryTagCheckedLong(tif,ndir,dir,tag,value));
1390 }
static int TIFFWriteDirectoryTagCheckedLong(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 value)
Definition: ecma_167.h:138
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112

Referenced by TIFFWriteDirectorySec().

◆ TIFFWriteDirectoryTagLong8Array()

static int TIFFWriteDirectoryTagLong8Array ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
uint64 value 
)
static

Definition at line 1497 of file tif_dirwrite.c.

1498 {
1499  if (dir==NULL)
1500  {
1501  (*ndir)++;
1502  return(1);
1503  }
1505 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
Definition: ecma_167.h:138
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112
static int TIFFWriteDirectoryTagCheckedLong8Array(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint64 *value)

Referenced by TIFFWriteDirectorySec().

◆ TIFFWriteDirectoryTagLongArray()

static int TIFFWriteDirectoryTagLongArray ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
uint32 value 
)
static

Definition at line 1393 of file tif_dirwrite.c.

1394 {
1395  if (dir==NULL)
1396  {
1397  (*ndir)++;
1398  return(1);
1399  }
1401 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
Definition: ecma_167.h:138
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112
static int TIFFWriteDirectoryTagCheckedLongArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint32 *value)

Referenced by TIFFWriteDirectorySec(), and TIFFWriteDirectoryTagSampleformatArray().

◆ TIFFWriteDirectoryTagLongLong8Array()

static int TIFFWriteDirectoryTagLongLong8Array ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
uint64 value 
)
static

Definition at line 1741 of file tif_dirwrite.c.

1742 {
1743  static const char module[] = "TIFFWriteDirectoryTagLongLong8Array";
1744  int o;
1745  int write_aslong4;
1746 
1747  /* is this just a counting pass? */
1748  if (dir==NULL)
1749  {
1750  (*ndir)++;
1751  return(1);
1752  }
1753 
1755  {
1756  return TIFFWriteDirectoryTagData(tif, ndir, dir, tag, TIFF_NOTYPE, 0, 0, NULL);
1757  }
1758 
1759  if( tif->tif_flags&TIFF_BIGTIFF )
1760  {
1761  int write_aslong8 = 1;
1762  /* In the case of ByteCounts array, we may be able to write them on */
1763  /* LONG if the strip/tilesize is not too big. */
1764  /* Also do that for count > 1 in the case someone would want to create */
1765  /* a single-strip file with a growing height, in which case using */
1766  /* LONG8 will be safer. */
1767  if( count > 1 && tag == TIFFTAG_STRIPBYTECOUNTS )
1768  {
1769  write_aslong8 = WriteAsLong8(tif, TIFFStripSize64(tif));
1770  }
1771  else if( count > 1 && tag == TIFFTAG_TILEBYTECOUNTS )
1772  {
1773  write_aslong8 = WriteAsLong8(tif, TIFFTileSize64(tif));
1774  }
1775  if( write_aslong8 )
1776  {
1778  tag,count,value);
1779  }
1780  }
1781 
1782  write_aslong4 = 1;
1783  if( count > 1 && tag == TIFFTAG_STRIPBYTECOUNTS )
1784  {
1785  write_aslong4 = WriteAsLong4(tif, TIFFStripSize64(tif));
1786  }
1787  else if( count > 1 && tag == TIFFTAG_TILEBYTECOUNTS )
1788  {
1789  write_aslong4 = WriteAsLong4(tif, TIFFTileSize64(tif));
1790  }
1791  if( write_aslong4 )
1792  {
1793  /*
1794  ** For classic tiff we want to verify everything is in range for LONG
1795  ** and convert to long format.
1796  */
1797 
1798  uint32* p = _TIFFmalloc(count*sizeof(uint32));
1799  uint32* q;
1800  uint64* ma;
1801  uint32 mb;
1802 
1803  if (p==NULL)
1804  {
1805  TIFFErrorExt(tif->tif_clientdata,module,"Out of memory");
1806  return(0);
1807  }
1808 
1809  for (q=p, ma=value, mb=0; mb<count; ma++, mb++, q++)
1810  {
1811  if (*ma>0xFFFFFFFF)
1812  {
1814  "Attempt to write value larger than 0xFFFFFFFF in LONG array.");
1815  _TIFFfree(p);
1816  return(0);
1817  }
1818  *q= (uint32)(*ma);
1819  }
1820 
1822  _TIFFfree(p);
1823  }
1824  else
1825  {
1826  uint16* p = _TIFFmalloc(count*sizeof(uint16));
1827  uint16* q;
1828  uint64* ma;
1829  uint32 mb;
1830 
1831  if (p==NULL)
1832  {
1833  TIFFErrorExt(tif->tif_clientdata,module,"Out of memory");
1834  return(0);
1835  }
1836 
1837  for (q=p, ma=value, mb=0; mb<count; ma++, mb++, q++)
1838  {
1839  if (*ma>0xFFFF)
1840  {
1841  /* Should not happen normally given the check we did before */
1843  "Attempt to write value larger than 0xFFFF in SHORT array.");
1844  _TIFFfree(p);
1845  return(0);
1846  }
1847  *q= (uint16)(*ma);
1848  }
1849 
1851  _TIFFfree(p);
1852  }
1853 
1854  return(o);
1855 }
unsigned long long uint64
Definition: platform.h:18
static int TIFFWriteDirectoryTagData(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 datatype, uint32 count, uint32 datalength, void *data)
#define TIFFTAG_STRIPBYTECOUNTS
Definition: tiff.h:234
GLuint GLuint GLsizei count
Definition: gl.h:1545
unsigned int uint32
Definition: types.h:32
Definition: ecma_167.h:138
thandle_t tif_clientdata
Definition: tiffiop.h:207
static int TIFFWriteDirectoryTagCheckedShortArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint16 *value)
#define TIFFTAG_TILEBYTECOUNTS
Definition: tiff.h:289
#define TIFF_BIGTIFF
Definition: tiffiop.h:138
uint32 tif_flags
Definition: tiffiop.h:119
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112
void * _TIFFmalloc(tmsize_t s)
Definition: tif_unix.c:309
static int WriteAsLong4(TIFF *tif, uint64 strile_size)
unsigned char td_deferstrilearraywriting
Definition: tif_dir.h:124
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
uint64 TIFFTileSize64(TIFF *tif)
Definition: tif_tile.c:252
static int TIFFWriteDirectoryTagCheckedLong8Array(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint64 *value)
uint64 TIFFStripSize64(TIFF *tif)
Definition: tif_strip.c:193
unsigned short uint16
Definition: types.h:30
TIFFDirectory tif_dir
Definition: tiffiop.h:151
static int WriteAsLong8(TIFF *tif, uint64 strile_size)
void _TIFFfree(void *p)
Definition: tif_unix.c:326
GLfloat GLfloat p
Definition: glext.h:8902
static int TIFFWriteDirectoryTagCheckedLongArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint32 *value)

Referenced by TIFFWriteDirectorySec().

◆ TIFFWriteDirectoryTagRational()

static int TIFFWriteDirectoryTagRational ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
double  value 
)
static

Definition at line 1532 of file tif_dirwrite.c.

1533 {
1534  if (dir==NULL)
1535  {
1536  (*ndir)++;
1537  return(1);
1538  }
1540 }
Definition: ecma_167.h:138
static int TIFFWriteDirectoryTagCheckedRational(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, double value)
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112

Referenced by TIFFWriteDirectorySec().

◆ TIFFWriteDirectoryTagRationalArray()

static int TIFFWriteDirectoryTagRationalArray ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
float value 
)
static

Definition at line 1543 of file tif_dirwrite.c.

1544 {
1545  if (dir==NULL)
1546  {
1547  (*ndir)++;
1548  return(1);
1549  }
1551 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
Definition: ecma_167.h:138
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112
static int TIFFWriteDirectoryTagCheckedRationalArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, float *value)

Referenced by TIFFWriteDirectorySec().

◆ TIFFWriteDirectoryTagSampleformatArray()

static int TIFFWriteDirectoryTagSampleformatArray ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
double value 
)
static

Definition at line 1049 of file tif_dirwrite.c.

1050 {
1051  static const char module[] = "TIFFWriteDirectoryTagSampleformatArray";
1052  void* conv;
1053  uint32 i;
1054  int ok;
1055  conv = _TIFFmalloc(count*sizeof(double));
1056  if (conv == NULL)
1057  {
1058  TIFFErrorExt(tif->tif_clientdata, module, "Out of memory");
1059  return (0);
1060  }
1061 
1062  switch (tif->tif_dir.td_sampleformat)
1063  {
1064  case SAMPLEFORMAT_IEEEFP:
1065  if (tif->tif_dir.td_bitspersample<=32)
1066  {
1067  for (i = 0; i < count; ++i)
1068  ((float*)conv)[i] = _TIFFClampDoubleToFloat(value[i]);
1069  ok = TIFFWriteDirectoryTagFloatArray(tif,ndir,dir,tag,count,(float*)conv);
1070  }
1071  else
1072  {
1074  }
1075  break;
1076  case SAMPLEFORMAT_INT:
1077  if (tif->tif_dir.td_bitspersample<=8)
1078  {
1079  for (i = 0; i < count; ++i)
1080  ((int8*)conv)[i] = TIFFClampDoubleToInt8(value[i]);
1081  ok = TIFFWriteDirectoryTagSbyteArray(tif,ndir,dir,tag,count,(int8*)conv);
1082  }
1083  else if (tif->tif_dir.td_bitspersample<=16)
1084  {
1085  for (i = 0; i < count; ++i)
1086  ((int16*)conv)[i] = TIFFClampDoubleToInt16(value[i]);
1088  }
1089  else
1090  {
1091  for (i = 0; i < count; ++i)
1092  ((int32*)conv)[i] = TIFFClampDoubleToInt32(value[i]);
1093  ok = TIFFWriteDirectoryTagSlongArray(tif,ndir,dir,tag,count,(int32*)conv);
1094  }
1095  break;
1096  case SAMPLEFORMAT_UINT:
1097  if (tif->tif_dir.td_bitspersample<=8)
1098  {
1099  for (i = 0; i < count; ++i)
1100  ((uint8*)conv)[i] = TIFFClampDoubleToUInt8(value[i]);
1101  ok = TIFFWriteDirectoryTagByteArray(tif,ndir,dir,tag,count,(uint8*)conv);
1102  }
1103  else if (tif->tif_dir.td_bitspersample<=16)
1104  {
1105  for (i = 0; i < count; ++i)
1106  ((uint16*)conv)[i] = TIFFClampDoubleToUInt16(value[i]);
1108  }
1109  else
1110  {
1111  for (i = 0; i < count; ++i)
1112  ((uint32*)conv)[i] = TIFFClampDoubleToUInt32(value[i]);
1113  ok = TIFFWriteDirectoryTagLongArray(tif,ndir,dir,tag,count,(uint32*)conv);
1114  }
1115  break;
1116  default:
1117  ok = 0;
1118  }
1119 
1120  _TIFFfree(conv);
1121  return (ok);
1122 }
static uint16 TIFFClampDoubleToUInt16(double val)
uint16 td_bitspersample
Definition: tif_dir.h:75
GLuint GLuint GLsizei count
Definition: gl.h:1545
unsigned int uint32
Definition: types.h:32
static int32 TIFFClampDoubleToInt32(double val)
Definition: ecma_167.h:138
thandle_t tif_clientdata
Definition: tiffiop.h:207
#define SAMPLEFORMAT_INT
Definition: tiff.h:310
static int TIFFWriteDirectoryTagShortArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint16 *value)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
smooth NULL
Definition: ftsmooth.c:416
static uint32 TIFFClampDoubleToUInt32(double val)
unsigned int dir
Definition: maze.c:112
static int TIFFWriteDirectoryTagSshortArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, int16 *value)
void * _TIFFmalloc(tmsize_t s)
Definition: tif_unix.c:309
static uint8 TIFFClampDoubleToUInt8(double val)
static int TIFFWriteDirectoryTagByteArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint8 *value)
#define SAMPLEFORMAT_UINT
Definition: tiff.h:309
#define SAMPLEFORMAT_IEEEFP
Definition: tiff.h:311
unsigned char uint8
Definition: types.h:28
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
static int8 TIFFClampDoubleToInt8(double val)
Definition: tif_dirwrite.c:994
uint16 td_sampleformat
Definition: tif_dir.h:76
static int TIFFWriteDirectoryTagFloatArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, float *value)
float _TIFFClampDoubleToFloat(double val)
Definition: tif_aux.c:397
static int TIFFWriteDirectoryTagLongArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint32 *value)
unsigned short uint16
Definition: types.h:30
short int16
Definition: platform.h:11
#define ok(value,...)
Definition: atltest.h:57
TIFFDirectory tif_dir
Definition: tiffiop.h:151
static int TIFFWriteDirectoryTagSbyteArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, int8 *value)
static int16 TIFFClampDoubleToInt16(double val)
long int32
Definition: platform.h:12
void _TIFFfree(void *p)
Definition: tif_unix.c:326
char int8
Definition: platform.h:10
static int TIFFWriteDirectoryTagDoubleArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, double *value)
static int TIFFWriteDirectoryTagSlongArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, int32 *value)

Referenced by TIFFWriteDirectorySec().

◆ TIFFWriteDirectoryTagSbyteArray()

static int TIFFWriteDirectoryTagSbyteArray ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
int8 value 
)
static

Definition at line 1243 of file tif_dirwrite.c.

1244 {
1245  if (dir==NULL)
1246  {
1247  (*ndir)++;
1248  return(1);
1249  }
1251 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
Definition: ecma_167.h:138
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112
static int TIFFWriteDirectoryTagCheckedSbyteArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, int8 *value)

Referenced by TIFFWriteDirectorySec(), and TIFFWriteDirectoryTagSampleformatArray().

◆ TIFFWriteDirectoryTagShort()

static int TIFFWriteDirectoryTagShort ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint16  value 
)
static

Definition at line 1282 of file tif_dirwrite.c.

1283 {
1284  if (dir==NULL)
1285  {
1286  (*ndir)++;
1287  return(1);
1288  }
1289  return(TIFFWriteDirectoryTagCheckedShort(tif,ndir,dir,tag,value));
1290 }
Definition: ecma_167.h:138
static int TIFFWriteDirectoryTagCheckedShort(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 value)