diff options
author | jstebbins <[email protected]> | 2009-11-07 17:29:03 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2009-11-07 17:29:03 +0000 |
commit | ccca5789382f571a21edf068549a5bf85dfbbda4 (patch) | |
tree | 361668f605bad25a3022c42b186f30cddbdd34b0 /libhb | |
parent | 953bf32afdef1656cc22c3ab973b32cc4b2b78f0 (diff) |
Maintain an accurate job ETA across pause/resume
Keeps track of how much time is spent paused and factors that into
the ETA calculation
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2918 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb')
-rw-r--r-- | libhb/common.h | 3 | ||||
-rw-r--r-- | libhb/hb.c | 9 | ||||
-rw-r--r-- | libhb/sync.c | 4 |
3 files changed, 15 insertions, 1 deletions
diff --git a/libhb/common.h b/libhb/common.h index 15ab737bd..b6c5e5714 100644 --- a/libhb/common.h +++ b/libhb/common.h @@ -277,6 +277,9 @@ struct hb_job_s volatile int * die; volatile int done; + uint64_t st_pause_date; + uint64_t st_paused; + hb_fifo_t * fifo_mpeg2; /* MPEG-2 video ES */ hb_fifo_t * fifo_raw; /* Raw pictures */ hb_fifo_t * fifo_sync; /* Raw pictures, framerate corrected */ diff --git a/libhb/hb.c b/libhb/hb.c index 898650ac2..34fe53b72 100644 --- a/libhb/hb.c +++ b/libhb/hb.c @@ -1195,6 +1195,8 @@ void hb_pause( hb_handle_t * h ) hb_lock( h->pause_lock ); h->paused = 1; + hb_current_job( h )->st_pause_date = hb_get_date(); + hb_lock( h->state_lock ); h->state.state = HB_STATE_PAUSED; hb_unlock( h->state_lock ); @@ -1209,6 +1211,13 @@ void hb_resume( hb_handle_t * h ) { if( h->paused ) { +#define job hb_current_job( h ) + if( job->st_pause_date != -1 ) + { + job->st_paused += hb_get_date() - job->st_pause_date; + } +#undef job + hb_unlock( h->pause_lock ); h->paused = 0; } diff --git a/libhb/sync.c b/libhb/sync.c index 514b1fb43..94b8411b4 100644 --- a/libhb/sync.c +++ b/libhb/sync.c @@ -973,6 +973,8 @@ static void UpdateState( hb_work_object_t * w ) if( !pv->count_frames ) { pv->st_first = hb_get_date(); + pv->job->st_pause_date = -1; + pv->job->st_paused = 0; } pv->count_frames++; @@ -1000,7 +1002,7 @@ static void UpdateState( hb_work_object_t * w ) { int eta; p.rate_avg = 1000.0 * (float) pv->st_counts[3] / - (float) ( pv->st_dates[3] - pv->st_first ); + (float) ( pv->st_dates[3] - pv->st_first - pv->job->st_paused); eta = (float) ( pv->count_frames_max - pv->st_counts[3] ) / p.rate_avg; p.hours = eta / 3600; |