ReactOS  0.4.14-dev-323-g6fe6a88
tif_tile.c File Reference
#include <precomp.h>
Include dependency graph for tif_tile.c:

Go to the source code of this file.

Functions

uint32 TIFFComputeTile (TIFF *tif, uint32 x, uint32 y, uint32 z, uint16 s)
 
int TIFFCheckTile (TIFF *tif, uint32 x, uint32 y, uint32 z, uint16 s)
 
uint32 TIFFNumberOfTiles (TIFF *tif)
 
uint64 TIFFTileRowSize64 (TIFF *tif)
 
tmsize_t TIFFTileRowSize (TIFF *tif)
 
uint64 TIFFVTileSize64 (TIFF *tif, uint32 nrows)
 
tmsize_t TIFFVTileSize (TIFF *tif, uint32 nrows)
 
uint64 TIFFTileSize64 (TIFF *tif)
 
tmsize_t TIFFTileSize (TIFF *tif)
 
void TIFFDefaultTileSize (TIFF *tif, uint32 *tw, uint32 *th)
 
void _TIFFDefaultTileSize (TIFF *tif, uint32 *tw, uint32 *th)
 

Function Documentation

◆ _TIFFDefaultTileSize()

void _TIFFDefaultTileSize ( TIFF tif,
uint32 tw,
uint32 th 
)

Definition at line 300 of file tif_tile.c.

301 {
302  (void) tif;
303  if (*(int32*) tw < 1)
304  *tw = 256;
305  if (*(int32*) th < 1)
306  *th = 256;
307  /* roundup to a multiple of 16 per the spec */
308  if (*tw & 0xf)
309  *tw = TIFFroundup_32(*tw, 16);
310  if (*th & 0xf)
311  *th = TIFFroundup_32(*th, 16);
312 }
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
long int32
Definition: platform.h:12
#define TIFFroundup_32(x, y)
Definition: tiffiop.h:256

Referenced by _TIFFSetDefaultCompressionState().

◆ TIFFCheckTile()

int TIFFCheckTile ( TIFF tif,
uint32  x,
uint32  y,
uint32  z,
uint16  s 
)

Definition at line 74 of file tif_tile.c.

75 {
76  TIFFDirectory *td = &tif->tif_dir;
77 
78  if (x >= td->td_imagewidth) {
80  "%lu: Col out of range, max %lu",
81  (unsigned long) x,
82  (unsigned long) (td->td_imagewidth - 1));
83  return (0);
84  }
85  if (y >= td->td_imagelength) {
87  "%lu: Row out of range, max %lu",
88  (unsigned long) y,
89  (unsigned long) (td->td_imagelength - 1));
90  return (0);
91  }
92  if (z >= td->td_imagedepth) {
94  "%lu: Depth out of range, max %lu",
95  (unsigned long) z,
96  (unsigned long) (td->td_imagedepth - 1));
97  return (0);
98  }
100  s >= td->td_samplesperpixel) {
102  "%lu: Sample out of range, max %lu",
103  (unsigned long) s,
104  (unsigned long) (td->td_samplesperpixel - 1));
105  return (0);
106  }
107  return (1);
108 }
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
uint32 td_imagedepth
Definition: tif_dir.h:71
thandle_t tif_clientdata
Definition: tiffiop.h:191
char * tif_name
Definition: tiffiop.h:103
GLdouble GLdouble z
Definition: glext.h:5874
uint16 td_planarconfig
Definition: tif_dir.h:88
uint32 td_imagelength
Definition: tif_dir.h:71
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
#define PLANARCONFIG_SEPARATE
Definition: tiff.h:241
GLdouble s
Definition: gl.h:2039
TIFFDirectory tif_dir
Definition: tiffiop.h:135
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
uint16 td_samplesperpixel
Definition: tif_dir.h:81
uint32 td_imagewidth
Definition: tif_dir.h:71

Referenced by _TIFFReadTileAndAllocBuffer(), TIFFReadTile(), and TIFFWriteTile().

◆ TIFFComputeTile()

uint32 TIFFComputeTile ( TIFF tif,
uint32  x,
uint32  y,
uint32  z,
uint16  s 
)

Definition at line 37 of file tif_tile.c.

