]>
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
14 # include <inttypes.h>
15 #elif defined _MSC_VER
16 # define PRId64 "I64d"
22 void seconds_to_hms(double seconds
, int *h
, int *m
, int *s
, int *millis
)
24 *h
= (int)(seconds
/ 3600.0);
26 *m
= (int)(seconds
/ 60.0);
29 *millis
= (int)((seconds
- *s
) * 1000.0 + 0.5);
33 void print_seconds(FILE *fp
, double seconds
)
36 seconds_to_hms(seconds
, &h
, &m
, &s
, &millis
);
38 fprintf(stderr
, "%d:%02d:%02d.%03d", h
, m
, s
, millis
);
40 fprintf(stderr
, "%02d:%02d.%03d", m
, s
, millis
);
43 void aacenc_progress_init(aacenc_progress_t
*progress
, int64_t total
,
46 progress
->start
= aacenc_timer();
47 progress
->timescale
= timescale
;
48 progress
->total
= total
;
51 void aacenc_progress_update(aacenc_progress_t
*progress
, int64_t current
,
54 int percent
= 100.0 * current
/ progress
->total
+ .5;
55 double seconds
= current
/ progress
->timescale
;
56 double ellapsed
= (aacenc_timer() - progress
->start
) / 1000.0;
57 double eta
= ellapsed
* (progress
->total
/ (double)current
- 1.0);
58 double speed
= ellapsed
? seconds
/ ellapsed
: 0.0;
59 if (current
< progress
->processed
+ period
)
62 if (progress
->total
== INT64_MAX
) {
64 print_seconds(stderr
, seconds
);
65 fprintf(stderr
, " (%.0fx) ", speed
);
67 fprintf(stderr
, "\r[%d%%] ", percent
);
68 print_seconds(stderr
, seconds
);
70 print_seconds(stderr
, progress
->total
/ progress
->timescale
);
71 fprintf(stderr
, " (%.0fx), ETA ", speed
);
72 print_seconds(stderr
, eta
);
75 progress
->processed
= current
;
78 void aacenc_progress_finish(aacenc_progress_t
*progress
, int64_t current
)
80 double ellapsed
= (aacenc_timer() - progress
->start
) / 1000.0;
81 aacenc_progress_update(progress
, current
, 0);
82 if (progress
->total
== INT64_MAX
)
83 fprintf(stderr
, "\n%" PRId64
"samples processed in ", current
);
85 fprintf(stderr
, "\n%" PRId64
"/%" PRId64
" samples processed in ",
86 current
, progress
->total
);
87 print_seconds(stderr
, ellapsed
);
This page took 0.051348 seconds and 4 git commands to generate.