diff options
| -rw-r--r-- | rotord/src/graph.cpp | 8 | ||||
| -rw-r--r-- | rotord/src/rotor.cpp | 24 | ||||
| -rw-r--r-- | rotord/src/rotor.h | 66 |
3 files changed, 85 insertions, 13 deletions
diff --git a/rotord/src/graph.cpp b/rotord/src/graph.cpp index cc624a8..8cf5950 100644 --- a/rotord/src/graph.cpp +++ b/rotord/src/graph.cpp @@ -145,6 +145,8 @@ bool Graph::video_render(const string &output_filename,const float framerate,int uint16_t *audio=nullptr; int samples_in_frame; + for (auto n:nodes) n.second->reset_timer(); + if (usingaudio){ samples_in_frame=(audioloader.get_sample_rate())/framerate; string whether=usingaudio?"Loading":"Cannot load"; @@ -230,10 +232,14 @@ bool Graph::video_render(const string &output_filename,const float framerate,int gettimeofday(&_end, NULL); - float mtime = ((_end.tv_sec-_start.tv_sec) + (_end.tv_usec-_start.tv_usec)/1000000.0) + 0.5; + float mtime = ((_end.tv_sec-_start.tv_sec) + (_end.tv_usec-_start.tv_usec)/1000000.0); logger.information("Video_output: rendered "+output_filename+": in "+toString(mtime)+" seconds"); + for (auto n:nodes) { + logger.information(n.second->type+" node '"+n.first+"' took "+toString(n.second->get_time_used())+" seconds"); + } + if (usingaudio) { audioloader.cleanup(); delete[] audioframe; diff --git a/rotord/src/rotor.cpp b/rotord/src/rotor.cpp index b7bf642..83a0fa7 100644 --- a/rotord/src/rotor.cpp +++ b/rotord/src/rotor.cpp @@ -81,6 +81,18 @@ Node_factory::Node_factory(){ add_type("ui_text",new UI_text(),category["UI"]); } +float Signal_input::get_time_used(){ + if (connection){ + return ((Signal_node*)connection)->get_time_used(); + } + return 0.0f; +} +float Signal_input::get_time_taken(){ + if (connection){ + return ((Signal_node*)connection)->time_taken; + } + return 0.0f; +} bool Signal_input::connect(Node* source) { connection=dynamic_cast<Signal_node*>(source); if (connection) return true; @@ -92,6 +104,18 @@ float Signal_input::get(const Time_spec& time){ //gets input and updates variabl } else return 0.0f; } +float Image_input::get_time_used(){ + if (connection){ + return ((Image_node*)connection)->get_time_used(); + } + return 0.0f; +} +float Image_input::get_time_taken(){ + if (connection){ + return ((Image_node*)connection)->time_taken; + } + return 0.0f; +} bool Image_input::connect(Node* source) { connection=dynamic_cast<Image_node*>(source); if (connection) return true; diff --git a/rotord/src/rotor.h b/rotord/src/rotor.h index e882c05..75e7914 100644 --- a/rotord/src/rotor.h +++ b/rotord/src/rotor.h @@ -64,6 +64,13 @@ Requirements this is why I think Sasha's video is the most succesful attempt so far- it takes a recognisable style that people understand and deconstructs it. + + + + + http://www.ogre3d.org/forums/viewtopic.php?f=16&t=52936 + chaiscript binding to cairo + -------------------------*/ @@ -179,6 +186,8 @@ namespace Rotor { Node* connection; string description; string title; + virtual float get_time_used()=0; + virtual float get_time_taken()=0; }; class Image_input: public Input{ public: @@ -188,6 +197,8 @@ namespace Rotor { connect(_connect); }; Image* get(const Frame_spec& time); + float get_time_used(); + float get_time_taken(); }; class Signal_input: public Input{ public: @@ -197,6 +208,8 @@ namespace Rotor { connect(_connect); }; float get(const Time_spec& time); + float get_time_used(); + float get_time_taken(); }; class Parameter: public Signal_input{ public: @@ -258,6 +271,7 @@ namespace Rotor { description=_desc; title=_title; type="lyrics"; + blank_response=""; }; void init(const std::map<float,std::pair<string,float> > _lyrics){ lyrics=_lyrics; @@ -273,10 +287,11 @@ namespace Rotor { //cerr<<(time.time)<<" "<<l->second.first<<","<<(l->first)<<" ("<<(l->second.second)<<")"<<endl; if ((time.time>l->first)&&((time.time-l->first) < l->second.second)) return l->second.first; } - return ""; + return blank_response; } private: std::map<float,std::pair<string,float> > lyrics; //lyrics[startime]=pair<lyric,endtime> + std::string blank_response; }; class Node{ public: @@ -344,6 +359,7 @@ namespace Rotor { } } void update(const Time_spec &time){ + gettimeofday(&frame_time, NULL); for (auto p: parameters){ p.second->get(time); } @@ -351,18 +367,38 @@ namespace Rotor { void set_parameter(const std::string &key,const std::string &value){ if (parameters.find(key)!=parameters.end()) parameters[key]->value=toFloat(value); }; + void reset_timer(){ + time_taken=0.0f; + } + void time_frame(){ + struct timeval end_time; + gettimeofday(&end_time, NULL); + time_taken+=((end_time.tv_sec-frame_time.tv_sec) + (end_time.tv_usec-frame_time.tv_usec)/1000000.0); + } + virtual float get_time_used()=0; + float time_taken; + protected: + struct timeval frame_time; }; class Signal_node: public Node{ public: virtual ~Signal_node(){}; const float get_output(const Time_spec &time) { update(time); - return output(time); + float o=output(time); + time_frame(); + return o; }; const float get_time_for_value(const float &value) { return 0.0f; }; virtual const float output(const Time_spec &time) { return 0.0f; }; + float get_time_used(){ + float t=time_taken; + for (auto i:inputs) t-=i->get_time_taken(); + for (auto p:parameters) t-=p.second->get_time_taken(); + return t; + } }; class Image_node: public Node{ public: @@ -374,12 +410,21 @@ namespace Rotor { image_inputs.push_back(new Image_input(_desc,_title,_connect)); }; Image *get_image_output(const Frame_spec &frame) { - image.setup(frame.w,frame.h); update((Time_spec)frame); - return output(frame); + image.setup(frame.w,frame.h); + Image *i=output(frame); + time_frame(); + return i; } virtual Image *output(const Frame_spec &frame)=0; Image image; + float get_time_used(){ + float t=time_taken; + for (auto i:inputs) t-=i->get_time_taken(); + for (auto p:parameters) t-=p.second->get_time_taken(); + for (auto i:image_inputs) t-=i->get_time_taken(); + return t; + } private: float image_time; //? could be used to detect image reuse? @@ -519,8 +564,8 @@ namespace Rotor { } } lastframe=thisframe; - float start_time=(((Time_spec)frame).time-segment_start); - float end_time=(((Time_spec)frame).time-segment_end); + //float start_time=(((Time_spec)frame).time-segment_start); + //float end_time=(((Time_spec)frame).time-segment_end); float in_time=(((Time_spec)frame).time-segment_start); //time in seconds for the incoming sequence: starts at 0 @@ -799,7 +844,6 @@ namespace Rotor { } } if (isLoaded){ - int tests=0; int wanted=0.0f; int thisframe=((Time_spec)frame).frame(); float clipframerate=(parameters["framerate"]->value==0.0f?player.get_framerate():parameters["framerate"]->value); @@ -844,9 +888,7 @@ namespace Rotor { return nullptr; } Video_bank* clone(map<string,string> &_settings) { return new Video_bank(_settings);}; - ~Video_bank(){ - - }; + ~Video_bank(){}; private: int clip_loaded; float segment_start; @@ -909,11 +951,11 @@ namespace Rotor { amount = 1.0f-((track_time-end_peak)/(end_silence-end_peak)); } } - if (amount<(1.0f/254.0f)){ + if (amount<(1.0f/256.0f)){ image.clear(); } image=(*in); - if (amount<1.0f){ + if (amount<(255.0f/256.0f)){ image*=amount; } //seems to be outputting correctly but not saving frames |
