Bump version.
[LameXP.git] / etc / Patches / deprecated / OpusTools-Git20130117-Progress+NoResample.diff
blob1f1540826137e88f4eb38b37db0caeb4edb76bd3
1 src/opusdec.c | 24 +++++++++++++++++++++---
2 src/opusenc.c | 17 +++++++----------
3 2 files changed, 134 insertions(+), 71 deletions(-)
5 diff --git a/src/opusdec.c b/src/opusdec.c
6 index 397ecb5..ade69fc 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 @@ -658,6 +659,7 @@ int main(int argc, char **argv)
18 {"force-wav", no_argument, NULL, 0},
19 {"packet-loss", required_argument, NULL, 0},
20 {"save-range", required_argument, NULL, 0},
21 + {"no-resample", no_argument, NULL, 0},
22 {0, 0, 0, 0}
24 ogg_sync_state oy;
25 @@ -667,6 +669,7 @@ int main(int argc, char **argv)
26 int close_in=0;
27 int eos=0;
28 ogg_int64_t audio_size=0;
29 + ogg_int64_t input_size=0;
30 double last_coded_seconds=0;
31 float loss_percent=-1;
32 float manual_gain=0;
33 @@ -681,6 +684,7 @@ int main(int argc, char **argv)
34 int dither=1;
35 shapestate shapemem;
36 SpeexResamplerState *resampler=NULL;
37 + int no_resample = 0;
38 float gain=1;
39 int streams=0;
40 size_t last_spin=0;
41 @@ -743,6 +747,9 @@ int main(int argc, char **argv)
42 } else if (strcmp(long_options[option_index].name,"rate")==0)
44 rate=atoi (optarg);
45 + } else if (strcmp(long_options[option_index].name,"no-resample")==0)
46 + {
47 + no_resample=1;
48 } else if (strcmp(long_options[option_index].name,"gain")==0)
50 manual_gain=atof (optarg);
51 @@ -824,6 +831,16 @@ int main(int argc, char **argv)
52 close_in=1;
55 + /*detect input size*/
56 + if(fin != stdin)
57 + {
58 + struct _stat64 info;
59 + if(_fstati64(_fileno(fin), &info) == 0)
60 + {
61 + input_size = info.st_size;
62 + }
63 + }
65 /* .opus files use the Ogg container to provide framing and timekeeping.
66 * http://tools.ietf.org/html/draft-terriberry-oggopus
67 * The easiest way to decode the Ogg container is to use libogg, so
68 @@ -914,7 +931,7 @@ int main(int argc, char **argv)
69 as described in the OggOpus spec. But for commandline tools
70 like opusdec it can be desirable to exactly preserve the original
71 sampling rate and duration, so we have a resampler here.*/
72 - if (rate != 48000)
73 + if ((rate != 48000) && (!no_resample))
75 int err;
76 resampler = speex_resampler_init(channels, 48000, rate, 5, &err);
77 @@ -971,10 +988,11 @@ int main(int argc, char **argv)
78 /*Display a progress spinner while decoding.*/
79 static const char spinner[]="|/-\\";
80 double coded_seconds = (double)audio_size/(channels*rate*sizeof(short));
81 + double percent = (input_size>0) ? ((double)ftello64(fin))/((double)input_size) : 0.0;
82 if(coded_seconds>=last_coded_seconds+1){
83 - fprintf(stderr,"\r[%c] %02d:%02d:%02d", spinner[last_spin&3],
84 + fprintf(stderr,"\r[%c] %02d:%02d:%02d (%.f%%)", spinner[last_spin&3],
85 (int)(coded_seconds/3600),(int)(coded_seconds/60)%60,
86 - (int)(coded_seconds)%60);
87 + (int)(coded_seconds)%60,percent*100.0);
88 fflush(stderr);
89 last_spin++;
90 last_coded_seconds=coded_seconds;
91 diff --git a/src/opusenc.c b/src/opusenc.c
92 index 749760a..2b472b0 100644
93 --- a/src/opusenc.c
94 +++ b/src/opusenc.c
95 @@ -954,6 +954,7 @@ int main(int argc, char **argv)
96 double estbitrate;
97 double coded_seconds=nb_encoded/(double)coding_rate;
98 double wall_time=(stop_time-start_time)+1e-6;
99 + double percent = 0.0;
100 char sbuf[55];
101 static const char spinner[]="|/-\\";
102 if(!with_hard_cbr){
103 @@ -961,20 +962,16 @@ int main(int argc, char **argv)
104 estbitrate=(total_bytes*8.0/coded_seconds)*tweight+
105 bitrate*(1.-tweight);
106 }else estbitrate=nbBytes*8*((double)coding_rate/frame_size);
107 + if(inopt.total_samples_per_channel>0){
108 + percent = ((double)nb_encoded) / ((double)inopt.total_samples_per_channel);
110 fprintf(stderr,"\r");
111 for(i=0;i<last_spin_len;i++)fprintf(stderr," ");
112 - if(inopt.total_samples_per_channel>0 && inopt.total_samples_per_channel<nb_encoded){
113 - snprintf(sbuf,54,"\r[%c] %02d%% ",spinner[last_spin&3],
114 - (int)floor(nb_encoded/(double)(inopt.total_samples_per_channel+inopt.skip)*100.));
115 - }else{
116 - snprintf(sbuf,54,"\r[%c] ",spinner[last_spin&3]);
118 - last_spin_len=strlen(sbuf);
119 - snprintf(sbuf+last_spin_len,54-last_spin_len,
120 - "%02d:%02d:%02d.%02d %4.3gx realtime, %5.4gkbit/s",
121 + snprintf(sbuf,54,"\r[%c] %02d:%02d:%02d.%02d (%.f%%) %4.3gx realtime, %5.4gkbit/s",
122 + spinner[last_spin&3],
123 (int)(coded_seconds/3600),(int)(coded_seconds/60)%60,
124 (int)(coded_seconds)%60,(int)(coded_seconds*100)%100,
125 - coded_seconds/wall_time,
126 + percent*100.0,coded_seconds/wall_time,
127 estbitrate/1000.);
128 fprintf(stderr,"%s",sbuf);
129 fflush(stderr);