From 93ecd810cda833416353f66c88c67e06df8a7129 Mon Sep 17 00:00:00 2001 From: John Stebbins <jstebbins.hb@gmail.com> Date: Wed, 18 May 2016 09:46:20 -0600 Subject: sync: improve code readability --- libhb/sync.c | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/libhb/sync.c b/libhb/sync.c index 413011913..dd975e817 100644 --- a/libhb/sync.c +++ b/libhb/sync.c @@ -2356,14 +2356,6 @@ static void UpdateState( sync_common_t * common, int frame_count ) hb_job_t * job = common->job; hb_state_t state; - hb_get_state2(job->h, &state); - if (frame_count == 0) - { - common->st_first = hb_get_date(); - job->st_pause_date = -1; - job->st_paused = 0; - } - if (job->indepth_scan) { // Progress for indept scan is handled by reader @@ -2372,6 +2364,13 @@ static void UpdateState( sync_common_t * common, int frame_count ) return; } + if (frame_count == 0) + { + common->st_first = hb_get_date(); + job->st_pause_date = -1; + job->st_paused = 0; + } + if (hb_get_date() > common->st_dates[3] + 1000) { memmove( &common->st_dates[0], &common->st_dates[1], @@ -2382,8 +2381,10 @@ static void UpdateState( sync_common_t * common, int frame_count ) common->st_counts[3] = frame_count; } -#define p state.param.working + hb_get_state2(job->h, &state); state.state = HB_STATE_WORKING; + +#define p state.param.working p.progress = (float)frame_count / common->est_frame_count; if (p.progress > 1.0) { @@ -2421,14 +2422,6 @@ static void UpdateSearchState( sync_common_t * common, int64_t start, uint64_t now; double avg; - now = hb_get_date(); - if (frame_count == 0) - { - common->st_first = now; - job->st_pause_date = -1; - job->st_paused = 0; - } - if (job->indepth_scan) { // Progress for indept scan is handled by reader @@ -2437,10 +2430,18 @@ static void UpdateSearchState( sync_common_t * common, int64_t start, return; } + now = hb_get_date(); + if (frame_count == 0) + { + common->st_first = now; + job->st_pause_date = -1; + job->st_paused = 0; + } + hb_get_state2(job->h, &state); + state.state = HB_STATE_SEARCHING; #define p state.param.working - state.state = HB_STATE_SEARCHING; if (job->frame_to_start) p.progress = (float)frame_count / job->frame_to_start; else if (job->pts_to_start) -- cgit v1.2.3