53 uint16_t s,
bool *pOverflowed)
55 static const char module[] = "TIFFComputeTile";
58 uint32_t dy = td->td_tilelength;
59 uint32_t dz = td->td_tiledepth;
61 bool overflow =
false;
63 if (td->td_imagedepth == 1)
65 if (dx == (uint32_t)-1)
66 dx = td->td_imagewidth;
67 if (dy == (uint32_t)-1)
68 dy = td->td_imagelength;
69 if (dz == (uint32_t)-1)
70 dz = td->td_imagedepth;
71 if (dx != 0 && dy != 0 && dz != 0)
77 uint32_t xpt_ypt_zpt =
85 (uint64_t)xpt * (y / dy), module, &overflow);
86 tile64 =
_TIFFAdd64Ext(tif, tile64, x / dx, module, &overflow);
91 if (s >= td->td_samplesperpixel)
93 TIFFErrorExtR(tif, module,
"%lu: Sample out of range, max %lu",
95 (
unsigned long)td->td_samplesperpixel);
99 tile64 =
_TIFFAdd64Ext(tif, (uint64_t)xpt_ypt_zpt * s, tile64,
109 if (pOverflowed != NULL)
163 if (dx == (uint32_t)-1)
165 if (dy == (uint32_t)-1)
167 if (dz == (uint32_t)-1)
170 (dx == 0 || dy == 0 || dz == 0)
176 "TIFFNumberOfTiles"),
180 "TIFFNumberOfTiles");
189 static const char module[] = "TIFFTileRowSize64";
192 uint64_t tilerowsize;
194 if (td->td_tilelength == 0)
199 if (td->td_tilewidth == 0)
220 (td->td_samplesperpixel == 3) && (!
isUpSampled(tif)))
222 uint16_t ycbcrsubsampling[2];
223 uint16_t samplingblock_samples;
224 uint32_t samplingblocks_hor;
225 uint64_t samplingrow_samples;
228 ycbcrsubsampling + 0, ycbcrsubsampling + 1);
229 if ((ycbcrsubsampling[0] != 1 && ycbcrsubsampling[0] != 2 &&
230 ycbcrsubsampling[0] != 4) ||
231 (ycbcrsubsampling[1] != 1 && ycbcrsubsampling[1] != 2 &&
232 ycbcrsubsampling[1] != 4) ||
233 (ycbcrsubsampling[0] == 0 || ycbcrsubsampling[1] == 0))
235 TIFFErrorExtR(tif, module,
"Invalid YCbCr subsampling (%u*%u)",
236 ycbcrsubsampling[0], ycbcrsubsampling[1]);
239 samplingblock_samples =
240 (uint16_t)(ycbcrsubsampling[0] * ycbcrsubsampling[1] + 2);
244 samplingblock_samples, module);
247 td->td_bitspersample, module)) /
249 if (tilerowsize == 0)
251 TIFFErrorExtR(tif, module,
"Computed tile row size is zero");
254 return (tilerowsize);
260 if (td->td_samplesperpixel == 0)
269 if (tilerowsize == 0)
271 TIFFErrorExtR(tif, module,
"Computed tile row size is zero");
274 return (tilerowsize);
278 static const char module[] = "TIFFTileRowSize";
294 static const char module[] = "TIFFVTileSize";
309 static const char module[] = "TIFFTileSize";
329 if (*(int32_t *)tw < 1)
331 if (*(int32_t *)th < 1)
uint32_t _TIFFMultiply32Ext(TIFF *tif, uint32_t first, uint32_t second, const char *where, bool *pOverflowed)
Multiply two unsigned values with an overflow check, and record an overflow in a caller-provided flag...
uint32_t _TIFFMultiply32(TIFF *tif, uint32_t first, uint32_t second, const char *where)
Multiply two unsigned values with an overflow check.
uint32_t _TIFFCastUInt64ToUInt32Ext(TIFF *tif, uint64_t val, const char *module, bool *pOverflowed)
Convert an unsigned 64-bit value after checking the destination range, and record a rejection in a ca...
tmsize_t _TIFFCastUInt64ToSSize(TIFF *tif, uint64_t val, const char *module)
Convert an unsigned 64-bit value after checking the destination range.
uint64_t _TIFFAdd64Ext(TIFF *tif, uint64_t first, uint64_t second, const char *where, bool *pOverflowed)
Check and add two unsigned operands, and record an overflow in a caller-provided flag.
uint64_t _TIFFMultiply64(TIFF *tif, uint64_t first, uint64_t second, const char *where)
Multiply two unsigned values with an overflow check.
void _TIFFDefaultTileSize(TIFF *tif, uint32_t *tw, uint32_t *th)
Supply default tile dimensions and round them to multiples of sixteen.
uint64_t _TIFFStrileSize64(TIFF *tif, uint32_t nrows, int isStrip)
Compute row-aligned decoded storage for a strip or tile-height request.
uint32_t _TIFFComputeTileExt(TIFF *tif, uint32_t x, uint32_t y, uint32_t z, uint16_t s, bool *pOverflowed)
Compute a tile index as TIFFComputeTile() does, and record an index overflow in a caller-provided fla...
#define isUpSampled(tif)
Test whether the codec reports upsampled output.
#define TIFFroundup_32(x, y)
Round a 32-bit value up to a multiple using the guarded quotient.
#define FALSE
Represent the legacy internal false value.
#define TIFFhowmany_32(x, y)
Compute a guarded 32-bit ceiling quotient.
#define TIFFhowmany8_64(x)
Compute the byte count needed to hold a 64-bit bit count.
void TIFFErrorExtR(TIFF *tif, const char *module, const char *fmt,...)
Dispatch a error diagnostic to the configured handlers.
tmsize_t TIFFTileSize(TIFF *tif)
Compute the decoded-size estimate for the configured tile height.
uint64_t TIFFVTileSize64(TIFF *tif, uint32_t nrows)
Compute the decoded-size estimate for a requested tile height.
tmsize_t TIFFTileRowSize(TIFF *tif)
Compute the packed byte count of one tile row.
uint64_t TIFFTileSize64(TIFF *tif)
Compute the decoded-size estimate for the configured tile height.
tmsize_t TIFFVTileSize(TIFF *tif, uint32_t nrows)
Compute the decoded-size estimate for a requested tile height.
uint32_t TIFFComputeTile(TIFF *tif, uint32_t x, uint32_t y, uint32_t z, uint16_t s)
Compute a tile index from pixel and sample coordinates.
int TIFFCheckTile(TIFF *tif, uint32_t x, uint32_t y, uint32_t z, uint16_t s)
Check pixel and separate-sample coordinates against image bounds.
uint32_t TIFFNumberOfTiles(TIFF *tif)
Compute the tile count across image depth and sample planes.
void TIFFDefaultTileSize(TIFF *tif, uint32_t *tw, uint32_t *th)
Ask the installed sizing method to adjust tile width and height.
uint64_t TIFFTileRowSize64(TIFF *tif)
Compute the packed byte count of one tile row.
int TIFFGetFieldDefaulted(TIFF *tif, uint32_t tag,...)
Query a present tag or a supported default.
TIFF_SSIZE_T tmsize_t
Represent a signed memory or I/O size in bytes.
Store the current directory values and image traversal state.
uint32_t td_tiledepth
Tile depth in slices.
uint32_t td_imagewidth
Image width in pixels.
uint32_t td_tilewidth
Tile width in pixels.
uint32_t td_imagedepth
Image depth in slices.
uint16_t td_planarconfig
PLANARCONFIG_* sample-plane arrangement.
uint16_t td_samplesperpixel
Samples per pixel, including extra samples.
uint32_t td_imagelength
Image length in rows.
uint32_t td_tilelength
Tile length in rows.
Hold private state for one open TIFF library instance.
TIFFTileMethod tif_deftilesize
Codec callback computing or constraining default tile dimensions.
char * tif_name
Current filename pointer; may refer to inline or client-supplied storage.
TIFFDirectory tif_dir
Inline representation of the current image directory.
Declare private library state, callbacks, and implementation helpers.