~ubuntu-branches/debian/sid/gdal/sid

« back to all changes in this revision

Viewing changes to frmts/gtiff/libtiff/tif_tile.c

  • Committer: Package Import Robot
  • Author(s): Francesco Paolo Lovergine
  • Date: 2012-05-07 15:04:42 UTC
  • mfrom: (5.5.16 experimental)
  • Revision ID: package-import@ubuntu.com-20120507150442-2eks97loeh6rq005
Tags: 1.9.0-1
* Ready for sid, starting transition.
* All symfiles updated to latest builds.
* Added dh_numpy call in debian/rules to depend on numpy ABI.
* Policy bumped to 3.9.3, no changes required.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: tif_tile.c,v 1.20 2007/06/27 16:09:58 joris Exp $ */
 
1
/* $Id: tif_tile.c,v 1.22 2010-07-01 15:33:28 dron Exp $ */
2
2
 
3
3
/*
4
4
 * Copyright (c) 1991-1997 Sam Leffler
31
31
 */
32
32
#include "tiffiop.h"
33
33
 
34
 
static uint32
35
 
multiply_32(TIFF* tif, uint32 nmemb, uint32 elem_size, const char* where)
36
 
{
37
 
        uint32 bytes = nmemb * elem_size;
38
 
 
39
 
        if (elem_size && bytes / elem_size != nmemb) {
40
 
                TIFFErrorExt(tif->tif_clientdata, where, "Integer overflow in %s", where);
41
 
                bytes = 0;
42
 
        }
43
 
 
44
 
        return (bytes);
45
 
}
46
 
 
47
 
static uint64
48
 
multiply_64(TIFF* tif, uint64 nmemb, uint64 elem_size, const char* where)
49
 
{
50
 
        uint64 bytes = nmemb * elem_size;
51
 
 
52
 
        if (elem_size && bytes / elem_size != nmemb) {
53
 
                TIFFErrorExt(tif->tif_clientdata, where, "Integer overflow in %s", where);
54
 
                bytes = 0;
55
 
        }
56
 
 
57
 
        return (bytes);
58
 
}
59
 
 
60
34
/*
61
35
 * Compute which tile an (x,y,z,s) value is in.
62
36
 */
153
127
        if (dz == (uint32) -1)
154
128
                dz = td->td_imagedepth;
155
129
        ntiles = (dx == 0 || dy == 0 || dz == 0) ? 0 :
156
 
            multiply_32(tif, multiply_32(tif, TIFFhowmany_32(td->td_imagewidth, dx),
 
130
            _TIFFMultiply32(tif, _TIFFMultiply32(tif, TIFFhowmany_32(td->td_imagewidth, dx),
157
131
            TIFFhowmany_32(td->td_imagelength, dy),
158
132
            "TIFFNumberOfTiles"),
159
133
            TIFFhowmany_32(td->td_imagedepth, dz), "TIFFNumberOfTiles");
160
134
        if (td->td_planarconfig == PLANARCONFIG_SEPARATE)
161
 
                ntiles = multiply_32(tif, ntiles, td->td_samplesperpixel,
 
135
                ntiles = _TIFFMultiply32(tif, ntiles, td->td_samplesperpixel,
162
136
                    "TIFFNumberOfTiles");
163
137
        return (ntiles);
164
138
}
174
148
 
175
149
        if (td->td_tilelength == 0 || td->td_tilewidth == 0)
176
150
                return (0);
177
 
        rowsize = multiply_64(tif, td->td_bitspersample, td->td_tilewidth,
 
151
        rowsize = _TIFFMultiply64(tif, td->td_bitspersample, td->td_tilewidth,
178
152
            "TIFFTileRowSize");
179
153
        if (td->td_planarconfig == PLANARCONFIG_CONTIG)
180
 
                rowsize = multiply_64(tif, rowsize, td->td_samplesperpixel,
 
154
                rowsize = _TIFFMultiply64(tif, rowsize, td->td_samplesperpixel,
181
155
                    "TIFFTileRowSize");
182
156
        return (TIFFhowmany8_64(rowsize));
183
157
}
240
214
                samplingblock_samples=ycbcrsubsampling[0]*ycbcrsubsampling[1]+2;
241
215
                samplingblocks_hor=TIFFhowmany_32(td->td_tilewidth,ycbcrsubsampling[0]);
242
216
                samplingblocks_ver=TIFFhowmany_32(nrows,ycbcrsubsampling[1]);
243
 
                samplingrow_samples=multiply_64(tif,samplingblocks_hor,samplingblock_samples,module);
244
 
                samplingrow_size=TIFFhowmany8_64(multiply_64(tif,samplingrow_samples,td->td_bitspersample,module));
245
 
                return(multiply_64(tif,samplingrow_size,samplingblocks_ver,module));
 
217
                samplingrow_samples=_TIFFMultiply64(tif,samplingblocks_hor,samplingblock_samples,module);
 
218
                samplingrow_size=TIFFhowmany8_64(_TIFFMultiply64(tif,samplingrow_samples,td->td_bitspersample,module));
 
219
                return(_TIFFMultiply64(tif,samplingrow_size,samplingblocks_ver,module));
246
220
        }
247
221
        else
248
 
                return(multiply_64(tif,nrows,TIFFTileRowSize64(tif),module));
 
222
                return(_TIFFMultiply64(tif,nrows,TIFFTileRowSize64(tif),module));
249
223
}
250
224
tmsize_t
251
225
TIFFVTileSize(TIFF* tif, uint32 nrows)
315
289
}
316
290
 
317
291
/* vim: set ts=8 sts=8 sw=8 noet: */
 
292
/*
 
293
 * Local Variables:
 
294
 * mode: c
 
295
 * c-basic-offset: 8
 
296
 * fill-column: 78
 
297
 * End:
 
298
 */