ReactOS 0.4.16-dev-122-g325d74c
tif_strip.c File Reference
#include <precomp.h>
Include dependency graph for tif_strip.c:

Go to the source code of this file.

Functions

uint32 TIFFComputeStrip (TIFF *tif, uint32 row, uint16 sample)
 
uint32 TIFFNumberOfStrips (TIFF *tif)
 
uint64 TIFFVStripSize64 (TIFF *tif, uint32 nrows)
 
tmsize_t TIFFVStripSize (TIFF *tif, uint32 nrows)
 
uint64 TIFFRawStripSize64 (TIFF *tif, uint32 strip)
 
tmsize_t TIFFRawStripSize (TIFF *tif, uint32 strip)
 
uint64 TIFFStripSize64 (TIFF *tif)
 
tmsize_t TIFFStripSize (TIFF *tif)
 
uint32 TIFFDefaultStripSize (TIFF *tif, uint32 request)
 
uint32 _TIFFDefaultStripSize (TIFF *tif, uint32 s)
 
uint64 TIFFScanlineSize64 (TIFF *tif)
 
tmsize_t TIFFScanlineSize (TIFF *tif)
 
uint64 TIFFRasterScanlineSize64 (TIFF *tif)
 
tmsize_t TIFFRasterScanlineSize (TIFF *tif)
 

Function Documentation

◆ _TIFFDefaultStripSize()

uint32 _TIFFDefaultStripSize ( TIFF tif,
uint32  s 
)

Definition at line 223 of file tif_strip.c.

224{
225 if ((int32) s < 1) {
226 /*
227 * If RowsPerStrip is unspecified, try to break the
228 * image up into strips that are approximately
229 * STRIP_SIZE_DEFAULT bytes long.
230 */
231 uint64 scanlinesize;
232 uint64 rows;
233 scanlinesize=TIFFScanlineSize64(tif);
234 if (scanlinesize==0)
235 scanlinesize=1;
236 rows=(uint64)STRIP_SIZE_DEFAULT/scanlinesize;
237 if (rows==0)
238 rows=1;
239 else if (rows>0xFFFFFFFF)
240 rows=0xFFFFFFFF;
241 s=(uint32)rows;
242 }
243 return (s);
244}
unsigned int uint32
Definition: types.h:32
unsigned long long uint64
Definition: platform.h:18
long int32
Definition: platform.h:12
GLdouble s
Definition: gl.h:2039
uint64 TIFFScanlineSize64(TIFF *tif)
Definition: tif_strip.c:257
#define STRIP_SIZE_DEFAULT
Definition: tiffiop.h:69

Referenced by _TIFFSetDefaultCompressionState().

◆ TIFFComputeStrip()

uint32 TIFFComputeStrip ( TIFF tif,
uint32  row,
uint16  sample 
)

Definition at line 36 of file tif_strip.c.

37{
38 static const char module[] = "TIFFComputeStrip";
39 TIFFDirectory *td = &tif->tif_dir;
40 uint32 strip;
41
42 strip = row / td->td_rowsperstrip;
44 if (sample >= td->td_samplesperpixel) {
46 "%lu: Sample out of range, max %lu",
47 (unsigned long) sample, (unsigned long) td->td_samplesperpixel);
48 return (0);
49 }
50 strip += (uint32)sample*td->td_stripsperimage;
51 }
52 return (strip);
53}
struct png_info_def *typedef unsigned char **typedef struct png_info_def *typedef struct png_info_def *typedef struct png_info_def *typedef unsigned char ** row
Definition: typeof.h:78
uint16 td_samplesperpixel
Definition: tif_dir.h:82
uint32 td_rowsperstrip
Definition: tif_dir.h:83
uint16 td_planarconfig
Definition: tif_dir.h:89
uint32 td_stripsperimage
Definition: tif_dir.h:99
thandle_t tif_clientdata
Definition: tiffiop.h:207
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 gtStripContig(), and gtStripSeparate().

◆ TIFFDefaultStripSize()

uint32 TIFFDefaultStripSize ( TIFF tif,
uint32  request 
)

