TuttleOFX  1
TuttleOFX/libraries/tuttle/src/tuttle/host/InputBufferWrapper.hpp
Go to the documentation of this file.
00001 #ifndef _TUTTLE_HOST_INPUTBUFFERNODE_HPP_
00002 #define _TUTTLE_HOST_INPUTBUFFERNODE_HPP_
00003 
00004 #include "INode.hpp"
00005 #include <tuttle/host/attribute/Param.hpp>
00006 #include <tuttle/host/attribute/ClipImage.hpp>
00007 #include <tuttle/host/attribute/ClipImage.hpp>
00008 #include <tuttle/host/ofx/attribute/OfxhClipImageDescriptor.hpp>
00009 #include <tuttle/host/graph/ProcessVertexData.hpp>
00010 #include <tuttle/host/graph/ProcessVertexAtTimeData.hpp>
00011 
00012 namespace tuttle {
00013 namespace host {
00014 
00015 class InputBufferWrapper
00016 {
00017 public:
00018         enum EMode
00019         {
00020                 eModeBuffer,
00021                 eModeCallback
00022         };
00023         enum EPixelComponent
00024         {
00025                 ePixelComponentRGBA,
00026                 ePixelComponentRGB,
00027                 ePixelComponentAlpha
00028         };
00029         enum EBitDepth
00030         {
00031                 eBitDepthUByte,
00032                 eBitDepthUShort,
00033                 eBitDepthFloat
00034         };
00035         enum EImageOrientation
00036         {
00037                 eImageOrientationFromTopToBottom,
00038                 eImageOrientationFromBottomToTop
00039         };
00040         enum EField
00041         {
00042                 eFieldBoth,  //< @brief fielded image with both fields present
00043                 eFieldLower, //< @brief only the spatially lower field is present
00044                 eFieldUpper  //< @brief only the spatially upper field is present
00045         };
00046         
00047         typedef void* CustomDataPtr;
00048         typedef void (*CallbackInputImagePtr)( OfxTime time, CustomDataPtr outputCustomData, void** rawdata, int* width, int* height, int* rowSizeBytes );
00049         typedef void (*CallbackDestroyCustomDataPtr)( CustomDataPtr outputCustomData );
00050 
00051 private:
00052         INode* _node;
00053         
00054 public:
00055         InputBufferWrapper( INode& node )
00056         : _node(&node)
00057         {}
00058         InputBufferWrapper()
00059         : _node(NULL)
00060         {}
00061         ~InputBufferWrapper()
00062         {}
00063 
00064         INode& getNode() { return *_node; }
00065 
00066         void setMode( const EMode mode );
00067         void setBuffer( void* rawBuffer );
00068 private:
00069         void set2DArrayBuffer( void* rawBuffer, const int width, const int height );
00070         void set3DArrayBuffer( void* rawBuffer, const int width, const int height, const int nbComponents );
00071         
00072 public:
00073         void set2DArrayBuffer( unsigned char* rawBuffer, int height, int width )
00074         {
00075                 set2DArrayBuffer( (void*)rawBuffer, width, height );
00076                 setBitDepth( eBitDepthUByte );
00077         }
00078         void set3DArrayBuffer( unsigned char* rawBuffer, int height, int width, int nbComponents )
00079         {
00080                 set3DArrayBuffer( (void*)rawBuffer, width, height, nbComponents );
00081                 setBitDepth( eBitDepthUByte );
00082         }
00083         
00084         void set2DArrayBuffer( unsigned short* rawBuffer, int height, int width )
00085         {
00086                 set2DArrayBuffer( (void*)rawBuffer, width, height );
00087                 setBitDepth( eBitDepthUShort );
00088         }
00089         void set3DArrayBuffer( unsigned short* rawBuffer, int height, int width, int nbComponents )
00090         {
00091                 set3DArrayBuffer( (void*)rawBuffer, width, height, nbComponents );
00092                 setBitDepth( eBitDepthUShort );
00093         }
00094         
00095         void set2DArrayBuffer( float* rawBuffer, int height, int width )
00096         {
00097                 set2DArrayBuffer( (void*)rawBuffer, width, height );
00098                 setBitDepth( eBitDepthUShort );
00099         }
00100         void set3DArrayBuffer( float* rawBuffer, int height, int width, int nbComponents )
00101         {
00102                 set3DArrayBuffer( (void*)rawBuffer, width, height, nbComponents );
00103                 setBitDepth( eBitDepthUShort );
00104         }
00105         
00106         void setSize( const int width, const int height );
00107         void setComponents( const EPixelComponent components );
00108         void setBitDepth( const EBitDepth bitDepth );
00109         void setRowDistanceSize( const int rowDistanceBytes );
00110         void setOrientation( const EImageOrientation orientation );
00111         
00112         void setRawImageBuffer(
00113                         void* rawBuffer,
00114                         const int width, const int height,
00115                         const EPixelComponent components,
00116                         const EBitDepth bitDepth,
00117                         const int rowDistanceBytes = 0,
00118                         const EImageOrientation orientation = eImageOrientationFromBottomToTop );
00119         
00120         void setRawImageBuffer(
00121                         unsigned char* rawBuffer,
00122                         const int width, const int height,
00123                         const EPixelComponent components,
00124                         const int rowDistanceBytes = 0,
00125                         const EImageOrientation orientation = eImageOrientationFromBottomToTop )
00126         {
00127                 setRawImageBuffer( reinterpret_cast<void*>(rawBuffer),
00128                         width, height,
00129                         components,
00130                         eBitDepthUByte,
00131                         rowDistanceBytes,
00132                         orientation );
00133         }
00134         
00135         void setRawImageBuffer(
00136                         unsigned short* rawBuffer,
00137                         const int width, const int height,
00138                         const EPixelComponent components,
00139                         const int rowDistanceBytes = 0,
00140                         const EImageOrientation orientation = eImageOrientationFromBottomToTop )
00141         {
00142                 setRawImageBuffer( reinterpret_cast<void*>(rawBuffer),
00143                         width, height,
00144                         components,
00145                         eBitDepthUShort,
00146                         rowDistanceBytes,
00147                         orientation );
00148         }
00149         
00150         void setRawImageBuffer(
00151                         float* rawBuffer,
00152                         const int width, const int height,
00153                         const EPixelComponent components,
00154                         const int rowDistanceBytes = 0,
00155                         const EImageOrientation orientation = eImageOrientationFromBottomToTop )
00156         {
00157                 setRawImageBuffer( reinterpret_cast<void*>(rawBuffer),
00158                         width, height,
00159                         components,
00160                         eBitDepthFloat,
00161                         rowDistanceBytes,
00162                         orientation );
00163         }
00164         
00165         void setCallback( CallbackInputImagePtr callback, CustomDataPtr customData = NULL, CallbackDestroyCustomDataPtr destroyCustomData = NULL );
00166         
00167 };
00168 
00169 }
00170 }
00171 
00172 #endif
00173