ReactOS  0.4.15-dev-439-g292f67a
tif_aux.c File Reference
#include <precomp.h>
#include "tif_predict.h"
#include <math.h>
#include <float.h>
Include dependency graph for tif_aux.c:

Go to the source code of this file.

Classes

struct  _Int64Parts
 
union  _Int64
 

Functions

uint32 _TIFFMultiply32 (TIFF *tif, uint32 first, uint32 second, const char *where)
 
uint64 _TIFFMultiply64 (TIFF *tif, uint64 first, uint64 second, const char *where)
 
tmsize_t _TIFFMultiplySSize (TIFF *tif, tmsize_t first, tmsize_t second, const char *where)
 
tmsize_t _TIFFCastUInt64ToSSize (TIFF *tif, uint64 val, const char *module)
 
void_TIFFCheckRealloc (TIFF *tif, void *buffer, tmsize_t nmemb, tmsize_t elem_size, const char *what)
 
void_TIFFCheckMalloc (TIFF *tif, tmsize_t nmemb, tmsize_t elem_size, const char *what)
 
static int TIFFDefaultTransferFunction (TIFFDirectory *td)
 
static int TIFFDefaultRefBlackWhite (TIFFDirectory *td)
 
int TIFFVGetFieldDefaulted (TIFF *tif, uint32 tag, va_list ap)
 
int TIFFGetFieldDefaulted (TIFF *tif, uint32 tag,...)
 
float _TIFFUInt64ToFloat (uint64 ui64)
 
double _TIFFUInt64ToDouble (uint64 ui64)
 
float _TIFFClampDoubleToFloat (double val)
 
int _TIFFSeekOK (TIFF *tif, toff_t off)
 

Function Documentation

◆ _TIFFCastUInt64ToSSize()

tmsize_t _TIFFCastUInt64ToSSize ( TIFF tif,
uint64  val,
const char module 
)

Definition at line 83 of file tif_aux.c.

84 {
86  {
87  if( tif != NULL && module != NULL )
88  {
89  TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow");
90  }
91  return 0;
92  }
93  return (tmsize_t)val;
94 }
unsigned long long uint64
Definition: platform.h:18
thandle_t tif_clientdata
Definition: tiffiop.h:207
TIFF_SSIZE_T tmsize_t
Definition: tiffio.h:65
smooth NULL
Definition: ftsmooth.c:416
GLuint GLfloat * val
Definition: glext.h:7180
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
#define TIFF_TMSIZE_T_MAX
Definition: tiffiop.h:81

Referenced by TIFFRasterScanlineSize(), TIFFReadRawStrip(), TIFFReadRawTile(), TIFFScanlineSize(), TIFFStripSize(), TIFFTileRowSize(), TIFFTileSize(), TIFFVStripSize(), and TIFFVTileSize().

◆ _TIFFCheckMalloc()

void* _TIFFCheckMalloc ( TIFF tif,
tmsize_t  nmemb,
tmsize_t  elem_size,
const char what 
)

Definition at line 121 of file tif_aux.c.

122 {
123  return _TIFFCheckRealloc(tif, NULL, nmemb, elem_size, what);
124 }
void * _TIFFCheckRealloc(TIFF *tif, void *buffer, tmsize_t nmemb, tmsize_t elem_size, const char *what)
Definition: tif_aux.c:97
smooth NULL
Definition: ftsmooth.c:416

Referenced by _TIFFMergeFields(), _TIFFRewriteField(), _TIFFVSetField(), allocChoppedUpStripArrays(), EstimateStripByteCounts(), TIFFFetchDirectory(), TIFFFetchStripThing(), TIFFMergeFieldInfo(), TIFFReadDirEntryArrayWithLimit(), and TIFFSetupStrips().

◆ _TIFFCheckRealloc()

void* _TIFFCheckRealloc ( TIFF tif,
void buffer,
tmsize_t  nmemb,
tmsize_t  elem_size,
const char what 
)

Definition at line 97 of file tif_aux.c.

