----------------------------------------------------------------------
($data, &$parity)
| 2396 | |
| 2397 | //---------------------------------------------------------------------- |
| 2398 | public function encode_rs_char($data, &$parity) |
| 2399 | { |
| 2400 | $MM =& $this->mm; |
| 2401 | $NN =& $this->nn; |
| 2402 | $ALPHA_TO =& $this->alpha_to; |
| 2403 | $INDEX_OF =& $this->index_of; |
| 2404 | $GENPOLY =& $this->genpoly; |
| 2405 | $NROOTS =& $this->nroots; |
| 2406 | $FCR =& $this->fcr; |
| 2407 | $PRIM =& $this->prim; |
| 2408 | $IPRIM =& $this->iprim; |
| 2409 | $PAD =& $this->pad; |
| 2410 | $A0 =& $NN; |
| 2411 | |
| 2412 | $parity = array_fill(0, $NROOTS, 0); |
| 2413 | |
| 2414 | for($i=0; $i< ($NN-$NROOTS-$PAD); $i++) { |
| 2415 | |
| 2416 | $feedback = $INDEX_OF[$data[$i] ^ $parity[0]]; |
| 2417 | if($feedback != $A0) { |
| 2418 | // feedback term is non-zero |
| 2419 | |
| 2420 | // This line is unnecessary when GENPOLY[NROOTS] is unity, as it must |
| 2421 | // always be for the polynomials constructed by init_rs() |
| 2422 | $feedback = $this->modnn($NN - $GENPOLY[$NROOTS] + $feedback); |
| 2423 | |
| 2424 | for($j=1;$j<$NROOTS;$j++) { |
| 2425 | $parity[$j] ^= $ALPHA_TO[$this->modnn($feedback + $GENPOLY[$NROOTS-$j])]; |
| 2426 | } |
| 2427 | } |
| 2428 | |
| 2429 | // Shift |
| 2430 | array_shift($parity); |
| 2431 | if($feedback != $A0) { |
| 2432 | array_push($parity, $ALPHA_TO[$this->modnn($feedback + $GENPOLY[0])]); |
| 2433 | } else { |
| 2434 | array_push($parity, 0); |
| 2435 | } |
| 2436 | } |
| 2437 | } |
| 2438 | } |
| 2439 | |
| 2440 | //########################################################################## |