summaryrefslogtreecommitdiff
path: root/rotord/rotor.h
diff options
context:
space:
mode:
Diffstat (limited to 'rotord/rotor.h')
-rwxr-xr-xrotord/rotor.h35
1 files changed, 19 insertions, 16 deletions
diff --git a/rotord/rotor.h b/rotord/rotor.h
index c38a83f..fe0f7d9 100755
--- a/rotord/rotor.h
+++ b/rotord/rotor.h
@@ -128,7 +128,8 @@ namespace Rotor {
class Frame_spec: public Time_spec{
public:
Frame_spec(float _time,float _framerate,float _duration,int _w,int _h){ time=_time; framerate=_framerate; duration=_duration; w=_w; h=_h;};
- Frame_spec(int _frame,float _framerate,float _duration,int _w,int _h){ time=((float)_frame)/_framerate; Frame_spec(time,_framerate,_duration,_w,_h);};
+ Frame_spec(int _frame,float _framerate,float _duration,int _w,int _h){ time=((float)_frame)/_framerate; framerate=_framerate; duration=_duration; w=_w; h=_h;};
+ //Frame_spec(time,_framerate,_duration,_w,_h);};
//float time; //this hould probably be implemented with a num/denom scheme eventually for accuracy
//float framerate;
@@ -769,7 +770,7 @@ namespace Rotor {
Echo_trails(){};
Echo_trails(map<string,string> &settings) {
base_settings(settings);
- duration=find_setting(settings,"duration",1.0f);
+ //duration=find_setting(settings,"duration",1.0f);
number=find_setting(settings,"number",1);
fadeto=find_setting(settings,"fadeto",1.0f);
levels_settings(settings);
@@ -798,16 +799,18 @@ namespace Rotor {
images.clear();
lastframe=-1;
//calculate frame interval
- interval=(int)(((duration/number)*frame.framerate)+0.5);
- total=interval*number;
+ //interval=(int)(((duration/number)*frame.framerate)+0.5);
+ //total=interval*number;
}
int thisframe=frame.frame();
//iterate cache and throw out any obsolete frames
auto i = std::begin(images);
while (i != std::end(images)) {
// check if the image is in the range we need
- if (thisframe-(*i).first>total||thisframe-(*i).first<0)
+ if (thisframe-(*i).first>number||thisframe-(*i).first<0) {
+ delete (*i).second;
i = images.erase(i);
+ }
else
++i;
}
@@ -822,28 +825,28 @@ namespace Rotor {
//copy incoming image **writable
image->free();
image=(((Image_node*)image_inputs[0]->connection)->get_output(frame))->clone();
- for (int i=0;i<number;i++){
+ for (int i=1;i<number;i++){
//check echo frame isn't at negative time
- int absframe=thisframe-(i*interval);
+ int absframe=thisframe-i;
if (absframe>-1){
//check if image is in the cache
if (images.find(absframe)==images.end()){
- //cerr<<"Rotor: preparing image ("<<image->w<<"x"<<image->h<<")"<<endl;
-
- images[absframe]=new Image(image->w,image->h);
- //cerr<<"Rotor: prepared image ("<<images[absframe].w<<"x"<<images[absframe].h<<")"<<endl;
-
+ images[absframe]=new Image(frame.w,frame.h);
Frame_spec wanted=Frame_spec(absframe,frame.framerate,frame.duration,frame.w,frame.h);
- apply_LUT(*(((Image_node*)image_inputs[0]->connection)->get_output(wanted)),*images[absframe]);
+ apply_LUT(*(((Image_node*)image_inputs[0]->connection)->get_output(wanted)),*(images[absframe]));
}
//cerr<<"Rotor: about to apply image ("<<images[absframe].w<<"x"<<images[absframe].h<<")"<<endl;
- if (fless(fadeto,1.0f)){
- Image *temp=*images[absframe]*((float)number/((fadeto*number)+((1.0-fadeto)*i)));
+ if (fless(1.0f,fadeto)){
+ float amount=((((float)number-i)/number)*(1.0f-fadeto))+(1.0f-fadeto);
+ Image *temp=*images[absframe]*amount;
if (mode<0.5) (*image)+=*temp;
else (*image)=image->add_wrap(*temp);
delete temp;
}
- else (*image)+=*images[absframe];
+ else {
+ if (mode<0.5) (*image)+=*(images[absframe]);
+ else (*image)=image->add_wrap(*(images[absframe]));
+ }
}
}
//for (int i=0;i<frame.w*frame.h*3;i++){