1 src/opusdec.c | 17 +++++++++++++++--
2 src/opusenc.c | 8 ++++++--
3 2 files changed, 21 insertions(+), 4 deletions(-)
5 diff --git a/src/opusdec.c b/src/opusdec.c
6 index 5c35242..da23c97 100644
12 # define I64FORMAT "I64d"
13 +# define ftello64(_x) _ftelli64((_x))
15 # define I64FORMAT "lld"
16 # define fopen_utf8(_x,_y) fopen((_x),(_y))
17 @@ -645,6 +646,7 @@ int main(int argc, char **argv)
20 ogg_int64_t audio_size=0;
21 + ogg_int64_t input_size=0;
22 double last_coded_seconds=0;
23 float loss_percent=-1;
25 @@ -789,6 +791,16 @@ int main(int argc, char **argv)
29 + /*detect input size*/
32 + struct _stat64 info;
33 + if(_fstati64(_fileno(fin), &info) == 0)
35 + input_size = info.st_size;
39 /*Init Ogg data struct*/
42 @@ -911,10 +923,11 @@ int main(int argc, char **argv)
44 static const char spinner[]="|/-\\";
45 double coded_seconds = (double)audio_size/(channels*rate*sizeof(short));
46 + double percent = (input_size>0) ? ((double)ftello64(fin))/((double)input_size) : 0.0;
47 if(coded_seconds>=last_coded_seconds+1){
48 - fprintf(stderr,"\r[%c] %02d:%02d:%02d", spinner[last_spin&3],
49 + fprintf(stderr,"\r[%c] %02d:%02d:%02d (%.f%%)", spinner[last_spin&3],
50 (int)(coded_seconds/3600),(int)(coded_seconds/60)%60,
51 - (int)(coded_seconds)%60);
52 + (int)(coded_seconds)%60,percent*100.0);
55 last_coded_seconds=coded_seconds;
56 diff --git a/src/opusenc.c b/src/opusenc.c
57 index f6cc762..a34b340 100644
60 @@ -895,6 +895,7 @@ int main(int argc, char **argv)
62 double coded_seconds=nb_encoded/(double)coding_rate;
63 double wall_time=(stop_time-start_time)+1e-6;
64 + double percent = 0.0;
66 static const char spinner[]="|/-\\";
68 @@ -909,12 +910,15 @@ int main(int argc, char **argv)
70 snprintf(sbuf,54,"\r[%c] ",spinner[last_spin&3]);
72 + if(inopt.total_samples_per_channel>0){
73 + percent = ((double)nb_encoded) / ((double)inopt.total_samples_per_channel);
75 last_spin_len=strlen(sbuf);
76 snprintf(sbuf+last_spin_len,54-last_spin_len,
77 - "%02d:%02d:%02d.%02d %4.3gx realtime, %5.4gkbit/s\r",
78 + "%02d:%02d:%02d.%02d (%.f%%) %4.3gx realtime, %5.4gkbit/s\r",
79 (int)(coded_seconds/3600),(int)(coded_seconds/60)%60,
80 (int)(coded_seconds)%60,(int)(coded_seconds*100)%100,
81 - coded_seconds/wall_time,
82 + percent*100.0,coded_seconds/wall_time,
84 fprintf(stderr,"%s",sbuf);