X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.0%2Fguicast%2Fvicon.C;h=906fb6e938556377af762768e82dd8cd9428a823;hb=63c49c5fdda77aadc2d0addc26a6884aadec8542;hp=269c96a2b23c18438366aa774a6cf6642bcfa060;hpb=0c4a2f8b1eeef69a9fb35868e36c8772141e3c4b;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.0/guicast/vicon.C b/cinelerra-5.0/guicast/vicon.C index 269c96a2..906fb6e9 100644 --- a/cinelerra-5.0/guicast/vicon.C +++ b/cinelerra-5.0/guicast/vicon.C @@ -12,9 +12,10 @@ VIcon(int vw, int vh, double rate) { this->vw = vw; this->vh = vh; - this->period = 1000./rate; + this->frame_rate = rate; + this->cycle_start = 0; this->age = 0; - this->seq_no = 0; + this->seq_no = 0; this->in_use = 1; } @@ -73,6 +74,7 @@ VIconThread(BC_WindowBase *wdw, int vw, int vh) this->viewing = 0; draw_lock = new Condition(0, "VIconThread::draw_lock", 1); timer = new Timer(); + this->refresh_rate = VICON_RATE; done = 0; interrupted = 1; } @@ -175,14 +177,14 @@ ViewPopup *VIconThread::new_view_window(VFrame *frame) void VIconThread:: reset_images() { - for( int i=t_heap.size(); --i>=0; ) t_heap[i]->age = 0; + for( int i=t_heap.size(); --i>=0; ) t_heap[i]->reset(); timer->update(); img_dirty = win_dirty = 0; } -void VIconThread::add_vicon(VIcon *vip, double age) +void VIconThread::add_vicon(VIcon *vip) { - vip->age = age; + double age = vip->age; int i = t_heap.size(); t_heap.append(vip); for( int k; i>0 && ageage; i=k ) t_heap[i] = t_heap[k]; @@ -260,47 +262,51 @@ run() draw_lock->lock("VIconThread::run 0"); if( done ) break;; wdw->lock_window("BC_WindowBase::run 1"); - reset_images(); interrupted = 0; drawing_started(); - int64_t draw_flash = 0; - VIcon *first = 0; + reset_images(); + int64_t seq_no = 0, now = 0; + int64_t draw_flash = 1000 / refresh_rate; while( !interrupted ) { if( viewing != vicon ) update_view(); VIcon *next = low_vicon(); + while( next && next->age < draw_flash ) { + now = timer->get_difference(); + if( now >= draw_flash ) break; + draw(next); + if( !next->seq_no ) next->cycle_start = now; + int64_t ref_no = (now - next->cycle_start) / 1000. * refresh_rate; + int count = ref_no - next->seq_no; + if( count < 1 ) count = 1; + ref_no = next->seq_no + count; + next->age = next->cycle_start + 1000. * ref_no / refresh_rate; + if( !next->set_seq_no(ref_no) ) + next->age = now + 1000.; + add_vicon(next); + next = low_vicon(); + } if( !next ) break; - int64_t now = timer->get_difference(); - if( next == first || (draw_flash && now >= draw_flash) ) { - add_vicon(next, next->age); - if( !draw_flash ) draw_flash = now + 100; - else if( now >= draw_flash ) draw_flash = now + 1; - wdw->unlock_window(); - while( !interrupted ) { - now = timer->get_difference(); - int64_t ms = draw_flash - now; - if( ms <= 0 ) break; - if( ms > 100 ) ms = 100; - Timer::delay(ms); - } - wdw->lock_window("BC_WindowBase::run 2"); + add_vicon(next); + if( draw_flash < now+1 ) + draw_flash = now+1; + wdw->unlock_window(); + while( !interrupted ) { now = timer->get_difference(); - int64_t late = now - draw_flash; - if( late < 1000 ) flash(); - draw_flash = 0; - first = 0; - continue; + int64_t ms = draw_flash - now; + if( ms <= 0 ) break; + if( ms > 100 ) ms = 100; + Timer::delay(ms); } - if( !first ) first = next; - if( draw(next) && !draw_flash ) - draw_flash = next->age; + wdw->lock_window("BC_WindowBase::run 2"); now = timer->get_difference(); - int64_t late = now - next->age; - int count = late / next->period; - int nfrms = count > 0 ? count : 1; - if( !next->next_frame(nfrms) ) - next->age = now + 1000; - add_vicon(next, next->age); + int64_t late = now - draw_flash; + if( late < 1000 ) flash(); + int64_t ref_no = now / 1000. * refresh_rate; + int64_t count = ref_no - seq_no; + if( count < 1 ) count = 1; + seq_no += count; + draw_flash = seq_no * 1000. / refresh_rate; } if( viewing != vicon ) update_view();