Blame IlmImf/ImfScanLineInputFile.h

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