Alien-FreeImage
view release on metacpan or search on metacpan
src/Source/OpenEXR/IlmImf/ImfTiledInputFile.cpp view on Meta::CPAN
int minY; // data window's min y coord
int maxY; // data window's max x coord
int numXLevels; // number of x levels
int numYLevels; // number of y levels
int * numXTiles; // number of x tiles at a level
int * numYTiles; // number of y tiles at a level
TileOffsets tileOffsets; // stores offsets in file for
// each tile
bool fileIsComplete; // True if no tiles are missing
// in the file
vector<TInSliceInfo> slices; // info about channels in file
size_t bytesPerPixel; // size of an uncompressed pixel
size_t maxBytesPerTileLine; // combined size of a line
// over all channels
int partNumber; // part number
bool multiPartBackwardSupport; // if we are reading a multipart file
// using OpenEXR 1.7 API
int numThreads; // number of threads
MultiPartInputFile* multiPartFile; // the MultiPartInputFile used to
// support backward compatibility
vector<TileBuffer*> tileBuffers; // each holds a single tile
size_t tileBufferSize; // size of the tile buffers
bool memoryMapped; // if the stream is memory mapped
InputStreamMutex * _streamData;
bool _deleteStream;
Data (int numThreads);
~Data ();
inline TileBuffer * getTileBuffer (int number);
// hash function from tile indices
// into our vector of tile buffers
};
TiledInputFile::Data::Data (int numThreads):
numXTiles (0),
numYTiles (0),
partNumber (-1),
multiPartBackwardSupport(false),
numThreads(numThreads),
memoryMapped(false),
_streamData(NULL),
_deleteStream(false)
{
//
// We need at least one tileBuffer, but if threading is used,
// to keep n threads busy we need 2*n tileBuffers
//
tileBuffers.resize (max (1, 2 * numThreads));
}
TiledInputFile::Data::~Data ()
{
delete [] numXTiles;
delete [] numYTiles;
for (size_t i = 0; i < tileBuffers.size(); i++)
delete tileBuffers[i];
if (multiPartBackwardSupport)
delete multiPartFile;
}
TileBuffer*
TiledInputFile::Data::getTileBuffer (int number)
{
return tileBuffers[number % tileBuffers.size()];
}
namespace {
void
readTileData (InputStreamMutex *streamData,
TiledInputFile::Data *ifd,
int dx, int dy,
int lx, int ly,
char *&buffer,
int &dataSize)
{
//
// Read a single tile block from the file and into the array pointed
// to by buffer. If the file is memory-mapped, then we change where
// buffer points instead of writing into the array (hence buffer needs
// to be a reference to a char *).
//
//
// Look up the location for this tile in the Index and
// seek to that position if necessary
//
Int64 tileOffset = ifd->tileOffsets (dx, dy, lx, ly);
if (tileOffset == 0)
{
THROW (IEX_NAMESPACE::InputExc, "Tile (" << dx << ", " << dy << ", " <<
lx << ", " << ly << ") is missing.");
}
//
// In a multi-part file, the next chunk does not need to
// belong to the same part, so we have to compare the
( run in 0.956 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )