PageRenderTime 22ms CodeModel.GetById 11ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 1ms

/src/core/Lut1DOp.h

http://github.com/imageworks/OpenColorIO
C++ Header | 107 lines | 43 code | 21 blank | 43 comment | 0 complexity | ccde4dd2090df4e1b2d35334ad695973 MD5 | raw file
  1/*
  2Copyright (c) 2003-2010 Sony Pictures Imageworks Inc., et al.
  3All Rights Reserved.
  4
  5Redistribution and use in source and binary forms, with or without
  6modification, are permitted provided that the following conditions are
  7met:
  8* Redistributions of source code must retain the above copyright
  9  notice, this list of conditions and the following disclaimer.
 10* Redistributions in binary form must reproduce the above copyright
 11  notice, this list of conditions and the following disclaimer in the
 12  documentation and/or other materials provided with the distribution.
 13* Neither the name of Sony Pictures Imageworks nor the names of its
 14  contributors may be used to endorse or promote products derived from
 15  this software without specific prior written permission.
 16THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 17"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 18LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 19A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 20OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 21SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 22LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 23DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 24THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 25(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 26OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 27*/
 28
 29
 30#ifndef INCLUDED_OCIO_LUT1DOP_H
 31#define INCLUDED_OCIO_LUT1DOP_H
 32
 33#include <OpenColorIO/OpenColorIO.h>
 34
 35#include "Mutex.h"
 36#include "Op.h"
 37
 38#include <vector>
 39
 40OCIO_NAMESPACE_ENTER
 41{
 42    // TODO: turn into a class instead of a struct?
 43    
 44    enum ErrorType
 45    {
 46        ERROR_ABSOLUTE = 1,
 47        ERROR_RELATIVE
 48    };
 49    
 50    
 51    struct Lut1D;
 52    typedef OCIO_SHARED_PTR<Lut1D> Lut1DRcPtr;
 53    
 54    struct Lut1D
 55    {
 56        static Lut1DRcPtr Create();
 57        
 58        // This will compute the cacheid, and also
 59        // determine if the lut is a no-op.
 60        // If this lut is being read in from float ASCII text
 61        // a value of 1e-5 is preferable.
 62        // If this lut is being read in from integer ASCII
 63        // representation, the value will depend on the LSB
 64        // at the specified integer precision.
 65        // Example: reading 10-bit ints? Use 2/1023.0
 66        // If you dont want to do the noop computation,
 67        // specify a 0.0 tolerance.
 68        //
 69        // TODO: Instead of having each user compute the error
 70        // individually, maybe they should specify the original file bitdepth?
 71        // (with appropriate precision tokens?)
 72        float maxerror;
 73        ErrorType errortype;
 74        
 75        float from_min[3];
 76        float from_max[3];
 77        
 78        typedef std::vector<float> fv_t;
 79        fv_t luts[3];
 80        
 81        std::string getCacheID() const;
 82        bool isNoOp() const;
 83        
 84        void unfinalize();
 85    private:
 86        Lut1D();
 87        
 88        mutable std::string m_cacheID;
 89        mutable bool m_isNoOp;
 90        mutable Mutex m_mutex;
 91        
 92        void finalize() const;
 93    };
 94    
 95    typedef OCIO_SHARED_PTR<Lut1D> Lut1DRcPtr;
 96    
 97    // This generates an identity 1d lut, from 0.0 to 1.0
 98    void GenerateIdentityLut1D(float* img, int numElements, int numChannels);
 99    
100    void CreateLut1DOp(OpRcPtrVec & ops,
101                       const Lut1DRcPtr & lut,
102                       Interpolation interpolation,
103                       TransformDirection direction);
104}
105OCIO_NAMESPACE_EXIT
106
107#endif