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) 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 = 0;
int retrySectorsCount = sheet.CDRipper.RetrySectors.PopulationCount((int)start - (int)sheet.TOC[sheet.TOC.FirstAudio][0].Start, (int)length); for (int i = 0; i < (int)length; i++)
return 100 * (1.0 - Math.Log(failedSectorsCount / 5.0 + retrySectorsCount / 100.0 + 1) / Math.Log(length / 5.0 + length / 100.0 + 1)); 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) public static string GetExactAudioCopyLog(CUESheet sheet)

View File

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

View File

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