CUERipper: track quality calculations closer to EAC values

This commit is contained in:
Grigory Chudov
2013-06-11 23:40:48 -04:00
parent e0d789b727
commit 4c9b64b04a
3 changed files with 46 additions and 34 deletions

View File

@@ -87,9 +87,15 @@ namespace CUETools.Processor
private static double GetRangeQuality(CUESheet sheet, uint start, uint length)
{
int failedSectorsCount = sheet.CDRipper.FailedSectors.PopulationCount((int)start - (int)sheet.TOC[sheet.TOC.FirstAudio][0].Start, (int)length);
int retrySectorsCount = sheet.CDRipper.RetrySectors.PopulationCount((int)start - (int)sheet.TOC[sheet.TOC.FirstAudio][0].Start, (int)length);
return 100 * (1.0 - Math.Log(failedSectorsCount / 5.0 + retrySectorsCount / 100.0 + 1) / Math.Log(length / 5.0 + length / 100.0 + 1));
int retrySectorsCount = 0;
for (int i = 0; i < (int)length; i++)
retrySectorsCount += sheet.CDRipper.RetryCount[(int)start - (int)sheet.TOC[sheet.TOC.FirstAudio][0].Start + i];
#if LOGQ
int max_scans = (16 << sheet.CDRipper.CorrectionQuality) - 1;
return 100 * (1.0 - Math.Log(retrySectorsCount / 100.0 + 1) / Math.Log(max_scans * (int)length / 100.0 + 1));
#else
return 100.0 * (sheet.CDRipper.CorrectionQuality + 1) * length / retrySectorsCount;
#endif
}
public static string GetExactAudioCopyLog(CUESheet sheet)

View File

@@ -60,8 +60,8 @@ namespace CUETools.Ripper.SCSI
public long[,,] UserData;
public byte[,] C2Count;
public long[] byte2long;
BitArray m_failedSectors, m_retrySctors;
int _crcErrorsCount = 0;
BitArray m_failedSectors;
byte[] m_retryCount;
AudioBuffer currentData = new AudioBuffer(AudioPCMConfig.RedBook, MSECTORS * 588);
short[] _valueScore = new short[256];
bool _debugMessages = false;
@@ -85,22 +85,28 @@ namespace CUETools.Ripper.SCSI
}
}
public byte[] RetryCount
{
get
{
return m_retryCount;
}
}
public BitArray FailedSectors
{
get
{
if (m_failedSectors == null)
{
m_failedSectors = new BitArray((int)_toc.AudioLength);
for (int i = 0; i < m_failedSectors.Length; i++)
m_failedSectors[i] = m_retryCount[i] == (16 << _correctionQuality) + 1;
}
return m_failedSectors;
}
}
public BitArray RetrySectors
{
get
{
return m_retrySctors;
}
}
public int Timeout
{
get
@@ -966,7 +972,7 @@ namespace CUETools.Ripper.SCSI
throw ex;
}
private unsafe void CorrectSectors(int pass, int sector, int Sectors2Read, BitArray markErrors)
private unsafe void CorrectSectors(int pass, int sector, int Sectors2Read)
{
for (int iSector = 0; iSector < Sectors2Read; iSector++)
{
@@ -1000,17 +1006,16 @@ namespace CUETools.Ripper.SCSI
}
currentData.Bytes[pos * 4 * 588 + iPar] = (byte)bestValue;
}
int newerr = (fError ? 1 : 0);
//_currentErrorsCount += newerr;
_currentErrorsCount += newerr - errtmp[pos];
errtmp[pos] = newerr;
if (markErrors != null)
markErrors[sector + iSector] |= fError;
}
if (pass > _correctionQuality || fError)
{
int olderr = pass > _correctionQuality && m_retryCount[sector + iSector] == pass + 1 ? 1 : 0;
int newerr = fError ? 1 : 0;
_currentErrorsCount += newerr - olderr;
if (fError) m_retryCount[sector + iSector] = (byte)(pass + 2);
}
}
}
int[] errtmp = new int[MSECTORS];
public unsafe void PrefetchSector(int iSector)
{
@@ -1041,8 +1046,6 @@ namespace CUETools.Ripper.SCSI
//correctFile.Close();
_currentErrorsCount = 0;
for (int i = 0; i < MSECTORS; i++)
errtmp[i] = 0;
//Device.CommandStatus st = m_device.SetCdSpeed(Device.RotationalControl.CLVandNonPureCav, (ushort)(176 * 4), 65535);
//if (st != Device.CommandStatus.Success)
@@ -1071,7 +1074,7 @@ namespace CUETools.Ripper.SCSI
//TimeSpan delay1 = DateTime.Now - LastFetch;
//DateTime LastFetched = DateTime.Now;
if (pass >= _correctionQuality)
CorrectSectors(pass, sector, Sectors2Read, pass == max_scans - 1 ? m_failedSectors : pass == _correctionQuality ? m_retrySctors : null);
CorrectSectors(pass, sector, Sectors2Read);
//TimeSpan delay2 = DateTime.Now - LastFetched;
//if (sector == _currentStart)
//System.Console.WriteLine("\n{0},{1}", delay1.TotalMilliseconds, delay2.TotalMilliseconds);
@@ -1189,11 +1192,12 @@ namespace CUETools.Ripper.SCSI
{
if (_toc == null || _toc.AudioLength <= 0)
throw new ReadCDException(Resource1.NoAudio);
_crcErrorsCount = 0;
_currentStart = -1;
_currentEnd = -1;
m_failedSectors = new BitArray((int)_toc.AudioLength); // !!!
m_retrySctors = new BitArray((int)_toc.AudioLength);
m_retryCount = new byte[(int)_toc.AudioLength];
for (int i = 0; i < m_retryCount.Length; i++)
m_retryCount[i] = (byte)(_correctionQuality + 1);
m_failedSectors = null;
_sampleOffset = (int)value + _driveOffset;
}
}
@@ -1230,6 +1234,8 @@ namespace CUETools.Ripper.SCSI
if (value < 0 || value > 3)
throw new Exception("invalid CorrectionQuality");
_correctionQuality = value;
for (int i = 0; i < m_retryCount.Length; i++)
m_retryCount[i] = (byte)(_correctionQuality + 1);
}
}

View File

@@ -22,7 +22,7 @@ namespace CUETools.Ripper
string CurrentReadCommand { get; }
int CorrectionQuality { get; set; }
BitArray FailedSectors { get; }
BitArray RetrySectors { get; }
byte[] RetryCount { get; }
event EventHandler<ReadProgressArgs> ReadProgress;
}