X-Git-Url: http://git.cinelerra-gg.org/git/?p=goodguy%2Fhistory.git;a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Ffloatautos.C;h=95dcace9ce6d97288a6357a7e93512ec7a825eb6;hp=4ee1d4070702542362fcf360577d4729f00d91c2;hb=502b6f3b6fd04f6b01c6d70dcb81aa304dd0db1c;hpb=0c36fdb4fc4d4a2efe353e2b6eb0bf5a1b1485d6 diff --git a/cinelerra-5.1/cinelerra/floatautos.C b/cinelerra-5.1/cinelerra/floatautos.C index 4ee1d407..95dcace9 100644 --- a/cinelerra-5.1/cinelerra/floatautos.C +++ b/cinelerra-5.1/cinelerra/floatautos.C @@ -449,16 +449,14 @@ 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; - FloatAuto *prev = 0, *next = 0; - prev = (FloatAuto*)get_prev_auto(pos, direction, (Auto* &)prev, 0); + 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; - next = (FloatAuto*)get_next_auto(pos, direction, (Auto* &)next, 0); + FloatAuto *next = (FloatAuto*)get_next_auto(pos, direction, znext, 0); if( next ) next_pos = next->position; if( !prev && !next ) prev = next = (FloatAuto*)default_auto; else if( !prev ) prev = next; @@ -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; +} +