Blame IlmImf/ImfScanLineInputFile.h

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_SCAN_LINE_INPUT_FILE_H
Packit 0d464f
#define INCLUDED_IMF_SCAN_LINE_INPUT_FILE_H
Packit 0d464f
Packit 0d464f
//-----------------------------------------------------------------------------
Packit 0d464f
//
Packit 0d464f
//	class ScanLineInputFile
Packit 0d464f
//
Packit 0d464f
//-----------------------------------------------------------------------------
Packit 0d464f
Packit 0d464f
#include "ImfHeader.h"
Packit 0d464f
#include "ImfFrameBuffer.h"
Packit 0d464f
#include "ImfThreading.h"
Packit 0d464f
#include "ImfInputStreamMutex.h"
Packit 0d464f
#include "ImfInputPartData.h"
Packit 0d464f
#include "ImfGenericInputFile.h"
Packit 0d464f
#include "ImfExport.h"
Packit 0d464f
#include "ImfNamespace.h"
Packit 0d464f
Packit 0d464f
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
Packit 0d464f
Packit 0d464f
Packit 0d464f
class IMF_EXPORT ScanLineInputFile : public GenericInputFile
Packit 0d464f
{
Packit 0d464f
  public:
Packit 0d464f
Packit 0d464f
    //------------
Packit 0d464f
    // Constructor
Packit 0d464f
    //------------
Packit 0d464f
Packit 0d464f
    ScanLineInputFile (const Header &header, OPENEXR_IMF_INTERNAL_NAMESPACE::IStream *is,
Packit 0d464f
                       int numThreads = globalThreadCount());
Packit 0d464f
Packit 0d464f
Packit 0d464f
    //-----------------------------------------
Packit 0d464f
    // Destructor -- deallocates internal data
Packit 0d464f
    // structures, but does not close the file.
Packit 0d464f
    //-----------------------------------------
Packit 0d464f
Packit 0d464f
    virtual ~ScanLineInputFile ();
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
    //---------------------------------------------------------------
Packit 0d464f
    // Check if SSE optimisation is enabled
Packit 0d464f
    //
Packit 0d464f
    // Call after setFrameBuffer() to query whether optimised file decoding
Packit 0d464f
    // is available - decode times will be faster if returns true
Packit 0d464f
    //
Packit 0d464f
    // Optimisation depends on the framebuffer channels and channel types
Packit 0d464f
    // as well as the file/part channels and channel types, as well as
Packit 0d464f
    // whether SSE2 instruction support was detected at compile time
Packit 0d464f
    //
Packit 0d464f
    // Calling 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
    // If threading is enabled, readPixels (s1, s2) tries to perform
Packit 0d464f
    // decopmression of multiple scanlines in parallel.
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
    struct Data;
Packit 0d464f
Packit 0d464f
  private:
Packit 0d464f
Packit 0d464f
    Data *		_data;
Packit 0d464f
Packit 0d464f
    InputStreamMutex*   _streamData;
Packit 0d464f
Packit 0d464f
    ScanLineInputFile   (InputPartData* part);
Packit 0d464f
Packit 0d464f
    void                initialize(const Header& header);
Packit 0d464f
Packit 0d464f
    friend class MultiPartInputFile;
Packit 0d464f
    friend class InputFile;
Packit 0d464f
};
Packit 0d464f
Packit 0d464f
Packit 0d464f
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
Packit 0d464f
Packit 0d464f
Packit 0d464f
Packit 0d464f
Packit 0d464f
Packit 0d464f
#endif