ReactOS  0.4.14-dev-368-gfa26425
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 239 of file tif_strip.c.

240 {
241  if ((int32) s < 1) {
242  /*
243  * If RowsPerStrip is unspecified, try to break the
244  * image up into strips that are approximately
245  * STRIP_SIZE_DEFAULT bytes long.
246  */
247  uint64 scanlinesize;
248  uint64 rows;
249  scanlinesize=TIFFScanlineSize64(tif);
250  if (scanlinesize==0)
251  scanlinesize=1;
252  rows=(uint64)STRIP_SIZE_DEFAULT/scanlinesize;
253  if (rows==0)
254  rows=1;
255  else if (rows>0xFFFFFFFF)
256  rows=0xFFFFFFFF;
257  s=(uint32)rows;
258  }
259  return (s);
260 }
unsigned long long uint64
Definition: platform.h:18
#define STRIP_SIZE_DEFAULT
Definition: tiffiop.h:69
unsigned int uint32
Definition: types.h:32
uint64 TIFFScanlineSize64(TIFF *tif)
Definition: tif_strip.c:273
GLdouble s
Definition: gl.h:2039
long int32
Definition: platform.h:12

Referenced by _TIFFSetDefaultCompressionState().

◆ TIFFComputeStrip()

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

Definition at line 37 of file tif_strip.c.

38 {
39  static const char module[] = "TIFFComputeStrip";
40  TIFFDirectory *td = &tif->tif_dir;
41  uint32 strip;
42 
43  strip = row / td->td_rowsperstrip;
45  if (sample >= td->td_samplesperpixel) {
47  "%lu: Sample out of range, max %lu",
48  (unsigned long) sample, (unsigned long) td->td_samplesperpixel);
49  return (0);
50  }
51  strip += (uint32)sample*td->td_stripsperimage;
52  }
53  return (strip);
54 }
unsigned int uint32
Definition: types.h:32
thandle_t tif_clientdata
Definition: tiffiop.h:191
uint32 td_stripsperimage
Definition: tif_dir.h:98
uint16 td_planarconfig
Definition: tif_dir.h:88
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
#define PLANARCONFIG_SEPARATE
Definition: tiff.h:241
uint32 td_rowsperstrip
Definition: tif_dir.h:82
TIFFDirectory tif_dir
Definition: tiffiop.h:135
uint16 td_samplesperpixel
Definition: tif_dir.h:81
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

Referenced by gtStripContig(), and gtStripSeparate().

◆ TIFFDefaultStripSize()

uint32 TIFFDefaultStripSize ( TIFF tif,
uint32  request 
)

Definition at line 233 of file tif_strip.c.

234 {
235  return (*tif->tif_defstripsize)(tif, request);
236 }
Definition: tftpd.h:85
TIFFStripMethod tif_defstripsize
Definition: tiffiop.h:173

◆ TIFFNumberOfStrips()

uint32 TIFFNumberOfStrips ( TIFF tif)

Definition at line 60 of file tif_strip.c.

