Optimize quirc_flip()
This commit is contained in:
parent
5beb59e3b4
commit
4bc17cf8c6
2 changed files with 13 additions and 14 deletions
25
lib/decode.c
25
lib/decode.c
|
@ -919,16 +919,15 @@ quirc_decode_error_t quirc_decode(const struct quirc_code *code,
|
||||||
|
|
||||||
void quirc_flip(struct quirc_code *code)
|
void quirc_flip(struct quirc_code *code)
|
||||||
{
|
{
|
||||||
struct quirc_code flipped;
|
struct quirc_code flipped = {0};
|
||||||
memset(&flipped, 0, sizeof(flipped));
|
unsigned int offset = 0;
|
||||||
int offset = 0;
|
for (int y = 0; y < code->size; y++) {
|
||||||
for (int y = 0, sx = 0; y < code->size; y++, sx++) {
|
for (int x = 0; x < code->size; x++) {
|
||||||
for (int x = 0, sy = 0; x < code->size; x++, sy++) {
|
if (grid_bit(code, y, x)) {
|
||||||
if (grid_bit(code, sx, sy)) {
|
flipped.cell_bitmap[offset >> 3u] |= (1u << (offset & 7u));
|
||||||
flipped.cell_bitmap[offset >> 3] |= (1 << (offset & 7));
|
}
|
||||||
}
|
offset++;
|
||||||
offset++;
|
}
|
||||||
}
|
}
|
||||||
}
|
memcpy(&code->cell_bitmap, &flipped.cell_bitmap, sizeof(flipped.cell_bitmap));
|
||||||
memcpy(&code->cell_bitmap, &flipped.cell_bitmap, sizeof(flipped.cell_bitmap));
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -1140,7 +1140,7 @@ void quirc_extract(const struct quirc *q, int index,
|
||||||
int x;
|
int x;
|
||||||
for (x = 0; x < qr->grid_size; x++) {
|
for (x = 0; x < qr->grid_size; x++) {
|
||||||
if (read_cell(q, index, x, y) > 0) {
|
if (read_cell(q, index, x, y) > 0) {
|
||||||
code->cell_bitmap[i >> 3] |= (1 << (i & 7));
|
code->cell_bitmap[i >> 3] |= (1 << (i & 7));
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue