Blame IlmImf/ImfDeepCompositing.h

Packit 0d464f
///////////////////////////////////////////////////////////////////////////
Packit 0d464f
//
Packit 0d464f
// Copyright (c) 2012, Weta Digital Ltd
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 Weta Digital 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_DEEPCOMPOSITING_H
Packit 0d464f
#define INCLUDED_IMF_DEEPCOMPOSITING_H
Packit 0d464f
Packit 0d464f
//-----------------------------------------------------------------------------
Packit 0d464f
//
Packit 0d464f
//	Class to sort and composite deep samples into a frame buffer
Packit 0d464f
//      You may derive from this class to change the way that CompositeDeepScanLine
Packit 0d464f
//      and CompositeDeepTile combine samples together - pass an instance of your derived
Packit 0d464f
//      class to the compositing engine
Packit 0d464f
//
Packit 0d464f
//-----------------------------------------------------------------------------
Packit 0d464f
Packit 0d464f
#include "ImfForward.h"
Packit 0d464f
#include "ImfNamespace.h"
Packit 0d464f
#include "ImfExport.h"
Packit 0d464f
Packit 0d464f
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
Packit 0d464f
Packit 0d464f
class IMF_EXPORT DeepCompositing
Packit 0d464f
{
Packit 0d464f
    public:
Packit 0d464f
        DeepCompositing();
Packit 0d464f
        virtual ~DeepCompositing();
Packit 0d464f
        
Packit 0d464f
        
Packit 0d464f
        //////////////////////////////////////////////
Packit 0d464f
        ///
Packit 0d464f
        /// composite together the given channels
Packit 0d464f
        /// 
Packit 0d464f
        ///  @param outputs       - return array of pixel values - 
Packit 0d464f
        ///  @param inputs        - arrays of input sample
Packit 0d464f
        ///  @param channel_names - array of channel names for corresponding channels
Packit 0d464f
        ///  @param num_channels  - number of active channels (3 or greater)    
Packit 0d464f
        ///  @param num_samples   - number of values in all input arrays
Packit 0d464f
        ///  @param sources       - number of different sources
Packit 0d464f
        ///
Packit 0d464f
        /// each array input has num_channels entries: outputs[n] should be the composited
Packit 0d464f
        /// values in array inputs[n], whose name will be given by channel_names[n]
Packit 0d464f
        /// 
Packit 0d464f
        /// The channel ordering shall be as follows:
Packit 0d464f
        /// Position Channel
Packit 0d464f
        ///    0     Z
Packit 0d464f
        ///    1     ZBack (if no ZBack, then inputs[1]==inputs[0] and channel_names[1]==channel_names[0])
Packit 0d464f
        ///    2     A (alpha channel)
Packit 0d464f
        ///    3-n   other channels - only channels in the frame buffer will appear here
Packit 0d464f
        ///
Packit 0d464f
        /// since a Z and Alpha channel is required, and channel[1] is ZBack or another copy of Z
Packit 0d464f
        /// there will always be 3 or more channels.
Packit 0d464f
        ///
Packit 0d464f
        /// The default implementation calls sort() if and only if more than one source is active,
Packit 0d464f
        /// composites all samples together using the Over operator from front to back,
Packit 0d464f
        /// stopping as soon as a sample with alpha=1 is found
Packit 0d464f
        /// It also blanks all outputs if num_samples==0
Packit 0d464f
        ///
Packit 0d464f
        /// note - multiple threads may call composite_pixel simultaneously for different pixels
Packit 0d464f
        ///
Packit 0d464f
        ///
Packit 0d464f
        //////////////////////////////////////////////
Packit 0d464f
        virtual void composite_pixel(float outputs[],
Packit 0d464f
                                     const float * inputs[],
Packit 0d464f
                                     const char * channel_names[],
Packit 0d464f
                                     int num_channels,
Packit 0d464f
                                     int num_samples,
Packit 0d464f
                                     int sources
Packit 0d464f
                                     );
Packit 0d464f
                                     
Packit 0d464f
        
Packit 0d464f
       
Packit 0d464f
       ////////////////////////////////////////////////////////////////
Packit 0d464f
       ///
Packit 0d464f
       /// find the depth order for samples with given channel values
Packit 0d464f
       /// does not sort the values in-place. Instead it populates
Packit 0d464f
       /// array 'order' with the desired sorting order
Packit 0d464f
       ///
Packit 0d464f
       /// the default operation sorts samples from front to back according to their Z channel
Packit 0d464f
       ///
Packit 0d464f
       /// @param order         - required output order. order[n] shall be the nth closest sample
Packit 0d464f
       /// @param inputs        - arrays of input samples, one array per channel_name
Packit 0d464f
       /// @param channel_names - array of channel names for corresponding channels
Packit 0d464f
       /// @param num_channels  - number of channels (3 or greater)  
Packit 0d464f
       /// @param num_samples   - number of samples in each array
Packit 0d464f
       /// @param sources       - number of different sources the data arises from
Packit 0d464f
       ///
Packit 0d464f
       /// the channel layout is identical to composite_pixel() 
Packit 0d464f
       ///
Packit 0d464f
       ///////////////////////////////////////////////////////////////
Packit 0d464f
                                     
Packit 0d464f
       virtual void sort(int order[],
Packit 0d464f
                         const float * inputs[],
Packit 0d464f
                         const char * channel_names[],
Packit 0d464f
                         int num_channels,
Packit 0d464f
                         int num_samples,
Packit 0d464f
                         int sources);
Packit 0d464f
};
Packit 0d464f
Packit 0d464f
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
Packit 0d464f
Packit 0d464f
#endif