mirror of
https://github.com/claunia/cuetools.net.git
synced 2025-12-16 18:14:25 +00:00
reorganizing a bit
This commit is contained in:
@@ -35,32 +35,32 @@ namespace CUETools.FlaCudaExe
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("Options:");
|
||||
Console.WriteLine();
|
||||
Console.WriteLine(" -0 .. -11 Compression level, default 5.");
|
||||
Console.WriteLine(" -o <file> Output filename, or \"-\" for stdout, or nul.");
|
||||
Console.WriteLine(" -p # Padding bytes.");
|
||||
Console.WriteLine(" -q --quiet Quiet mode.");
|
||||
Console.WriteLine(" --verify Verify during encoding.");
|
||||
Console.WriteLine(" --no-md5 Don't compute MD5 hash.");
|
||||
Console.WriteLine(" --no-seektable Don't generate a seektable.");
|
||||
Console.WriteLine(" --gpu-only Do everything on GPU.");
|
||||
Console.WriteLine(" --cpu-threads Use additional CPU threads.");
|
||||
Console.WriteLine(" -0 .. -11 Compression level, default 7; 9..11 are non-subset");
|
||||
Console.WriteLine(" -o <file> Output filename, or \"-\" for stdout, or nul");
|
||||
Console.WriteLine(" -p # Padding bytes");
|
||||
Console.WriteLine(" -q --quiet Quiet mode");
|
||||
Console.WriteLine(" --verify Verify during encoding");
|
||||
Console.WriteLine(" --no-md5 Don't compute MD5 hash");
|
||||
Console.WriteLine(" --no-seektable Don't generate a seektable");
|
||||
Console.WriteLine(" --slow-gpu Some encoding stages are done on CPU");
|
||||
Console.WriteLine(" --cpu-threads Use additional CPU threads");
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("Advanced Options:");
|
||||
Console.WriteLine();
|
||||
Console.WriteLine(" -b # Block size.");
|
||||
Console.WriteLine(" -v # Variable block size mode (0,4).");
|
||||
Console.WriteLine(" -s <method> Stereo decorrelation (independent,search).");
|
||||
Console.WriteLine(" -r #[,#] Rice partition order {max} or {min},{max} (0..8).");
|
||||
Console.WriteLine(" -b # Block size");
|
||||
Console.WriteLine(" -v # Variable block size mode (0,4)");
|
||||
Console.WriteLine(" -s <method> Stereo decorrelation (independent,search)");
|
||||
Console.WriteLine(" -r #[,#] Rice partition order {max} or {min},{max} (0..8)");
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("LPC options:");
|
||||
Console.WriteLine();
|
||||
Console.WriteLine(" -w <func>[,<func>] One or more window functions (bartlett,welch,hann,flattop,tukey).");
|
||||
Console.WriteLine(" -l #[,#] Prediction order {max} or {min},{max} (1..32).");
|
||||
Console.WriteLine(" --max-precision Coefficients precision search (0..1).");
|
||||
Console.WriteLine(" -w <func>[,<func>] Window functions (bartlett,welch,hann,flattop,tukey)");
|
||||
Console.WriteLine(" -l #[,#] Prediction order {max} or {min},{max} (1..32)");
|
||||
Console.WriteLine(" --max-precision Coefficients precision search (0..1)");
|
||||
Console.WriteLine();
|
||||
}
|
||||
|
||||
static void Main(string[] args)
|
||||
static int Main(string[] args)
|
||||
{
|
||||
TextWriter stdout = Console.Out;
|
||||
Console.SetOut(Console.Error);
|
||||
@@ -79,7 +79,8 @@ namespace CUETools.FlaCudaExe
|
||||
orders_per_window = -1,
|
||||
blocksize = -1;
|
||||
int level = -1, padding = -1, vbr_mode = -1;
|
||||
bool do_md5 = true, do_seektable = true, do_verify = false, gpu_only = false, use_lattice = false;
|
||||
bool do_md5 = true, do_seektable = true, do_verify = false, gpu_only = true, use_lattice = false;
|
||||
bool buffered = false;
|
||||
int cpu_threads = 0;
|
||||
bool ok = true;
|
||||
|
||||
@@ -95,12 +96,14 @@ namespace CUETools.FlaCudaExe
|
||||
do_verify = true;
|
||||
else if (args[arg] == "--no-seektable")
|
||||
do_seektable = false;
|
||||
else if (args[arg] == "--gpu-only")
|
||||
gpu_only = true;
|
||||
else if (args[arg] == "--slow-gpu")
|
||||
gpu_only = false;
|
||||
else if (args[arg] == "--use-lattice")
|
||||
use_lattice = true;
|
||||
else if (args[arg] == "--no-md5")
|
||||
do_md5 = false;
|
||||
else if (args[arg] == "--buffered")
|
||||
buffered = true;
|
||||
else if (args[arg] == "--cpu-threads")
|
||||
ok = (++arg < args.Length) && int.TryParse(args[arg], out cpu_threads);
|
||||
else if ((args[arg] == "-o" || args[arg] == "--output") && ++arg < args.Length)
|
||||
@@ -156,14 +159,14 @@ namespace CUETools.FlaCudaExe
|
||||
}
|
||||
if (!quiet)
|
||||
{
|
||||
Console.WriteLine("CUETools.FlaCuda, Copyright (C) 2009 Gregory S. Chudov.");
|
||||
Console.WriteLine("{0}, Copyright (C) 2009 Gregory S. Chudov.", FlaCudaWriter.vendor_string);
|
||||
Console.WriteLine("This is free software under the GNU GPLv3+ license; There is NO WARRANTY, to");
|
||||
Console.WriteLine("the extent permitted by law. <http://www.gnu.org/licenses/> for details.");
|
||||
}
|
||||
if (!ok || input_file == null)
|
||||
{
|
||||
Usage();
|
||||
return;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (((input_file == "-" || Path.GetExtension(input_file) == ".flac") && output_file == null))
|
||||
@@ -172,12 +175,12 @@ namespace CUETools.FlaCudaExe
|
||||
Console.WriteLine("Output file not specified.");
|
||||
Console.WriteLine();
|
||||
Usage();
|
||||
return;
|
||||
return 2;
|
||||
}
|
||||
|
||||
IAudioSource audioSource;
|
||||
if (input_file == "-")
|
||||
audioSource = new WAVReader(Console.OpenStandardInput());
|
||||
audioSource = new WAVReader("", Console.OpenStandardInput());
|
||||
else if (File.Exists(input_file) && Path.GetExtension(input_file) == ".wav")
|
||||
audioSource = new WAVReader(input_file, null);
|
||||
else if (File.Exists(input_file) && Path.GetExtension(input_file) == ".flac")
|
||||
@@ -185,18 +188,19 @@ namespace CUETools.FlaCudaExe
|
||||
else
|
||||
{
|
||||
Usage();
|
||||
return;
|
||||
return 2;
|
||||
}
|
||||
if (buffered)
|
||||
audioSource = new AudioPipe(audioSource, FlaCudaWriter.MAX_BLOCKSIZE);
|
||||
if (output_file == null)
|
||||
output_file = Path.ChangeExtension(input_file, "flac");
|
||||
FlaCudaWriter encoder = new FlaCudaWriter((output_file == "-" || output_file == "nul") ? "" : output_file,
|
||||
audioSource.BitsPerSample, audioSource.ChannelCount, audioSource.SampleRate,
|
||||
output_file == "-" ? Console.OpenStandardOutput() :
|
||||
output_file == "nul" ? new NullStream() : null);
|
||||
if (audioSource.Length != 0)
|
||||
encoder.FinalSampleCount = (long)audioSource.Length;
|
||||
output_file == "nul" ? new NullStream() : null,
|
||||
audioSource.PCM);
|
||||
encoder.FinalSampleCount = audioSource.Length;
|
||||
IAudioDest audioDest = encoder;
|
||||
int[,] buff = new int[FlaCudaWriter.MAX_BLOCKSIZE, audioSource.ChannelCount];
|
||||
AudioBuffer buff = new AudioBuffer(audioSource, FlaCudaWriter.MAX_BLOCKSIZE);
|
||||
|
||||
try
|
||||
{
|
||||
@@ -242,25 +246,22 @@ namespace CUETools.FlaCudaExe
|
||||
Usage();
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("Error: {0}.", ex.Message);
|
||||
return;
|
||||
return 3;
|
||||
}
|
||||
|
||||
if (!quiet)
|
||||
{
|
||||
Console.WriteLine("Filename : {0}", input_file);
|
||||
Console.WriteLine("File Info : {0}kHz; {1} channel; {2} bit; {3}", audioSource.SampleRate, audioSource.ChannelCount, audioSource.BitsPerSample, TimeSpan.FromSeconds(audioSource.Length * 1.0 / audioSource.SampleRate));
|
||||
Console.WriteLine("File Info : {0}kHz; {1} channel; {2} bit; {3}", audioSource.PCM.SampleRate, audioSource.PCM.ChannelCount, audioSource.PCM.BitsPerSample, TimeSpan.FromSeconds(audioSource.Length * 1.0 / audioSource.PCM.SampleRate));
|
||||
}
|
||||
|
||||
#if !DEBUG
|
||||
try
|
||||
#endif
|
||||
{
|
||||
do
|
||||
while (audioSource.Read(buff, -1) != 0)
|
||||
{
|
||||
uint toRead = audioSource.Length == 0 ? (uint)buff.GetLength(0) : Math.Min((uint)buff.GetLength(0), (uint)audioSource.Remaining);
|
||||
uint samplesRead = audioSource.Read(buff, toRead);
|
||||
if (samplesRead == 0) break;
|
||||
audioDest.Write(buff, 0, (int)samplesRead);
|
||||
audioDest.Write(buff);
|
||||
TimeSpan elapsed = DateTime.Now - start;
|
||||
if (!quiet)
|
||||
{
|
||||
@@ -268,14 +269,14 @@ namespace CUETools.FlaCudaExe
|
||||
{
|
||||
Console.Error.Write("\rProgress : {0:00}%; {1:0.00}x; {2}/{3}",
|
||||
100.0 * audioSource.Position / audioSource.Length,
|
||||
audioSource.Position / elapsed.TotalSeconds / audioSource.SampleRate,
|
||||
audioSource.Position / elapsed.TotalSeconds / audioSource.PCM.SampleRate,
|
||||
elapsed,
|
||||
TimeSpan.FromMilliseconds(elapsed.TotalMilliseconds / audioSource.Position * audioSource.Length)
|
||||
);
|
||||
lastPrint = elapsed;
|
||||
}
|
||||
}
|
||||
} while (true);
|
||||
}
|
||||
audioDest.Close();
|
||||
}
|
||||
#if !DEBUG
|
||||
@@ -285,7 +286,7 @@ namespace CUETools.FlaCudaExe
|
||||
Console.WriteLine("Error : {0}", ex.Message);
|
||||
audioDest.Delete();
|
||||
audioSource.Close();
|
||||
return;
|
||||
return 4;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -294,7 +295,7 @@ namespace CUETools.FlaCudaExe
|
||||
{
|
||||
Console.Error.Write("\r \r");
|
||||
Console.WriteLine("Results : {0:0.00}x; {2} bytes in {1} seconds;",
|
||||
audioSource.Position / totalElapsed.TotalSeconds / audioSource.SampleRate,
|
||||
audioSource.Position / totalElapsed.TotalSeconds / audioSource.PCM.SampleRate,
|
||||
totalElapsed,
|
||||
encoder.TotalSize
|
||||
);
|
||||
@@ -319,6 +320,7 @@ namespace CUETools.FlaCudaExe
|
||||
encoder.VBRMode
|
||||
);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user