internal static void GenerateECC(byte[] wd, int nd, int datablock, int nc) {
int blocks = (nd + 2) / datablock;
int b;
byte[] buf = new byte[256];
byte[] ecc = new byte[256];
int[] c = GetPoly(nc);
for (b = 0; b < blocks; b++)
{
int n, p = 0;
for (n = b; n < nd; n += blocks)
buf[p++] = wd[n];
ReedSolomonBlock(buf, p, ecc, nc, c);
p = 0;
for (n = b; n < nc * blocks; n += blocks)
wd[nd + n] = ecc[p++];
}
}
}