Struktur Codeword dan Interleaving

Embed This Widget

Theme


      
    

Widget powered by . Free, no account required.

How data and EC codewords are organised into blocks and interleaved for damage distribution. Block structure per version and EC level.

Codeword Structure and Interleaving

QR codes organise data and error correction into blocks and then interleave codewords from different blocks. This distribution strategy is critical for surviving localised physical damage.

Why Interleave?

If a scratch crosses a QR code, it corrupts a contiguous region of modules. Without interleaving, all corrupted codewords would belong to the same RS block, potentially overwhelming its correction capacity.

Interleaving distributes consecutive codewords from different blocks across the symbol. A localised scratch then damages one or two codewords per block instead of many in a single block — well within each block's correction capacity.

Block Structure

Each version and EC level combination specifies a fixed block structure. For example, Version 5 at EC Level Q uses:

  • 2 blocks of Group 1: 15 data codewords + 18 EC codewords each
  • 2 blocks of Group 2: 16 data codewords + 18 EC codewords each
  • Total: 62 data codewords + 72 EC codewords = 134 codewords

Larger versions have more blocks — Version 40 at EC Level H uses up to 20+ blocks.

Interleaving Order

The interleaving process:

  1. Arrange data blocks side by side
  2. Take the first codeword from each block in sequence
  3. Then the second codeword from each block, and so on
  4. Repeat for EC codewords separately

Example with 4 blocks (A, B, C, D) of 3 data codewords each:

Original: A1 A2 A3 | B1 B2 B3 | C1 C2 C3 | D1 D2 D3

Interleaved: A1 B1 C1 D1 A2 B2 C2 D2 A3 B3 C3 D3

Remainder Bits

After all data and EC codewords are placed, some versions require remainder bits (0-7 zero bits) to fill the remaining module positions. These are padding only and carry no data.

Practical Impact

The interleaving strategy means:

  • A 1 cm scratch across a Version 10 QR code might corrupt 30 contiguous modules
  • Without interleaving: 30 codewords in one block — likely unrecoverable
  • With interleaving: ~3-5 codewords per block — easily corrected

This is why QR codes can survive surprisingly large physical defects at higher EC levels.

Key Takeaways

  • Codewords are organised into blocks, each with its own RS error correction
  • Interleaving distributes block codewords across the physical symbol
  • Localised damage is spread across multiple blocks, improving recovery
  • Block structure varies by version and EC level
  • Remainder bits pad the final module positions to fill the grid