61 {
62  TIFFDirectory *td = &tif->tif_dir;
63  uint32 nstrips;
64 
65  nstrips = (td->td_rowsperstrip == (uint32) -1 ? 1 :
68  nstrips = _TIFFMultiply32(tif, nstrips, (uint32)td->td_samplesperpixel,
69  "TIFFNumberOfStrips");
70  return (nstrips);
71 }
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
uint16 td_planarconfig
Definition: tif_dir.h:88
uint32 td_imagelength
Definition: tif_dir.h:71
#define PLANARCONFIG_SEPARATE
Definition: tiff.h:241
uint32 td_rowsperstrip
Definition: tif_dir.h:82
TIFFDirectory tif_dir
Definition: tiffiop.h:135
uint16 td_samplesperpixel
Definition: tif_dir.h:81

Referenced by TIFFReadDirectory(), and TIFFSetupStrips().

◆ TIFFRasterScanlineSize()

tmsize_t TIFFRasterScanlineSize ( TIFF tif)

Definition at line 366 of file tif_strip.c.

367 {
368  static const char module[] = "TIFFRasterScanlineSize";
369  uint64 m;
370  tmsize_t n;
372  n=(tmsize_t)m;
373  if ((uint64)n!=m)
374  {
375  TIFFErrorExt(tif->tif_clientdata,module,"Integer arithmetic overflow");
376  n=0;
377  }
378  return(n);
379 }
unsigned long long uint64
Definition: platform.h:18
uint64 TIFFRasterScanlineSize64(TIFF *tif)
Definition: tif_strip.c:351
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

◆ TIFFRasterScanlineSize64()

uint64 TIFFRasterScanlineSize64 ( TIFF tif)

Definition at line 351 of file tif_strip.c.

352 {
353  static const char module[] = "TIFFRasterScanlineSize64";
354  TIFFDirectory *td = &tif->tif_dir;
355  uint64 scanline;
356 
357  scanline = _TIFFMultiply64(tif, td->td_bitspersample, td->td_imagewidth, module);
359  scanline = _TIFFMultiply64(tif, scanline, td->td_samplesperpixel, module);
360  return (TIFFhowmany8_64(scanline));
361  } else
362  return (_TIFFMultiply64(tif, TIFFhowmany8_64(scanline),
363  td->td_samplesperpixel, module));
364 }
unsigned long long uint64
Definition: platform.h:18
uint16 td_bitspersample
Definition: tif_dir.h:74
#define TIFFhowmany8_64(x)
Definition: tiffiop.h:258
uint16 td_planarconfig
Definition: tif_dir.h:88
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
uint32 td_imagewidth
Definition: tif_dir.h:71
#define PLANARCONFIG_CONTIG
Definition: tiff.h:240

Referenced by TIFFRasterScanlineSize().

◆ TIFFRawStripSize()

tmsize_t TIFFRawStripSize ( TIFF tif,
uint32  strip 
)

Definition at line 173 of file tif_strip.c.

174 {
175  static const char module[] = "TIFFRawStripSize";
176  uint64 m;
177  tmsize_t n;
178  m=TIFFRawStripSize64(tif,strip);
179  if (m==(uint64)(-1))
180  n=(tmsize_t)(-1);
181  else
182  {
183  n=(tmsize_t)m;
184  if ((uint64)n!=m)
185  {
186  TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow");
187  n=0;
188  }
189  }
190  return(n);
191 }
unsigned long long uint64
Definition: platform.h:18
uint64 TIFFRawStripSize64(TIFF *tif, uint32 strip)
Definition: tif_strip.c:148
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

◆ TIFFRawStripSize64()

uint64 TIFFRawStripSize64 ( TIFF tif,
uint32  strip 
)

Definition at line 148 of file tif_strip.c.

149 {
150  static const char module[] = "TIFFRawStripSize64";
151  TIFFDirectory* td = &tif->tif_dir;
152  uint64 bytecount = td->td_stripbytecount[strip];
153 
154  if (bytecount == 0)
155  {
156 #if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
158  "%I64u: Invalid strip byte count, strip %lu",
159  (unsigned __int64) bytecount,
160  (unsigned long) strip);
161 #else
163  "%llu: Invalid strip byte count, strip %lu",
164  (unsigned long long) bytecount,
165  (unsigned long) strip);
166 #endif
167  bytecount = (uint64) -1;
168  }
169 
170  return bytecount;
171 }
unsigned long long uint64
Definition: platform.h:18
thandle_t tif_clientdata
Definition: tiffiop.h:191
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
uint64 * td_stripbytecount
Definition: tif_dir.h:101
TIFFDirectory tif_dir
Definition: tiffiop.h:135
#define __int64
Definition: basetyps.h:16

Referenced by TIFFRawStripSize().

◆ TIFFScanlineSize()

tmsize_t TIFFScanlineSize ( TIFF tif)

Definition at line 330 of file tif_strip.c.

331 {
332  static const char module[] = "TIFFScanlineSize";
333  uint64 m;
334  tmsize_t n;
335  m=TIFFScanlineSize64(tif);
336  n=(tmsize_t)m;
337  if ((uint64)n!=m) {
338  TIFFErrorExt(tif->tif_clientdata,module,"Integer arithmetic overflow");
339  n=0;
340  }
341  return(n);
342 }
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 TIFFScanlineSize64(TIFF *tif)
Definition: tif_strip.c:273
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65

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

◆ TIFFScanlineSize64()

uint64 TIFFScanlineSize64 ( TIFF tif)

