protected function getErrorCorrection($cw, $ecl)
{
// get error correction coefficients
$ecc = $this->rsfactors[$ecl];
// number of error correction factors
$eclsize = 2 << $ecl;
// maximum index for $rsfactors[$ecl]
$eclmaxid = $eclsize - 1;
// initialize array of error correction codewords
$ecw = array_fill(0, $eclsize, 0);
// for each data codeword
foreach ($cw as $k => $d) {
$t1 = ($d + $ecw[$eclmaxid]) % 929;
for ($j = $eclmaxid; $j > 0; --$j) {
$t2 = $t1 * $ecc[$j] % 929;
$t3 = 929 - $t2;
$ecw[$j] = ($ecw[$j - 1] + $t3) % 929;
}
$t2 = $t1 * $ecc[0] % 929;
$t3 = 929 - $t2;
$ecw[0] = $t3 % 929;
}
foreach ($ecw as $j => $e) {
if ($e != 0) {
$ecw[$j] = 929 - $e;
}
}
$ecw = array_reverse($ecw);
return $ecw;
}