2010-04-24 17:47:57 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using CUETools.CDImage;
|
|
|
|
|
|
using CUETools.Codecs;
|
|
|
|
|
|
using CUETools.Parity;
|
|
|
|
|
|
using CUETools.AccurateRip;
|
|
|
|
|
|
|
|
|
|
|
|
namespace CUETools.AccurateRip
|
|
|
|
|
|
{
|
|
|
|
|
|
public class CDRepair
|
|
|
|
|
|
{
|
|
|
|
|
|
protected int sampleCount;
|
|
|
|
|
|
protected int finalSampleCount;
|
|
|
|
|
|
internal Galois galois;
|
|
|
|
|
|
internal int stride;
|
|
|
|
|
|
internal int laststride;
|
|
|
|
|
|
internal int stridecount;
|
|
|
|
|
|
|
2011-10-27 20:50:11 +00:00
|
|
|
|
public CDRepair(int finalSampleCount, int stride)
|
2010-04-24 17:47:57 +00:00
|
|
|
|
{
|
|
|
|
|
|
this.stride = stride;
|
|
|
|
|
|
this.finalSampleCount = finalSampleCount;
|
|
|
|
|
|
sampleCount = 0;
|
|
|
|
|
|
galois = Galois16.instance;
|
|
|
|
|
|
laststride = stride + (finalSampleCount * 2) % stride;
|
|
|
|
|
|
stridecount = (finalSampleCount * 2) / stride - 2; // minus one for leadin and one for leadout
|
2011-10-27 20:50:11 +00:00
|
|
|
|
if ((finalSampleCount * 2 + stride - 1) / stride + AccurateRipVerify.maxNpar > galois.Max)
|
2010-04-24 17:47:57 +00:00
|
|
|
|
throw new Exception("invalid stride");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public CDRepair(CDRepair src)
|
2011-10-27 20:50:11 +00:00
|
|
|
|
: this(src.finalSampleCount, src.stride)
|
2010-04-24 17:47:57 +00:00
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public long FinalSampleCount
|
|
|
|
|
|
{
|
2011-04-24 21:07:50 +00:00
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return finalSampleCount;
|
|
|
|
|
|
}
|
2010-04-24 17:47:57 +00:00
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
if (value < 0) // != _toc.Length?
|
|
|
|
|
|
throw new Exception("invalid FinalSampleCount");
|
|
|
|
|
|
finalSampleCount = (int)value;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2011-04-24 21:07:50 +00:00
|
|
|
|
public int Stride
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return stride;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2010-04-24 17:47:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class CDRepairEncode : CDRepair
|
|
|
|
|
|
{
|
|
|
|
|
|
protected AccurateRipVerify ar;
|
|
|
|
|
|
|
2011-10-27 20:50:11 +00:00
|
|
|
|
public CDRepairEncode(AccurateRipVerify ar, int stride)
|
|
|
|
|
|
: base ((int)ar.FinalSampleCount, stride)
|
2010-04-24 17:47:57 +00:00
|
|
|
|
{
|
|
|
|
|
|
this.ar = ar;
|
2011-10-25 01:16:11 +00:00
|
|
|
|
ar.InitCDRepair(stride, laststride, stridecount, true);
|
2010-04-24 17:47:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2011-04-24 21:07:50 +00:00
|
|
|
|
public AccurateRipVerify AR
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return ar;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2010-04-24 17:47:57 +00:00
|
|
|
|
public uint CRC
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return ar.CTDBCRC(0);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2011-04-24 21:07:50 +00:00
|
|
|
|
public string TrackCRCs
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
var sb = new StringBuilder();
|
|
|
|
|
|
for (int i = 1; i <= ar.TOC.AudioTracks; i++)
|
|
|
|
|
|
sb.AppendFormat(" {0:x8}", ar.CTDBCRC(i, 0, stride / 2, laststride / 2));
|
|
|
|
|
|
return sb.ToString().Substring(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2011-10-26 05:09:37 +00:00
|
|
|
|
public unsafe bool FindOffset(ushort[,] syn2, uint expectedCRC, out int actualOffset, out bool hasErrors)
|
|
|
|
|
|
{
|
|
|
|
|
|
int npar2 = syn2.GetLength(1);
|
2011-10-27 20:50:11 +00:00
|
|
|
|
int npar = Math.Min(AccurateRipVerify.maxNpar, npar2);
|
2011-10-26 05:09:37 +00:00
|
|
|
|
|
|
|
|
|
|
if (npar2 != npar)
|
|
|
|
|
|
throw new Exception("npar mismatch");
|
|
|
|
|
|
if (ar.Position != ar.FinalSampleCount)
|
|
|
|
|
|
throw new Exception("ar.Position != ar.FinalSampleCount");
|
|
|
|
|
|
|
2011-10-27 20:50:11 +00:00
|
|
|
|
var rs = new RsDecode16(npar, this.galois);
|
2011-10-26 05:09:37 +00:00
|
|
|
|
int part2 = 0;
|
|
|
|
|
|
// find offset
|
|
|
|
|
|
fixed (ushort* chT = rs.chienTable, syn2part = &syn2[part2, 0])
|
|
|
|
|
|
{
|
|
|
|
|
|
int* _sigma = stackalloc int[npar];
|
|
|
|
|
|
int* _errpos = stackalloc int[npar];
|
|
|
|
|
|
int* syn = stackalloc int[npar];
|
|
|
|
|
|
bool foundOffset = false;
|
|
|
|
|
|
var arSyndrome = ar.GetSyndrome(npar);
|
|
|
|
|
|
|
|
|
|
|
|
for (int allowed_errors = 0; allowed_errors < npar / 2 && !foundOffset; allowed_errors++)
|
|
|
|
|
|
{
|
|
|
|
|
|
// We can only use offset if Abs(offset * 2) < stride,
|
|
|
|
|
|
// else we might need to add/remove more than one sample
|
|
|
|
|
|
// from syndrome calculations, and that would be too difficult
|
|
|
|
|
|
// and will probably require longer leadin/leadout.
|
|
|
|
|
|
for (int offset = 1 - stride / 2; offset < stride / 2; offset++)
|
|
|
|
|
|
{
|
|
|
|
|
|
int err = 0;
|
|
|
|
|
|
int part = (part2 + stride - offset * 2) % stride;
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < npar; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
int synI = arSyndrome[part, i];
|
|
|
|
|
|
|
|
|
|
|
|
// offset < 0
|
|
|
|
|
|
if (part < -offset * 2)
|
|
|
|
|
|
{
|
|
|
|
|
|
synI ^= galois.mulExp(ar.leadin[stride + part], (i * (stridecount - 1)) % galois.Max);
|
|
|
|
|
|
synI = ar.leadout[laststride - part - 1] ^ galois.mulExp(synI, i);
|
|
|
|
|
|
}
|
|
|
|
|
|
// offset > 0
|
|
|
|
|
|
if (part >= stride - offset * 2)
|
|
|
|
|
|
{
|
|
|
|
|
|
synI = galois.divExp(synI ^ ar.leadout[laststride + stride - part - 1], i);
|
|
|
|
|
|
synI ^= galois.mulExp(ar.leadin[part], (i * (stridecount - 1)) % galois.Max);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
synI = galois.mulExp(synI ^ syn2part[i], i * npar);
|
|
|
|
|
|
syn[i] = synI;
|
|
|
|
|
|
err |= synI;
|
|
|
|
|
|
}
|
|
|
|
|
|
int err_count = err == 0 ? 0 : rs.calcSigmaMBM(_sigma, syn);
|
|
|
|
|
|
if (err_count == allowed_errors && (err_count == 0 || rs.chienSearch(_errpos, stridecount + npar, err_count, _sigma, chT)))
|
|
|
|
|
|
{
|
|
|
|
|
|
actualOffset = offset;
|
|
|
|
|
|
hasErrors = err_count != 0 || ar.CTDBCRC(-offset) != expectedCRC;
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
actualOffset = 0;
|
|
|
|
|
|
hasErrors = true;
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public unsafe CDRepairFix VerifyParity(ushort[,] syn2, int actualOffset)
|
2010-04-24 17:47:57 +00:00
|
|
|
|
{
|
2011-10-26 05:09:37 +00:00
|
|
|
|
int npar2 = syn2.GetLength(1);
|
2011-10-27 20:50:11 +00:00
|
|
|
|
int npar = Math.Min(AccurateRipVerify.maxNpar, npar2);
|
2010-04-24 17:47:57 +00:00
|
|
|
|
|
2011-10-27 20:50:11 +00:00
|
|
|
|
CDRepairFix fix = new CDRepairFix(this, npar);
|
2010-04-24 17:47:57 +00:00
|
|
|
|
fix.actualOffset = actualOffset;
|
|
|
|
|
|
fix.correctableErrors = 0;
|
|
|
|
|
|
fix.hasErrors = false;
|
|
|
|
|
|
fix.canRecover = true;
|
|
|
|
|
|
|
|
|
|
|
|
fix.sigma = new int[stride, npar / 2 + 2];
|
|
|
|
|
|
fix.omega = new int[stride, npar / 2 + 1];
|
|
|
|
|
|
fix.errpos = new int[stride, npar / 2];
|
|
|
|
|
|
//fix.erroff = new int[stride, npar / 2];
|
|
|
|
|
|
fix.errors = new int[stride];
|
|
|
|
|
|
|
2011-10-26 05:09:37 +00:00
|
|
|
|
var syn1 = ar.GetSyndrome(npar);
|
2011-10-27 20:50:11 +00:00
|
|
|
|
var rs = new RsDecode16(npar, this.galois);
|
2011-10-26 05:09:37 +00:00
|
|
|
|
|
|
|
|
|
|
//fixed (byte* par = &parity2[pos])
|
|
|
|
|
|
fixed (ushort* exp = galois.ExpTbl, log = galois.LogTbl, chT = rs.chienTable, psyn2 = syn2, psyn1 = syn1)
|
2011-05-06 20:22:21 +00:00
|
|
|
|
fixed (int* sf = fix.sigma, of = fix.omega, ef = fix.errpos)
|
2010-04-24 17:47:57 +00:00
|
|
|
|
{
|
2011-10-27 20:50:11 +00:00
|
|
|
|
int sfLen = fix.sigma.GetLength(1);
|
|
|
|
|
|
int ofLen = fix.omega.GetLength(1);
|
|
|
|
|
|
int efLen = fix.errpos.GetLength(1);
|
|
|
|
|
|
int* syn = stackalloc int[npar];
|
2010-04-24 17:47:57 +00:00
|
|
|
|
int offset = fix.actualOffset;
|
|
|
|
|
|
|
|
|
|
|
|
for (int part = 0; part < stride; part++)
|
|
|
|
|
|
{
|
|
|
|
|
|
int part2 = (part + offset * 2 + stride) % stride;
|
2011-10-26 05:09:37 +00:00
|
|
|
|
ushort* syn1part = psyn1 + part * npar;
|
|
|
|
|
|
ushort* syn2part = psyn2 + part2 * npar;
|
2010-04-24 17:47:57 +00:00
|
|
|
|
int err = 0;
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < npar; i++)
|
|
|
|
|
|
{
|
2011-10-26 05:09:37 +00:00
|
|
|
|
int synI = syn1part[i];
|
2010-04-24 17:47:57 +00:00
|
|
|
|
|
|
|
|
|
|
// offset < 0
|
|
|
|
|
|
if (part < -offset * 2)
|
|
|
|
|
|
{
|
2011-10-26 05:09:37 +00:00
|
|
|
|
synI ^= galois.mulExp(ar.leadin[stride + part], (i * (stridecount - 1)) % galois.Max);
|
|
|
|
|
|
synI = ar.leadout[laststride - part - 1] ^ galois.mulExp(synI, i);
|
2010-04-24 17:47:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
// offset > 0
|
|
|
|
|
|
if (part >= stride - offset * 2)
|
|
|
|
|
|
{
|
2011-10-26 05:09:37 +00:00
|
|
|
|
synI = galois.divExp(synI ^ ar.leadout[laststride + stride - part - 1], i);
|
|
|
|
|
|
synI ^= galois.mulExp(ar.leadin[part], (i * (stridecount - 1)) % galois.Max);
|
2010-04-24 17:47:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2011-10-26 05:09:37 +00:00
|
|
|
|
synI = galois.mulExp(synI ^ syn2part[i], i * npar);
|
|
|
|
|
|
syn[i] = synI;
|
|
|
|
|
|
err |= synI;
|
2010-04-24 17:47:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//for (int j = 0; j < npar; j++)
|
|
|
|
|
|
// if (wr[j] != 0)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// ushort* myexp = exp + log[wr[j]];
|
|
|
|
|
|
// syn[0] ^= wr[j];
|
|
|
|
|
|
// for (int i = 1; i < npar; i++)
|
|
|
|
|
|
// syn[i] ^= myexp[(npar - j - 1) * i];
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
//for (int i = 0; i < npar; i++)
|
|
|
|
|
|
// err |= syn[i];
|
|
|
|
|
|
|
|
|
|
|
|
if (err != 0)
|
|
|
|
|
|
{
|
2011-10-27 20:50:11 +00:00
|
|
|
|
int* s = sf + part * sfLen;
|
|
|
|
|
|
int* o = of + part * ofLen;
|
|
|
|
|
|
int* e = ef + part * efLen;
|
2011-05-06 20:22:21 +00:00
|
|
|
|
//fixed (int* s = &fix.sigma[part, 0], o = &fix.omega[part, 0], e = &fix.errpos[part, 0])
|
2010-04-24 17:47:57 +00:00
|
|
|
|
{
|
|
|
|
|
|
fix.errors[part] = rs.calcSigmaMBM(s, syn);
|
|
|
|
|
|
fix.hasErrors = true;
|
|
|
|
|
|
fix.correctableErrors += fix.errors[part];
|
2011-05-06 20:22:21 +00:00
|
|
|
|
if (fix.errors[part] <= 0 || !rs.chienSearch(e, stridecount + npar, fix.errors[part], s, chT))
|
2010-04-24 17:47:57 +00:00
|
|
|
|
fix.canRecover = false;
|
|
|
|
|
|
else
|
2011-10-27 20:50:11 +00:00
|
|
|
|
galois.mulPoly(o, s, syn, ofLen, sfLen, npar);
|
2010-04-24 17:47:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
fix.errors[part] = 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return fix;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2011-03-08 15:37:43 +00:00
|
|
|
|
public string OffsetSafeCRC
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return ar.OffsetSafeCRC.Base64;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2010-04-24 17:47:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class CDRepairFix : CDRepair, IAudioDest
|
|
|
|
|
|
{
|
|
|
|
|
|
internal bool hasErrors = false, canRecover = true;
|
|
|
|
|
|
internal int actualOffset = 0;
|
|
|
|
|
|
internal int correctableErrors = 0;
|
|
|
|
|
|
internal int[,] sigma;
|
|
|
|
|
|
internal int[,] omega;
|
|
|
|
|
|
internal int[,] errpos;
|
|
|
|
|
|
internal int[] erroffsorted;
|
|
|
|
|
|
internal ushort[] forneysorted;
|
|
|
|
|
|
internal int erroffcount;
|
|
|
|
|
|
internal int[] errors;
|
|
|
|
|
|
private BitArray affectedSectorArray;
|
|
|
|
|
|
private int nexterroff;
|
2011-10-27 20:50:11 +00:00
|
|
|
|
private int npar;
|
2010-04-24 17:47:57 +00:00
|
|
|
|
uint crc = 0;
|
|
|
|
|
|
|
2011-10-27 20:50:11 +00:00
|
|
|
|
internal CDRepairFix(CDRepairEncode decode, int npar)
|
2010-04-24 17:47:57 +00:00
|
|
|
|
: base(decode)
|
|
|
|
|
|
{
|
2011-10-27 20:50:11 +00:00
|
|
|
|
this.npar = npar;
|
2010-04-24 17:47:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string AffectedSectors
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
|
SortErrors();
|
|
|
|
|
|
for (int i = 0; i < erroffcount; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
int j;
|
|
|
|
|
|
for (j = i + 1; j < erroffcount; j++)
|
|
|
|
|
|
if (erroffsorted[j] - erroffsorted[j - 1] > 2 * 588 * 5)
|
|
|
|
|
|
break;
|
|
|
|
|
|
uint sec1 = (uint)erroffsorted[i] / 2 / 588;
|
|
|
|
|
|
uint sec2 = (uint)erroffsorted[j - 1] / 2 / 588;
|
|
|
|
|
|
if (sb.Length != 0) sb.Append(",");
|
|
|
|
|
|
sb.Append(CDImageLayout.TimeToString(sec1));
|
|
|
|
|
|
if (sec1 != sec2) sb.Append("-");
|
|
|
|
|
|
if (sec1 != sec2) sb.Append(CDImageLayout.TimeToString(sec2));
|
|
|
|
|
|
i = j - 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
return sb.ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public BitArray AffectedSectorArray
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
if (affectedSectorArray == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
affectedSectorArray = new BitArray(finalSampleCount / 588 + 1);
|
|
|
|
|
|
SortErrors();
|
|
|
|
|
|
for (int i = 0; i < erroffcount; i++)
|
|
|
|
|
|
affectedSectorArray[erroffsorted[i] / 2 / 588] = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
return affectedSectorArray;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private int GetErrOff(int part, int i)
|
|
|
|
|
|
{
|
|
|
|
|
|
return (2 + galois.toPos(stridecount + npar, errpos[part, i]) - (stride + part + ActualOffset * 2) / stride) * stride + part;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private unsafe void SortErrors()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (erroffsorted != null)
|
|
|
|
|
|
return;
|
|
|
|
|
|
erroffcount = 0;
|
|
|
|
|
|
erroffsorted = new int[errpos.GetLength(0) * errpos.GetLength(1)];
|
|
|
|
|
|
forneysorted = new ushort[errpos.GetLength(0) * errpos.GetLength(1)];
|
2011-10-27 20:50:11 +00:00
|
|
|
|
for (int part = 0; part < stride; part++)
|
2010-04-24 17:47:57 +00:00
|
|
|
|
{
|
|
|
|
|
|
fixed (int* s = &sigma[part, 0], o = &omega[part, 0])
|
|
|
|
|
|
for (int i = 0; i < errors[part]; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
erroffsorted[erroffcount] = GetErrOff(part, i);
|
|
|
|
|
|
if (erroffsorted[erroffcount] >= 0 && erroffsorted[erroffcount] < finalSampleCount * 2)
|
|
|
|
|
|
{
|
2011-10-27 20:50:11 +00:00
|
|
|
|
forneysorted[erroffcount] = (ushort)this.galois.doForney(errors[part], errpos[part, i], s, o);
|
2010-04-24 17:47:57 +00:00
|
|
|
|
erroffcount++;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
Array.Sort<int, ushort>(erroffsorted, forneysorted, 0, erroffcount);
|
|
|
|
|
|
// assert erroffcount == CorrectableErrors
|
|
|
|
|
|
nexterroff = 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public unsafe void Write(AudioBuffer sampleBuffer)
|
|
|
|
|
|
{
|
|
|
|
|
|
sampleBuffer.Prepare(this);
|
|
|
|
|
|
|
|
|
|
|
|
if ((sampleBuffer.ByteLength & 1) != 0)
|
|
|
|
|
|
throw new Exception("never happens");
|
|
|
|
|
|
|
|
|
|
|
|
int firstPos = Math.Max(0, stride - sampleCount * 2 - ActualOffset * 2);
|
|
|
|
|
|
int lastPos = Math.Min(sampleBuffer.ByteLength >> 1, (finalSampleCount - sampleCount) * 2 - laststride - ActualOffset * 2);
|
|
|
|
|
|
|
|
|
|
|
|
SortErrors();
|
|
|
|
|
|
|
|
|
|
|
|
fixed (byte* bytes = sampleBuffer.Bytes)
|
|
|
|
|
|
fixed (uint* t = Crc32.table)
|
|
|
|
|
|
{
|
|
|
|
|
|
ushort* data = (ushort*)bytes;
|
|
|
|
|
|
for (int pos = firstPos; pos < lastPos; pos++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (sampleCount * 2 + pos == erroffsorted[nexterroff] && nexterroff < erroffsorted.Length)
|
|
|
|
|
|
data[pos] ^= forneysorted[nexterroff++];
|
|
|
|
|
|
|
|
|
|
|
|
ushort dd = data[pos];
|
|
|
|
|
|
crc = (crc >> 8) ^ t[(byte)(crc ^ dd)];
|
|
|
|
|
|
crc = (crc >> 8) ^ t[(byte)(crc ^ (dd >> 8))];
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
sampleCount += sampleBuffer.Length;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public unsafe void Close()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (sampleCount != finalSampleCount)
|
|
|
|
|
|
throw new Exception("sampleCount != finalSampleCount");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public bool HasErrors
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return hasErrors;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public bool CanRecover
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return canRecover;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public int CorrectableErrors
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return correctableErrors;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public int ActualOffset
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return actualOffset;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public uint CRC
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return 0xffffffff ^ Crc32.Combine(0xffffffff, crc, stride * stridecount * 2);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Delete()
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new Exception("unsupported");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public int CompressionLevel
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return 0; }
|
|
|
|
|
|
set { }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2010-05-18 17:18:37 +00:00
|
|
|
|
public object Settings
|
2010-04-24 17:47:57 +00:00
|
|
|
|
{
|
2010-05-18 17:18:37 +00:00
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
2010-04-24 17:47:57 +00:00
|
|
|
|
set
|
|
|
|
|
|
{
|
2010-05-18 17:18:37 +00:00
|
|
|
|
if (value != null && value.GetType() != typeof(object))
|
|
|
|
|
|
throw new Exception("Unsupported options " + value);
|
2010-04-24 17:47:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2010-05-18 17:18:37 +00:00
|
|
|
|
public long Padding
|
|
|
|
|
|
{
|
|
|
|
|
|
set { }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2010-04-24 17:47:57 +00:00
|
|
|
|
public AudioPCMConfig PCM
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return AudioPCMConfig.RedBook; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public long BlockSize
|
|
|
|
|
|
{
|
|
|
|
|
|
set { throw new Exception("unsupported"); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string Path
|
|
|
|
|
|
{
|
|
|
|
|
|
get { throw new Exception("unsupported"); }
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|