]>
iEval git - fdkaac.git/blob - src/progress.c
2 * Copyright (C) 2013 nu774
3 * For conditions of distribution and use, see copyright notice in COPYING
16 # include <inttypes.h>
17 #elif defined _MSC_VER
18 # define PRId64 "I64d"
24 void seconds_to_hms(double seconds
, int *h
, int *m
, int *s
, int *millis
)
26 *h
= (int)(seconds
/ 3600.0);
28 *m
= (int)(seconds
/ 60.0);
31 *millis
= (int)((seconds
- *s
) * 1000.0 + 0.5);
35 void print_seconds(FILE *fp
, double seconds
)
38 seconds_to_hms(seconds
, &h
, &m
, &s
, &millis
);
40 fprintf(stderr
, "%d:%02d:%02d.%03d", h
, m
, s
, millis
);
42 fprintf(stderr
, "%02d:%02d.%03d", m
, s
, millis
);
45 void aacenc_progress_init(aacenc_progress_t
*progress
, int64_t total
,
48 progress
->start
= aacenc_timer();
49 progress
->timescale
= timescale
;
50 progress
->total
= total
;
53 void aacenc_progress_update(aacenc_progress_t
*progress
, int64_t current
,
56 double seconds
= current
/ progress
->timescale
;
57 double ellapsed
= (aacenc_timer() - progress
->start
) / 1000.0;
58 double speed
= ellapsed
? seconds
/ ellapsed
: 1.0;
59 int percent
= progress
->total
? 100.0 * current
/ progress
->total
+ .5
61 double eta
= current
? ellapsed
* (progress
->total
/ (double)current
- 1.0)
62 : progress
->total
? DBL_MAX
: 0;
64 if (current
< progress
->processed
+ period
)
67 if (progress
->total
== INT64_MAX
) {
69 print_seconds(stderr
, seconds
);
70 fprintf(stderr
, " (%.0fx) ", speed
);
72 fprintf(stderr
, "\r[%d%%] ", percent
);
73 print_seconds(stderr
, seconds
);
75 print_seconds(stderr
, progress
->total
/ progress
->timescale
);
76 fprintf(stderr
, " (%.0fx), ETA ", speed
);
77 print_seconds(stderr
, eta
);
80 progress
->processed
= current
;
83 void aacenc_progress_finish(aacenc_progress_t
*progress
, int64_t current
)
85 double ellapsed
= (aacenc_timer() - progress
->start
) / 1000.0;
86 aacenc_progress_update(progress
, current
, 0);
87 if (progress
->total
== INT64_MAX
)
88 fprintf(stderr
, "\n%" PRId64
" samples processed in ", current
);
90 fprintf(stderr
, "\n%" PRId64
"/%" PRId64
" samples processed in ",
91 current
, progress
->total
);
92 print_seconds(stderr
, ellapsed
);
This page took 0.051923 seconds and 4 git commands to generate.