Bump version.
[LameXP.git] / etc / Patches / deprecated / OpusTools-Git20120724-Progress.diff
blob60a01ddc20cbe5a84fae90e6935d6879e45181d2
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
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 @@ -645,6 +646,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 @@ -789,6 +791,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 @@ -911,10 +923,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 f6cc762..a34b340 100644
58 --- a/src/opusenc.c
59 +++ b/src/opusenc.c
60 @@ -895,6 +895,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 @@ -909,12 +910,15 @@ int main(int argc, char **argv)
69 }else{
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);
74 + }
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,
83 estbitrate/1000.);
84 fprintf(stderr,"%s",sbuf);
85 fflush(stderr);