Definition at line 217 of file tif_strip.c.

218{
219 return (*tif->tif_defstripsize)(tif, request);
220}
Definition: tftpd.h:86
TIFFStripMethod tif_defstripsize
Definition: tiffiop.h:189

◆ TIFFNumberOfStrips()

uint32 TIFFNumberOfStrips ( TIFF tif)

Definition at line 59 of file tif_strip.c.

60{
61 TIFFDirectory *td = &tif->tif_dir;
62 uint32 nstrips;
63
64 nstrips = (td->td_rowsperstrip == (uint32) -1 ? 1 :
67 nstrips = _TIFFMultiply32(tif, nstrips, (uint32)td->td_samplesperpixel,
68 "TIFFNumberOfStrips");
69 return (nstrips);
70}
uint32 td_imagelength
Definition: tif_dir.h:72
uint32 _TIFFMultiply32(TIFF *tif, uint32 first, uint32 second, const char *where)
Definition: tif_aux.c:37
#define TIFFhowmany_32(x, y)
Definition: tiffiop.h:264

Referenced by TIFFReadDirectory(), and TIFFSetupStrips().

◆ TIFFRasterScanlineSize()

tmsize_t TIFFRasterScanlineSize ( TIFF tif)

Definition at line 344 of file tif_strip.c.

345{
346 static const char module[] = "TIFFRasterScanlineSize";
347 uint64 m;
349 return _TIFFCastUInt64ToSSize(tif, m, module);
350}
const GLfloat * m
Definition: glext.h:10848
tmsize_t _TIFFCastUInt64ToSSize(TIFF *tif, uint64 val, const char *module)
Definition: tif_aux.c:83
uint64 TIFFRasterScanlineSize64(TIFF *tif)
Definition: tif_strip.c:329

◆ TIFFRasterScanlineSize64()

uint64 TIFFRasterScanlineSize64 ( TIFF tif)

Definition at line 329 of file tif_strip.c.

330{
331 static const char module[] = "TIFFRasterScanlineSize64";
332 TIFFDirectory *td = &tif->tif_dir;
333 uint64 scanline;
334
335 scanline = _TIFFMultiply64(tif, td->td_bitspersample, td->td_imagewidth, module);
337 scanline = _TIFFMultiply64(tif, scanline, td->td_samplesperpixel, module);
338 return (TIFFhowmany8_64(scanline));
339 } else
340 return (_TIFFMultiply64(tif, TIFFhowmany8_64(scanline),
342}
uint16 td_bitspersample
Definition: tif_dir.h:75
uint32 td_imagewidth
Definition: tif_dir.h:72
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 TIFFRasterScanlineSize().

◆ TIFFRawStripSize()

tmsize_t TIFFRawStripSize ( TIFF tif,
uint32  strip 
)

Definition at line 164 of file tif_strip.c.

165{
166 static const char module[] = "TIFFRawStripSize";
167 uint64 m;
168 tmsize_t n;
169 m=TIFFRawStripSize64(tif,strip);
170 if (m==(uint64)(-1))
171 n=(tmsize_t)(-1);
172 else
173 {
174 n=(tmsize_t)m;
175 if ((uint64)n!=m)
176 {
177 TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow");
178 n=0;
179 }
180 }
181 return(n);
182}
GLdouble n
Definition: glext.h:7729
uint64 TIFFRawStripSize64(TIFF *tif, uint32 strip)
Definition: tif_strip.c:140
TIFF_SSIZE_T tmsize_t
Definition: tiffio.h:65

◆ TIFFRawStripSize64()

uint64 TIFFRawStripSize64 ( TIFF tif,
uint32  strip 
)

Definition at line 140 of file tif_strip.c.

141{
142 static const char module[] = "TIFFRawStripSize64";
143 uint64 bytecount = TIFFGetStrileByteCount(tif, strip);
144
145 if (bytecount == 0)
146 {
147#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
149 "%I64u: Invalid strip byte count, strip %lu",
150 (unsigned __int64) bytecount,
151 (unsigned long) strip);
152#else
154 "%llu: Invalid strip byte count, strip %lu",
155 (unsigned long long) bytecount,
156 (unsigned long) strip);
157#endif
158 bytecount = (uint64) -1;
159 }
160
161 return bytecount;
162}
#define __int64
Definition: basetyps.h:16
uint64 TIFFGetStrileByteCount(TIFF *tif, uint32 strile)
Definition: tif_dirread.c:6305

