ReactOS 0.4.15-dev-7889-g76290a6
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 278 of file tif_tile.c.

279{
280 (void) tif;
281 if (*(int32*) tw < 1)
282 *tw = 256;
283 if (*(int32*) th < 1)
284 *th = 256;
285 /* roundup to a multiple of 16 per the spec */
286 if (*tw & 0xf)
287 *tw = TIFFroundup_32(*tw, 16);
288 if (*th & 0xf)
289 *th = TIFFroundup_32(*th, 16);
290}
long int32
Definition: platform.h:12
#define TIFFroundup_32(x, y)
Definition: tiffiop.h:272

Referenced by _TIFFSetDefaultCompressionState().

◆ TIFFCheckTile()

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

Definition at line 73 of file tif_tile.c.

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

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

◆ TIFFComputeTile()

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

Definition at line 36 of file tif_tile.c.

37{
38 TIFFDirectory *td = &tif->tif_dir;
41 uint32 dz = td->td_tiledepth;
42 uint32 tile = 1;
43
44 if (td->td_imagedepth == 1)
45 z = 0;
46 if (dx == (uint32) -1)
47 dx = td->td_imagewidth;
48 if (dy == (uint32) -1)
49 dy = td->td_imagelength;
50 if (dz == (uint32) -1)
51 dz = td->td_imagedepth;
52 if (dx != 0 && dy != 0 && dz != 0) {
55 uint32 zpt = TIFFhowmany_32(td->td_imagedepth, dz);
56
58 tile = (xpt*ypt*zpt)*s +
59 (xpt*ypt)*(z/dz) +
60 xpt*(y/dy) +
61 x/dx;
62 else
63 tile = (xpt*ypt)*(z/dz) + xpt*(y/dy) + x/dx;
64 }
65 return (tile);
66}
unsigned int uint32
Definition: types.h:32
GLint dy
Definition: linetemp.h:97
GLint dx
Definition: linetemp.h:97
uint32 td_tiledepth
Definition: tif_dir.h:73
uint32 td_tilelength
Definition: tif_dir.h:73
uint32 td_tilewidth
Definition: tif_dir.h:73
#define TIFFhowmany_32(x, y)
Definition: tiffiop.h:264

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

◆ TIFFDefaultTileSize()

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

Definition at line 272 of file tif_tile.c.

273{
274 (*tif->tif_deftilesize)(tif, tw, th);
275}
TIFFTileMethod tif_deftilesize
Definition: tiffiop.h:190

◆ TIFFNumberOfTiles()

uint32 TIFFNumberOfTiles ( TIFF tif)

Definition at line 113 of file tif_tile.c.

114{
115 TIFFDirectory *td = &tif->tif_dir;
116 uint32 dx = td->td_tilewidth;
117 uint32 dy = td->td_tilelength;
118 uint32 dz = td->td_tiledepth;
119 uint32 ntiles;
120
121 if (dx == (uint32) -1)
122 dx = td->td_imagewidth;
123 if (dy == (uint32) -1)
124 dy = td->td_imagelength;
125 if (dz == (uint32) -1)
126 dz = td->td_imagedepth;
127 ntiles = (dx == 0 || dy == 0 || dz == 0) ? 0 :
130 "TIFFNumberOfTiles"),
131 TIFFhowmany_32(td->td_imagedepth, dz), "TIFFNumberOfTiles");
133 ntiles = _TIFFMultiply32(tif, ntiles, td->td_samplesperpixel,
134 "TIFFNumberOfTiles");
135 return (ntiles);
136}
uint32 _TIFFMultiply32(TIFF *tif, uint32 first, uint32 second, const char *where)
Definition: tif_aux.c:37

Referenced by TIFFReadDirectory(), and TIFFSetupStrips().

◆ TIFFTileRowSize()

tmsize_t TIFFTileRowSize ( TIFF tif)

Definition at line 180 of file tif_tile.c.

181{
182 static const char module[] = "TIFFTileRowSize";
183 uint64 m;
184 m=TIFFTileRowSize64(tif);
185 return _TIFFCastUInt64ToSSize(tif, m, module);
186}
unsigned long long uint64
Definition: platform.h:18
const GLfloat * m
Definition: glext.h:10848
tmsize_t _TIFFCastUInt64ToSSize(TIFF *tif, uint64 val, const char *module)
Definition: tif_aux.c:83
uint64 TIFFTileRowSize64(TIFF *tif)
Definition: tif_tile.c:142

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

◆ TIFFTileRowSize64()

uint64 TIFFTileRowSize64 ( TIFF tif)

Definition at line 142 of file tif_tile.c.

