PBRT
/home/felix/UBC/projects/AdaptiveLightfieldSampling/pbrt_v2/src/3rdparty/openexr-1.7.0/ImfScanLineInputFile.h
00001 
00002 //
00003 // Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
00004 // Digital Ltd. LLC
00005 // 
00006 // All rights reserved.
00007 // 
00008 // Redistribution and use in source and binary forms, with or without
00009 // modification, are permitted provided that the following conditions are
00010 // met:
00011 // *       Redistributions of source code must retain the above copyright
00012 // notice, this list of conditions and the following disclaimer.
00013 // *       Redistributions in binary form must reproduce the above
00014 // copyright notice, this list of conditions and the following disclaimer
00015 // in the documentation and/or other materials provided with the
00016 // distribution.
00017 // *       Neither the name of Industrial Light & Magic nor the names of
00018 // its contributors may be used to endorse or promote products derived
00019 // from this software without specific prior written permission. 
00020 // 
00021 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00024 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00025 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00026 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00027 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00028 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00029 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00030 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00031 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00032 //
00034 
00035 
00036 #ifndef INCLUDED_IMF_SCAN_LINE_INPUT_FILE_H
00037 #define INCLUDED_IMF_SCAN_LINE_INPUT_FILE_H
00038 
00039 //-----------------------------------------------------------------------------
00040 //
00041 //      class ScanLineInputFile
00042 //
00043 //-----------------------------------------------------------------------------
00044 
00045 #include <ImfHeader.h>
00046 #include <ImfFrameBuffer.h>
00047 #include <ImfThreading.h>
00048 
00049 namespace Imf {
00050 
00051 
00052 class ScanLineInputFile
00053 {
00054   public:
00055 
00056     //------------
00057     // Constructor
00058     //------------
00059 
00060     ScanLineInputFile (const Header &header, IStream *is,
00061                        int numThreads = globalThreadCount());
00062 
00063 
00064     //-----------------------------------------
00065     // Destructor -- deallocates internal data
00066     // structures, but does not close the file.
00067     //-----------------------------------------
00068 
00069     virtual ~ScanLineInputFile ();
00070 
00071 
00072     //------------------------
00073     // Access to the file name
00074     //------------------------
00075 
00076     const char *        fileName () const;
00077 
00078 
00079     //--------------------------
00080     // Access to the file header
00081     //--------------------------
00082 
00083     const Header &      header () const;
00084 
00085 
00086     //----------------------------------
00087     // Access to the file format version
00088     //----------------------------------
00089 
00090     int                 version () const;
00091 
00092 
00093     //-----------------------------------------------------------
00094     // Set the current frame buffer -- copies the FrameBuffer
00095     // object into the InputFile object.
00096     //
00097     // The current frame buffer is the destination for the pixel
00098     // data read from the file.  The current frame buffer must be
00099     // set at least once before readPixels() is called.
00100     // The current frame buffer can be changed after each call
00101     // to readPixels().
00102     //-----------------------------------------------------------
00103 
00104     void                setFrameBuffer (const FrameBuffer &frameBuffer);
00105 
00106 
00107     //-----------------------------------
00108     // Access to the current frame buffer
00109     //-----------------------------------
00110 
00111     const FrameBuffer & frameBuffer () const;
00112 
00113 
00114     //---------------------------------------------------------------
00115     // Check if the file is complete:
00116     //
00117     // isComplete() returns true if all pixels in the data window are
00118     // present in the input file, or false if any pixels are missing.
00119     // (Another program may still be busy writing the file, or file
00120     // writing may have been aborted prematurely.)
00121     //---------------------------------------------------------------
00122 
00123     bool                isComplete () const;
00124 
00125 
00126     //---------------------------------------------------------------
00127     // Read pixel data:
00128     //
00129     // readPixels(s1,s2) reads all scan lines with y coordinates
00130     // in the interval [min (s1, s2), max (s1, s2)] from the file,
00131     // and stores them in the current frame buffer.
00132     //
00133     // Both s1 and s2 must be within the interval
00134     // [header().dataWindow().min.y, header.dataWindow().max.y]
00135     //
00136     // The scan lines can be read from the file in random order, and
00137     // individual scan lines may be skipped or read multiple times.
00138     // For maximum efficiency, the scan lines should be read in the
00139     // order in which they were written to the file.
00140     //
00141     // readPixels(s) calls readPixels(s,s).
00142     //
00143     // If threading is enabled, readPixels (s1, s2) tries to perform
00144     // decopmression of multiple scanlines in parallel.
00145     //
00146     //---------------------------------------------------------------
00147 
00148     void                readPixels (int scanLine1, int scanLine2);
00149     void                readPixels (int scanLine);
00150 
00151 
00152     //----------------------------------------------
00153     // Read a block of raw pixel data from the file,
00154     // without uncompressing it (this function is
00155     // used to implement OutputFile::copyPixels()).
00156     //----------------------------------------------
00157 
00158     void                rawPixelData (int firstScanLine,
00159                                       const char *&pixelData,
00160                                       int &pixelDataSize);
00161 
00162     struct Data;
00163 
00164   private:
00165 
00166     Data *              _data;
00167 };
00168 
00169 
00170 } // namespace Imf
00171 
00172 #endif