@@ -42,33 +42,25 @@ begin
4242%
4343% Reed-Solomon encoder for prime-field GF(p).
4444%
45- % Runs a streaming LFSR over nd data codewords using the generator polynomial
46- % coeffs . The caller-owned lfsr is the shift register; on return, its first
47- % nc cells are the ECC codewords in the negated form expected by callers
48- % (pdf417, micropdf417, ultracode): this fuses what used to be a separate
49- % post-pass of (p - cws[i]) mod p into the inner update .
45+ % Runs a streaming LFSR over nd data codewords using the generator
46+ % polynomial . The caller-owned lfsr is the shift register; on return, its
47+ % first nc cells are the ECC codewords, where nc is the length of
48+ % coeffsrev, negated ((p - c) mod p) as the callers expect. The caller
49+ % must supply the generator coefficients reversed .
5050%
5151/rsecprime {
5252
5353 8 dict begin
5454
55- /p exch def % Prime modulus
56- /lfsr exch def % Workspace of length at least nc
57- /nc exch def % Number of ECC codewords to produce
58- /coeffs exch def % Generator polynomial coefficients
59- /nd exch def % Number of data codewords
60- /getdata exch def % Implements fetching nth codeword
55+ /p exch def % Prime modulus
56+ /lfsr exch def % Workspace of length at least nc
57+ /coeffsrev exch def % Reversed generator polynomial coefficients
58+ /nd exch def % Number of data codewords
59+ /getdata exch def % Implements fetching nth codeword
6160
62- 0 1 nc 1 sub {lfsr exch 0 put} for % Zero LFSR
61+ / nc coeffsrev length def % Number of ECC codewords to produce
6362
64- %
65- % Reverse coeffs to simplify the inner loop
66- %
67- /coeffsrev nc array def
68- 0 1 nc 1 sub {
69- /j exch def
70- coeffsrev j coeffs nc 1 sub j sub get put
71- } for
63+ 0 1 nc 1 sub {lfsr exch 0 put} for % Zero LFSR
7264
7365 0 1 nd 1 sub { % m
7466 getdata exec lfsr 0 get sub p add p mod % fb = (data[m] - S[0]) mod p
0 commit comments