143{
144 static const char module[] = "TIFFTileRowSize64";
145 TIFFDirectory *td = &tif->tif_dir;
146 uint64 rowsize;
147 uint64 tilerowsize;
148
149 if (td->td_tilelength == 0)
150 {
151 TIFFErrorExt(tif->tif_clientdata,module,"Tile length is zero");
152 return 0;
153 }
154 if (td->td_tilewidth == 0)
155 {
156 TIFFErrorExt(tif->tif_clientdata,module,"Tile width is zero");
157 return (0);
158 }
159 rowsize = _TIFFMultiply64(tif, td->td_bitspersample, td->td_tilewidth,
160 "TIFFTileRowSize");
162 {
163 if (td->td_samplesperpixel == 0)
164 {
165 TIFFErrorExt(tif->tif_clientdata,module,"Samples per pixel is zero");
166 return 0;
167 }
168 rowsize = _TIFFMultiply64(tif, rowsize, td->td_samplesperpixel,
169 "TIFFTileRowSize");
170 }
171 tilerowsize=TIFFhowmany8_64(rowsize);
172 if (tilerowsize == 0)
173 {
174 TIFFErrorExt(tif->tif_clientdata,module,"Computed tile row size is zero");
175 return 0;
176 }
177 return (tilerowsize);
178}
uint16 td_bitspersample
Definition: tif_dir.h:75
uint64 _TIFFMultiply64(TIFF *tif, uint64 first, uint64 second, const char *where)
Definition: tif_aux.c:48
#define PLANARCONFIG_CONTIG
Definition: tiff.h:239
#define TIFFhowmany8_64(x)
Definition: tiffiop.h:274

Referenced by TIFFTileRowSize(), and TIFFVTileSize64().

◆ TIFFTileSize()

tmsize_t TIFFTileSize ( TIFF tif)

Definition at line 257 of file tif_tile.c.

258{
259 static const char module[] = "TIFFTileSize";
260 uint64 m;
261 m=TIFFTileSize64(tif);
262 return _TIFFCastUInt64ToSSize(tif, m, module);
263}
uint64 TIFFTileSize64(TIFF *tif)
Definition: tif_tile.c:252

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

◆ TIFFTileSize64()

uint64 TIFFTileSize64 ( TIFF tif)

Definition at line 252 of file tif_tile.c.

253{
254 return (TIFFVTileSize64(tif, tif->tif_dir.td_tilelength));
255}
uint64 TIFFVTileSize64(TIFF *tif, uint32 nrows)
Definition: tif_tile.c:192

Referenced by _TIFFRewriteField(), EstimateStripByteCounts(), TIFFTileSize(), and TIFFWriteDirectoryTagLongLong8Array().

◆ TIFFVTileSize()

tmsize_t TIFFVTileSize ( TIFF tif,
uint32  nrows 
)

Definition at line 240 of file tif_tile.c.

241{
242 static const char module[] = "TIFFVTileSize";
243 uint64 m;
244 m=TIFFVTileSize64(tif,nrows);
245 return _TIFFCastUInt64ToSSize(tif, m, module);
246}

◆ TIFFVTileSize64()

uint64 TIFFVTileSize64 ( TIFF tif,
uint32  nrows 
)

Definition at line 192 of file tif_tile.c.

193{
194 static const char module[] = "TIFFVTileSize64";
195 TIFFDirectory *td = &tif->tif_dir;
196 if (td->td_tilelength == 0 || td->td_tilewidth == 0 ||
197 td->td_tiledepth == 0)
198 return (0);
201 (td->td_samplesperpixel==3)&&
202 (!isUpSampled(tif)))
203 {
204 /*
205 * Packed YCbCr data contain one Cb+Cr for every
206 * HorizontalSampling*VerticalSampling Y values.
207 * Must also roundup width and height when calculating
208 * since images that are not a multiple of the
209 * horizontal/vertical subsampling area include
210 * YCbCr data for the extended image.
211 */
212 uint16 ycbcrsubsampling[2];
213 uint16 samplingblock_samples;
214 uint32 samplingblocks_hor;
215 uint32 samplingblocks_ver;
216 uint64 samplingrow_samples;
217 uint64 samplingrow_size;
218 TIFFGetFieldDefaulted(tif,TIFFTAG_YCBCRSUBSAMPLING,ycbcrsubsampling+0,
219 ycbcrsubsampling+1);
220 if ((ycbcrsubsampling[0] != 1 && ycbcrsubsampling[0] != 2 && ycbcrsubsampling[0] != 4)
221 ||(ycbcrsubsampling[1] != 1 && ycbcrsubsampling[1] != 2 && ycbcrsubsampling[1] != 4))
222 {
224 "Invalid YCbCr subsampling (%dx%d)",
225 ycbcrsubsampling[0],
226 ycbcrsubsampling[1] );
227 return 0;
228 }
229 samplingblock_samples=ycbcrsubsampling[0]*ycbcrsubsampling[1]+2;
230 samplingblocks_hor=TIFFhowmany_32(td->td_tilewidth,ycbcrsubsampling[0]);
231 samplingblocks_ver=TIFFhowmany_32(nrows,ycbcrsubsampling[1]);
232 samplingrow_samples=_TIFFMultiply64(tif,samplingblocks_hor,samplingblock_samples,module);
233 samplingrow_size=TIFFhowmany8_64(_TIFFMultiply64(tif,samplingrow_samples,td->td_bitspersample,module));
234 return(_TIFFMultiply64(tif,samplingrow_size,samplingblocks_ver,module));
235 }
236 else
237 return(_TIFFMultiply64(tif,nrows,TIFFTileRowSize64(tif),module));
238}
unsigned short uint16
Definition: types.h:30
uint16 td_photometric
Definition: tif_dir.h:78
int TIFFGetFieldDefaulted(TIFF *tif, uint32 tag,...)
Definition: tif_aux.c:345
#define PHOTOMETRIC_YCBCR
Definition: tiff.h:201
#define TIFFTAG_YCBCRSUBSAMPLING
Definition: tiff.h:362
#define isUpSampled(tif)
Definition: tiffiop.h:232

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