TuttleOFX
1
|
00001 #include "OfxhClipImage.hpp" 00002 00003 namespace tuttle { 00004 namespace host { 00005 namespace ofx { 00006 namespace attribute { 00007 00008 /** 00009 * clipimage instance 00010 */ 00011 OfxhClipImage::OfxhClipImage( const attribute::OfxhClipImageDescriptor& desc ) 00012 : attribute::OfxhClip( desc ) 00013 // , _pixelDepth( kOfxBitDepthNone ) 00014 // , _components( kOfxImageComponentNone ) 00015 { 00016 // _par = 1.0; 00017 /** 00018 * extra properties for the instance, these are fetched from the host 00019 * via a get hook and some virtuals 00020 */ 00021 static property::OfxhPropSpec clipImageInstanceStuffs[] = { 00022 { kOfxImageEffectPropPixelDepth, property::ePropTypeString, 1, true, kOfxBitDepthNone }, 00023 { kOfxImageEffectPropComponents, property::ePropTypeString, 1, true, kOfxImageComponentNone }, 00024 { kOfxImageClipPropUnmappedPixelDepth, property::ePropTypeString, 1, true, kOfxBitDepthNone }, 00025 { kOfxImageClipPropUnmappedComponents, property::ePropTypeString, 1, true, kOfxImageComponentNone }, 00026 { kOfxImageEffectPropPreMultiplication, property::ePropTypeString, 1, true, kOfxImageOpaque }, 00027 { kOfxImagePropPixelAspectRatio, property::ePropTypeDouble, 1, true, "1.0" }, 00028 { kOfxImageEffectPropFrameRate, property::ePropTypeDouble, 1, true, "25.0" }, 00029 { kOfxImageEffectPropFrameRange, property::ePropTypeDouble, 2, true, "0" }, 00030 { kOfxImageClipPropFieldOrder, property::ePropTypeString, 1, true, kOfxImageFieldNone }, 00031 { kOfxImageEffectPropUnmappedFrameRange, property::ePropTypeDouble, 2, true, "0" }, 00032 { kOfxImageEffectPropUnmappedFrameRate, property::ePropTypeDouble, 1, true, "25.0" }, 00033 { kOfxImageClipPropContinuousSamples, property::ePropTypeInt, 1, true, "0" }, 00034 { 0 }, 00035 }; 00036 00037 _properties.addProperties( clipImageInstanceStuffs ); 00038 initHook( clipImageInstanceStuffs ); 00039 } 00040 00041 OfxhClipImage::OfxhClipImage( const OfxhClipImage& other ) 00042 : attribute::OfxhClip( other ) 00043 {} 00044 00045 /// given the colour component, find the nearest set of supported colour components 00046 00047 const std::string& OfxhClipImage::findSupportedComp( const std::string& s ) const 00048 { 00049 static const std::string none( kOfxImageComponentNone ); 00050 static const std::string rgba( kOfxImageComponentRGBA ); 00051 static const std::string rgb( kOfxImageComponentRGB ); 00052 static const std::string alpha( kOfxImageComponentAlpha ); 00053 00054 /// is it there 00055 if( isSupportedComponent( s ) ) 00056 return s; 00057 00058 /// @todo tuttle: can we remove this check ? 00059 // /// were we fed some custom non chromatic component by getUnmappedComponents? Return it. 00060 // /// we should never be here mind, so a bit weird 00061 // if( !_effectInstance.isChromaticComponent( s ) ) 00062 // return s; 00063 00064 /// Means we have RGBA or Alpha being passed in and the clip 00065 /// only supports the other one, so return that 00066 if( s == rgba ) 00067 { 00068 if( isSupportedComponent( rgb ) ) 00069 return rgb; 00070 if( isSupportedComponent( alpha ) ) 00071 return alpha; 00072 } 00073 else if( s == alpha ) 00074 { 00075 if( isSupportedComponent( rgba ) ) 00076 return rgba; 00077 if( isSupportedComponent( rgb ) ) 00078 return rgb; 00079 } 00080 00081 /// wierd, must be some custom bit , if only one, choose that, otherwise no idea 00082 /// how to map, you need to derive to do so. 00083 const std::vector<std::string>& supportedComps = getSupportedComponents(); 00084 if( supportedComps.size() == 1 ) 00085 return supportedComps[0]; 00086 00087 return none; 00088 } 00089 00090 } 00091 } 00092 } 00093 }