38 {
39  TIFFDirectory *td = &tif->tif_dir;
40  uint32 dx = td->td_tilewidth;
41  uint32 dy = td->td_tilelength;
42  uint32 dz = td->td_tiledepth;
43  uint32 tile = 1;
44 
45  if (td->td_imagedepth == 1)
46  z = 0;
47  if (dx == (uint32) -1)
48  dx = td->td_imagewidth;
49  if (dy == (uint32) -1)
50  dy = td->td_imagelength;
51  if (dz == (uint32) -1)
52  dz = td->td_imagedepth;
53  if (dx != 0 && dy != 0 && dz != 0) {
56  uint32 zpt = TIFFhowmany_32(td->td_imagedepth, dz);
57 
59  tile = (xpt*ypt*zpt)*s +
60  (xpt*ypt)*(z/dz) +
61  xpt*(y/dy) +
62  x/dx;
63  else
64  tile = (xpt*ypt)*(z/dz) + xpt*(y/dy) + x/dx;
65  }
66  return (tile);
67 }
uint32 td_tiledepth
Definition: tif_dir.h:72
#define TIFFhowmany_32(x, y)
Definition: tiffiop.h:248
unsigned int uint32
Definition: types.h:32
GLint dy
Definition: linetemp.h:97
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
uint32 td_imagedepth
Definition: tif_dir.h:71
uint32 td_tilelength
Definition: tif_dir.h:72
GLdouble GLdouble z
Definition: glext.h:5874
uint16 td_planarconfig
Definition: tif_dir.h:88
uint32 td_imagelength
Definition: tif_dir.h:71
uint32 td_tilewidth
Definition: tif_dir.h:72
#define PLANARCONFIG_SEPARATE
Definition: tiff.h:241
GLdouble s
Definition: gl.h:2039
TIFFDirectory tif_dir
Definition: tiffiop.h:135
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLint dx
Definition: linetemp.h:97
uint32 td_imagewidth
Definition: tif_dir.h:71

Referenced by _TIFFReadTileAndAllocBuffer(), TIFFReadTile(), and TIFFWriteTile().

◆ TIFFDefaultTileSize()

void TIFFDefaultTileSize ( TIFF tif,
uint32 tw,
uint32 th 
)

Definition at line 294 of file tif_tile.c.

295 {
296  (*tif->tif_deftilesize)(tif, tw, th);
297 }
TIFFTileMethod tif_deftilesize
Definition: tiffiop.h:174

◆ TIFFNumberOfTiles()

uint32 TIFFNumberOfTiles ( TIFF tif)

Definition at line 114 of file tif_tile.c.

115 {
116  TIFFDirectory *td = &tif->tif_dir;
117  uint32 dx = td->td_tilewidth;
118  uint32 dy = td->td_tilelength;
119  uint32 dz = td->td_tiledepth;
120  uint32 ntiles;
121 
122  if (dx == (uint32) -1)
123  dx = td->td_imagewidth;
124  if (dy == (uint32) -1)
125  dy = td->td_imagelength;
126  if (dz == (uint32) -1)
127  dz = td->td_imagedepth;
128  ntiles = (dx == 0 || dy == 0 || dz == 0) ? 0 :
131  "TIFFNumberOfTiles"),
132  TIFFhowmany_32(td->td_imagedepth, dz), "TIFFNumberOfTiles");
134  ntiles = _TIFFMultiply32(tif, ntiles, td->td_samplesperpixel,
135  "TIFFNumberOfTiles");
136  return (ntiles);
137 }
uint32 td_tiledepth
Definition: tif_dir.h:72
uint32 _TIFFMultiply32(TIFF *tif, uint32 first, uint32 second, const char *where)
Definition: tif_aux.c:36
#define TIFFhowmany_32(x, y)
Definition: tiffiop.h:248
unsigned int uint32
Definition: types.h:32
GLint dy
Definition: linetemp.h:97
uint32 td_imagedepth
Definition: tif_dir.h:71
uint32 td_tilelength
Definition: tif_dir.h:72
uint16 td_planarconfig
Definition: tif_dir.h:88
uint32 td_imagelength
Definition: tif_dir.h:71
uint32 td_tilewidth
Definition: tif_dir.h:72
#define PLANARCONFIG_SEPARATE
Definition: tiff.h:241
TIFFDirectory tif_dir
Definition: tiffiop.h:135
GLint dx
Definition: linetemp.h:97
uint16 td_samplesperpixel
Definition: tif_dir.h:81
uint32 td_imagewidth
Definition: tif_dir.h:71

Referenced by TIFFReadDirectory(), and TIFFSetupStrips().

◆ TIFFTileRowSize()

tmsize_t TIFFTileRowSize ( TIFF tif)

Definition at line 181 of file tif_tile.c.

182 {
183  static const char module[] = "TIFFTileRowSize";
184  uint64 m;
185  tmsize_t n;
186  m=TIFFTileRowSize64(tif);
187  n=(tmsize_t)m;
188  if ((uint64)n!=m)
189  {
190  TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow");
191  n=0;
192  }
193  return(n);
194 }
unsigned long long uint64
Definition: platform.h:18
GLdouble n
Definition: glext.h:7729
thandle_t tif_clientdata
Definition: tiffiop.h:191
const GLfloat * m
Definition: glext.h:10848
TIFF_SSIZE_T tmsize_t
Definition: tiffio.h:65
uint64 TIFFTileRowSize64(TIFF *tif)
Definition: tif_tile.c:143
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65

