mirror of
https://github.com/claunia/cuetools.net.git
synced 2025-12-16 18:14:25 +00:00
FLACCL, Flake & Converter: support for --ignore-chunk-sizes
This commit is contained in:
@@ -74,6 +74,11 @@ namespace CUETools.Codecs
|
|||||||
public string Path { get { return _path; } }
|
public string Path { get { return _path; } }
|
||||||
|
|
||||||
public WAVReader(string path, Stream IO)
|
public WAVReader(string path, Stream IO)
|
||||||
|
: this(path, IO, false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public WAVReader(string path, Stream IO, bool ignore_chunk_sizes)
|
||||||
{
|
{
|
||||||
_path = path;
|
_path = path;
|
||||||
_IO = IO != null ? IO : new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, 0x10000, FileOptions.SequentialScan);
|
_IO = IO != null ? IO : new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, 0x10000, FileOptions.SequentialScan);
|
||||||
@@ -81,7 +86,7 @@ namespace CUETools.Codecs
|
|||||||
|
|
||||||
ParseHeaders();
|
ParseHeaders();
|
||||||
|
|
||||||
if (_dataLen < 0)
|
if (_dataLen < 0 || ignore_chunk_sizes)
|
||||||
_sampleLen = -1;
|
_sampleLen = -1;
|
||||||
else
|
else
|
||||||
_sampleLen = _dataLen / pcm.BlockAlign;
|
_sampleLen = _dataLen / pcm.BlockAlign;
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ namespace CUETools.Converter
|
|||||||
Console.Error.WriteLine(" --encoder-format <ext> Use encoder format different from file extension.");
|
Console.Error.WriteLine(" --encoder-format <ext> Use encoder format different from file extension.");
|
||||||
Console.Error.WriteLine(" --lossy Use lossy encoder/mode.");
|
Console.Error.WriteLine(" --lossy Use lossy encoder/mode.");
|
||||||
Console.Error.WriteLine(" --lossless Use lossless encoder/mode (default).");
|
Console.Error.WriteLine(" --lossless Use lossless encoder/mode (default).");
|
||||||
|
Console.Error.WriteLine(" --ignore-chunk-sizes Ignore WAV length (for pipe input)");
|
||||||
Console.Error.WriteLine(" -p # Padding bytes.");
|
Console.Error.WriteLine(" -p # Padding bytes.");
|
||||||
Console.Error.WriteLine(" -m <mode> Encoder mode (0..8 for flac, V0..V9 for mp3, etc)");
|
Console.Error.WriteLine(" -m <mode> Encoder mode (0..8 for flac, V0..V9 for mp3, etc)");
|
||||||
Console.Error.WriteLine();
|
Console.Error.WriteLine();
|
||||||
@@ -32,10 +33,10 @@ namespace CUETools.Converter
|
|||||||
(lossless ? fmt.encoderLossless : fmt.encoderLossy);
|
(lossless ? fmt.encoderLossless : fmt.encoderLossy);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IAudioSource GetAudioSource(CUEToolsCodecsConfig config, string path, string chosenDecoder)
|
public static IAudioSource GetAudioSource(CUEToolsCodecsConfig config, string path, string chosenDecoder, bool ignore_chunk_sizes)
|
||||||
{
|
{
|
||||||
if (path == "-")
|
if (path == "-")
|
||||||
return new WAVReader("", Console.OpenStandardInput());
|
return new WAVReader("", Console.OpenStandardInput(), ignore_chunk_sizes);
|
||||||
string extension = Path.GetExtension(path).ToLower();
|
string extension = Path.GetExtension(path).ToLower();
|
||||||
Stream IO = null;
|
Stream IO = null;
|
||||||
if (extension == ".bin")
|
if (extension == ".bin")
|
||||||
@@ -78,11 +79,15 @@ namespace CUETools.Converter
|
|||||||
string decoderName = null;
|
string decoderName = null;
|
||||||
string encoderName = null;
|
string encoderName = null;
|
||||||
string encoderFormat = null;
|
string encoderFormat = null;
|
||||||
|
bool ignore_chunk_sizes = false;
|
||||||
AudioEncoderType audioEncoderType = AudioEncoderType.NoAudio;
|
AudioEncoderType audioEncoderType = AudioEncoderType.NoAudio;
|
||||||
|
|
||||||
for (int arg = 0; arg < args.Length; arg++)
|
for (int arg = 0; arg < args.Length; arg++)
|
||||||
{
|
{
|
||||||
if (args[arg].Length == 0)
|
if (args[arg].Length == 0)
|
||||||
ok = false;
|
ok = false;
|
||||||
|
else if (args[arg] == "--ignore-chunk-sizes")
|
||||||
|
ignore_chunk_sizes = true;
|
||||||
else if (args[arg] == "--decoder" && ++arg < args.Length)
|
else if (args[arg] == "--decoder" && ++arg < args.Length)
|
||||||
decoderName = args[arg];
|
decoderName = args[arg];
|
||||||
else if (args[arg] == "--encoder" && ++arg < args.Length)
|
else if (args[arg] == "--encoder" && ++arg < args.Length)
|
||||||
@@ -137,7 +142,7 @@ namespace CUETools.Converter
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
audioSource = Program.GetAudioSource(config, sourceFile, decoderName);
|
audioSource = Program.GetAudioSource(config, sourceFile, decoderName, ignore_chunk_sizes);
|
||||||
AudioBuffer buff = new AudioBuffer(audioSource, 0x10000);
|
AudioBuffer buff = new AudioBuffer(audioSource, 0x10000);
|
||||||
Console.Error.WriteLine("Filename : {0}", sourceFile);
|
Console.Error.WriteLine("Filename : {0}", sourceFile);
|
||||||
Console.Error.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));
|
Console.Error.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));
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ namespace CUETools.FLACCL.cmd
|
|||||||
Console.WriteLine(" --verify Verify during encoding");
|
Console.WriteLine(" --verify Verify during encoding");
|
||||||
Console.WriteLine(" --no-md5 Don't compute MD5 hash");
|
Console.WriteLine(" --no-md5 Don't compute MD5 hash");
|
||||||
Console.WriteLine(" --no-seektable Don't generate a seektable");
|
Console.WriteLine(" --no-seektable Don't generate a seektable");
|
||||||
|
Console.WriteLine(" --ignore-chunk-sizes Ignore WAV length (for pipe input)");
|
||||||
Console.WriteLine(" --cpu-threads Use additional CPU threads");
|
Console.WriteLine(" --cpu-threads Use additional CPU threads");
|
||||||
Console.WriteLine();
|
Console.WriteLine();
|
||||||
Console.WriteLine("OpenCL Options:");
|
Console.WriteLine("OpenCL Options:");
|
||||||
@@ -94,6 +95,7 @@ namespace CUETools.FLACCL.cmd
|
|||||||
bool buffered = false;
|
bool buffered = false;
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
bool allowNonSubset = false;
|
bool allowNonSubset = false;
|
||||||
|
bool ignore_chunk_sizes = false;
|
||||||
int intarg;
|
int intarg;
|
||||||
|
|
||||||
for (int arg = 0; arg < args.Length; arg++)
|
for (int arg = 0; arg < args.Length; arg++)
|
||||||
@@ -108,6 +110,8 @@ namespace CUETools.FLACCL.cmd
|
|||||||
settings.DoVerify = true;
|
settings.DoVerify = true;
|
||||||
else if (args[arg] == "--no-seektable")
|
else if (args[arg] == "--no-seektable")
|
||||||
do_seektable = false;
|
do_seektable = false;
|
||||||
|
else if (args[arg] == "--ignore-chunk-sizes")
|
||||||
|
ignore_chunk_sizes = true;
|
||||||
else if (args[arg] == "--slow-gpu")
|
else if (args[arg] == "--slow-gpu")
|
||||||
settings.GPUOnly = false;
|
settings.GPUOnly = false;
|
||||||
else if (args[arg] == "--fast-gpu")
|
else if (args[arg] == "--fast-gpu")
|
||||||
@@ -238,7 +242,7 @@ namespace CUETools.FLACCL.cmd
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (input_file == "-")
|
if (input_file == "-")
|
||||||
audioSource = new WAVReader("", Console.OpenStandardInput());
|
audioSource = new WAVReader("", Console.OpenStandardInput(), ignore_chunk_sizes);
|
||||||
else if (input_file == "nul")
|
else if (input_file == "nul")
|
||||||
audioSource = new SilenceGenerator(new AudioPCMConfig(input_bps, input_ch, input_rate), input_len, input_val);
|
audioSource = new SilenceGenerator(new AudioPCMConfig(input_bps, input_ch, input_rate), input_len, input_val);
|
||||||
else if (File.Exists(input_file) && Path.GetExtension(input_file) == ".wav")
|
else if (File.Exists(input_file) && Path.GetExtension(input_file) == ".wav")
|
||||||
@@ -337,11 +341,12 @@ namespace CUETools.FLACCL.cmd
|
|||||||
{
|
{
|
||||||
if ((elapsed - lastPrint).TotalMilliseconds > 60)
|
if ((elapsed - lastPrint).TotalMilliseconds > 60)
|
||||||
{
|
{
|
||||||
|
long length = Math.Max(audioSource.Position, audioSource.Length);
|
||||||
Console.Error.Write("\rProgress : {0:00}%; {1:0.00}x; {2}/{3}",
|
Console.Error.Write("\rProgress : {0:00}%; {1:0.00}x; {2}/{3}",
|
||||||
100.0 * audioSource.Position / audioSource.Length,
|
100.0 * audioSource.Position / length,
|
||||||
audioSource.Position / elapsed.TotalSeconds / audioSource.PCM.SampleRate,
|
audioSource.Position / elapsed.TotalSeconds / audioSource.PCM.SampleRate,
|
||||||
elapsed,
|
elapsed,
|
||||||
TimeSpan.FromMilliseconds(elapsed.TotalMilliseconds / audioSource.Position * audioSource.Length)
|
TimeSpan.FromMilliseconds(elapsed.TotalMilliseconds / audioSource.Position * length)
|
||||||
);
|
);
|
||||||
lastPrint = elapsed;
|
lastPrint = elapsed;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,6 +100,7 @@ namespace CUETools.FlakeExe
|
|||||||
Console.WriteLine(" --verify Verify during encoding.");
|
Console.WriteLine(" --verify Verify during encoding.");
|
||||||
Console.WriteLine(" --no-md5 Don't compute MD5 hash.");
|
Console.WriteLine(" --no-md5 Don't compute MD5 hash.");
|
||||||
Console.WriteLine(" --no-seektable Don't generate a seektable.");
|
Console.WriteLine(" --no-seektable Don't generate a seektable.");
|
||||||
|
Console.WriteLine(" --ignore-chunk-sizes Ignore WAV length (for pipe input)");
|
||||||
Console.WriteLine();
|
Console.WriteLine();
|
||||||
Console.WriteLine("Advanced Options:");
|
Console.WriteLine("Advanced Options:");
|
||||||
Console.WriteLine();
|
Console.WriteLine();
|
||||||
@@ -147,6 +148,7 @@ namespace CUETools.FlakeExe
|
|||||||
string coeffs = null;
|
string coeffs = null;
|
||||||
var settings = new FlakeWriterSettings() { AllowNonSubset = true };
|
var settings = new FlakeWriterSettings() { AllowNonSubset = true };
|
||||||
bool allowNonSubset = false;
|
bool allowNonSubset = false;
|
||||||
|
bool ignore_chunk_sizes = false;
|
||||||
#if FINETUNE
|
#if FINETUNE
|
||||||
int finetune_depth = -1;
|
int finetune_depth = -1;
|
||||||
#endif
|
#endif
|
||||||
@@ -164,6 +166,8 @@ namespace CUETools.FlakeExe
|
|||||||
settings.DoVerify = true;
|
settings.DoVerify = true;
|
||||||
else if (args[arg] == "--no-seektable")
|
else if (args[arg] == "--no-seektable")
|
||||||
do_seektable = false;
|
do_seektable = false;
|
||||||
|
else if (args[arg] == "--ignore-chunk-sizes")
|
||||||
|
ignore_chunk_sizes = true;
|
||||||
else if (args[arg] == "--no-md5")
|
else if (args[arg] == "--no-md5")
|
||||||
settings.DoMD5 = false;
|
settings.DoMD5 = false;
|
||||||
else if (args[arg] == "--lax")
|
else if (args[arg] == "--lax")
|
||||||
@@ -321,7 +325,7 @@ namespace CUETools.FlakeExe
|
|||||||
|
|
||||||
IAudioSource audioSource;
|
IAudioSource audioSource;
|
||||||
if (input_file == "-")
|
if (input_file == "-")
|
||||||
audioSource = new WAVReader("", Console.OpenStandardInput());
|
audioSource = new WAVReader("", Console.OpenStandardInput(), ignore_chunk_sizes);
|
||||||
else if (File.Exists(input_file) && Path.GetExtension(input_file) == ".wav")
|
else if (File.Exists(input_file) && Path.GetExtension(input_file) == ".wav")
|
||||||
audioSource = new WAVReader(input_file, null);
|
audioSource = new WAVReader(input_file, null);
|
||||||
else if (File.Exists(input_file) && Path.GetExtension(input_file) == ".flac")
|
else if (File.Exists(input_file) && Path.GetExtension(input_file) == ".flac")
|
||||||
@@ -346,7 +350,7 @@ namespace CUETools.FlakeExe
|
|||||||
output_file == "-" ? Console.OpenStandardOutput() :
|
output_file == "-" ? Console.OpenStandardOutput() :
|
||||||
output_file == "nul" ? new NullStream() : null,
|
output_file == "nul" ? new NullStream() : null,
|
||||||
settings);
|
settings);
|
||||||
flake.FinalSampleCount = audioSource.Length - skip_a - skip_b;
|
flake.FinalSampleCount = audioSource.Length < 0 ? -1 : audioSource.Length - skip_a - skip_b;
|
||||||
|
|
||||||
if (prediction_type != null)
|
if (prediction_type != null)
|
||||||
flake.PredictionType = Flake.LookupPredictionType(prediction_type);
|
flake.PredictionType = Flake.LookupPredictionType(prediction_type);
|
||||||
@@ -412,11 +416,12 @@ namespace CUETools.FlakeExe
|
|||||||
{
|
{
|
||||||
if ((elapsed - lastPrint).TotalMilliseconds > 60)
|
if ((elapsed - lastPrint).TotalMilliseconds > 60)
|
||||||
{
|
{
|
||||||
|
long length = Math.Max(audioSource.Position, audioSource.Length);
|
||||||
Console.Error.Write("\rProgress : {0:00}%; {1:0.00}x; {2}/{3}",
|
Console.Error.Write("\rProgress : {0:00}%; {1:0.00}x; {2}/{3}",
|
||||||
100.0 * audioSource.Position / audioSource.Length,
|
100.0 * audioSource.Position / length,
|
||||||
audioSource.Position / elapsed.TotalSeconds / audioSource.PCM.SampleRate,
|
audioSource.Position / elapsed.TotalSeconds / audioSource.PCM.SampleRate,
|
||||||
elapsed,//.ToString(@"[-][d<>.<2E>]hh<68>:<3A>mm<6D>:<3A>ss[<5B>.<2E>ff]"),
|
elapsed,//.ToString(@"[-][d<>.<2E>]hh<68>:<3A>mm<6D>:<3A>ss[<5B>.<2E>ff]"),
|
||||||
TimeSpan.FromMilliseconds(elapsed.TotalMilliseconds / audioSource.Position * audioSource.Length)
|
TimeSpan.FromMilliseconds(elapsed.TotalMilliseconds / audioSource.Position * length)
|
||||||
);
|
);
|
||||||
lastPrint = elapsed;
|
lastPrint = elapsed;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user