Home | History | Annotate | Download | only in IlmImf
      1 ///////////////////////////////////////////////////////////////////////////
      2 //
      3 // Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
      4 // Digital Ltd. LLC
      5 //
      6 // All rights reserved.
      7 //
      8 // Redistribution and use in source and binary forms, with or without
      9 // modification, are permitted provided that the following conditions are
     10 // met:
     11 // *       Redistributions of source code must retain the above copyright
     12 // notice, this list of conditions and the following disclaimer.
     13 // *       Redistributions in binary form must reproduce the above
     14 // copyright notice, this list of conditions and the following disclaimer
     15 // in the documentation and/or other materials provided with the
     16 // distribution.
     17 // *       Neither the name of Industrial Light & Magic nor the names of
     18 // its contributors may be used to endorse or promote products derived
     19 // from this software without specific prior written permission.
     20 //
     21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     22 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     23 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     24 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     25 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     26 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     27 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     28 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     29 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     30 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     31 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     32 //
     33 ///////////////////////////////////////////////////////////////////////////
     34 
     35 
     36 #ifndef INCLUDED_IMF_SCAN_LINE_INPUT_FILE_H
     37 #define INCLUDED_IMF_SCAN_LINE_INPUT_FILE_H
     38 
     39 //-----------------------------------------------------------------------------
     40 //
     41 //	class ScanLineInputFile
     42 //
     43 //-----------------------------------------------------------------------------
     44 
     45 #include <ImfHeader.h>
     46 #include <ImfFrameBuffer.h>
     47 #include <ImfThreading.h>
     48 
     49 namespace Imf {
     50 
     51 
     52 class ScanLineInputFile
     53 {
     54   public:
     55 
     56     //------------
     57     // Constructor
     58     //------------
     59 
     60     ScanLineInputFile (const Header &header, IStream *is,
     61                        int numThreads = globalThreadCount());
     62 
     63 
     64     //-----------------------------------------
     65     // Destructor -- deallocates internal data
     66     // structures, but does not close the file.
     67     //-----------------------------------------
     68 
     69     virtual ~ScanLineInputFile ();
     70 
     71 
     72     //------------------------
     73     // Access to the file name
     74     //------------------------
     75 
     76     const char *	fileName () const;
     77 
     78 
     79     //--------------------------
     80     // Access to the file header
     81     //--------------------------
     82 
     83     const Header &	header () const;
     84 
     85 
     86     //----------------------------------
     87     // Access to the file format version
     88     //----------------------------------
     89 
     90     int			version () const;
     91 
     92 
     93     //-----------------------------------------------------------
     94     // Set the current frame buffer -- copies the FrameBuffer
     95     // object into the InputFile object.
     96     //
     97     // The current frame buffer is the destination for the pixel
     98     // data read from the file.  The current frame buffer must be
     99     // set at least once before readPixels() is called.
    100     // The current frame buffer can be changed after each call
    101     // to readPixels().
    102     //-----------------------------------------------------------
    103 
    104     void		setFrameBuffer (const FrameBuffer &frameBuffer);
    105 
    106 
    107     //-----------------------------------
    108     // Access to the current frame buffer
    109     //-----------------------------------
    110 
    111     const FrameBuffer &	frameBuffer () const;
    112 
    113 
    114     //---------------------------------------------------------------
    115     // Check if the file is complete:
    116     //
    117     // isComplete() returns true if all pixels in the data window are
    118     // present in the input file, or false if any pixels are missing.
    119     // (Another program may still be busy writing the file, or file
    120     // writing may have been aborted prematurely.)
    121     //---------------------------------------------------------------
    122 
    123     bool		isComplete () const;
    124 
    125 
    126     //---------------------------------------------------------------
    127     // Read pixel data:
    128     //
    129     // readPixels(s1,s2) reads all scan lines with y coordinates
    130     // in the interval [min (s1, s2), max (s1, s2)] from the file,
    131     // and stores them in the current frame buffer.
    132     //
    133     // Both s1 and s2 must be within the interval
    134     // [header().dataWindow().min.y, header.dataWindow().max.y]
    135     //
    136     // The scan lines can be read from the file in random order, and
    137     // individual scan lines may be skipped or read multiple times.
    138     // For maximum efficiency, the scan lines should be read in the
    139     // order in which they were written to the file.
    140     //
    141     // readPixels(s) calls readPixels(s,s).
    142     //
    143     // If threading is enabled, readPixels (s1, s2) tries to perform
    144     // decopmression of multiple scanlines in parallel.
    145     //
    146     //---------------------------------------------------------------
    147 
    148     void		readPixels (int scanLine1, int scanLine2);
    149     void		readPixels (int scanLine);
    150 
    151 
    152     //----------------------------------------------
    153     // Read a block of raw pixel data from the file,
    154     // without uncompressing it (this function is
    155     // used to implement OutputFile::copyPixels()).
    156     //----------------------------------------------
    157 
    158     void		rawPixelData (int firstScanLine,
    159                       const char *&pixelData,
    160                       int &pixelDataSize);
    161 
    162     struct Data;
    163 
    164   private:
    165 
    166     Data *		_data;
    167 };
    168 
    169 
    170 } // namespace Imf
    171 
    172 #endif
    173