diff options
| -rwxr-xr-x | rotord/src/rotor.cpp | 4 | ||||
| -rwxr-xr-x | rotord/src/rotor.h | 24 |
2 files changed, 25 insertions, 3 deletions
diff --git a/rotord/src/rotor.cpp b/rotord/src/rotor.cpp index c45ce5e..8883a71 100755 --- a/rotord/src/rotor.cpp +++ b/rotord/src/rotor.cpp @@ -346,10 +346,10 @@ Image* Video_loader::output(const Frame_spec &frame){ int wanted; if (attributes["mode"]->intVal==VIDEOFRAMES_frame) { - wanted=(((int) ((frame.time*frame.framerate)+0.5))%(player.getNumberOfFrames()-1))+1; //+1 is necessary because 1st frame in a video is number 1? + wanted=(((int) ((frame.time*frame.framerate)+0.5))%(player.getNumberOfFrames()))+1; //+1 is necessary because 1st frame in a video is number 1? } if (attributes["mode"]->intVal==VIDEOFRAMES_blend) { - wanted=(((int) ((frame.time*frame.framerate*clipspeed)+0.5))%(player.getNumberOfFrames()-1))+1; //+1 is necessary because 1st frame in a video is number 1? + wanted=(((int) ((frame.time*frame.framerate*clipspeed)+0.5))%(player.getNumberOfFrames()))+1; //+1 is necessary because 1st frame in a video is number 1? } if (wanted!=lastframe){ diff --git a/rotord/src/rotor.h b/rotord/src/rotor.h index ec9f072..6b80762 100755 --- a/rotord/src/rotor.h +++ b/rotord/src/rotor.h @@ -374,11 +374,14 @@ namespace Rotor { } private: }; - class Video_cycler: public Image_node { + #define CYCLER_cut 1 + #define CYCLER_mix 2 + class Video_cycler: public Image_node { public: Video_cycler(){ create_image_input("Image input","Image input"); create_signal_input("Selector","Selector input"); + create_attribute("mode","Cycling mode {cut|mix}","Mode","cut",{"cut","mix"}); title="Video cycler"; description="Cycles through video inputs according to selector signal"; duplicate_inputs=true; @@ -389,6 +392,25 @@ namespace Rotor { ~Video_cycler(){}; bool load(const string &filename); Image *output(const Frame_spec &frame){ + if (attributes["mode"]->intVal==CYCLER_mix&&image_inputs.size()>1){ + int im1=((int)inputs[0]->get((Time_spec)frame))%image_inputs.size(); + int im2=(im1+1)%image_inputs.size(); + float f=fmod(inputs[0]->get((Time_spec)frame),1.0f); + Image *in1=image_inputs[im1]->get(frame); + if (in1){ + Image *in2=image_inputs[im2]->get(frame); + if (in2){ + image=(*in1); + image*=(1.0f-f); + Image i2=(*in2); + i2*=f; + image+=i2; + return ℑ + } + return in1; + } + return nullptr; + } return image_inputs[((int)inputs[0]->get((Time_spec)frame))%image_inputs.size()]->get(frame); } Video_cycler* clone(map<string,string> &_settings) { return new Video_cycler(_settings);}; |
