Bump version.
[LameXP.git] / etc / Patches / OpusTools-Git20120805-Progress.diff
blob813d7659c5148a7bba4122b0f78af7077707bc85
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 fd52b2b..3f685d4 100644
7 --- a/src/opusdec.c
8 +++ b/src/opusdec.c
9 @@ -57,6 +57,7 @@
10 # include <io.h>
11 # include <fcntl.h>
12 # define I64FORMAT "I64d"
13 +# define ftello64(_x) _ftelli64((_x))
14 #else
15 # define I64FORMAT "lld"
16 # define fopen_utf8(_x,_y) fopen((_x),(_y))
17 @@ -646,6 +647,7 @@ int main(int argc, char **argv)
18 int close_in=0;
19 int eos=0;
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;
24 float manual_gain=0;
25 @@ -797,6 +799,16 @@ int main(int argc, char **argv)
26 close_in=1;
29 + /*detect input size*/
30 + if(fin != stdin)
31 + {
32 + struct _stat64 info;
33 + if(_fstati64(_fileno(fin), &info) == 0)
34 + {
35 + input_size = info.st_size;
36 + }
37 + }
39 /*Init Ogg data struct*/
40 ogg_sync_init(&oy);
42 @@ -919,10 +931,11 @@ int main(int argc, char **argv)
43 if(!quiet){
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);
53 fflush(stderr);
54 last_spin++;
55 last_coded_seconds=coded_seconds;
56 diff --git a/src/opusenc.c b/src/opusenc.c
57 index 3051bee..0a5bc4f 100644
58 --- a/src/opusenc.c
59 +++ b/src/opusenc.c
60 @@ -910,6 +910,7 @@ int main(int argc, char **argv)
61 double estbitrate;
62 double coded_seconds=nb_encoded/(double)coding_rate;
63 double wall_time=(stop_time-start_time)+1e-6;
64 + double percent = 0.0;
65 char sbuf[55];
66 static const char spinner[]="|/-\\";
67 if(!with_hard_cbr){
68 @@ -917,20 +918,16 @@ int main(int argc, char **argv)
69 estbitrate=(total_bytes*8.0/coded_seconds)*tweight+
70 bitrate*(1.-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);
74 + }
75 fprintf(stderr,"\r");
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.));
80 - }else{
81 - snprintf(sbuf,54,"\r[%c] ",spinner[last_spin&3]);
82 - }
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,
92 estbitrate/1000.);
93 fprintf(stderr,"%s",sbuf);
94 fflush(stderr);