99 {
100  void* cp = NULL;
101  tmsize_t count = _TIFFMultiplySSize(tif, nmemb, elem_size, NULL);
102  /*
103  * Check for integer overflow.
104  */
105  if (count != 0)
106  {
108  }
109 
110  if (cp == NULL) {
112  "Failed to allocate memory for %s "
113  "(%ld elements of %ld bytes each)",
114  what,(long) nmemb, (long) elem_size);
115  }
116 
117  return cp;
118 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint buffer
Definition: glext.h:5915
thandle_t tif_clientdata
Definition: tiffiop.h:207
char * tif_name
Definition: tiffiop.h:116
TIFF_SSIZE_T tmsize_t
Definition: tiffio.h:65
smooth NULL
Definition: ftsmooth.c:416
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
void * _TIFFrealloc(void *p, tmsize_t s)
Definition: tif_unix.c:332
tmsize_t _TIFFMultiplySSize(TIFF *tif, tmsize_t first, tmsize_t second, const char *where)
Definition: tif_aux.c:59
POINT cp
Definition: magnifier.c:59

Referenced by _TIFFCheckMalloc(), _TIFFMergeFields(), TIFFCheckDirOffset(), and TIFFMergeFieldInfo().

◆ _TIFFClampDoubleToFloat()

float _TIFFClampDoubleToFloat ( double  val)

Definition at line 397 of file tif_aux.c.

398 {
399  if( val > FLT_MAX )
400  return FLT_MAX;
401  if( val < -FLT_MAX )
402  return -FLT_MAX;
403  return (float)val;
404 }
#define FLT_MAX
Definition: gcc_float.h:107
GLuint GLfloat * val
Definition: glext.h:7180

Referenced by _TIFFVSetField(), and TIFFWriteDirectoryTagSampleformatArray().

◆ _TIFFMultiply32()

uint32 _TIFFMultiply32 ( TIFF tif,
uint32  first,
uint32  second,
const char where 
)

Definition at line 37 of file tif_aux.c.

38 {
39  if (second && first > TIFF_UINT32_MAX / second) {
40  TIFFErrorExt(tif->tif_clientdata, where, "Integer overflow in %s", where);
41  return 0;
42  }
43 
44  return first * second;
45 }
const GLint * first
Definition: glext.h:5794
thandle_t tif_clientdata
Definition: tiffiop.h:207
#define TIFF_UINT32_MAX
Definition: tiffiop.h:86
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65

Referenced by TIFFNumberOfStrips(), and TIFFNumberOfTiles().

◆ _TIFFMultiply64()

uint64 _TIFFMultiply64 ( TIFF tif,
uint64  first,
uint64  second,
const char where 
)

Definition at line 48 of file tif_aux.c.

49 {
50  if (second && first > TIFF_UINT64_MAX / second) {
51  TIFFErrorExt(tif->tif_clientdata, where, "Integer overflow in %s", where);
52  return 0;
53  }
54 
55  return first * second;
56 }
const GLint * first
Definition: glext.h:5794
#define TIFF_UINT64_MAX
Definition: tiffiop.h:91
thandle_t tif_clientdata
Definition: tiffiop.h:207
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65

Referenced by TIFFRasterScanlineSize64(), TIFFScanlineSize64(), TIFFTileRowSize64(), TIFFVStripSize64(), and TIFFVTileSize64().

◆ _TIFFMultiplySSize()

tmsize_t _TIFFMultiplySSize ( TIFF tif,
tmsize_t  first,
tmsize_t  second,
const char where 
)

Definition at line 59 of file tif_aux.c.

60 {
61  if( first <= 0 || second <= 0 )
62  {
63  if( tif != NULL && where != NULL )
64  {
65  TIFFErrorExt(tif->tif_clientdata, where,
66  "Invalid argument to _TIFFMultiplySSize() in %s", where);
67  }
68  return 0;
69  }
70 
71  if( first > TIFF_TMSIZE_T_MAX / second )
72  {
73  if( tif != NULL && where != NULL )
74  {
75  TIFFErrorExt(tif->tif_clientdata, where,
76  "Integer overflow in %s", where);
77  }
78  return 0;
79  }
80  return first * second;
81 }
const GLint * first
Definition: glext.h:5794
thandle_t tif_clientdata
Definition: tiffiop.h:207
smooth NULL
Definition: ftsmooth.c:416
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
#define TIFF_TMSIZE_T_MAX
Definition: tiffiop.h:81

Referenced by _TIFFCheckRealloc(), gtStripSeparate(), gtTileSeparate(), and setByteArray().

◆ _TIFFSeekOK()

int _TIFFSeekOK ( TIFF tif,
toff_t  off 
)

Definition at line 406 of file tif_aux.c.