Referenced by gtTileContig(), gtTileSeparate(), and PredictorSetup().

◆ TIFFTileRowSize64()

uint64 TIFFTileRowSize64 ( TIFF tif)

Definition at line 143 of file tif_tile.c.

144 {
145  static const char module[] = "TIFFTileRowSize64";
146  TIFFDirectory *td = &tif->tif_dir;
147  uint64 rowsize;
148  uint64 tilerowsize;
149 
150  if (td->td_tilelength == 0)
151  {
152  TIFFErrorExt(tif->tif_clientdata,module,"Tile length is zero");
153  return 0;
154  }
155  if (td->td_tilewidth == 0)
156  {
157  TIFFErrorExt(tif->tif_clientdata,module,"Tile width is zero");
158  return (0);
159  }
160  rowsize = _TIFFMultiply64(tif, td->td_bitspersample, td->td_tilewidth,
161  "TIFFTileRowSize");
163  {
164  if (td->td_samplesperpixel == 0)
165  {
166  TIFFErrorExt(tif->tif_clientdata,module,"Samples per pixel is zero");
167  return 0;
168  }
169  rowsize = _TIFFMultiply64(tif, rowsize, td->td_samplesperpixel,
170  "TIFFTileRowSize");
171  }
172  tilerowsize=TIFFhowmany8_64(rowsize);
173  if (tilerowsize == 0)
174  {
175  TIFFErrorExt(tif->tif_clientdata,module,"Computed tile row size is zero");
176  return 0;
177  }
178  return (tilerowsize);
179 }
unsigned long long uint64
Definition: platform.h:18
uint16 td_bitspersample
Definition: tif_dir.h:74
thandle_t tif_clientdata
Definition: tiffiop.h:191
#define TIFFhowmany8_64(x)
Definition: tiffiop.h:258
uint32 td_tilelength
Definition: tif_dir.h:72
uint16 td_planarconfig
Definition: tif_dir.h:88
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
uint32 td_tilewidth
Definition: tif_dir.h:72
TIFFDirectory tif_dir
Definition: tiffiop.h:135
uint64 _TIFFMultiply64(TIFF *tif, uint64 first, uint64 second, const char *where)
Definition: tif_aux.c:49
uint16 td_samplesperpixel
Definition: tif_dir.h:81
#define PLANARCONFIG_CONTIG
Definition: tiff.h:240

Referenced by TIFFTileRowSize(), and TIFFVTileSize64().

◆ TIFFTileSize()

tmsize_t TIFFTileSize ( TIFF tif)

Definition at line 272 of file tif_tile.c.

273 {
274  static const char module[] = "TIFFTileSize";
275  uint64 m;
276  tmsize_t n;
277  m=TIFFTileSize64(tif);
278  n=(tmsize_t)m;
279  if ((uint64)n!=m)
280  {
281  TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow");
282  n=0;
283  }
284  return(n);
285 }
unsigned long long uint64
Definition: platform.h:18
GLdouble n
Definition: glext.h:7729
thandle_t tif_clientdata
Definition: tiffiop.h:191
const GLfloat * m
Definition: glext.h:10848
TIFF_SSIZE_T tmsize_t
Definition: tiffio.h:65
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
uint64 TIFFTileSize64(TIFF *tif)
Definition: tif_tile.c:267

Referenced by gtTileContig(), gtTileSeparate(), TIFFFillTile(), TIFFReadDirectory(), and TIFFWriteCheck().

◆ TIFFTileSize64()

uint64 TIFFTileSize64 ( TIFF tif)

Definition at line 267 of file tif_tile.c.

268 {
269  return (TIFFVTileSize64(tif, tif->tif_dir.td_tilelength));
270 }
uint32 td_tilelength
Definition: tif_dir.h:72
TIFFDirectory tif_dir
Definition: tiffiop.h:135
uint64 TIFFVTileSize64(TIFF *tif, uint32 nrows)
Definition: tif_tile.c:200

Referenced by EstimateStripByteCounts(), and TIFFTileSize().

◆ TIFFVTileSize()

tmsize_t TIFFVTileSize ( TIFF tif,
uint32  nrows 
)

Definition at line 248 of file tif_tile.c.

