diff options
Diffstat (limited to 'rotord/rotor.h')
| -rwxr-xr-x | rotord/rotor.h | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/rotord/rotor.h b/rotord/rotor.h index f530bc3..2915fb6 100755 --- a/rotord/rotor.h +++ b/rotord/rotor.h @@ -66,6 +66,7 @@ main definitions of libavcodec.h are in utils.c #include "Poco/AutoPtr.h" #include "Poco/File.h" #include "Poco/Base64Encoder.h" +#include "Poco/Path.h" #include <iostream> using Poco::UUID; @@ -160,9 +161,9 @@ namespace Rotor { free(); }; void free(){ - if (RGBdata) delete[] RGBdata; - if (Adata) delete[] Adata; - if (Zdata) delete[] Zdata; + if (RGBdata&&ownsRGBdata) delete[] RGBdata; + if (Adata&&ownsAdata) delete[] Adata; + if (Zdata&&ownsZdata) delete[] Zdata; zero(); } void zero(){ @@ -171,23 +172,40 @@ namespace Rotor { Zdata=nullptr; w=0; h=0; + ownsRGBdata=ownsAdata=ownsZdata=false; } - bool setup(int _w,int _h){ - if (w!=_w||h!=_h){ + bool setup(int _w,int _h){ //set up with internal data + if (w!=_w||h!=_h||!ownsRGBdata||!ownsAdata||!ownsZdata){ free(); w=_w; h=_h; RGBdata=new uint8_t[w*h*3]; Adata=new uint8_t[w*h]; Zdata=new uint16_t[w*h]; + ownsRGBdata=ownsAdata=ownsZdata=true; return true; } else return false; } + bool setup_fromRGB(int _w,int _h,uint8_t *pRGBdata){ //possibility of just resetting pointer? + if (w!=_w||h!=_h||ownsRGBdata||!ownsAdata||!ownsZdata){ + free(); + w=_w; + h=_h; + RGBdata=pRGBdata; + Adata=new uint8_t[w*h]; + Zdata=new uint16_t[w*h]; + ownsRGBdata=false; + ownsAdata=ownsZdata=true; + return true; + } + return false; + } uint8_t *RGBdata; uint8_t *Adata; uint16_t *Zdata; int h,w; + bool ownsRGBdata,ownsAdata,ownsZdata; //better done through auto_ptr? }; class Time_spec{ public: |
