2012-08-05 22:40:56 +02:00
|
|
|
diff --git a/src/opusdec.c b/src/opusdec.c
|
2013-06-16 22:06:58 +02:00
|
|
|
index 2ed4ba3..b104954 100644
|
2012-08-05 22:40:56 +02:00
|
|
|
--- a/src/opusdec.c
|
|
|
|
+++ b/src/opusdec.c
|
2013-06-16 22:06:58 +02:00
|
|
|
@@ -53,6 +53,7 @@
|
2012-08-05 22:40:56 +02:00
|
|
|
# include <io.h>
|
|
|
|
# include <fcntl.h>
|
|
|
|
# define I64FORMAT "I64d"
|
|
|
|
+# define ftello64(_x) _ftelli64((_x))
|
|
|
|
#else
|
|
|
|
# define I64FORMAT "lld"
|
|
|
|
# define fopen_utf8(_x,_y) fopen((_x),(_y))
|
2013-06-16 22:06:58 +02:00
|
|
|
@@ -653,6 +654,7 @@ int main(int argc, char **argv)
|
2013-01-17 20:46:07 +01:00
|
|
|
{"force-wav", no_argument, NULL, 0},
|
|
|
|
{"packet-loss", required_argument, NULL, 0},
|
|
|
|
{"save-range", required_argument, NULL, 0},
|
|
|
|
+ {"no-resample", no_argument, NULL, 0},
|
|
|
|
{0, 0, 0, 0}
|
|
|
|
};
|
|
|
|
ogg_sync_state oy;
|
2013-06-16 22:06:58 +02:00
|
|
|
@@ -662,6 +664,7 @@ int main(int argc, char **argv)
|
2012-08-05 22:40:56 +02:00
|
|
|
int close_in=0;
|
|
|
|
int eos=0;
|
|
|
|
ogg_int64_t audio_size=0;
|
|
|
|
+ ogg_int64_t input_size=0;
|
|
|
|
double last_coded_seconds=0;
|
|
|
|
float loss_percent=-1;
|
|
|
|
float manual_gain=0;
|
2013-06-16 22:06:58 +02:00
|
|
|
@@ -677,6 +680,7 @@ int main(int argc, char **argv)
|
2013-01-17 20:46:07 +01:00
|
|
|
int dither=1;
|
|
|
|
shapestate shapemem;
|
|
|
|
SpeexResamplerState *resampler=NULL;
|
|
|
|
+ int no_resample = 0;
|
|
|
|
float gain=1;
|
|
|
|
int streams=0;
|
|
|
|
size_t last_spin=0;
|
2013-06-16 22:06:58 +02:00
|
|
|
@@ -738,7 +742,10 @@ int main(int argc, char **argv)
|
2013-01-18 01:08:58 +01:00
|
|
|
forcewav=1;
|
2013-01-17 20:46:07 +01:00
|
|
|
} else if (strcmp(long_options[option_index].name,"rate")==0)
|
|
|
|
{
|
2013-01-18 01:08:58 +01:00
|
|
|
- rate=atoi (optarg);
|
|
|
|
+ rate=((no_resample) ? 48000 : atoi(optarg));
|
2013-01-17 20:46:07 +01:00
|
|
|
+ } else if (strcmp(long_options[option_index].name,"no-resample")==0)
|
|
|
|
+ {
|
2013-01-18 01:08:58 +01:00
|
|
|
+ no_resample=1; rate=48000;
|
2013-01-17 20:46:07 +01:00
|
|
|
} else if (strcmp(long_options[option_index].name,"gain")==0)
|
|
|
|
{
|
|
|
|
manual_gain=atof (optarg);
|
2013-06-16 22:06:58 +02:00
|
|
|
@@ -820,6 +827,16 @@ int main(int argc, char **argv)
|
2012-08-05 22:40:56 +02:00
|
|
|
close_in=1;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ /*detect input size*/
|
|
|
|
+ if(fin != stdin)
|
|
|
|
+ {
|
|
|
|
+ struct _stat64 info;
|
|
|
|
+ if(_fstati64(_fileno(fin), &info) == 0)
|
|
|
|
+ {
|
|
|
|
+ input_size = info.st_size;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
2012-08-17 22:10:46 +02:00
|
|
|
/* .opus files use the Ogg container to provide framing and timekeeping.
|
|
|
|
* http://tools.ietf.org/html/draft-terriberry-oggopus
|
|
|
|
* The easiest way to decode the Ogg container is to use libogg, so
|
2013-06-16 22:06:58 +02:00
|
|
|
@@ -984,10 +1001,11 @@ int main(int argc, char **argv)
|
2012-08-17 22:10:46 +02:00
|
|
|
/*Display a progress spinner while decoding.*/
|
2012-08-05 22:40:56 +02:00
|
|
|
static const char spinner[]="|/-\\";
|
|
|
|
double coded_seconds = (double)audio_size/(channels*rate*sizeof(short));
|
|
|
|
+ double percent = (input_size>0) ? ((double)ftello64(fin))/((double)input_size) : 0.0;
|
|
|
|
if(coded_seconds>=last_coded_seconds+1){
|
|
|
|
- fprintf(stderr,"\r[%c] %02d:%02d:%02d", spinner[last_spin&3],
|
|
|
|
+ fprintf(stderr,"\r[%c] %02d:%02d:%02d (%.f%%)", spinner[last_spin&3],
|
|
|
|
(int)(coded_seconds/3600),(int)(coded_seconds/60)%60,
|
|
|
|
- (int)(coded_seconds)%60);
|
|
|
|
+ (int)(coded_seconds)%60,percent*100.0);
|
|
|
|
fflush(stderr);
|
|
|
|
last_spin++;
|
|
|
|
last_coded_seconds=coded_seconds;
|
|
|
|
diff --git a/src/opusenc.c b/src/opusenc.c
|
2013-06-16 22:06:58 +02:00
|
|
|
index a2355d8..2f13414 100644
|
2012-08-05 22:40:56 +02:00
|
|
|
--- a/src/opusenc.c
|
|
|
|
+++ b/src/opusenc.c
|
2013-06-16 22:06:58 +02:00
|
|
|
@@ -1047,6 +1047,7 @@ int main(int argc, char **argv)
|
2012-08-05 22:40:56 +02:00
|
|
|
double estbitrate;
|
|
|
|
double coded_seconds=nb_encoded/(double)coding_rate;
|
|
|
|
double wall_time=(stop_time-start_time)+1e-6;
|
|
|
|
+ double percent = 0.0;
|
|
|
|
char sbuf[55];
|
|
|
|
static const char spinner[]="|/-\\";
|
|
|
|
if(!with_hard_cbr){
|
2013-06-16 22:06:58 +02:00
|
|
|
@@ -1054,20 +1055,16 @@ int main(int argc, char **argv)
|
2012-08-05 22:40:56 +02:00
|
|
|
estbitrate=(total_bytes*8.0/coded_seconds)*tweight+
|
|
|
|
bitrate*(1.-tweight);
|
|
|
|
}else estbitrate=nbBytes*8*((double)coding_rate/frame_size);
|
|
|
|
+ if(inopt.total_samples_per_channel>0){
|
|
|
|
+ percent = ((double)nb_encoded) / ((double)inopt.total_samples_per_channel);
|
|
|
|
+ }
|
|
|
|
fprintf(stderr,"\r");
|
|
|
|
for(i=0;i<last_spin_len;i++)fprintf(stderr," ");
|
|
|
|
- if(inopt.total_samples_per_channel>0 && inopt.total_samples_per_channel<nb_encoded){
|
|
|
|
- snprintf(sbuf,54,"\r[%c] %02d%% ",spinner[last_spin&3],
|
|
|
|
- (int)floor(nb_encoded/(double)(inopt.total_samples_per_channel+inopt.skip)*100.));
|
|
|
|
- }else{
|
|
|
|
- snprintf(sbuf,54,"\r[%c] ",spinner[last_spin&3]);
|
|
|
|
- }
|
|
|
|
- last_spin_len=strlen(sbuf);
|
|
|
|
- snprintf(sbuf+last_spin_len,54-last_spin_len,
|
|
|
|
- "%02d:%02d:%02d.%02d %4.3gx realtime, %5.4gkbit/s",
|
|
|
|
+ snprintf(sbuf,54,"\r[%c] %02d:%02d:%02d.%02d (%.f%%) %4.3gx realtime, %5.4gkbit/s",
|
|
|
|
+ spinner[last_spin&3],
|
|
|
|
(int)(coded_seconds/3600),(int)(coded_seconds/60)%60,
|
|
|
|
(int)(coded_seconds)%60,(int)(coded_seconds*100)%100,
|
|
|
|
- coded_seconds/wall_time,
|
|
|
|
+ percent*100.0,coded_seconds/wall_time,
|
|
|
|
estbitrate/1000.);
|
|
|
|
fprintf(stderr,"%s",sbuf);
|
|
|
|
fflush(stderr);
|