Add support for flipped QR-codes in inspect and qrtest tools

This commit is contained in:
Claudio Felber 2020-09-22 12:18:23 +02:00
parent 4bc17cf8c6
commit 2fd06df8de
2 changed files with 18 additions and 5 deletions

View file

@ -34,6 +34,10 @@ static void dump_info(struct quirc *q)
quirc_extract(q, i, &code); quirc_extract(q, i, &code);
err = quirc_decode(&code, &data); err = quirc_decode(&code, &data);
if (err == QUIRC_ERROR_DATA_ECC) {
quirc_flip(&code);
err = quirc_decode(&code, &data);
}
dump_cells(&code); dump_cells(&code);
printf("\n"); printf("\n");

View file

@ -125,8 +125,15 @@ static int scan_file(const char *path, const char *filename,
quirc_extract(decoder, i, &code); quirc_extract(decoder, i, &code);
if (!quirc_decode(&code, &data)) quirc_decode_error_t err = quirc_decode(&code, &data);
if (err == QUIRC_ERROR_DATA_ECC) {
quirc_flip(&code);
err = quirc_decode(&code, &data);
}
if (!err) {
info->decode_count++; info->decode_count++;
}
} }
(void)clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &tp); (void)clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &tp);
@ -150,12 +157,14 @@ static int scan_file(const char *path, const char *filename,
if (want_verbose) { if (want_verbose) {
struct quirc_data data; struct quirc_data data;
quirc_decode_error_t err = quirc_decode_error_t err = quirc_decode(&code, &data);
quirc_decode(&code, &data); if (err == QUIRC_ERROR_DATA_ECC) {
quirc_flip(&code);
err = quirc_decode(&code, &data);
}
if (err) { if (err) {
printf(" ERROR: %s\n\n", printf(" ERROR: %s\n\n", quirc_strerror(err));
quirc_strerror(err));
} else { } else {
printf(" Decode successful:\n"); printf(" Decode successful:\n");
dump_data(&data); dump_data(&data);