mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
Corrected reed-solomon/Data Matrix bug
This commit is contained in:
parent
5994ff5cf7
commit
944a754fee
@ -91,6 +91,7 @@ void rs_error(char data_pattern[])
|
|||||||
{
|
{
|
||||||
concat(data_pattern, AusBarTable[(int)result[reader - 1]]);
|
concat(data_pattern, AusBarTable[(int)result[reader - 1]]);
|
||||||
}
|
}
|
||||||
|
rs_free();
|
||||||
}
|
}
|
||||||
|
|
||||||
int australia_post(struct zint_symbol *symbol, unsigned char source[])
|
int australia_post(struct zint_symbol *symbol, unsigned char source[])
|
||||||
|
@ -802,6 +802,7 @@ int aztec(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
if(ecc_part[i] & 0x02) { concat(adjusted_string, "1"); } else { concat(adjusted_string, "0"); }
|
if(ecc_part[i] & 0x02) { concat(adjusted_string, "1"); } else { concat(adjusted_string, "0"); }
|
||||||
if(ecc_part[i] & 0x01) { concat(adjusted_string, "1"); } else { concat(adjusted_string, "0"); }
|
if(ecc_part[i] & 0x01) { concat(adjusted_string, "1"); } else { concat(adjusted_string, "0"); }
|
||||||
}
|
}
|
||||||
|
rs_free();
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
for(i = 0; i < data_blocks; i++) {
|
for(i = 0; i < data_blocks; i++) {
|
||||||
@ -827,6 +828,7 @@ int aztec(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
if(ecc_part[i] & 0x02) { concat(adjusted_string, "1"); } else { concat(adjusted_string, "0"); }
|
if(ecc_part[i] & 0x02) { concat(adjusted_string, "1"); } else { concat(adjusted_string, "0"); }
|
||||||
if(ecc_part[i] & 0x01) { concat(adjusted_string, "1"); } else { concat(adjusted_string, "0"); }
|
if(ecc_part[i] & 0x01) { concat(adjusted_string, "1"); } else { concat(adjusted_string, "0"); }
|
||||||
}
|
}
|
||||||
|
rs_free();
|
||||||
break;
|
break;
|
||||||
case 10:
|
case 10:
|
||||||
for(i = 0; i < data_blocks; i++) {
|
for(i = 0; i < data_blocks; i++) {
|
||||||
@ -856,6 +858,7 @@ int aztec(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
if(ecc_part[i] & 0x02) { concat(adjusted_string, "1"); } else { concat(adjusted_string, "0"); }
|
if(ecc_part[i] & 0x02) { concat(adjusted_string, "1"); } else { concat(adjusted_string, "0"); }
|
||||||
if(ecc_part[i] & 0x01) { concat(adjusted_string, "1"); } else { concat(adjusted_string, "0"); }
|
if(ecc_part[i] & 0x01) { concat(adjusted_string, "1"); } else { concat(adjusted_string, "0"); }
|
||||||
}
|
}
|
||||||
|
rs_free();
|
||||||
break;
|
break;
|
||||||
case 12:
|
case 12:
|
||||||
for(i = 0; i < data_blocks; i++) {
|
for(i = 0; i < data_blocks; i++) {
|
||||||
@ -889,6 +892,7 @@ int aztec(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
if(ecc_part[i] & 0x02) { concat(adjusted_string, "1"); } else { concat(adjusted_string, "0"); }
|
if(ecc_part[i] & 0x02) { concat(adjusted_string, "1"); } else { concat(adjusted_string, "0"); }
|
||||||
if(ecc_part[i] & 0x01) { concat(adjusted_string, "1"); } else { concat(adjusted_string, "0"); }
|
if(ecc_part[i] & 0x01) { concat(adjusted_string, "1"); } else { concat(adjusted_string, "0"); }
|
||||||
}
|
}
|
||||||
|
rs_free();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -968,6 +972,7 @@ int aztec(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
if(desc_ecc[i] & 0x01) { descriptor[(i * 4) + 19] = '1'; }
|
if(desc_ecc[i] & 0x01) { descriptor[(i * 4) + 19] = '1'; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
rs_free();
|
||||||
|
|
||||||
/* Merge descriptor with the rest of the symbol */
|
/* Merge descriptor with the rest of the symbol */
|
||||||
for(i = 0; i < 40; i++) {
|
for(i = 0; i < 40; i++) {
|
||||||
|
@ -221,6 +221,7 @@ static void ecc200(unsigned char *binary, int bytes, int datablock, int rsblock)
|
|||||||
for (n = b; n < rsblock * blocks; n += blocks)
|
for (n = b; n < rsblock * blocks; n += blocks)
|
||||||
binary[bytes + n] = ecc[p--];
|
binary[bytes + n] = ecc[p--];
|
||||||
}
|
}
|
||||||
|
rs_free();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -237,6 +238,7 @@ char ecc200encode(unsigned char *t, int tl, unsigned char *s, int sl, char *enco
|
|||||||
fprintf(stderr, "Encoding string too short\n");
|
fprintf(stderr, "Encoding string too short\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// do the encoding
|
// do the encoding
|
||||||
while (sp < sl && tp < tl) {
|
while (sp < sl && tp < tl) {
|
||||||
char newenc = enc; // suggest new encoding
|
char newenc = enc; // suggest new encoding
|
||||||
@ -851,14 +853,12 @@ int iec16022ecc200(unsigned char *barcode, int barcodelen, struct zint_symbol *s
|
|||||||
}
|
}
|
||||||
symbol->row_height[(H - y) - 1] = 1;
|
symbol->row_height[(H - y) - 1] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(grid);
|
free(grid);
|
||||||
free(places);
|
free(places);
|
||||||
}
|
}
|
||||||
|
|
||||||
symbol->rows = H;
|
symbol->rows = H;
|
||||||
symbol->width = W;
|
symbol->width = W;
|
||||||
|
|
||||||
free(encoding);
|
free(encoding);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,7 @@ void maxi_do_primary_check( )
|
|||||||
|
|
||||||
for ( j = 0; j < ecclen; j += 1)
|
for ( j = 0; j < ecclen; j += 1)
|
||||||
maxi_codeword[ datalen + j] = results[j];
|
maxi_codeword[ datalen + j] = results[j];
|
||||||
|
rs_free();
|
||||||
}
|
}
|
||||||
|
|
||||||
void maxi_do_secondary_chk_odd( int ecclen )
|
void maxi_do_secondary_chk_odd( int ecclen )
|
||||||
@ -72,6 +73,7 @@ void maxi_do_secondary_chk_odd( int ecclen )
|
|||||||
|
|
||||||
for ( j = 0; j < (ecclen); j += 1)
|
for ( j = 0; j < (ecclen); j += 1)
|
||||||
maxi_codeword[ datalen + (2 *j) + 1 + 20 ] = results[j];
|
maxi_codeword[ datalen + (2 *j) + 1 + 20 ] = results[j];
|
||||||
|
rs_free();
|
||||||
}
|
}
|
||||||
|
|
||||||
void maxi_do_secondary_chk_even(int ecclen )
|
void maxi_do_secondary_chk_even(int ecclen )
|
||||||
@ -96,6 +98,7 @@ void maxi_do_secondary_chk_even(int ecclen )
|
|||||||
|
|
||||||
for ( j = 0; j < (ecclen); j += 1)
|
for ( j = 0; j < (ecclen); j += 1)
|
||||||
maxi_codeword[ datalen + (2 *j) + 20] = results[j];
|
maxi_codeword[ datalen + (2 *j) + 20] = results[j];
|
||||||
|
rs_free();
|
||||||
}
|
}
|
||||||
|
|
||||||
void maxi_bump(int set[], int character[], int bump_posn)
|
void maxi_bump(int set[], int character[], int bump_posn)
|
||||||
|
@ -104,8 +104,7 @@ void rs_init_code(int nsym, int index)
|
|||||||
rspoly[i] = 1;
|
rspoly[i] = 1;
|
||||||
for (k = i - 1; k > 0; k--) {
|
for (k = i - 1; k > 0; k--) {
|
||||||
if (rspoly[k])
|
if (rspoly[k])
|
||||||
rspoly[k] =
|
rspoly[k] = alog[(log[rspoly[k]] + index) % logmod];
|
||||||
alog[(log[rspoly[k]] + index) % logmod];
|
|
||||||
rspoly[k] ^= rspoly[k - 1];
|
rspoly[k] ^= rspoly[k - 1];
|
||||||
}
|
}
|
||||||
rspoly[0] = alog[(log[rspoly[0]] + index) % logmod];
|
rspoly[0] = alog[(log[rspoly[0]] + index) % logmod];
|
||||||
@ -122,10 +121,7 @@ void rs_encode(int len, unsigned char *data, unsigned char *res)
|
|||||||
m = res[rlen - 1] ^ data[i];
|
m = res[rlen - 1] ^ data[i];
|
||||||
for (k = rlen - 1; k > 0; k--) {
|
for (k = rlen - 1; k > 0; k--) {
|
||||||
if (m && rspoly[k])
|
if (m && rspoly[k])
|
||||||
res[k] =
|
res[k] = res[k - 1] ^ alog[(log[m] + log[rspoly[k]]) % logmod];
|
||||||
res[k -
|
|
||||||
1] ^ alog[(log[m] +
|
|
||||||
log[rspoly[k]]) % logmod];
|
|
||||||
else
|
else
|
||||||
res[k] = res[k - 1];
|
res[k] = res[k - 1];
|
||||||
}
|
}
|
||||||
@ -134,12 +130,6 @@ void rs_encode(int len, unsigned char *data, unsigned char *res)
|
|||||||
else
|
else
|
||||||
res[0] = 0;
|
res[0] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(log);
|
|
||||||
free(alog);
|
|
||||||
free(rspoly);
|
|
||||||
rspoly = NULL;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void rs_encode_long(int len, unsigned int *data, unsigned int *res)
|
void rs_encode_long(int len, unsigned int *data, unsigned int *res)
|
||||||
@ -151,10 +141,7 @@ void rs_encode_long(int len, unsigned int *data, unsigned int *res)
|
|||||||
m = res[rlen - 1] ^ data[i];
|
m = res[rlen - 1] ^ data[i];
|
||||||
for (k = rlen - 1; k > 0; k--) {
|
for (k = rlen - 1; k > 0; k--) {
|
||||||
if (m && rspoly[k])
|
if (m && rspoly[k])
|
||||||
res[k] =
|
res[k] = res[k - 1] ^ alog[(log[m] + log[rspoly[k]]) % logmod];
|
||||||
res[k -
|
|
||||||
1] ^ alog[(log[m] +
|
|
||||||
log[rspoly[k]]) % logmod];
|
|
||||||
else
|
else
|
||||||
res[k] = res[k - 1];
|
res[k] = res[k - 1];
|
||||||
}
|
}
|
||||||
@ -163,10 +150,12 @@ void rs_encode_long(int len, unsigned int *data, unsigned int *res)
|
|||||||
else
|
else
|
||||||
res[0] = 0;
|
res[0] = 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void rs_free()
|
||||||
|
{ /* Free memory */
|
||||||
free(log);
|
free(log);
|
||||||
free(alog);
|
free(alog);
|
||||||
free(rspoly);
|
free(rspoly);
|
||||||
rspoly = NULL;
|
rspoly = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,5 +26,6 @@ void rs_init_gf(int poly);
|
|||||||
void rs_init_code(int nsym, int index);
|
void rs_init_code(int nsym, int index);
|
||||||
void rs_encode(int len, unsigned char *data, unsigned char *res);
|
void rs_encode(int len, unsigned char *data, unsigned char *res);
|
||||||
void rs_encode_long(int len, unsigned int *data, unsigned int *res);
|
void rs_encode_long(int len, unsigned int *data, unsigned int *res);
|
||||||
|
void rs_free();
|
||||||
|
|
||||||
#endif /* __REEDSOL_H */
|
#endif /* __REEDSOL_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user