1 src/opusdec.c | 17 +++++++++++++++--
2 src/opusenc.c | 17 +++++++----------
3 2 files changed, 22 insertions(+), 12 deletions(-)
5 diff --git a/src/opusdec.c b/src/opusdec.c
6 index dcf487f..eb67961 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 @@ -653,6 +654,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 @@ -806,6 +808,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 /* .opus files use the Ogg container to provide framing and timekeeping.
40 * http://tools.ietf.org/html/draft-terriberry-oggopus
41 * The easiest way to decode the Ogg container is to use libogg, so
42 @@ -938,10 +950,11 @@ int main(int argc, char **argv)
43 /*Display a progress spinner while decoding.*/
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 0a27f32..0af8f40 100644
60 @@ -910,6 +910,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 @@ -917,20 +918,16 @@ int main(int argc, char **argv)
69 estbitrate=(total_bytes*8.0/coded_seconds)*tweight+
71 }else estbitrate=nbBytes*8*((double)coding_rate/frame_size);
72 + if(inopt.total_samples_per_channel>0){
73 + percent = ((double)nb_encoded) / ((double)inopt.total_samples_per_channel);
76 for(i=0;i<last_spin_len;i++)fprintf(stderr," ");
77 - if(inopt.total_samples_per_channel>0 && inopt.total_samples_per_channel<nb_encoded){
78 - snprintf(sbuf,54,"\r[%c] %02d%% ",spinner[last_spin&3],
79 - (int)floor(nb_encoded/(double)(inopt.total_samples_per_channel+inopt.skip)*100.));
81 - snprintf(sbuf,54,"\r[%c] ",spinner[last_spin&3]);
83 - last_spin_len=strlen(sbuf);
84 - snprintf(sbuf+last_spin_len,54-last_spin_len,
85 - "%02d:%02d:%02d.%02d %4.3gx realtime, %5.4gkbit/s",
86 + snprintf(sbuf,54,"\r[%c] %02d:%02d:%02d.%02d (%.f%%) %4.3gx realtime, %5.4gkbit/s",
87 + spinner[last_spin&3],
88 (int)(coded_seconds/3600),(int)(coded_seconds/60)%60,
89 (int)(coded_seconds)%60,(int)(coded_seconds*100)%100,
90 - coded_seconds/wall_time,
91 + percent*100.0,coded_seconds/wall_time,
93 fprintf(stderr,"%s",sbuf);