diff options
Diffstat (limited to 'rotord')
| -rw-r--r-- | rotord/src/rotor.h | 117 |
1 files changed, 113 insertions, 4 deletions
diff --git a/rotord/src/rotor.h b/rotord/src/rotor.h index 5a48011..9c484c9 100644 --- a/rotord/src/rotor.h +++ b/rotord/src/rotor.h @@ -914,6 +914,109 @@ namespace Rotor { media_path=find_setting(settings,"media_path",""); }; ~Video_bank(){}; + Image *output(const Frame_spec &frame){ + if (!inputs[0]->connection){ //default to single loader if the selector isn't in use + if (!isLoaded){ + if (attributes["filenames"]->vals.size()){ + if (load(media_path+attributes["filenames"]->vals[0])) { + isLoaded=true; + } + } + } + if (isLoaded){ + return Base_video::output(frame); + } + return nullptr; + } + if (attributes["filenames"]->vals.size()){ + double ph=inputs[0]->get((Time_spec)frame); + int seg=((int)ph); + int wv=seg%attributes["filenames"]->vals.size(); + ph=seg==0?ph:fmod(ph,seg); + if (clip_loaded!=wv){ + if (load(media_path+attributes["filenames"]->vals[wv])) { //check if loading is succesful + clip_loaded=wv; + isLoaded=true; + lastframe=-2; + } + //else { + //cerr<<"Video bank could not load "<<(media_path+attributes["filenames"]->vals[wv])<<endl; + // clip_loaded=-1; + //} + } + if (isLoaded){ //always checks if loading was succesful + int wanted=0.0; + int thisframe=((Time_spec)frame).frame(); + double clipframerate=(parameters["framerate"]->value==0.0?player.get_framerate():parameters["framerate"]->value); + double clipspeed=(clipframerate/frame.framerate)*parameters["speed"]->value; + switch (attributes["time_mode"]->intVal){ + case VIDEOTIME_play: + if(thisframe==lastframe||thisframe==lastframe+1){ + if (segment!=seg){ + //start of new segment + //cerr<<"Video_bank: segment "<<seg<<" started: "<<((Time_spec)frame).time<<endl; + segment=seg; + segment_start=((Time_spec)frame).time; + } + } + else { + if (thisframe==0){ + segment_start=0.0; + segment=seg; + } + else { + //find segment start + Time_spec testframe=(Time_spec)frame.lastframe(); + while ((int)inputs[0]->get(testframe)==seg&&testframe.frame()>1){ + testframe=testframe.lastframe(); + + } + segment_start=testframe.time; + segment=seg; + } + } + wanted=(((Time_spec)frame).time-segment_start)*clipspeed*frame.framerate; + lastframe=thisframe; + break; + case VIDEOTIME_stretch: + wanted=ph*player.get_number_frames(); + break; + } + if (get_frame(wanted,frame)) return ℑ //only return if succesful + } + + } + return nullptr; + } + Video_bank* clone(map<string,string> &_settings) { return new Video_bank(_settings);}; + private: + int clip_loaded; + double segment_start; + int segment; + }; + class Video_bank2: public Base_video { + public: + //manage a bank of video inclusing transitions + //blend mode etc + //there may be a total of 4 frames required + //and 2 videos open + //is there any way to re-use the parts which prepare frames + Video_bank2(){ + create_attribute("filenames","names of video files to load","File names","",{},"array"); + NODEID="73616e66-4306-11e3-981e-74d02b29f6a6"; + title="Video bank"; + description="Loads a banks of video files"; + clip_loaded=-1; + isLoaded=false; + segment=0; + segment_start=0.0; + lastframe=-2; + }; + Video_bank2(map<string,string> &settings): Video_bank2() { + base_settings(settings); + media_path=find_setting(settings,"media_path",""); + }; + ~Video_bank2(){}; bool load(int v){ if (players[v].loaded) return true; Poco::Logger& logger = Poco::Logger::get(Log_name); @@ -979,6 +1082,11 @@ namespace Rotor { return true; } Image *output(const Frame_spec &frame){ + if (frame.w<1||frame.h<1){ //?? + Poco::Logger& logger = Poco::Logger::get(Log_name); + logger.error("Video bank: bad frame request "+toString(frame.w)+"x"+toString(frame.h)); + return nullptr; + } if (!inputs[0]->connection){ //default to single loader if the selector isn't in use if (!isLoaded){ if (attributes["filenames"]->vals.size()){ @@ -1003,10 +1111,11 @@ namespace Rotor { clip_loaded=wv; isLoaded=true; } - //else { - //cerr<<"Video bank could not load "<<(media_path+attributes["filenames"]->vals[wv])<<endl; - // clip_loaded=-1; - //} + else { + cerr<<"Video bank could not load "<<(media_path+attributes["filenames"]->vals[wv])<<endl; + clip_loaded=-1; + isLoaded=false; + } } if (isLoaded){ //always checks if loading was succesful int wanted=0.0; |
