From 0582c81b7499281cfd9e8643e763c7521a67aec9 Mon Sep 17 00:00:00 2001 From: Comment Date: Sun, 24 Nov 2013 11:12:28 +0000 Subject: analytics --- rotord/src/graph.cpp | 8 +++++++- rotord/src/rotor.cpp | 12 ++++++++++++ rotord/src/rotor.h | 51 +++++++++++++++++++++++++++++++++++++++++++++------ 3 files changed, 64 insertions(+), 7 deletions(-) diff --git a/rotord/src/graph.cpp b/rotord/src/graph.cpp index cc624a8..a6ef7a8 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 0bb9341..9d76626 100644 --- a/rotord/src/rotor.cpp +++ b/rotord/src/rotor.cpp @@ -78,6 +78,12 @@ Node_factory::Node_factory(){ add_type("video_feedback",new Video_feedback(),category["FX"]); } +float Signal_input::get_time_used(){ + if (connection){ + return ((Signal_node*)connection)->get_time_used(); + } + return 0.0f; +} bool Signal_input::connect(Node* source) { connection=dynamic_cast(source); if (connection) return true; @@ -89,6 +95,12 @@ 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; +} bool Image_input::connect(Node* source) { connection=dynamic_cast(source); if (connection) return true; diff --git a/rotord/src/rotor.h b/rotord/src/rotor.h index 0833096..c86eae8 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,7 @@ namespace Rotor { Node* connection; string description; string title; + virtual float get_time_used()=0; }; class Image_input: public Input{ public: @@ -188,6 +196,7 @@ namespace Rotor { connect(_connect); }; Image* get(const Frame_spec& time); + float get_time_used(); }; class Signal_input: public Input{ public: @@ -197,6 +206,7 @@ namespace Rotor { connect(_connect); }; float get(const Time_spec& time); + float get_time_used(); }; class Parameter: public Signal_input{ public: @@ -258,6 +268,7 @@ namespace Rotor { description=_desc; title=_title; type="lyrics"; + blank_response=""; }; void init(const std::map > _lyrics){ lyrics=_lyrics; @@ -273,10 +284,11 @@ namespace Rotor { //cerr<<(time.time)<<" "<second.first<<","<<(l->first)<<" ("<<(l->second.second)<<")"<l->first)&&((time.time-l->first) < l->second.second)) return l->second.first; } - return ""; + return blank_response; } private: std::map > lyrics; //lyrics[startime]=pair + std::string blank_response; }; class Node{ public: @@ -343,6 +355,7 @@ namespace Rotor { } } void update(const Time_spec &time){ + gettimeofday(&frame_time, NULL); for (auto p: parameters){ p.second->get(time); } @@ -350,18 +363,37 @@ 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_used=0.0f; + } + void time_frame(){ + struct timeval end_time; + gettimeofday(&end_time, NULL); + time_used+=((end_time.tv_sec-frame_time.tv_sec) + (end_time.tv_usec-frame_time.tv_usec)/1000000.0); + } + virtual float get_time_used()=0; + protected: + float time_used; + 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_used; + for (auto i:inputs) t-=i->get_time_used(); + return t; + } }; class Image_node: public Node{ public: @@ -375,10 +407,18 @@ namespace Rotor { Image *get_image_output(const Frame_spec &frame) { image.setup(frame.w,frame.h); update((Time_spec)frame); - return output(frame); + 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_used; + for (auto i:inputs) t-=i->get_time_used(); + for (auto i:image_inputs) t-=i->get_time_used(); + return t; + } private: float image_time; //? could be used to detect image reuse? @@ -518,8 +558,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 @@ -798,7 +838,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); -- cgit v1.2.3