Referenced by TIFFRawStripSize().

◆ TIFFScanlineSize()

tmsize_t TIFFScanlineSize ( TIFF tif)

Definition at line 314 of file tif_strip.c.

315{
316 static const char module[] = "TIFFScanlineSize";
317 uint64 m;
319 return _TIFFCastUInt64ToSSize(tif, m, module);
320}

Referenced by gtStripContig(), gtStripSeparate(), PredictorSetup(), TIFFReadDirectory(), and TIFFWriteCheck().

◆ TIFFScanlineSize64()

uint64 TIFFScanlineSize64 ( TIFF tif)

Definition at line 257 of file tif_strip.c.

258{
259 static const char module[] = "TIFFScanlineSize64";
260 TIFFDirectory *td = &tif->tif_dir;
261 uint64 scanline_size;
263 {
265 (td->td_samplesperpixel==3)&&
266 (!isUpSampled(tif)))
267 {
268 uint16 ycbcrsubsampling[2];
269 uint16 samplingblock_samples;
270 uint32 samplingblocks_hor;
271 uint64 samplingrow_samples;
272 uint64 samplingrow_size;
273 if(td->td_samplesperpixel!=3)
274 {
276 "Invalid td_samplesperpixel value");
277 return 0;
278 }
280 ycbcrsubsampling+0,
281 ycbcrsubsampling+1);
282 if (((ycbcrsubsampling[0]!=1)&&(ycbcrsubsampling[0]!=2)&&(ycbcrsubsampling[0]!=4)) ||
283 ((ycbcrsubsampling[1]!=1)&&(ycbcrsubsampling[1]!=2)&&(ycbcrsubsampling[1]!=4)))
284 {
286 "Invalid YCbCr subsampling");
287 return 0;
288 }
289 samplingblock_samples = ycbcrsubsampling[0]*ycbcrsubsampling[1]+2;
290 samplingblocks_hor = TIFFhowmany_32(td->td_imagewidth,ycbcrsubsampling[0]);
291 samplingrow_samples = _TIFFMultiply64(tif,samplingblocks_hor,samplingblock_samples,module);
292 samplingrow_size = TIFFhowmany_64(_TIFFMultiply64(tif,samplingrow_samples,td->td_bitspersample,module),8);
293 scanline_size = (samplingrow_size/ycbcrsubsampling[1]);
294 }
295 else
296 {
297 uint64 scanline_samples;
298 scanline_samples=_TIFFMultiply64(tif,td->td_imagewidth,td->td_samplesperpixel,module);
299 scanline_size=TIFFhowmany_64(_TIFFMultiply64(tif,scanline_samples,td->td_bitspersample,module),8);
300 }
301 }
302 else
303 {
305 }
306 if (scanline_size == 0)
307 {
308 TIFFErrorExt(tif->tif_clientdata,module,"Computed scanline size is zero");
309 return 0;
310 }
311 return(scanline_size);
312}
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 TIFFhowmany_64(x, y)
Definition: tiffiop.h:273
#define isUpSampled(tif)
Definition: tiffiop.h:232

Referenced by _TIFFDefaultStripSize(), ByteCountLooksBad(), EstimateStripByteCounts(), TIFFScanlineSize(), and TIFFVStripSize64().

◆ TIFFStripSize()

tmsize_t TIFFStripSize ( TIFF tif)

Definition at line 202 of file tif_strip.c.

203{
204 static const char module[] = "TIFFStripSize";
205 uint64 m;
206 m=TIFFStripSize64(tif);
207 return _TIFFCastUInt64ToSSize(tif, m, module);
208}
uint64 TIFFStripSize64(TIFF *tif)
Definition: tif_strip.c:193