407 {
408  /* Huge offsets, especially -1 / UINT64_MAX, can cause issues */
409  /* See http://bugzilla.maptools.org/show_bug.cgi?id=2726 */
410  return off <= (~(uint64)0)/2 && TIFFSeekFile(tif,off,SEEK_SET)==off;
411 }
unsigned long long uint64
Definition: platform.h:18
#define TIFFSeekFile(tif, off, whence)
Definition: tiffiop.h:237
#define SEEK_SET
Definition: jmemansi.c:26
off
Definition: i386-dis.c:3909

◆ _TIFFUInt64ToDouble()

double _TIFFUInt64ToDouble ( uint64  ui64)

Definition at line 382 of file tif_aux.c.

383 {
384  _Int64 i;
385 
386  i.value = ui64;
387  if (i.part.high >= 0) {
388  return (double)i.value;
389  } else {
390  long double df;
391  df = (long double)i.value;
392  df += 18446744073709551616.0; /* adding 2**64 */
393  return (double)df;
394  }
395 }
return
Definition: dirsup.c:529
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
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:80

Referenced by TIFFReadDirEntryDouble(), and TIFFReadDirEntryDoubleArray().

◆ _TIFFUInt64ToFloat()

float _TIFFUInt64ToFloat ( uint64  ui64)

Definition at line 366 of file tif_aux.c.

367 {
368  _Int64 i;
369 
370  i.value = ui64;
371  if (i.part.high >= 0) {
372  return (float)i.value;
373  } else {
374  long double df;
375  df = (long double)i.value;
376  df += 18446744073709551616.0; /* adding 2**64 */
377  return (float)df;
378  }
379 }
return
Definition: dirsup.c:529
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
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:80

Referenced by TIFFReadDirEntryFloat(), and TIFFReadDirEntryFloatArray().

◆ TIFFDefaultRefBlackWhite()

static int TIFFDefaultRefBlackWhite ( TIFFDirectory td)
static

Definition at line 171 of file tif_aux.c.

