diff options
| author | Comment <tim@gray.(none)> | 2013-04-17 21:06:22 +0100 |
|---|---|---|
| committer | Comment <tim@gray.(none)> | 2013-04-17 21:06:22 +0100 |
| commit | 66d5eec509cf1a5b376f4111b12dc9f31fe968a0 (patch) | |
| tree | 036cbe156155e213199b52ec3d5c68de1deae670 /rotord/rotor.h | |
| parent | 4dc41d7c3d1b7dab41b648e9677d2b4e1d3d602c (diff) | |
working encoder
Diffstat (limited to 'rotord/rotor.h')
| -rwxr-xr-x | rotord/rotor.h | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/rotord/rotor.h b/rotord/rotor.h index e5b4085..af1bb72 100755 --- a/rotord/rotor.h +++ b/rotord/rotor.h @@ -98,7 +98,7 @@ extern "C" { #include "vampHost.h" #include "xmlIO.h" //#include "avCodec.h" - + namespace Rotor { #define IDLE 0 #define ANALYSING_AUDIO 1 @@ -116,7 +116,7 @@ namespace Rotor { class Node; class Signal_node; class Image_node; - + //http://blog.tomaka17.com/2012/03/libavcodeclibavformat-tutorial/ struct Packet { explicit Packet(AVFormatContext* ctxt = nullptr) { @@ -182,7 +182,7 @@ namespace Rotor { }; class Input{ public: - Input(const string &_desc): description(_desc){}; + Input(const string &_desc): description(_desc),connection(nullptr){}; Node* connection; string description; }; @@ -195,9 +195,9 @@ namespace Rotor { public: bool connect(Signal_node *source); Signal_input(const string &_desc): Input(_desc){}; - + }; - class Node{ + class Node{ public: virtual Node* clone(map<string,string> &_settings)=0; UUID uid; //every usable node has a UUID @@ -222,6 +222,7 @@ namespace Rotor { zero(); }; Image(int _w,int _h){ + zero(); setup(_w,_h); }; ~Image() { @@ -266,11 +267,14 @@ namespace Rotor { public: vector<Image_input*> image_inputs; //image node also has image inputs and outputs void create_image_input(const string &description) {image_inputs.push_back(new Image_input(description));}; - Image *get_output(const Frame_spec &frame){ //sample implementation + virtual Image *get_output(const Frame_spec &frame)=0; + + /*{ //sample implementation //do something with the inputs //and then return ((Image_node*)(image_inputs[0]->connection))->get_output(frame); } + */ Image *get_preview(const Frame_spec &frame); Image *image; //this can be privately allocated or just passed on as the node see fit private: @@ -309,7 +313,7 @@ namespace Rotor { } else return (float)ln; } - } + } return 0.0f; } void print_features(); @@ -372,18 +376,20 @@ namespace Rotor { Testcard(){}; Testcard(map<string,string> &settings) { base_settings(settings); + image=new Image(); }; + ~Testcard(){ delete image;}; Testcard* clone(map<string,string> &_settings) { return new Testcard(_settings);}; - Image *get_output(const Frame_spec &frame){ + Image *get_output(const Frame_spec &frame){ if (image->setup(frame.w,frame.h)) { //create testcard float ws=(255.0f/frame.w); float hs=(255.0f/frame.h); for (int i=0;i<frame.h;i++){ for (int j=0;j<frame.w;j++){ - image->RGBdata[i*frame.w+j]=(uint8_t)(i*hs); - image->RGBdata[i*frame.w+j+1]=(uint8_t)(j*ws); - image->RGBdata[i*frame.w+j+2]=(uint8_t)(0); + image->RGBdata[(i*frame.w+j)*3]=(uint8_t)(i*hs); + image->RGBdata[((i*frame.w+j)*3)+1]=(uint8_t)(j*ws); + image->RGBdata[((i*frame.w+j)*3)+2]=(uint8_t)(0); image->Adata[i*frame.w+j]=(uint8_t)255; image->Zdata[i*frame.w+j]=(uint16_t)512; //1.0 in fixed point 8.8 bits } @@ -401,11 +407,17 @@ namespace Rotor { base_settings(settings); exporter=new ofxMovieExporter(); }; + Image *get_output(const Frame_spec &frame){ + if (image_inputs[0]->connection) { + return ((Image_node*)(image_inputs[0]->connection))->get_output(frame); + } + else return nullptr; + }; Video_output* clone(map<string,string> &_settings) { return new Video_output(_settings);}; bool render(const float duration, const float framerate,const string &output_filename,const string &audio_filename); private: - ofxMovieExporter *exporter; + ofxMovieExporter *exporter; }; //------------------------------------------------------------------- class Node_factory{ @@ -462,7 +474,7 @@ namespace Rotor { else return false; } int load(Poco::UUID uid); - bool load(string &graph_filename); + bool load(string &graph_filename); UUID save(); //save to DB, returns UUID of saved graph bool loaded; float duration; @@ -475,7 +487,7 @@ namespace Rotor { public: Audio_thumbnailer(){ height=32; - width=64; //fit + width=64; //fit data=new uint8_t[height*width]; memset(data,0,height*width); }; |
