Menu

#107 QR code error correction capacity optimization bug

1.0
closed
None
2018-11-02
2018-06-21
No

This is another one I'm not 100% sure is a bug, but looks suspicious. The following block of code in qr.c seems to compare bit length to codeword count:

/* Ensure maxium error correction capacity */
if (est_binlen <= qr_data_codewords_M[version - 1]) {
    ecc_level = LEVEL_M;
}
if (est_binlen <= qr_data_codewords_Q[version - 1]) {
    ecc_level = LEVEL_Q;
}
if (est_binlen <= qr_data_codewords_H[version - 1]) {
    ecc_level = LEVEL_H;
}

Similar code elsewhere in this file multiplies the codeword counts by 8 so that we're comparing bit lengths.

The equivalent Okapi code also multiplies the codeword count by 8:

    /* Ensure maximum error correction capacity */
    if (est_binlen <= (QR_DATA_CODEWORDS_M[version - 1] * 8)) {
        ecc_level = EccMode.M;
    }
    if (est_binlen <= (QR_DATA_CODEWORDS_Q[version - 1] * 8)) {
        ecc_level = EccMode.Q;
    }
    if (est_binlen <= (QR_DATA_CODEWORDS_H[version - 1] * 8)) {
        ecc_level = EccMode.H;

}

Discussion

  • Robin Stuart

    Robin Stuart - 2018-06-21
    • status: open --> accepted
    • assigned_to: Robin Stuart
     
  • Robin Stuart

    Robin Stuart - 2018-06-21

    Thanks Daniel,

    Well spotted! The Okapi code is correct. I have now corrected Zint.

    Robin.

     
  • Harald Oehlmann

    Harald Oehlmann - 2018-11-02
    • status: accepted --> closed
     

Log in to post a comment.

MongoDB Logo MongoDB