src/opusdec.c | 24 +++++++++++++++++++++--- src/opusenc.c | 18 ++++++++---------- win32/config.h | 16 +++++++++++++++- win32/genversion.bat | 1 + 4 files changed, 45 insertions(+), 14 deletions(-) diff --git a/src/opusdec.c b/src/opusdec.c index 7e51f7a..cced424 100644 --- a/src/opusdec.c +++ b/src/opusdec.c @@ -53,6 +53,7 @@ # include # include # define I64FORMAT "I64d" +# define ftello64(_x) _ftelli64((_x)) #else # define I64FORMAT "lld" # define fopen_utf8(_x,_y) fopen((_x),(_y)) @@ -658,6 +659,7 @@ int main(int argc, char **argv) {"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; @@ -667,6 +669,7 @@ int main(int argc, char **argv) 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; @@ -683,6 +686,7 @@ int main(int argc, char **argv) int fp=0; shapestate shapemem; SpeexResamplerState *resampler=NULL; + int no_resample = 0; float gain=1; int streams=0; size_t last_spin=0; @@ -747,7 +751,10 @@ int main(int argc, char **argv) forcewav=1; } else if (strcmp(long_options[option_index].name,"rate")==0) { - rate=atoi (optarg); + rate=((no_resample) ? 48000 : atoi(optarg)); + } else if (strcmp(long_options[option_index].name,"no-resample")==0) + { + no_resample=1; rate=48000; } else if (strcmp(long_options[option_index].name,"gain")==0) { manual_gain=atof (optarg); @@ -833,6 +840,16 @@ int main(int argc, char **argv) close_in=1; } + /*detect input size*/ + if(fin != stdin) + { + struct _stat64 info; + if(_fstati64(_fileno(fin), &info) == 0) + { + input_size = info.st_size; + } + } + /* .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 @@ -1011,10 +1028,11 @@ int main(int argc, char **argv) /*Display a progress spinner while decoding.*/ static const char spinner[]="|/-\\"; double coded_seconds = (double)audio_size/(channels*rate*(fp?4:2)); + 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 index 129dcdb..43b7273 100644 --- a/src/opusenc.c +++ b/src/opusenc.c @@ -41,6 +41,7 @@ #include #endif #include +#include #ifdef _MSC_VER #define snprintf _snprintf @@ -1032,6 +1033,7 @@ int main(int argc, char **argv) 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){ @@ -1039,20 +1041,16 @@ int main(int argc, char **argv) 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;i0 && nb_encoded= 1)) +#define __SSE__ 1 +#endif +#if defined(_M_X64) || (defined(_M_IX86_FP) && (_M_IX86_FP >= 2)) +#define __SSE2__ 1 +#endif + +#ifdef __SSE__ +#pragma message( "SSE code is enabled!" ) +#endif +#ifdef __SSE2__ +#pragma message( "SSE2 code is enabled!" ) +#endif #define RANDOM_PREFIX opustools diff --git a/win32/genversion.bat b/win32/genversion.bat index 1def746..64b0a5e 100644 --- a/win32/genversion.bat +++ b/win32/genversion.bat @@ -1,4 +1,5 @@ @echo off +goto:eof setlocal enableextensions enabledelayedexpansion