Definition at line 273 of file tif_strip.c.

274 {
275  static const char module[] = "TIFFScanlineSize64";
276  TIFFDirectory *td = &tif->tif_dir;
277  uint64 scanline_size;
279  {
280  if ((td->td_photometric==PHOTOMETRIC_YCBCR)&&
281  (td->td_samplesperpixel==3)&&
282  (!isUpSampled(tif)))
283  {
284  uint16 ycbcrsubsampling[2];
285  uint16 samplingblock_samples;
286  uint32 samplingblocks_hor;
287  uint64 samplingrow_samples;
288  uint64 samplingrow_size;
289  if(td->td_samplesperpixel!=3)
290  {
292  "Invalid td_samplesperpixel value");
293  return 0;
294  }
296  ycbcrsubsampling+0,
297  ycbcrsubsampling+1);
298  if (((ycbcrsubsampling[0]!=1)&&(ycbcrsubsampling[0]!=2)&&(ycbcrsubsampling[0]!=4)) ||
299  ((ycbcrsubsampling[1]!=1)&&(ycbcrsubsampling[1]!=2)&&(ycbcrsubsampling[1]!=4)))
300  {
302  "Invalid YCbCr subsampling");
303  return 0;
304  }
305  samplingblock_samples = ycbcrsubsampling[0]*ycbcrsubsampling[1]+2;
306  samplingblocks_hor = TIFFhowmany_32(td->td_imagewidth,ycbcrsubsampling[0]);
307  samplingrow_samples = _TIFFMultiply64(tif,samplingblocks_hor,samplingblock_samples,module);
308  samplingrow_size = TIFFhowmany_64(_TIFFMultiply64(tif,samplingrow_samples,td->td_bitspersample,module),8);
309  scanline_size = (samplingrow_size/ycbcrsubsampling[1]);
310  }
311  else
312  {
313  uint64 scanline_samples;
314  scanline_samples=_TIFFMultiply64(tif,td->td_imagewidth,td->td_samplesperpixel,module);
315  scanline_size=TIFFhowmany_64(_TIFFMultiply64(tif,scanline_samples,td->td_bitspersample,module),8);
316  }
317  }
318  else
319  {
321  }
322  if (scanline_size == 0)
323  {
324  TIFFErrorExt(tif->tif_clientdata,module,"Computed scanline size is zero");
325  return 0;
326  }
327  return(scanline_size);
328 }
unsigned long long uint64
Definition: platform.h:18
uint16 td_bitspersample
Definition: tif_dir.h:74
#define PHOTOMETRIC_YCBCR
Definition: tiff.h:202
#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
uint16 td_planarconfig
Definition: tif_dir.h:88
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
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
#define TIFFhowmany_64(x, y)
Definition: tiffiop.h:257
uint16 td_samplesperpixel
Definition: tif_dir.h:81
uint32 td_imagewidth
Definition: tif_dir.h:71
#define PLANARCONFIG_CONTIG
Definition: tiff.h:240

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

◆ TIFFStripSize()

tmsize_t TIFFStripSize ( TIFF tif)

Definition at line 211 of file tif_strip.c.

212 {
213  static const char module[] = "TIFFStripSize";
214  uint64 m;
215  tmsize_t n;
216  m=TIFFStripSize64(tif);
217  n=(tmsize_t)m;
218  if ((uint64)n!=m)
219  {
220  TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow");
221  n=0;
222  }
223  return(n);
224 }
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 TIFFStripSize64(TIFF *tif)
Definition: tif_strip.c:202

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

◆ TIFFStripSize64()

uint64 TIFFStripSize64 ( TIFF tif)

Definition at line 202 of file tif_strip.c.

203 {
204  TIFFDirectory* td = &tif->tif_dir;
205  uint32 rps = td->td_rowsperstrip;
206  if (rps > td->td_imagelength)
207  rps = td->td_imagelength;
208  return (TIFFVStripSize64(tif, rps));
209 }
uint64 TIFFVStripSize64(TIFF *tif, uint32 nrows)
Definition: tif_strip.c:77
unsigned int uint32
Definition: types.h:32
uint32 td_imagelength
Definition: tif_dir.h:71
uint32 td_rowsperstrip
Definition: tif_dir.h:82
TIFFDirectory tif_dir
Definition: tiffiop.h:135

