summaryrefslogtreecommitdiff
path: root/rotord/src
diff options
context:
space:
mode:
authorComment <tim@gray.(none)>2013-10-02 17:54:52 +0100
committerComment <tim@gray.(none)>2013-10-02 17:54:52 +0100
commit951c4b40a74b87b6467770ba369e9b2e74941339 (patch)
tree1128270afd88ce8844142f51399a2ada970706bb /rotord/src
parentd68f4dd6f58620f483be6a921201dd87ed04cd98 (diff)
slomo video mode
Diffstat (limited to 'rotord/src')
-rw-r--r--rotord/src/rotor.h29
1 files changed, 20 insertions, 9 deletions
diff --git a/rotord/src/rotor.h b/rotord/src/rotor.h
index bf54883..d1e42a9 100644
--- a/rotord/src/rotor.h
+++ b/rotord/src/rotor.h
@@ -406,12 +406,16 @@ namespace Rotor {
};
#define CYCLER_cut 1
#define CYCLER_mix 2
+ //new mode that remaps sequence length to segments
+ //combined with a video mode that maps video length to duration
+ //or
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"});
+ create_attribute("time_mode","Time mode {abs|rel}","time mode","abs",{"abs","rel"});
title="Video cycler";
description="Cycles through video inputs according to selector signal";
duplicate_inputs=true;
@@ -894,7 +898,7 @@ namespace Rotor {
if (attributes["filename"]->value!="") {
load(find_setting(settings,"media_path","")+attributes["filename"]->value);
}
- lastframe=-1;
+
};
~Video_loader(){};
bool load(const string &filename){
@@ -910,6 +914,7 @@ namespace Rotor {
+toString(player.get_framerate())+" fps, "\
+toString(player.get_width())+"x"+toString(player.get_height())\
+", channels:"+toString(player.get_number_channels()));
+ lastframe=-2;
return true;
}
logger.error("Video_loader failed to load "+filename);
@@ -920,29 +925,35 @@ namespace Rotor {
float clipframerate=(parameters["framerate"]->value==0.0f?player.get_framerate():parameters["framerate"]->value);
float clipspeed=(clipframerate/frame.framerate)*parameters["speed"]->value;
if (attributes["mode"]->intVal==VIDEOFRAMES_blend){
- float wanted=fmod(frame.time*frame.framerate,(float)player.get_number_frames());
+ float wanted=fmod(frame.time*frame.framerate*clipspeed,(float)player.get_number_frames());
if (((int)wanted)!=lastframe){
//get a new pair of frames possibly by switching the next one
- if (lastframe=(int)wanted-1){
+ //darn peculiar, as if copying wasn't actually copying
+ if ((lastframe==(((int)wanted)-1))&&(in2.w>0)) {
in1=in2;
}
else {
player.fetch_frame(frame.w,frame.h,(int)wanted);
- in1.setup_fromRGB(frame.w,frame.h,player.frame->Data[0],player.frame->Linesize[0]-(frame.w*3));
+ //use a temp image because setup_fromRGB just copies pointer
+ temp.setup_fromRGB(frame.w,frame.h,player.frame->Data[0],player.frame->Linesize[0]-(frame.w*3));
+ in1=temp;
}
player.fetch_frame(frame.w,frame.h,((int)wanted+1)%max(1,player.get_number_frames()));
- in2.setup_fromRGB(frame.w,frame.h,player.frame->Data[0],player.frame->Linesize[0]-(frame.w*3));
+ temp.setup_fromRGB(frame.w,frame.h,player.frame->Data[0],player.frame->Linesize[0]-(frame.w*3));
+ in2=temp;
+ lastframe=wanted;
}
- lastframe=wanted;
float amt=1.0f-(wanted-((int)wanted));
+ //cout<<"video loader time:"<<frame.time<<" frames "<<((int)wanted)<<" (x"<<amt<<"),"<<(((int)wanted+1)%max(1,player.get_number_frames()))<<endl;
image=in1;
image*=amt;
- Image in2t=in2;
+ //Image in2t=in2; //DOES NOT WORK, copies pointer by assignation
+ in2t=in2;
in2t*=(1.0f-amt);
image+=in2t;
}
else {
- int wanted=(((int) ((frame.time*frame.framerate)+0.5))%max(1,player.get_number_frames()));
+ int wanted=(((int) ((frame.time*frame.framerate*clipspeed)+0.5))%max(1,player.get_number_frames()));
if (wanted!=lastframe){
if (!player.fetch_frame(frame.w,frame.h,wanted)) { //seek fail
Poco::Logger& logger = Poco::Logger::get("Rotor");
@@ -964,7 +975,7 @@ namespace Rotor {
//ffmpegsource::decoder player;
libav::video_decoder player;
int lastframe;
- Image in1,in2; //for blend frames;
+ Image in1,in2,in2t,temp; //for blend frames;
};
class Video_output: public Image_node {
//Video_output 'presents' the output movie. Aspect ratio, bars, fadein/fadeout would happen here