|
Packit |
0d464f |
///////////////////////////////////////////////////////////////////////////
|
|
Packit |
0d464f |
//
|
|
Packit |
0d464f |
// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
|
|
Packit |
0d464f |
// Digital Ltd. LLC
|
|
Packit |
0d464f |
//
|
|
Packit |
0d464f |
// All rights reserved.
|
|
Packit |
0d464f |
//
|
|
Packit |
0d464f |
// Redistribution and use in source and binary forms, with or without
|
|
Packit |
0d464f |
// modification, are permitted provided that the following conditions are
|
|
Packit |
0d464f |
// met:
|
|
Packit |
0d464f |
// * Redistributions of source code must retain the above copyright
|
|
Packit |
0d464f |
// notice, this list of conditions and the following disclaimer.
|
|
Packit |
0d464f |
// * Redistributions in binary form must reproduce the above
|
|
Packit |
0d464f |
// copyright notice, this list of conditions and the following disclaimer
|
|
Packit |
0d464f |
// in the documentation and/or other materials provided with the
|
|
Packit |
0d464f |
// distribution.
|
|
Packit |
0d464f |
// * Neither the name of Industrial Light & Magic nor the names of
|
|
Packit |
0d464f |
// its contributors may be used to endorse or promote products derived
|
|
Packit |
0d464f |
// from this software without specific prior written permission.
|
|
Packit |
0d464f |
//
|
|
Packit |
0d464f |
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
Packit |
0d464f |
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
Packit |
0d464f |
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
Packit |
0d464f |
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
Packit |
0d464f |
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
Packit |
0d464f |
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
Packit |
0d464f |
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
Packit |
0d464f |
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
Packit |
0d464f |
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
Packit |
0d464f |
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
Packit |
0d464f |
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
Packit |
0d464f |
//
|
|
Packit |
0d464f |
///////////////////////////////////////////////////////////////////////////
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
#ifndef INCLUDED_IMF_INPUT_FILE_H
|
|
Packit |
0d464f |
#define INCLUDED_IMF_INPUT_FILE_H
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
//-----------------------------------------------------------------------------
|
|
Packit |
0d464f |
//
|
|
Packit |
0d464f |
// class InputFile -- a scanline-based interface that can be used
|
|
Packit |
0d464f |
// to read both scanline-based and tiled OpenEXR image files.
|
|
Packit |
0d464f |
//
|
|
Packit |
0d464f |
//-----------------------------------------------------------------------------
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
#include "ImfHeader.h"
|
|
Packit |
0d464f |
#include "ImfFrameBuffer.h"
|
|
Packit |
0d464f |
#include "ImfTiledOutputFile.h"
|
|
Packit |
0d464f |
#include "ImfThreading.h"
|
|
Packit |
0d464f |
#include "ImfGenericInputFile.h"
|
|
Packit |
0d464f |
#include "ImfNamespace.h"
|
|
Packit |
0d464f |
#include "ImfForward.h"
|
|
Packit |
0d464f |
#include "ImfExport.h"
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
#include <fstream>
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
class IMF_EXPORT InputFile : public GenericInputFile
|
|
Packit |
0d464f |
{
|
|
Packit |
0d464f |
public:
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
//-----------------------------------------------------------
|
|
Packit |
0d464f |
// A constructor that opens the file with the specified name.
|
|
Packit |
0d464f |
// Destroying the InputFile object will close the file.
|
|
Packit |
0d464f |
//
|
|
Packit |
0d464f |
// numThreads determines the number of threads that will be
|
|
Packit |
0d464f |
// used to read the file (see ImfThreading.h).
|
|
Packit |
0d464f |
//-----------------------------------------------------------
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
InputFile (const char fileName[], int numThreads = globalThreadCount());
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
//-------------------------------------------------------------
|
|
Packit |
0d464f |
// A constructor that attaches the new InputFile object to a
|
|
Packit |
0d464f |
// file that has already been opened. Destroying the InputFile
|
|
Packit |
0d464f |
// object will not close the file.
|
|
Packit |
0d464f |
//
|
|
Packit |
0d464f |
// numThreads determines the number of threads that will be
|
|
Packit |
0d464f |
// used to read the file (see ImfThreading.h).
|
|
Packit |
0d464f |
//-------------------------------------------------------------
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
InputFile (OPENEXR_IMF_INTERNAL_NAMESPACE::IStream &is, int numThreads = globalThreadCount());
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
//-----------
|
|
Packit |
0d464f |
// Destructor
|
|
Packit |
0d464f |
//-----------
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
virtual ~InputFile ();
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
//------------------------
|
|
Packit |
0d464f |
// Access to the file name
|
|
Packit |
0d464f |
//------------------------
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
const char * fileName () const;
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
//--------------------------
|
|
Packit |
0d464f |
// Access to the file header
|
|
Packit |
0d464f |
//--------------------------
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
const Header & header () const;
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
//----------------------------------
|
|
Packit |
0d464f |
// Access to the file format version
|
|
Packit |
0d464f |
//----------------------------------
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
int version () const;
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
//-----------------------------------------------------------
|
|
Packit |
0d464f |
// Set the current frame buffer -- copies the FrameBuffer
|
|
Packit |
0d464f |
// object into the InputFile object.
|
|
Packit |
0d464f |
//
|
|
Packit |
0d464f |
// The current frame buffer is the destination for the pixel
|
|
Packit |
0d464f |
// data read from the file. The current frame buffer must be
|
|
Packit |
0d464f |
// set at least once before readPixels() is called.
|
|
Packit |
0d464f |
// The current frame buffer can be changed after each call
|
|
Packit |
0d464f |
// to readPixels().
|
|
Packit |
0d464f |
//-----------------------------------------------------------
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
void setFrameBuffer (const FrameBuffer &frameBuffer);
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
//-----------------------------------
|
|
Packit |
0d464f |
// Access to the current frame buffer
|
|
Packit |
0d464f |
//-----------------------------------
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
const FrameBuffer & frameBuffer () const;
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
//---------------------------------------------------------------
|
|
Packit |
0d464f |
// Check if the file is complete:
|
|
Packit |
0d464f |
//
|
|
Packit |
0d464f |
// isComplete() returns true if all pixels in the data window are
|
|
Packit |
0d464f |
// present in the input file, or false if any pixels are missing.
|
|
Packit |
0d464f |
// (Another program may still be busy writing the file, or file
|
|
Packit |
0d464f |
// writing may have been aborted prematurely.)
|
|
Packit |
0d464f |
//---------------------------------------------------------------
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
bool isComplete () const;
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
//---------------------------------------------------------------
|
|
Packit |
0d464f |
// Check if SSE optimization is enabled
|
|
Packit |
0d464f |
//
|
|
Packit |
0d464f |
// Call after setFrameBuffer() to query whether optimized file decoding
|
|
Packit |
0d464f |
// is available - decode times will be faster if returns true
|
|
Packit |
0d464f |
//
|
|
Packit |
0d464f |
// Optimization depends on:
|
|
Packit |
0d464f |
// the file type (only scanline data is supported),
|
|
Packit |
0d464f |
// the framebuffer channels (RGB/RGBA mono or stereo)
|
|
Packit |
0d464f |
// the framebuffer channel types (all channels half-float format only)
|
|
Packit |
0d464f |
// the file channels (RGB/RGBA mono or stereo)
|
|
Packit |
0d464f |
// the file channel types (all channel half-float format only)
|
|
Packit |
0d464f |
// whether SSE2 instruction support was detected at compile time
|
|
Packit |
0d464f |
//
|
|
Packit |
0d464f |
// Calling isOptimizationEnabled before setFrameBuffer will throw an exception
|
|
Packit |
0d464f |
//
|
|
Packit |
0d464f |
//---------------------------------------------------------------
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
bool isOptimizationEnabled () const;
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
//---------------------------------------------------------------
|
|
Packit |
0d464f |
// Read pixel data:
|
|
Packit |
0d464f |
//
|
|
Packit |
0d464f |
// readPixels(s1,s2) reads all scan lines with y coordinates
|
|
Packit |
0d464f |
// in the interval [min (s1, s2), max (s1, s2)] from the file,
|
|
Packit |
0d464f |
// and stores them in the current frame buffer.
|
|
Packit |
0d464f |
//
|
|
Packit |
0d464f |
// Both s1 and s2 must be within the interval
|
|
Packit |
0d464f |
// [header().dataWindow().min.y, header().dataWindow().max.y]
|
|
Packit |
0d464f |
//
|
|
Packit |
0d464f |
// The scan lines can be read from the file in random order, and
|
|
Packit |
0d464f |
// individual scan lines may be skipped or read multiple times.
|
|
Packit |
0d464f |
// For maximum efficiency, the scan lines should be read in the
|
|
Packit |
0d464f |
// order in which they were written to the file.
|
|
Packit |
0d464f |
//
|
|
Packit |
0d464f |
// readPixels(s) calls readPixels(s,s).
|
|
Packit |
0d464f |
//
|
|
Packit |
0d464f |
//---------------------------------------------------------------
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
void readPixels (int scanLine1, int scanLine2);
|
|
Packit |
0d464f |
void readPixels (int scanLine);
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
//----------------------------------------------
|
|
Packit |
0d464f |
// Read a block of raw pixel data from the file,
|
|
Packit |
0d464f |
// without uncompressing it (this function is
|
|
Packit |
0d464f |
// used to implement OutputFile::copyPixels()).
|
|
Packit |
0d464f |
//----------------------------------------------
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
void rawPixelData (int firstScanLine,
|
|
Packit |
0d464f |
const char *&pixelData,
|
|
Packit |
0d464f |
int &pixelDataSize);
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
//--------------------------------------------------
|
|
Packit |
0d464f |
// Read a tile of raw pixel data from the file,
|
|
Packit |
0d464f |
// without uncompressing it (this function is
|
|
Packit |
0d464f |
// used to implement TiledOutputFile::copyPixels()).
|
|
Packit |
0d464f |
//--------------------------------------------------
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
void rawTileData (int &dx, int &dy,
|
|
Packit |
0d464f |
int &lx, int &ly,
|
|
Packit |
0d464f |
const char *&pixelData,
|
|
Packit |
0d464f |
int &pixelDataSize);
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
struct Data;
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
private:
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
InputFile (InputPartData* part);
|
|
Packit |
0d464f |
InputFile (const InputFile &); // not implemented
|
|
Packit |
0d464f |
InputFile & operator = (const InputFile &); // not implemented
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
void initialize ();
|
|
Packit |
0d464f |
void multiPartInitialize(InputPartData* part);
|
|
Packit |
0d464f |
void compatibilityInitialize(OPENEXR_IMF_INTERNAL_NAMESPACE::IStream& is);
|
|
Packit |
0d464f |
TiledInputFile * tFile ();
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
friend void TiledOutputFile::copyPixels (InputFile &);
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
Data * _data;
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
friend class MultiPartInputFile;
|
|
Packit |
0d464f |
};
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
#endif
|