Referenced by TIFFStripSize().

◆ TIFFVStripSize()

tmsize_t TIFFVStripSize ( TIFF tif,
uint32  nrows 
)

Definition at line 129 of file tif_strip.c.

130 {
131  static const char module[] = "TIFFVStripSize";
132  uint64 m;
133  tmsize_t n;
134  m=TIFFVStripSize64(tif,nrows);
135  n=(tmsize_t)m;
136  if ((uint64)n!=m)
137  {
138  TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow");
139  n=0;
140  }
141  return(n);
142 }
unsigned long long uint64
Definition: platform.h:18
uint64 TIFFVStripSize64(TIFF *tif, uint32 nrows)
Definition: tif_strip.c:77
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

Referenced by TIFFReadEncodedStripGetStripSize().

◆ TIFFVStripSize64()

uint64 TIFFVStripSize64 ( TIFF tif,
uint32  nrows 
)

Definition at line 77 of file tif_strip.c.

78 {
79  static const char module[] = "TIFFVStripSize64";
80  TIFFDirectory *td = &tif->tif_dir;
81  if (nrows==(uint32)(-1))
82  nrows=td->td_imagelength;
85  (!isUpSampled(tif)))
86  {
87  /*
88  * Packed YCbCr data contain one Cb+Cr for every
89  * HorizontalSampling*VerticalSampling Y values.
90  * Must also roundup width and height when calculating
91  * since images that are not a multiple of the
92  * horizontal/vertical subsampling area include
93  * YCbCr data for the extended image.
94  */
95  uint16 ycbcrsubsampling[2];
96  uint16 samplingblock_samples;
97  uint32 samplingblocks_hor;
98  uint32 samplingblocks_ver;
99  uint64 samplingrow_samples;
100  uint64 samplingrow_size;
101  if(td->td_samplesperpixel!=3)
102  {
104  "Invalid td_samplesperpixel value");
105  return 0;
106  }
107  TIFFGetFieldDefaulted(tif,TIFFTAG_YCBCRSUBSAMPLING,ycbcrsubsampling+0,
108  ycbcrsubsampling+1);
109  if ((ycbcrsubsampling[0] != 1 && ycbcrsubsampling[0] != 2 && ycbcrsubsampling[0] != 4)
110  ||(ycbcrsubsampling[1] != 1 && ycbcrsubsampling[1] != 2 && ycbcrsubsampling[1] != 4))
111  {
113  "Invalid YCbCr subsampling (%dx%d)",
114  ycbcrsubsampling[0],
115  ycbcrsubsampling[1] );
116  return 0;
117  }
118  samplingblock_samples=ycbcrsubsampling[0]*ycbcrsubsampling[1]+2;
119  samplingblocks_hor=TIFFhowmany_32(td->td_imagewidth,ycbcrsubsampling[0]);
120  samplingblocks_ver=TIFFhowmany_32(nrows,ycbcrsubsampling[1]);
121  samplingrow_samples=_TIFFMultiply64(tif,samplingblocks_hor,samplingblock_samples,module);
122  samplingrow_size=TIFFhowmany8_64(_TIFFMultiply64(tif,samplingrow_samples,td->td_bitspersample,module));
123  return(_TIFFMultiply64(tif,samplingrow_size,samplingblocks_ver,module));
124  }
125  else
126  return(_TIFFMultiply64(tif,nrows,TIFFScanlineSize64(tif),module));
127 }
unsigned long long uint64
Definition: platform.h:18
uint16 td_bitspersample
Definition: tif_dir.h:74
#define PHOTOMETRIC_YCBCR
Definition: tiff.h:202
#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
uint64 TIFFScanlineSize64(TIFF *tif)
Definition: tif_strip.c:273
uint16 td_planarconfig
Definition: tif_dir.h:88
int TIFFGetFieldDefaulted(TIFF *tif, uint32 tag,...)
Definition: tif_aux.c:309
uint32 td_imagelength
Definition: tif_dir.h:71
uint16 td_photometric
Definition: tif_dir.h:77
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
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
uint32 td_imagewidth
Definition: tif_dir.h:71
#define PLANARCONFIG_CONTIG
Definition: tiff.h:240

Referenced by TIFFStripSize64(), and TIFFVStripSize().