X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Ffloatautos.C;h=95dcace9ce6d97288a6357a7e93512ec7a825eb6;hb=5621db270ccbeabc106e0f438941dba6f930652b;hp=04741afe145fabd6fdefc63b31daab1c641f7bb4;hpb=689228697484138300ce427a680d69f2e44595c3;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/cinelerra/floatautos.C b/cinelerra-5.1/cinelerra/floatautos.C index 04741afe..95dcace9 100644 --- a/cinelerra-5.1/cinelerra/floatautos.C +++ b/cinelerra-5.1/cinelerra/floatautos.C @@ -449,12 +449,10 @@ double FloatAutos::automation_integral(int64_t start, int64_t length, int direct length += start; start = 0; } - int64_t end = start + length; - double value = 0, track_length = track->get_length(); - int64_t pos = start, len = track->to_units(track_length,0); - if( end > len ) end = len; + double value = 0; + int64_t pos = start, len = length, end = pos + len; while( pos < end ) { - int64_t prev_pos = 0, next_pos = len; + int64_t prev_pos = 0, next_pos = end; Auto *zprev = 0, *znext = 0; FloatAuto *prev = (FloatAuto*)get_prev_auto(pos, direction, zprev, 0); if( prev ) prev_pos = prev->position; @@ -491,3 +489,17 @@ double FloatAutos::automation_integral(int64_t start, int64_t length, int direct return value + 1e-6; } +int64_t FloatAutos::speed_position(double pos) +{ + double length = track->get_length(); + int64_t l = -1, r = track->to_units(length, 1); + if( r < 1 ) r = 1; + for( int i=32; --i >= 0 && automation_integral(0,r,PLAY_FORWARD) <= pos; r*=2 ); + for( int i=64; --i >= 0 && (r-l)>1; ) { + int64_t m = (l + r) / 2; + double t = automation_integral(0,m,PLAY_FORWARD) - pos; + *(t >= 0 ? &r : &l) = m; + } + return r; +} +