249 {
250  static const char module[] = "TIFFVTileSize";
251  uint64 m;
252  tmsize_t n;
253  m=TIFFVTileSize64(tif,nrows);
254  n=(tmsize_t)m;
255  if ((uint64)n!=m)
256  {
257  TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow");
258  n=0;
259  }
260  return(n);
261 }
unsigned long long uint64
Definition: platform.h:18
GLdouble n
Definition: glext.h:7729
thandle_t tif_clientdata
Definition: tiffiop.h:191
const GLfloat * m
Definition: glext.h:10848
TIFF_SSIZE_T tmsize_t
Definition: tiffio.h:65
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
uint64 TIFFVTileSize64(TIFF *tif, uint32 nrows)
Definition: tif_tile.c:200

◆ TIFFVTileSize64()

uint64 TIFFVTileSize64 ( TIFF tif,
uint32  nrows 
)

Definition at line 200 of file tif_tile.c.

201 {
202  static const char module[] = "TIFFVTileSize64";
203  TIFFDirectory *td = &tif->tif_dir;
204  if (td->td_tilelength == 0 || td->td_tilewidth == 0 ||
205  td->td_tiledepth == 0)
206  return (0);
209  (td->td_samplesperpixel==3)&&
210  (!isUpSampled(tif)))
211  {
212  /*
213  * Packed YCbCr data contain one Cb+Cr for every
214  * HorizontalSampling*VerticalSampling Y values.
215  * Must also roundup width and height when calculating
216  * since images that are not a multiple of the
217  * horizontal/vertical subsampling area include
218  * YCbCr data for the extended image.
219  */
220  uint16 ycbcrsubsampling[2];
221  uint16 samplingblock_samples;
222  uint32 samplingblocks_hor;
223  uint32 samplingblocks_ver;
224  uint64 samplingrow_samples;
225  uint64 samplingrow_size;
226  TIFFGetFieldDefaulted(tif,TIFFTAG_YCBCRSUBSAMPLING,ycbcrsubsampling+0,
227  ycbcrsubsampling+1);
228  if ((ycbcrsubsampling[0] != 1 && ycbcrsubsampling[0] != 2 && ycbcrsubsampling[0] != 4)
229  ||(ycbcrsubsampling[1] != 1 && ycbcrsubsampling[1] != 2 && ycbcrsubsampling[1] != 4))
230  {
232  "Invalid YCbCr subsampling (%dx%d)",
233  ycbcrsubsampling[0],
234  ycbcrsubsampling[1] );
235  return 0;
236  }
237  samplingblock_samples=ycbcrsubsampling[0]*ycbcrsubsampling[1]+2;
238  samplingblocks_hor=TIFFhowmany_32(td->td_tilewidth,ycbcrsubsampling[0]);
239  samplingblocks_ver=TIFFhowmany_32(nrows,ycbcrsubsampling[1]);
240  samplingrow_samples=_TIFFMultiply64(tif,samplingblocks_hor,samplingblock_samples,module);
241  samplingrow_size=TIFFhowmany8_64(_TIFFMultiply64(tif,samplingrow_samples,td->td_bitspersample,module));
242  return(_TIFFMultiply64(tif,samplingrow_size,samplingblocks_ver,module));
243  }
244  else
245  return(_TIFFMultiply64(tif,nrows,TIFFTileRowSize64(tif),module));
246 }
unsigned long long uint64
Definition: platform.h:18
uint16 td_bitspersample
Definition: tif_dir.h:74
#define PHOTOMETRIC_YCBCR
Definition: tiff.h:202
uint32 td_tiledepth
Definition: tif_dir.h:72
#define TIFFhowmany_32(x, y)
Definition: tiffiop.h:248
unsigned int uint32
Definition: types.h:32
#define TIFFTAG_YCBCRSUBSAMPLING
Definition: tiff.h:367
thandle_t tif_clientdata
Definition: tiffiop.h:191
#define isUpSampled(tif)
Definition: tiffiop.h:216
#define TIFFhowmany8_64(x)
Definition: tiffiop.h:258
uint32 td_tilelength
Definition: tif_dir.h:72
uint16 td_planarconfig
Definition: tif_dir.h:88
uint64 TIFFTileRowSize64(TIFF *tif)
Definition: tif_tile.c:143
int TIFFGetFieldDefaulted(TIFF *tif, uint32 tag,...)
Definition: tif_aux.c:309
uint16 td_photometric
Definition: tif_dir.h:77
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
uint32 td_tilewidth
Definition: tif_dir.h:72
unsigned short uint16
Definition: types.h:30
TIFFDirectory tif_dir
Definition: tiffiop.h:135
uint64 _TIFFMultiply64(TIFF *tif, uint64 first, uint64 second, const char *where)
Definition: tif_aux.c:49
uint16 td_samplesperpixel
Definition: tif_dir.h:81
#define PLANARCONFIG_CONTIG
Definition: tiff.h:240

Referenced by ChopUpSingleUncompressedStrip(), TIFFTileSize64(), and TIFFVTileSize().