172 {
173  int i;
174 
175  td->td_refblackwhite = (float *)_TIFFmalloc(6*sizeof (float));
176  if (td->td_refblackwhite == NULL)
177  return 0;
178  if (td->td_photometric == PHOTOMETRIC_YCBCR) {
179  /*
180  * YCbCr (Class Y) images must have the ReferenceBlackWhite
181  * tag set. Fix the broken images, which lacks that tag.
182  */
183  td->td_refblackwhite[0] = 0.0F;
184  td->td_refblackwhite[1] = td->td_refblackwhite[3] =
185  td->td_refblackwhite[5] = 255.0F;
186  td->td_refblackwhite[2] = td->td_refblackwhite[4] = 128.0F;
187  } else {
188  /*
189  * Assume RGB (Class R)
190  */
191  for (i = 0; i < 3; i++) {
192  td->td_refblackwhite[2*i+0] = 0;
193  td->td_refblackwhite[2*i+1] =
194  (float)((1L<<td->td_bitspersample)-1L);
195  }
196  }
197  return 1;
198 }
uint16 td_bitspersample
Definition: tif_dir.h:75
#define PHOTOMETRIC_YCBCR
Definition: tiff.h:202
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
void * _TIFFmalloc(tmsize_t s)
Definition: tif_unix.c:309
uint16 td_photometric
Definition: tif_dir.h:78
static const WCHAR L[]
Definition: oid.c:1250
static float(__cdecl *square_half_float)(float x
float * td_refblackwhite
Definition: tif_dir.h:116

Referenced by TIFFVGetFieldDefaulted().

◆ TIFFDefaultTransferFunction()

static int TIFFDefaultTransferFunction ( TIFFDirectory td)
static

Definition at line 127 of file tif_aux.c.

128 {
129  uint16 **tf = td->td_transferfunction;
130  tmsize_t i, n, nbytes;
131 
132  tf[0] = tf[1] = tf[2] = 0;
133  if (td->td_bitspersample >= sizeof(tmsize_t) * 8 - 2)
134  return 0;
135 
136  n = ((tmsize_t)1)<<td->td_bitspersample;
137  nbytes = n * sizeof (uint16);
138  tf[0] = (uint16 *)_TIFFmalloc(nbytes);
139  if (tf[0] == NULL)
140  return 0;
141  tf[0][0] = 0;
142  for (i = 1; i < n; i++) {
143  double t = (double)i/((double) n-1.);
144  tf[0][i] = (uint16)floor(65535.*pow(t, 2.2) + .5);
145  }
146 
147  if (td->td_samplesperpixel - td->td_extrasamples > 1) {
148  tf[1] = (uint16 *)_TIFFmalloc(nbytes);
149  if(tf[1] == NULL)
150  goto bad;
151  _TIFFmemcpy(tf[1], tf[0], nbytes);
152  tf[2] = (uint16 *)_TIFFmalloc(nbytes);
153  if (tf[2] == NULL)
154  goto bad;
155  _TIFFmemcpy(tf[2], tf[0], nbytes);
156  }
157  return 1;
158 
159 bad:
160  if (tf[0])
161  _TIFFfree(tf[0]);
162  if (tf[1])
163  _TIFFfree(tf[1]);
164  if (tf[2])
165  _TIFFfree(tf[2]);
166  tf[0] = tf[1] = tf[2] = 0;
167  return 0;
168 }
uint16 td_bitspersample
Definition: tif_dir.h:75
GLdouble n
Definition: glext.h:7729
GLdouble GLdouble t
Definition: gl.h:2047
HFONT tf
Definition: icontest.c:17
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
float pow(float __x, int __y)
Definition: _cmath.h:458
TIFF_SSIZE_T tmsize_t
Definition: tiffio.h:65
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:80
smooth NULL
Definition: ftsmooth.c:416
void * _TIFFmalloc(tmsize_t s)
Definition: tif_unix.c:309
uint16 td_extrasamples
Definition: tif_dir.h:94
unsigned short uint16
Definition: types.h:30
uint16 * td_transferfunction[3]
Definition: tif_dir.h:115
uint16 td_samplesperpixel
Definition: tif_dir.h:82
void _TIFFfree(void *p)
Definition: tif_unix.c:326
_Check_return_ _CRTIMP double __cdecl floor(_In_ double x)
void _TIFFmemcpy(void *d, const void *s, tmsize_t c)
Definition: tif_unix.c:344

Referenced by TIFFVGetFieldDefaulted().

◆ TIFFGetFieldDefaulted()

int TIFFGetFieldDefaulted ( TIFF tif,
uint32  tag,
  ... 
)

Definition at line 345 of file tif_aux.c.

346 {
347  int ok;
348  va_list ap;
349 
350  va_start(ap, tag);
351  ok = TIFFVGetFieldDefaulted(tif, tag, ap);
352  va_end(ap);
353  return (ok);
354 }
Definition: ecma_167.h:138
#define va_end(ap)
Definition: acmsvcex.h:90
char * va_list
Definition: acmsvcex.h:78
#define ok(value,...)
Definition: atltest.h:57
#define va_start(ap, A)
Definition: acmsvcex.h:91
void int int ULONGLONG int va_list * ap
Definition: winesup.h:32
int TIFFVGetFieldDefaulted(TIFF *tif, uint32 tag, va_list ap)
Definition: tif_aux.c:209

Referenced by gtStripContig(), gtStripSeparate(), initCIELabConversion(), initYCbCrConversion(), PickContigCase(), PickSeparateCase(), TIFFReadRGBAStripExt(), TIFFReadRGBATileExt(), TIFFRGBAImageBegin(), TIFFRGBAImageOK(), TIFFScanlineSize64(), TIFFVStripSize64(), TIFFVTileSize64(), and TIFFWriteDirectorySec().

◆ TIFFVGetFieldDefaulted()

int TIFFVGetFieldDefaulted ( TIFF tif,
uint32  tag,
va_list  ap 
)

Definition at line 209 of file tif_aux.c.

210 {
211  TIFFDirectory *td = &tif->tif_dir;
212 
213  if (TIFFVGetField(tif, tag, ap))
214  return (1);
215  switch (tag) {
216  case TIFFTAG_SUBFILETYPE:
217  *va_arg(ap, uint32 *) = td->td_subfiletype;
218  return (1);
220  *va_arg(ap, uint16 *) = td->td_bitspersample;
221  return (1);
223  *va_arg(ap, uint16 *) = td->td_threshholding;
224  return (1);
225  case TIFFTAG_FILLORDER:
226  *va_arg(ap, uint16 *) = td->td_fillorder;
227  return (1);
228  case TIFFTAG_ORIENTATION:
229  *va_arg(ap, uint16 *) = td->td_orientation;
230  return (1);
232  *va_arg(ap, uint16 *) = td->td_samplesperpixel;
233  return (1);
235  *va_arg(ap, uint32 *) = td->td_rowsperstrip;
236  return (1);
238  *va_arg(ap, uint16 *) = td->td_minsamplevalue;
239  return (1);
241  *va_arg(ap, uint16 *) = td->td_maxsamplevalue;
242  return (1);
244  *va_arg(ap, uint16 *) = td->td_planarconfig;
245  return (1);
247  *va_arg(ap, uint16 *) = td->td_resolutionunit;
248  return (1);
249  case TIFFTAG_PREDICTOR:
250  {
252  if( sp == NULL )
253  {
255  "Cannot get \"Predictor\" tag as plugin is not configured");
256  *va_arg(ap, uint16*) = 0;
257  return 0;
258  }
259  *va_arg(ap, uint16*) = (uint16) sp->predictor;
260  return 1;
261  }
262  case TIFFTAG_DOTRANGE:
263  *va_arg(ap, uint16 *) = 0;
264  *va_arg(ap, uint16 *) = (1<<td->td_bitspersample)-1;
265  return (1);
266  case TIFFTAG_INKSET:
267  *va_arg(ap, uint16 *) = INKSET_CMYK;
268  return 1;
270  *va_arg(ap, uint16 *) = 4;
271  return (1);
273  *va_arg(ap, uint16 *) = td->td_extrasamples;
274  *va_arg(ap, uint16 **) = td->td_sampleinfo;
275  return (1);
276  case TIFFTAG_MATTEING:
277  *va_arg(ap, uint16 *) =
278  (td->td_extrasamples == 1 &&
280  return (1);
281  case TIFFTAG_TILEDEPTH:
282  *va_arg(ap, uint32 *) = td->td_tiledepth;
283  return (1);
284  case TIFFTAG_DATATYPE:
285  *va_arg(ap, uint16 *) = td->td_sampleformat-1;
286  return (1);
288  *va_arg(ap, uint16 *) = td->td_sampleformat;
289  return(1);
290  case TIFFTAG_IMAGEDEPTH:
291  *va_arg(ap, uint32 *) = td->td_imagedepth;
292  return (1);
294  {
295  /* defaults are from CCIR Recommendation 601-1 */
296  static float ycbcrcoeffs[] = { 0.299f, 0.587f, 0.114f };
297  *va_arg(ap, float **) = ycbcrcoeffs;
298  return 1;
299  }
301  *va_arg(ap, uint16 *) = td->td_ycbcrsubsampling[0];
302  *va_arg(ap, uint16 *) = td->td_ycbcrsubsampling[1];
303  return (1);
305  *va_arg(ap, uint16 *) = td->td_ycbcrpositioning;
306  return (1);
307  case TIFFTAG_WHITEPOINT:
308  {
309  static float whitepoint[2];
310 
311  /* TIFF 6.0 specification tells that it is no default
312  value for the WhitePoint, but AdobePhotoshop TIFF
313  Technical Note tells that it should be CIE D50. */
314  whitepoint[0] = D50_X0 / (D50_X0 + D50_Y0 + D50_Z0);
315  whitepoint[1] = D50_Y0 / (D50_X0 + D50_Y0 + D50_Z0);
316  *va_arg(ap, float **) = whitepoint;
317  return 1;
318  }
320  if (!td->td_transferfunction[0] &&
322  TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "No space for \"TransferFunction\" tag");
323  return (0);
324  }
325  *va_arg(ap, uint16 **) = td->td_transferfunction[0];
326  if (td->td_samplesperpixel - td->td_extrasamples > 1) {
327  *va_arg(ap, uint16 **) = td->td_transferfunction[1];
328  *va_arg(ap, uint16 **) = td->td_transferfunction[2];
329  }
330  return (1);
333  return (0);
334  *va_arg(ap, float **) = td->td_refblackwhite;
335  return (1);
336  }
337  return 0;
338 }
#define D50_Z0
Definition: tiffio.h:132
#define TIFFTAG_SUBFILETYPE
Definition: tiff.h:146
uint16 td_ycbcrpositioning
Definition: tif_dir.h:113
uint16 td_bitspersample
Definition: tif_dir.h:75
uint32 td_tiledepth
Definition: tif_dir.h:73
#define TIFFTAG_BITSPERSAMPLE
Definition: tiff.h:156
#define TIFFTAG_ROWSPERSTRIP
Definition: tiff.h:233
#define TIFFTAG_EXTRASAMPLES
Definition: tiff.h:304
#define TIFFTAG_ORIENTATION
Definition: tiff.h:223
unsigned int uint32
Definition: types.h:32
static int TIFFDefaultRefBlackWhite(TIFFDirectory *td)
Definition: tif_aux.c:171
#define TIFFTAG_DATATYPE
Definition: tiff.h:385
#define TIFFTAG_MINSAMPLEVALUE
Definition: tiff.h:235
#define TIFFTAG_FILLORDER
Definition: tiff.h:215
#define D50_X0
Definition: tiffio.h:130
Definition: ecma_167.h:138
#define TIFFTAG_DOTRANGE
Definition: tiff.h:302
uint32 td_imagedepth
Definition: tif_dir.h:72
#define TIFFTAG_THRESHHOLDING
Definition: tiff.h:209
#define TIFFTAG_YCBCRSUBSAMPLING
Definition: tiff.h:367
thandle_t tif_clientdata
Definition: tiffiop.h:207
#define TIFFTAG_REFERENCEBLACKWHITE
Definition: tiff.h:371
#define TIFFTAG_PLANARCONFIG
Definition: tiff.h:239
#define TIFFTAG_MATTEING
Definition: tiff.h:384
char * tif_name
Definition: tiffiop.h:116
#define TIFFTAG_YCBCRCOEFFICIENTS
Definition: tiff.h:366
#define INKSET_CMYK
Definition: tiff.h:298
#define TIFFTAG_YCBCRPOSITIONING
Definition: tiff.h:368
uint32 td_subfiletype
Definition: tif_dir.h:74
uint16 * td_sampleinfo
Definition: tif_dir.h:95
uint16 td_resolutionunit
Definition: tif_dir.h:88
smooth NULL
Definition: ftsmooth.c:416
#define TIFFTAG_SAMPLESPERPIXEL
Definition: tiff.h:232
uint16 td_planarconfig
Definition: tif_dir.h:89
uint16 td_orientation
Definition: tif_dir.h:81
int TIFFVGetField(TIFF *tif, uint32 tag, va_list ap)
Definition: tif_dir.c:1250
uint16 td_minsamplevalue
Definition: tif_dir.h:84
static int TIFFDefaultTransferFunction(TIFFDirectory *td)
Definition: tif_aux.c:127
uint16 td_extrasamples
Definition: tif_dir.h:94
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
uint16 td_fillorder
Definition: tif_dir.h:80
uint8 * tif_data
Definition: tiffiop.h:191
#define TIFFTAG_TRANSFERFUNCTION
Definition: tiff.h:273
#define TIFFTAG_WHITEPOINT
Definition: tiff.h:282
uint16 td_sampleformat
Definition: tif_dir.h:76
uint16 td_threshholding
Definition: tif_dir.h:79
#define TIFFTAG_INKSET
Definition: tiff.h:297
#define TIFFTAG_NUMBEROFINKS
Definition: tiff.h:301
uint16 td_maxsamplevalue
Definition: tif_dir.h:84
#define va_arg(ap, T)
Definition: acmsvcex.h:89
uint32 td_rowsperstrip
Definition: tif_dir.h:83
#define TIFFTAG_TILEDEPTH
Definition: tiff.h:387
#define TIFFTAG_IMAGEDEPTH
Definition: tiff.h:386
#define TIFFTAG_RESOLUTIONUNIT
Definition: tiff.h:262
uint16 td_ycbcrsubsampling[2]
Definition: tif_dir.h:112
unsigned short uint16
Definition: types.h:30
TIFFDirectory tif_dir
Definition: tiffiop.h:151
float * td_refblackwhite
Definition: tif_dir.h:116
uint16 * td_transferfunction[3]
Definition: tif_dir.h:115
#define TIFFTAG_PREDICTOR
Definition: tiff.h:278
void int int ULONGLONG int va_list * ap
Definition: winesup.h:32
uint16 td_samplesperpixel
Definition: tif_dir.h:82
static const WCHAR sp[]
Definition: suminfo.c:288
#define D50_Y0
Definition: tiffio.h:131
#define TIFFTAG_SAMPLEFORMAT
Definition: tiff.h:308
#define EXTRASAMPLE_ASSOCALPHA
Definition: tiff.h:306
#define TIFFTAG_MAXSAMPLEVALUE
Definition: tiff.h:236

Referenced by TIFFGetFieldDefaulted().