3232% IN THE SOFTWARE.
3333
3434% --BEGIN ENCODER azteccode--
35- % --REQUIRES preamble raiseerror setuphooks processoptions parseinput setanycolor fifocache render renmatrix--
35+ % --REQUIRES preamble raiseerror setuphooks processoptions parseinput setanycolor fifocache rsecbinary render renmatrix--
3636% --DESC: Aztec Code
3737% --EXAM: This is Aztec Code
3838% --EXOP: format=full
@@ -46,6 +46,7 @@ dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
4646dup /processoptions dup /uk.co.terryburton.bwipp findresource put
4747dup /parseinput dup /uk.co.terryburton.bwipp findresource put
4848dup /fifocache dup /uk.co.terryburton.bwipp findresource put
49+ dup /rsecbinary dup /uk.co.terryburton.bwipp findresource put
4950dup /setuphooks dup /uk.co.terryburton.bwipp findresource put
5051dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
5152dup /render dup /uk.co.terryburton.bwipp findresource put
@@ -895,7 +896,8 @@ begin
895896 (input.encoding) //azteccode.after exec
896897
897898 %
898- % Reed-Solomon algorithm
899+ % Reed-Solomon algorithm. Returns rsnc ECC codewords. The GF parameters
900+ % (and hence rsprod) vary with rsbt, so both are bound per call.
899901 %
900902 /rscodes {
901903
@@ -924,27 +926,9 @@ begin
924926 /coeffs rsnc rsbt //azteccode.coeffscachefetch exec def
925927 (ecc.coeffs) //azteccode.after exec
926928
927- %
928- % Extend the input with the error correction values
929- %
930- /nd rscws length def
931- /rscws [ rscws aload pop rsnc {0} repeat 0 ] def
932- 0 1 nd 1 sub { % i
933- rscws exch get rscws nd get xor % k = rscws[i] ^ rscw[nd]
934- 0 1 rsnc 1 sub { % j
935- dup
936- rscws exch nd add 2 copy 1 add get % ... rscws nd+j rscws[nd+j+1]
937- coeffs rsnc 6 -1 roll sub 1 sub get % ... coeffs[rsnc-1-j]
938- 4 index % ... k
939- rsprod xor put % rscws[nd+j] = rscws[nd+j+1] ^ (coeffs[rsnc-1-j] * k)
940- } for
941- pop % k
942- } for
943-
944- %
945- % Return all but the last codeword
946- %
947- rscws 0 rscws length 1 sub getinterval
929+ /lfsr rsnc array def
930+ {rscws exch get} rscws length coeffs rsnc lfsr /rsprod load //rsecbinary exec
931+ lfsr
948932
949933 (ecc.cws) //azteccode.after exec
950934
@@ -962,7 +946,7 @@ begin
962946 mode 2#0000000011110000 and -4 bitshift
963947 mode 2#0000000000001111 and
964948 ] def
965- /mode mode 6 4 rscodes def
949+ /mode [ mode aload pop mode 6 4 rscodes aload pop ] def
966950 } if
967951 format (compact) eq {
968952 /mode layers 1 sub 6 bitshift cws length 1 sub add def
@@ -971,15 +955,15 @@ begin
971955 mode 2#11110000 and -4 bitshift
972956 mode 2#00001111 and
973957 ] def
974- /mode mode 5 4 rscodes def
958+ /mode [ mode aload pop mode 5 4 rscodes aload pop ] def
975959 } if
976960 format (rune) eq {
977961 /mode barcode cvi def
978962 /mode [
979963 mode 2#11110000 and -4 bitshift
980964 mode 2#00001111 and
981965 ] def
982- /mode mode 5 4 rscodes def
966+ /mode [ mode aload pop mode 5 4 rscodes aload pop ] def
983967 /mode [mode {2#1010 xor} forall] def % Invert alternate bits
984968 } if
985969 /modebits mode length 4 mul string def
@@ -996,9 +980,9 @@ begin
996980
997981 options /debugecc known
998982 /uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledebug known} {pop false} ifelse
999- and { /bwipp.debugecc ecws cws length ecws length cws length sub getinterval //raiseerror exec } if
983+ and { /bwipp.debugecc ecws //raiseerror exec } if
1000984
1001- /cws ecws def
985+ /cws [ cws aload pop ecws aload pop ] def
1002986 format (full) eq {
1003987 /databits layers layers mul 16 mul layers 112 mul add string def
1004988 } {
0 commit comments