Referenced by gtStripContig(), gtStripSeparate(), TIFFFillStrip(), TIFFReadDirectory(), and TIFFWriteBufferSetup().

◆ TIFFStripSize64()

uint64 TIFFStripSize64 ( TIFF tif)

Definition at line 193 of file tif_strip.c.

194{
195 TIFFDirectory* td = &tif->tif_dir;
196 uint32 rps = td->td_rowsperstrip;
197 if (rps > td->td_imagelength)
198 rps = td->td_imagelength;
199 return (TIFFVStripSize64(tif, rps));
200}
uint64 TIFFVStripSize64(TIFF *tif, uint32 nrows)
Definition: tif_strip.c:76

Referenced by _TIFFRewriteField(), TIFFReadDirectory(), TIFFStripSize(), TIFFWriteDirectoryTagLongLong8Array(), and TryChopUpUncompressedBigTiff().

◆ TIFFVStripSize()

tmsize_t TIFFVStripSize ( TIFF tif,
uint32  nrows 
)

Definition at line 128 of file tif_strip.c.

129{
130 static const char module[] = "TIFFVStripSize";
131 uint64 m;
132 m=TIFFVStripSize64(tif,nrows);
133 return _TIFFCastUInt64ToSSize(tif, m, module);
134}

Referenced by TIFFReadEncodedStripGetStripSize().

◆ TIFFVStripSize64()

uint64 TIFFVStripSize64 ( TIFF tif,
uint32  nrows 
)

Definition at line 76 of file tif_strip.c.

77{
78 static const char module[] = "TIFFVStripSize64";
79 TIFFDirectory *td = &tif->tif_dir;
80 if (nrows==(uint32)(-1))
81 nrows=td->td_imagelength;
84 (!isUpSampled(tif)))
85 {
86 /*
87 * Packed YCbCr data contain one Cb+Cr for every
88 * HorizontalSampling*VerticalSampling Y values.
89 * Must also roundup width and height when calculating
90 * since images that are not a multiple of the
91 * horizontal/vertical subsampling area include
92 * YCbCr data for the extended image.
93 */
94 uint16 ycbcrsubsampling[2];
95 uint16 samplingblock_samples;
96 uint32 samplingblocks_hor;
97 uint32 samplingblocks_ver;
98 uint64 samplingrow_samples;
99 uint64 samplingrow_size;
100 if(td->td_samplesperpixel!=3)
101 {
103 "Invalid td_samplesperpixel value");
104 return 0;
105 }
106 TIFFGetFieldDefaulted(tif,TIFFTAG_YCBCRSUBSAMPLING,ycbcrsubsampling+0,
107 ycbcrsubsampling+1);
108 if ((ycbcrsubsampling[0] != 1 && ycbcrsubsampling[0] != 2 && ycbcrsubsampling[0] != 4)
109 ||(ycbcrsubsampling[1] != 1 && ycbcrsubsampling[1] != 2 && ycbcrsubsampling[1] != 4))
110 {
112 "Invalid YCbCr subsampling (%dx%d)",
113 ycbcrsubsampling[0],
114 ycbcrsubsampling[1] );
115 return 0;
116 }
117 samplingblock_samples=ycbcrsubsampling[0]*ycbcrsubsampling[1]+2;
118 samplingblocks_hor=TIFFhowmany_32(td->td_imagewidth,ycbcrsubsampling[0]);
119 samplingblocks_ver=TIFFhowmany_32(nrows,ycbcrsubsampling[1]);
120 samplingrow_samples=_TIFFMultiply64(tif,samplingblocks_hor,samplingblock_samples,module);
121 samplingrow_size=TIFFhowmany8_64(_TIFFMultiply64(tif,samplingrow_samples,td->td_bitspersample,module));
122 return(_TIFFMultiply64(tif,samplingrow_size,samplingblocks_ver,module));
123 }
124 else
125 return(_TIFFMultiply64(tif,nrows,TIFFScanlineSize64(tif),module));
126}

Referenced by TIFFStripSize64(), TIFFVStripSize(), and TryChopUpUncompressedBigTiff().