Blame IlmImf/ImfDeepScanLineOutputFile.h

Packit Service 6754ca
///////////////////////////////////////////////////////////////////////////
Packit Service 6754ca
//
Packit Service 6754ca
// Copyright (c) 2011, 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
Packit Service 6754ca
#ifndef INCLUDED_IMF_DEEP_SCAN_LINE_OUTPUT_FILE_H
Packit Service 6754ca
#define INCLUDED_IMF_DEEP_SCAN_LINE_OUTPUT_FILE_H
Packit Service 6754ca
Packit Service 6754ca
//-----------------------------------------------------------------------------
Packit Service 6754ca
//
Packit Service 6754ca
//      class DeepScanLineOutputFile
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 "ImfGenericOutputFile.h"
Packit Service 6754ca
#include "ImfNamespace.h"
Packit Service 6754ca
#include "ImfForward.h"
Packit Service 6754ca
#include "ImfExport.h"
Packit Service 6754ca
Packit Service 6754ca
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
Packit Service 6754ca
Packit Service 6754ca
Packit Service 6754ca
struct PreviewRgba;
Packit Service 6754ca
Packit Service 6754ca
class IMF_EXPORT DeepScanLineOutputFile : public GenericOutputFile
Packit Service 6754ca
{
Packit Service 6754ca
  public:
Packit Service 6754ca
Packit Service 6754ca
    //-----------------------------------------------------------
Packit Service 6754ca
    // Constructor -- opens the file and writes the file header.
Packit Service 6754ca
    // The file header is also copied into the DeepScanLineOutputFile
Packit Service 6754ca
    // object, and can later be accessed via the header() method.
Packit Service 6754ca
    // Destroying this DeepScanLineOutputFile object automatically closes
Packit Service 6754ca
    // the file.
Packit Service 6754ca
    //
Packit Service 6754ca
    // numThreads determines the number of threads that will be
Packit Service 6754ca
    // used to write the file (see ImfThreading.h).
Packit Service 6754ca
    //-----------------------------------------------------------
Packit Service 6754ca
Packit Service 6754ca
    DeepScanLineOutputFile (const char fileName[], const Header &header,
Packit Service 6754ca
                int numThreads = globalThreadCount());
Packit Service 6754ca
Packit Service 6754ca
Packit Service 6754ca
    //------------------------------------------------------------
Packit Service 6754ca
    // Constructor -- attaches the new DeepScanLineOutputFile object
Packit Service 6754ca
    // to a file that has already been opened, and writes the file header.
Packit Service 6754ca
    // The file header is also copied into the DeepScanLineOutputFile
Packit Service 6754ca
    // object, and can later be accessed via the header() method.
Packit Service 6754ca
    // Destroying this DeepScanLineOutputFile object does not automatically
Packit Service 6754ca
    // close the file.
Packit Service 6754ca
    //
Packit Service 6754ca
    // numThreads determines the number of threads that will be
Packit Service 6754ca
    // used to write the file (see ImfThreading.h).
Packit Service 6754ca
    //------------------------------------------------------------
Packit Service 6754ca
Packit Service 6754ca
    DeepScanLineOutputFile (OPENEXR_IMF_INTERNAL_NAMESPACE::OStream &os, const Header &header,
Packit Service 6754ca
                int numThreads = globalThreadCount());
Packit Service 6754ca
Packit Service 6754ca
Packit Service 6754ca
    //-------------------------------------------------
Packit Service 6754ca
    // Destructor
Packit Service 6754ca
    //
Packit Service 6754ca
    // Destroying the DeepScanLineOutputFile object
Packit Service 6754ca
    // before writing all scan lines within the data
Packit Service 6754ca
    // window results in an incomplete file.
Packit Service 6754ca
    //-------------------------------------------------
Packit Service 6754ca
Packit Service 6754ca
    virtual ~DeepScanLineOutputFile ();
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
    // Set the current frame buffer -- copies the FrameBuffer
Packit Service 6754ca
    // object into the OutputFile object.
Packit Service 6754ca
    //
Packit Service 6754ca
    // The current frame buffer is the source of the pixel
Packit Service 6754ca
    // data written to the file.  The current frame buffer
Packit Service 6754ca
    // must be set at least once before writePixels() is
Packit Service 6754ca
    // called.  The current frame buffer can be changed
Packit Service 6754ca
    // after each call to writePixels.
Packit Service 6754ca
    //-------------------------------------------------------
Packit Service 6754ca
Packit Service 6754ca
    void                setFrameBuffer (const DeepFrameBuffer &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 DeepFrameBuffer & frameBuffer () const;
Packit Service 6754ca
Packit Service 6754ca
Packit Service 6754ca
    //-------------------------------------------------------------------
Packit Service 6754ca
    // Write pixel data:
Packit Service 6754ca
    //
Packit Service 6754ca
    // writePixels(n) retrieves the next n scan lines worth of data from
Packit Service 6754ca
    // the current frame buffer, starting with the scan line indicated by
Packit Service 6754ca
    // currentScanLine(), and stores the data in the output file, and
Packit Service 6754ca
    // progressing in the direction indicated by header.lineOrder().
Packit Service 6754ca
    //
Packit Service 6754ca
    // To produce a complete and correct file, exactly m scan lines must
Packit Service 6754ca
    // be written, where m is equal to
Packit Service 6754ca
    // header().dataWindow().max.y - header().dataWindow().min.y + 1.
Packit Service 6754ca
    //-------------------------------------------------------------------
Packit Service 6754ca
Packit Service 6754ca
    void                writePixels (int numScanLines = 1);
Packit Service 6754ca
Packit Service 6754ca
Packit Service 6754ca
    //------------------------------------------------------------------
Packit Service 6754ca
    // Access to the current scan line:
Packit Service 6754ca
    //
Packit Service 6754ca
    // currentScanLine() returns the y coordinate of the first scan line
Packit Service 6754ca
    // that will be read from the current frame buffer during the next
Packit Service 6754ca
    // call to writePixels().
Packit Service 6754ca
    //
Packit Service 6754ca
    // If header.lineOrder() == INCREASING_Y:
Packit Service 6754ca
    //
Packit Service 6754ca
    //  The current scan line before the first call to writePixels()
Packit Service 6754ca
    //  is header().dataWindow().min.y.  After writing each scan line,
Packit Service 6754ca
    //  the current scan line is incremented by 1.
Packit Service 6754ca
    //
Packit Service 6754ca
    // If header.lineOrder() == DECREASING_Y:
Packit Service 6754ca
    //
Packit Service 6754ca
    //  The current scan line before the first call to writePixels()
Packit Service 6754ca
    //  is header().dataWindow().max.y.  After writing each scan line,
Packit Service 6754ca
    //  the current scan line is decremented by 1.
Packit Service 6754ca
    //
Packit Service 6754ca
    //------------------------------------------------------------------
Packit Service 6754ca
Packit Service 6754ca
    int                 currentScanLine () const;
Packit Service 6754ca
Packit Service 6754ca
Packit Service 6754ca
    //--------------------------------------------------------------
Packit Service 6754ca
    // Shortcut to copy all pixels from an InputFile into this file,
Packit Service 6754ca
    // without uncompressing and then recompressing the pixel data.
Packit Service 6754ca
    // This file's header must be compatible with the InputFile's
Packit Service 6754ca
    // header:  The two header's "dataWindow", "compression",
Packit Service 6754ca
    // "lineOrder" and "channels" attributes must be the same.
Packit Service 6754ca
    //--------------------------------------------------------------
Packit Service 6754ca
Packit Service 6754ca
    void                copyPixels (DeepScanLineInputFile &in);
Packit Service 6754ca
    
Packit Service 6754ca
    // --------------------------------------------------------------
Packit Service 6754ca
    // Shortcut to copy pixels from a given part of a multipart file
Packit Service 6754ca
    // --------------------------------------------------------------
Packit Service 6754ca
    void                copyPixels (DeepScanLineInputPart &in);
Packit Service 6754ca
Packit Service 6754ca
Packit Service 6754ca
    //--------------------------------------------------------------
Packit Service 6754ca
    // Updating the preview image:
Packit Service 6754ca
    //
Packit Service 6754ca
    // updatePreviewImage() supplies a new set of pixels for the
Packit Service 6754ca
    // preview image attribute in the file's header.  If the header
Packit Service 6754ca
    // does not contain a preview image, updatePreviewImage() throws
Packit Service 6754ca
    // an IEX_NAMESPACE::LogicExc.
Packit Service 6754ca
    //
Packit Service 6754ca
    // Note: updatePreviewImage() is necessary because images are
Packit Service 6754ca
    // often stored in a file incrementally, a few scan lines at a
Packit Service 6754ca
    // time, while the image is being generated.  Since the preview
Packit Service 6754ca
    // image is an attribute in the file's header, it gets stored in
Packit Service 6754ca
    // the file as soon as the file is opened, but we may not know
Packit Service 6754ca
    // what the preview image should look like until we have written
Packit Service 6754ca
    // the last scan line of the main image.
Packit Service 6754ca
    //
Packit Service 6754ca
    //--------------------------------------------------------------
Packit Service 6754ca
Packit Service 6754ca
    void                updatePreviewImage (const PreviewRgba newPixels[]);
Packit Service 6754ca
Packit Service 6754ca
Packit Service 6754ca
    struct Data;
Packit Service 6754ca
Packit Service 6754ca
  private:
Packit Service 6754ca
Packit Service 6754ca
    //------------------------------------------------------------
Packit Service 6754ca
    // Constructor -- attaches the OutputStreamMutex to the
Packit Service 6754ca
    // given one from MultiPartOutputFile. Set the previewPosition
Packit Service 6754ca
    // and lineOffsetsPosition which have been acquired from
Packit Service 6754ca
    // the constructor of MultiPartOutputFile as well.
Packit Service 6754ca
    //------------------------------------------------------------
Packit Service 6754ca
    DeepScanLineOutputFile (const OutputPartData* part);
Packit Service 6754ca
Packit Service 6754ca
    DeepScanLineOutputFile (const DeepScanLineOutputFile &);                    // not implemented
Packit Service 6754ca
    DeepScanLineOutputFile & operator = (const DeepScanLineOutputFile &);       // not implemented
Packit Service 6754ca
Packit Service 6754ca
    void                initialize (const Header &header);
Packit Service 6754ca
    void                initializeLineBuffer();
Packit Service 6754ca
Packit Service 6754ca
    Data *              _data;
Packit Service 6754ca
Packit Service 6754ca
Packit Service 6754ca
Packit Service 6754ca
    friend class MultiPartOutputFile;
Packit Service 6754ca
};
Packit Service 6754ca
Packit Service 6754ca
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
Packit Service 6754ca
Packit Service 6754ca
#endif