4) Fixed bug in peak level measurement in verification log: it now produces exactly the same values as EAC

5) Verification speedup for albums with many short tracks
This commit is contained in:
chudov
2010-04-19 08:27:37 +00:00
parent 80fe7def42
commit 8a36121577
2 changed files with 158 additions and 52 deletions

View File

@@ -792,7 +792,7 @@ namespace CUETools.AccurateRip
CRCWONULL(iTrack), CRCWONULL(iTrack),
inLog, inLog,
extra, extra,
((iTrack == 0 ? PeakLevel() : PeakLevel(iTrack)) * 1000 / 65535) * 0.1); ((iTrack == 0 ? PeakLevel() : PeakLevel(iTrack)) * 1000 / 65534) * 0.1);
} }
} }
} }

View File

@@ -3298,7 +3298,7 @@ string status = processor.Go();
wereErrors |= PrintErrors(logWriter, _toc[track + _toc.FirstAudio].Start, _toc[track + _toc.FirstAudio].Length); wereErrors |= PrintErrors(logWriter, _toc[track + _toc.FirstAudio].Start, _toc[track + _toc.FirstAudio].Length);
logWriter.WriteLine(); logWriter.WriteLine();
logWriter.WriteLine(" Peak level {0:F1} %", (_arVerify.PeakLevel(track + 1) * 1000 / 65535) * 0.1); logWriter.WriteLine(" Peak level {0:F1} %", (_arVerify.PeakLevel(track + 1) * 1000 / 65534) * 0.1);
logWriter.WriteLine(" Track quality 100.0 %"); logWriter.WriteLine(" Track quality 100.0 %");
logWriter.WriteLine(" Test CRC {0:X8}", _arVerify.CRC32(track + 1)); logWriter.WriteLine(" Test CRC {0:X8}", _arVerify.CRC32(track + 1));
logWriter.WriteLine(" Copy CRC {0:X8}", _arVerify.CRC32(track + 1)); logWriter.WriteLine(" Copy CRC {0:X8}", _arVerify.CRC32(track + 1));
@@ -3780,7 +3780,10 @@ string status = processor.Go();
WriteText(_outputPath, cueContents); WriteText(_outputPath, cueContents);
} }
if (_audioEncoderType != AudioEncoderType.NoAudio || _action == CUEAction.Verify) if (_action == CUEAction.Verify)
VerifyAudio();
// WriteAudioFilesPass(OutputDir, OutputStyle, destLengths, htoaToFile, _action == CUEAction.Verify);
else if (_audioEncoderType != AudioEncoderType.NoAudio)
WriteAudioFilesPass(OutputDir, OutputStyle, destLengths, htoaToFile, _action == CUEAction.Verify); WriteAudioFilesPass(OutputDir, OutputStyle, destLengths, htoaToFile, _action == CUEAction.Verify);
if (_useCUEToolsDB && _CUEToolsDB.AccResult == HttpStatusCode.OK) if (_useCUEToolsDB && _CUEToolsDB.AccResult == HttpStatusCode.OK)
@@ -4262,21 +4265,11 @@ string status = processor.Go();
// return null; // return null;
//} //}
public void WriteAudioFilesPass(string dir, CUEStyle style, int[] destLengths, bool htoaToFile, bool noOutput) internal void ApplyWriteOffset()
{ {
int iTrack, iIndex; if (_writeOffset == 0)
AudioBuffer sampleBuffer = new AudioBuffer(AudioPCMConfig.RedBook, 0x10000); return;
TrackInfo track;
IAudioSource audioSource = null;
IAudioDest audioDest = null;
bool discardOutput;
int iSource = -1;
int iDest = -1;
int samplesRemSource = 0;
//CDImageLayout updatedTOC = null;
if (_writeOffset != 0)
{
int absOffset = Math.Abs(_writeOffset); int absOffset = Math.Abs(_writeOffset);
SourceInfo sourceInfo; SourceInfo sourceInfo;
@@ -4316,6 +4309,20 @@ string status = processor.Go();
_appliedWriteOffset = true; _appliedWriteOffset = true;
} }
public void WriteAudioFilesPass(string dir, CUEStyle style, int[] destLengths, bool htoaToFile, bool noOutput)
{
int iTrack, iIndex;
AudioBuffer sampleBuffer = new AudioBuffer(AudioPCMConfig.RedBook, 0x10000);
TrackInfo track;
IAudioSource audioSource = null;
IAudioDest audioDest = null;
bool discardOutput;
int iSource = -1;
int iDest = -1;
int samplesRemSource = 0;
ApplyWriteOffset();
int destBPS = 16; int destBPS = 16;
hdcdDecoder = null; hdcdDecoder = null;
if (_config.detectHDCD && CUEProcessorPlugins.hdcd != null) if (_config.detectHDCD && CUEProcessorPlugins.hdcd != null)
@@ -4415,7 +4422,7 @@ string status = processor.Go();
// if (_isCD && audioSource != null && audioSource is CDDriveReader) // if (_isCD && audioSource != null && audioSource is CDDriveReader)
// updatedTOC = ((CDDriveReader)audioSource).TOC; // updatedTOC = ((CDDriveReader)audioSource).TOC;
if (audioSource != null) audioSource.Close(); if (audioSource != null) audioSource.Close();
audioSource = GetAudioSource(++iSource); audioSource = GetAudioSource(++iSource, _config.separateDecodingThread || _isCD);
samplesRemSource = (int)_sources[iSource].Length; samplesRemSource = (int)_sources[iSource].Length;
} }
@@ -4500,6 +4507,100 @@ string status = processor.Go();
audioDest.Close(); audioDest.Close();
} }
public void VerifyAudio()
{
ApplyWriteOffset();
hdcdDecoder = null;
if (_config.detectHDCD && CUEProcessorPlugins.hdcd != null)
{
try { hdcdDecoder = Activator.CreateInstance(CUEProcessorPlugins.hdcd, 2, 44100, 20, false) as IAudioDest; }
catch { }
}
if (_useAccurateRip)
_arVerify.Init();
if (_useCUEToolsDB && !_useCUEToolsDBFix)
_CUEToolsDB.Init(_useCUEToolsDBSibmit);
ShowProgress(String.Format("{2} track {0:00} ({1:00}%)...", 0, 0, "Verifying"), 0, 0.0, null, null);
AudioBuffer sampleBuffer = new AudioBuffer(AudioPCMConfig.RedBook, 0x10000);
IAudioSource audioSource = new CUESheetAudio(this);
if (_isCD || _config.separateDecodingThread)
audioSource = new AudioPipe(audioSource, 0x10000);
#if !DEBUG
try
#endif
{
int lastProgress = -588 * 75;
do
{
if (audioSource.Position - lastProgress >= 588 * 75)
{
lastProgress = (int)audioSource.Position;
int pos = 0;
int trackStart = 0;
int trackLength = (int)_toc.Pregap * 588;
for (int iTrack = 0; iTrack < TrackCount; iTrack++)
for (int iIndex = 0; iIndex <= _toc[_toc.FirstAudio + iTrack].LastIndex; iIndex++)
{
int indexLen = (int)_toc.IndexLength(_toc.FirstAudio + iTrack, iIndex) * 588;
if (iIndex == 1)
{
trackStart = pos;
trackLength = (int)_toc[_toc.FirstAudio + iTrack].Length * 588;
}
if (audioSource.Position < pos + indexLen)
{
if (trackLength > 0 && !_isCD)
{
double trackPercent = (double)(audioSource.Position - trackStart) / trackLength;
int diskLength = 588 * (int)_toc.AudioLength;
int diskOffset = (int)audioSource.Position;
ShowProgress(String.Format("{2} track {0:00} ({1:00}%)...", iIndex > 0 ? iTrack + 1 : iTrack, (uint)(100 * trackPercent),
"Verifying"), trackPercent, diskOffset, diskLength, audioSource.Path, null);
}
iTrack = TrackCount;
break;
}
pos += indexLen;
}
}
int copyCount = audioSource.Read(sampleBuffer, -1);
if (copyCount == 0)
break;
if (_useCUEToolsDB) // !_useCUEToolsDBFix
_CUEToolsDB.Verify.Write(sampleBuffer);
if (_useAccurateRip)
_arVerify.Write(sampleBuffer);
if (hdcdDecoder != null)
{
hdcdDecoder.Write(sampleBuffer);
if (_config.wait750FramesForHDCD && audioSource.Position > 750 * 588 && string.Format("{0:s}", hdcdDecoder) == "")
hdcdDecoder = null;
}
CheckStop();
} while (true);
}
#if !DEBUG
catch (Exception ex)
{
hdcdDecoder = null;
if (audioSource != null)
try { audioSource.Close(); }
catch { }
audioSource = null;
throw ex;
}
#endif
if (audioSource != null)
audioSource.Close();
}
private void DetectGaps() private void DetectGaps()
{ {
if (!_isCD) if (!_isCD)
@@ -4813,7 +4914,7 @@ string status = processor.Go();
return AudioReadWrite.GetAudioDest(_audioEncoderType, path, finalSampleCount, bps, 44100, padding, _config); return AudioReadWrite.GetAudioDest(_audioEncoderType, path, finalSampleCount, bps, 44100, padding, _config);
} }
internal IAudioSource GetAudioSource(int sourceIndex) { internal IAudioSource GetAudioSource(int sourceIndex, bool pipe) {
SourceInfo sourceInfo = _sources[sourceIndex]; SourceInfo sourceInfo = _sources[sourceIndex];
IAudioSource audioSource; IAudioSource audioSource;
@@ -4825,7 +4926,10 @@ string status = processor.Go();
{ {
_ripper.Position = 0; _ripper.Position = 0;
//audioSource = _ripper; //audioSource = _ripper;
if (pipe)
audioSource = new AudioPipe(_ripper, 0x100000, false, ThreadPriority.Highest); audioSource = new AudioPipe(_ripper, 0x100000, false, ThreadPriority.Highest);
else
audioSource = _ripper;
} else } else
if (_isArchive) if (_isArchive)
audioSource = AudioReadWrite.GetAudioSource(sourceInfo.Path, OpenArchive(sourceInfo.Path, false), _config); audioSource = AudioReadWrite.GetAudioSource(sourceInfo.Path, OpenArchive(sourceInfo.Path, false), _config);
@@ -4837,7 +4941,7 @@ string status = processor.Go();
audioSource.Position = sourceInfo.Offset; audioSource.Position = sourceInfo.Offset;
//if (!(audioSource is AudioPipe) && !(audioSource is UserDefinedReader) && _config.separateDecodingThread) //if (!(audioSource is AudioPipe) && !(audioSource is UserDefinedReader) && _config.separateDecodingThread)
if (!(audioSource is AudioPipe) && _config.separateDecodingThread) if (!(audioSource is AudioPipe) && pipe)
audioSource = new AudioPipe(audioSource, 0x10000); audioSource = new AudioPipe(audioSource, 0x10000);
return audioSource; return audioSource;
@@ -5689,7 +5793,7 @@ string status = processor.Go();
this.currentSource = 0; this.currentSource = 0;
for (int iSource = 0; iSource < cueSheet._sources.Count; iSource++) for (int iSource = 0; iSource < cueSheet._sources.Count; iSource++)
this._sampleLen += cueSheet._sources[iSource].Length; this._sampleLen += cueSheet._sources[iSource].Length;
this.currentAudio = cueSheet.GetAudioSource(0); this.currentAudio = cueSheet.GetAudioSource(0, false);
} }
public void Close() public void Close()
@@ -5718,7 +5822,7 @@ string status = processor.Go();
{ {
currentAudio.Close(); currentAudio.Close();
currentSource = iSource; currentSource = iSource;
currentAudio = cueSheet.GetAudioSource(currentSource); currentAudio = cueSheet.GetAudioSource(currentSource, false);
} }
currentAudio.Position = value - sourceStart; currentAudio.Position = value - sourceStart;
_samplePos = value; _samplePos = value;
@@ -5775,10 +5879,12 @@ string status = processor.Go();
return 0; return 0;
} }
currentAudio.Close(); currentAudio.Close();
currentAudio = cueSheet.GetAudioSource(currentSource); currentAudio = cueSheet.GetAudioSource(currentSource, false);
} }
return currentAudio.Read(buff, maxLength); int res = currentAudio.Read(buff, maxLength);
_samplePos += res;
return res;
} }
} }
} }