Updated Opus encoder/decoder libraries v1.1.3-Git and Opus-Tools to v0.1.9-Git (2016...
[LameXP.git] / etc / Patches / deprecated / OpusTools-v0.1.9-Progress+NoResample.V3.diff
blobb9ec196fad9db6e01f68cea60ae71fddebe7e754
1 src/opusdec.c | 24 +++++++++++++++++++++---
2 src/opusenc.c | 18 ++++++++----------
3 win32/config.h | 6 +++++-
4 win32/version.h | 6 +++++-
5 4 files changed, 39 insertions(+), 15 deletions(-)
7 diff --git a/src/opusdec.c b/src/opusdec.c
8 index d085f04..92027fe 100644
9 --- a/src/opusdec.c
10 +++ b/src/opusdec.c
11 @@ -53,6 +53,7 @@
12 # include <io.h>
13 # include <fcntl.h>
14 # define I64FORMAT "I64d"
15 +# define ftello64(_x) _ftelli64((_x))
16 #else
17 # define I64FORMAT "lld"
18 # define fopen_utf8(_x,_y) fopen((_x),(_y))
19 @@ -658,6 +659,7 @@ int main(int argc, char **argv)
20 {"force-wav", no_argument, NULL, 0},
21 {"packet-loss", required_argument, NULL, 0},
22 {"save-range", required_argument, NULL, 0},
23 + {"no-resample", no_argument, NULL, 0},
24 {0, 0, 0, 0}
26 ogg_sync_state oy;
27 @@ -667,6 +669,7 @@ int main(int argc, char **argv)
28 int close_in=0;
29 int eos=0;
30 ogg_int64_t audio_size=0;
31 + ogg_int64_t input_size=0;
32 double last_coded_seconds=0;
33 float loss_percent=-1;
34 float manual_gain=0;
35 @@ -683,6 +686,7 @@ int main(int argc, char **argv)
36 int fp=0;
37 shapestate shapemem;
38 SpeexResamplerState *resampler=NULL;
39 + int no_resample = 0;
40 float gain=1;
41 int streams=0;
42 size_t last_spin=0;
43 @@ -747,7 +751,10 @@ int main(int argc, char **argv)
44 forcewav=1;
45 } else if (strcmp(long_options[option_index].name,"rate")==0)
47 - rate=atoi (optarg);
48 + rate=((no_resample) ? 48000 : atoi(optarg));
49 + } else if (strcmp(long_options[option_index].name,"no-resample")==0)
50 + {
51 + no_resample=1; rate=48000;
52 } else if (strcmp(long_options[option_index].name,"gain")==0)
54 manual_gain=atof (optarg);
55 @@ -833,6 +840,16 @@ int main(int argc, char **argv)
56 close_in=1;
59 + /*detect input size*/
60 + if(fin != stdin)
61 + {
62 + struct _stat64 info;
63 + if(_fstati64(_fileno(fin), &info) == 0)
64 + {
65 + input_size = info.st_size;
66 + }
67 + }
69 /* .opus files use the Ogg container to provide framing and timekeeping.
70 * http://tools.ietf.org/html/draft-terriberry-oggopus
71 * The easiest way to decode the Ogg container is to use libogg, so
72 @@ -1011,10 +1028,11 @@ int main(int argc, char **argv)
73 /*Display a progress spinner while decoding.*/
74 static const char spinner[]="|/-\\";
75 double coded_seconds = (double)audio_size/(channels*rate*(fp?4:2));
76 + double percent = (input_size>0) ? ((double)ftello64(fin))/((double)input_size) : 0.0;
77 if(coded_seconds>=last_coded_seconds+1){
78 - fprintf(stderr,"\r[%c] %02d:%02d:%02d", spinner[last_spin&3],
79 + fprintf(stderr,"\r[%c] %02d:%02d:%02d (%.f%%)", spinner[last_spin&3],
80 (int)(coded_seconds/3600),(int)(coded_seconds/60)%60,
81 - (int)(coded_seconds)%60);
82 + (int)(coded_seconds)%60, percent*100.0);
83 fflush(stderr);
84 last_spin++;
85 last_coded_seconds=coded_seconds;
86 diff --git a/src/opusenc.c b/src/opusenc.c
87 index 0f83194..6e21a0f 100644
88 --- a/src/opusenc.c
89 +++ b/src/opusenc.c
90 @@ -41,6 +41,7 @@
91 #include <time.h>
92 #endif
93 #include <math.h>
94 +#include <time.h>
96 #ifdef _MSC_VER
97 #define snprintf _snprintf
98 @@ -1027,6 +1028,7 @@ int main(int argc, char **argv)
99 double estbitrate;
100 double coded_seconds=nb_encoded/(double)coding_rate;
101 double wall_time=(stop_time-start_time)+1e-6;
102 + double percent = 0.0;
103 char sbuf[55];
104 static const char spinner[]="|/-\\";
105 if(!with_hard_cbr){
106 @@ -1034,20 +1036,16 @@ int main(int argc, char **argv)
107 estbitrate=(total_bytes*8.0/coded_seconds)*tweight+
108 bitrate*(1.-tweight);
109 }else estbitrate=nbBytes*8*((double)coding_rate/frame_size);
110 + if(inopt.total_samples_per_channel>0){
111 + percent = ((double)nb_encoded) / ((double)inopt.total_samples_per_channel);
113 fprintf(stderr,"\r");
114 for(i=0;i<last_spin_len;i++)fprintf(stderr," ");
115 - if(inopt.total_samples_per_channel>0 && inopt.total_samples_per_channel<nb_encoded){
116 - snprintf(sbuf,54,"\r[%c] %02d%% ",spinner[last_spin&3],
117 - (int)floor(nb_encoded/(double)(inopt.total_samples_per_channel+inopt.skip)*100.));
118 - }else{
119 - snprintf(sbuf,54,"\r[%c] ",spinner[last_spin&3]);
121 - last_spin_len=strlen(sbuf);
122 - snprintf(sbuf+last_spin_len,54-last_spin_len,
123 - "%02d:%02d:%02d.%02d %4.3gx realtime, %5.4gkbit/s",
124 + snprintf(sbuf,54,"\r[%c] %02d:%02d:%02d.%02d (%.f%%) %4.3gx realtime, %5.4gkbit/s",
125 + spinner[last_spin&3],
126 (int)(coded_seconds/3600),(int)(coded_seconds/60)%60,
127 (int)(coded_seconds)%60,(int)(coded_seconds*100)%100,
128 - coded_seconds/wall_time,
129 + percent*100.0,coded_seconds/wall_time,
130 estbitrate/1000.);
131 fprintf(stderr,"%s",sbuf);
132 fflush(stderr);
133 diff --git a/win32/config.h b/win32/config.h
134 index 5a1e250..8b435cd 100644
135 --- a/win32/config.h
136 +++ b/win32/config.h
137 @@ -10,7 +10,11 @@
138 #define USE_ALLOCA 1
139 #define FLOATING_POINT 1
140 #define SPX_RESAMPLE_EXPORT
141 -#define __SSE__
143 +/* Enable SSE functions, if compiled with SSE/SSE2 (note that AMD64 implies SSE2) */
144 +#if defined(_M_X64) || (defined(_M_IX86_FP) && (_M_IX86_FP >= 1))
145 +#define __SSE__ 1
146 +#endif
148 #define RANDOM_PREFIX foo
150 diff --git a/win32/version.h b/win32/version.h
151 index 892cbc1..a7a8d8d 100644
152 --- a/win32/version.h
153 +++ b/win32/version.h
154 @@ -1 +1,5 @@
155 -#define PACKAGE_VERSION "v0.1.9"
156 +#if defined(__SSE__) && __SSE__
157 +#define PACKAGE_VERSION "v0.1.9-git SSE2 [2015-03-26]"
158 +#else
159 +#define PACKAGE_VERSION "v0.1.9-git IA32 [2015-03-26]"
160 +#endif