OSDN Git Service

Updated Opus encoder/decoder libraries to v1.1.x and Opus-Tools to v0.1.6 (2013-03...
[lamexp/LameXP.git] / etc / Patches / OpusTools-Git20130312-Progress+NoResample.diff
1  src/opusdec.c        | 24 +++++++++++++++++++++---
2  src/opusenc.c        | 17 +++++++----------
3  win32/genversion.bat | 15 ---------------
4  win32/version.h      |  2 +-
5  4 files changed, 29 insertions(+), 29 deletions(-)
6
7 diff --git a/src/opusdec.c b/src/opusdec.c
8 index b23ae62..bfb2b68 100644
9 --- a/src/opusdec.c
10 +++ b/src/opusdec.c
11 @@ -57,6 +57,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}
25     };
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 @@ -682,6 +685,7 @@ int main(int argc, char **argv)
36     int dither=1;
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 @@ -743,7 +747,10 @@ int main(int argc, char **argv)
44              forcewav=1;
45           } else if (strcmp(long_options[option_index].name,"rate")==0)
46           {
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)
53           {
54              manual_gain=atof (optarg);
55 @@ -825,6 +832,16 @@ int main(int argc, char **argv)
56        close_in=1;
57     }
58  
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 +   }
68 +
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 @@ -989,10 +1006,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*sizeof(short));
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 b24f7c7..147bc07 100644
88 --- a/src/opusenc.c
89 +++ b/src/opusenc.c
90 @@ -968,6 +968,7 @@ int main(int argc, char **argv)
91          double estbitrate;
92          double coded_seconds=nb_encoded/(double)coding_rate;
93          double wall_time=(stop_time-start_time)+1e-6;
94 +        double percent = 0.0;
95          char sbuf[55];
96          static const char spinner[]="|/-\\";
97          if(!with_hard_cbr){
98 @@ -975,20 +976,16 @@ int main(int argc, char **argv)
99            estbitrate=(total_bytes*8.0/coded_seconds)*tweight+
100                        bitrate*(1.-tweight);
101          }else estbitrate=nbBytes*8*((double)coding_rate/frame_size);
102 +        if(inopt.total_samples_per_channel>0){
103 +          percent = ((double)nb_encoded) / ((double)inopt.total_samples_per_channel);
104 +        }
105          fprintf(stderr,"\r");
106          for(i=0;i<last_spin_len;i++)fprintf(stderr," ");
107 -        if(inopt.total_samples_per_channel>0 && inopt.total_samples_per_channel<nb_encoded){
108 -          snprintf(sbuf,54,"\r[%c] %02d%% ",spinner[last_spin&3],
109 -          (int)floor(nb_encoded/(double)(inopt.total_samples_per_channel+inopt.skip)*100.));
110 -        }else{
111 -          snprintf(sbuf,54,"\r[%c] ",spinner[last_spin&3]);
112 -        }
113 -        last_spin_len=strlen(sbuf);
114 -        snprintf(sbuf+last_spin_len,54-last_spin_len,
115 -          "%02d:%02d:%02d.%02d %4.3gx realtime, %5.4gkbit/s",
116 +        snprintf(sbuf,54,"\r[%c] %02d:%02d:%02d.%02d (%.f%%) %4.3gx realtime, %5.4gkbit/s",
117 +          spinner[last_spin&3],
118            (int)(coded_seconds/3600),(int)(coded_seconds/60)%60,
119            (int)(coded_seconds)%60,(int)(coded_seconds*100)%100,
120 -          coded_seconds/wall_time,
121 +          percent*100.0,coded_seconds/wall_time,
122            estbitrate/1000.);
123          fprintf(stderr,"%s",sbuf);
124          fflush(stderr);
125 diff --git a/win32/genversion.bat b/win32/genversion.bat
126 index 9bc6917..5388813 100644
127 --- a/win32/genversion.bat
128 +++ b/win32/genversion.bat
129 @@ -1,17 +1,2 @@
130  @echo off
131  
132 -for /f %%v in ('git describe --tags --match "v*"') do set version=%%v
133 -
134 -set version_out=#define %2 "%version%"
135 -
136 -echo %version_out% > %1_temp
137 -
138 -echo n | comp %1_temp %1 > NUL 2> NUL
139 -
140 -if not errorlevel 1 goto exit
141 -
142 -copy /y %1_temp %1
143 -
144 -:exit
145 -
146 -del %1_temp
147 diff --git a/win32/version.h b/win32/version.h
148 index 72d7eb6..71cbcf6 100644
149 --- a/win32/version.h
150 +++ b/win32/version.h
151 @@ -1 +1 @@
152 -#define VERSION "v0.1.6git"
153 +#define VERSION "v0.1.6 [2013-03-12]"