| 3158 | } |
| 3159 | |
| 3160 | static void UpdateState( sync_common_t * common, int frame_count ) |
| 3161 | { |
| 3162 | hb_job_t * job = common->job; |
| 3163 | hb_state_t state; |
| 3164 | |
| 3165 | if (job->indepth_scan) |
| 3166 | { |
| 3167 | // Progress for indepth scan is handled by reader |
| 3168 | // frame_count is used during indepth_scan |
| 3169 | // to find start & end points. |
| 3170 | return; |
| 3171 | } |
| 3172 | |
| 3173 | if (frame_count == 0) |
| 3174 | { |
| 3175 | common->st_first = hb_get_date(); |
| 3176 | } |
| 3177 | |
| 3178 | if (hb_get_date() > common->st_dates[3] + 1000) |
| 3179 | { |
| 3180 | memmove( &common->st_dates[0], &common->st_dates[1], |
| 3181 | 3 * sizeof( uint64_t ) ); |
| 3182 | memmove( &common->st_counts[0], &common->st_counts[1], |
| 3183 | 3 * sizeof( uint64_t ) ); |
| 3184 | common->st_dates[3] = hb_get_date(); |
| 3185 | common->st_counts[3] = frame_count; |
| 3186 | } |
| 3187 | |
| 3188 | hb_get_state2(job->h, &state); |
| 3189 | state.state = HB_STATE_WORKING; |
| 3190 | |
| 3191 | #define p state.param.working |
| 3192 | p.progress = (float)frame_count / common->est_frame_count; |
| 3193 | if (p.progress > 1.0) |
| 3194 | { |
| 3195 | p.progress = 1.0; |
| 3196 | } |
| 3197 | p.rate_cur = 1000.0 * (common->st_counts[3] - common->st_counts[0]) / |
| 3198 | (common->st_dates[3] - common->st_dates[0]); |
| 3199 | if (hb_get_date() > common->st_first + 4000) |
| 3200 | { |
| 3201 | p.rate_avg = 1000.0 * common->st_counts[3] / |
| 3202 | (common->st_dates[3] - common->st_first - job->st_paused); |
| 3203 | if (common->est_frame_count >= common->st_counts[3]) |
| 3204 | { |
| 3205 | int eta = (common->est_frame_count - common->st_counts[3]) / p.rate_avg; |
| 3206 | p.eta_seconds = eta; |
| 3207 | p.hours = eta / 3600; |
| 3208 | p.minutes = (eta % 3600) / 60; |
| 3209 | p.seconds = eta % 60; |
| 3210 | } |
| 3211 | else |
| 3212 | { |
| 3213 | p.eta_seconds = 0; |
| 3214 | p.hours = -1; |
| 3215 | p.minutes = -1; |
| 3216 | p.seconds = -1; |
| 3217 | } |
no test coverage detected