Reed-Solomon, Versions and Mask Selection
A QR symbol is a grid of 21 by 21 modules at version 1, growing four modules per side to 177 by 177 at version 40. Data codewords are split into blocks, each block gets Reed-Solomon parity over GF(256) using the primitive polynomial 0x11D, and the codewords are interleaved so burst damage spreads across blocks. That is what allows a scanner to reconstruct missing modules.
Eight mask patterns are applied to the data region, and the encoder scores each by penalty rules: runs of five or more same-coloured modules, 2 by 2 blocks, finder-like 1:1:3:1:1 sequences, and deviation from a 50 percent dark ratio. The lowest score wins. Choosing the smallest version that fits keeps modules large, which matters more than any other parameter.