TuttleOFX
1
|
00001 /* 00002 * Software License : 00003 * 00004 * Copyright (c) 2007-2009, The Open Effects Association Ltd. All Rights Reserved. 00005 * 00006 * Redistribution and use in source and binary forms, with or without 00007 * modification, are permitted provided that the following conditions are met: 00008 * 00009 * Redistributions of source code must retain the above copyright notice, 00010 * this list of conditions and the following disclaimer. 00011 * Redistributions in binary form must reproduce the above copyright notice, 00012 * this list of conditions and the following disclaimer in the documentation 00013 * and/or other materials provided with the distribution. 00014 * Neither the name The Open Effects Association Ltd, nor the names of its 00015 * contributors may be used to endorse or promote products derived from this 00016 * software without specific prior written permission. 00017 * 00018 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 00019 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00020 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00021 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 00022 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00023 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00024 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 00025 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00026 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00027 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00028 */ 00029 00030 #ifndef _TUTTLE_HOST_OFX_IMAGE_HPP_ 00031 #define _TUTTLE_HOST_OFX_IMAGE_HPP_ 00032 00033 #include "OfxhUtilities.hpp" 00034 #include "attribute/OfxhClip.hpp" 00035 #include "property/OfxhSet.hpp" 00036 00037 #include <tuttle/common/ofx/imageEffect.hpp> 00038 00039 #include <ofxImageEffect.h> 00040 00041 namespace tuttle { 00042 namespace host { 00043 namespace ofx { 00044 namespace imageEffect { 00045 00046 using namespace ::tuttle::ofx::imageEffect; 00047 00048 // forward declarations 00049 class OfxhImage; 00050 class OfxhImageEffectNode; 00051 00052 /** 00053 * instance of an image inside an image effect 00054 */ 00055 class OfxhImage : public property::OfxhSet 00056 { 00057 public: 00058 enum EReferenceOwner 00059 { 00060 eReferenceOwnerHost, 00061 eReferenceOwnerPlugin 00062 }; 00063 00064 protected: 00065 /// called during ctors to get bits from the clip props into ours 00066 void initClipBits( attribute::OfxhClip& instance ); 00067 static std::ptrdiff_t _count; ///< temp.... for check 00068 std::ptrdiff_t _id; ///< temp.... for check 00069 typedef std::map<EReferenceOwner, std::ptrdiff_t> RefMap; 00070 RefMap _referenceCount; ///< reference count on this image 00071 std::string _clipName; ///< for debug 00072 OfxTime _time; ///< for debug 00073 00074 public: 00075 // default constructor 00076 virtual ~OfxhImage(); 00077 00078 /// basic ctor, makes empty property set but sets not value 00079 OfxhImage(); 00080 00081 /// construct from a clip instance, but leave the 00082 /// filling it to the calling code via the propery set 00083 explicit OfxhImage( attribute::OfxhClip& instance, const OfxTime time ); 00084 00085 // Render Scale (renderScaleX,renderScaleY) - 00086 // 00087 // The proxy render scale currently being applied. 00088 // ------ 00089 // Data - 00090 // 00091 // The pixel data pointer of an image. 00092 // ------ 00093 // Bounds (bx1,by1,bx2,by2) - 00094 // 00095 // The bounds of an image's pixels. The bounds, in PixelCoordinates, are of the 00096 // addressable pixels in an image's data pointer. The order of the values is 00097 // x1, y1, x2, y2. X values are x1 <= X < x2 Y values are y1 <= Y < y2 00098 // ------ 00099 // ROD (rodx1,rody1,rodx2,rody2) - 00100 // 00101 // The full region of definition. The ROD, in PixelCoordinates, are of the 00102 // addressable pixels in an image's data pointer. The order of the values is 00103 // x1, y1, x2, y2. X values are x1 <= X < x2 Y values are y1 <= Y < y2 00104 // ------ 00105 // Row Bytes - 00106 // 00107 // The number of bytes in a row of an image. 00108 // ------ 00109 // Field - 00110 // 00111 // kOfxImageFieldNone - the image is an unfielded frame 00112 // kOfxImageFieldBoth - the image is fielded and contains both interlaced fields 00113 // kOfxImageFieldLower - the image is fielded and contains a single field, being the lower field (rows 0,2,4...) 00114 // kOfxImageFieldUpper - the image is fielded and contains a single field, being the upper field (rows 1,3,5...) 00115 // ------ 00116 // Unique Identifier - 00117 // 00118 // Uniquely labels an image. This is host set and allows a plug-in to differentiate between images. This is 00119 // especially useful if a plugin caches analysed information about the image (for example motion vectors). The 00120 // plugin can label the cached information with this identifier. If a user connects a different clip to the 00121 // analysed input, or the image has changed in some way then the plugin can detect this via an identifier change 00122 // and re-evaluate the cached information. 00123 /* 00124 // construction based on clip instance 00125 OfxhImage( attribute::OfxhClip& instance, // construct from clip instance taking pixel depth, components, pre mult and aspect ratio 00126 OfxTime time, 00127 double renderScaleX, 00128 double renderScaleY, 00129 void* data, 00130 const OfxRectI& bounds, 00131 const OfxRectI& rod, 00132 int rowBytes, 00133 const std::string& field, 00134 const std::string& uniqueIdentifier ); 00135 */ 00136 // OfxImageClipHandle getHandle(); 00137 00138 OfxPropertySetHandle getPropHandle() const 00139 { 00140 return property::OfxhSet::getHandle(); 00141 } 00142 00143 const std::string& getClipName() const { return _clipName; } 00144 OfxTime getTime() const { return _time; } 00145 std::ptrdiff_t getId() const { return _id; } 00146 00147 /// get the bounds of the pixels in memory 00148 OfxRectI getBounds() const; 00149 00150 /// get the full region of this image 00151 OfxRectI getROD() const; 00152 00153 EBitDepth getBitDepth() const; 00154 00155 inline std::size_t getBitDepthMemorySize() const 00156 { 00157 return bitDepthMemorySize( getBitDepth() ); 00158 } 00159 00160 int getRowBytes() const; 00161 00162 EPixelComponent getComponentsType() const; 00163 00164 int getReferenceCount( const EReferenceOwner from ) const; 00165 00166 void addReference( const EReferenceOwner from, const std::size_t n = 1 ); 00167 00168 /// release the reference count, which, if zero, deletes this 00169 bool releaseReference( const EReferenceOwner from ); 00170 }; 00171 00172 } 00173 } 00174 } 00175 } 00176 00177 #endif