Skip to content

Commit 6b8b72a

Browse files
quirc_decode: back to memcpy for stability
1 parent 8f4b3c5 commit 6b8b72a

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

c_mpos/src/quirc_decode.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,15 @@ static mp_obj_t qrdecode(mp_uint_t n_args, const mp_obj_t *args) {
5656
//QRDECODE_DEBUG_PRINT("qrdecode: Resized quirc object\n");
5757

5858
uint8_t *image = quirc_begin(qr, NULL, NULL);
59-
//memcpy(image, bufinfo.buf, width * height);
60-
uint8_t *temp_image = image;
61-
//image = bufinfo.buf; // use existing buffer, rather than memcpy - but this doesnt find any images anymore :-/
62-
qr->image = bufinfo.buf; // if this works then we can also eliminate quirc's ps_alloc()
59+
memcpy(image, bufinfo.buf, width * height);
60+
// would be nice to be able to use the existing buffer (bufinfo.buf) here, avoiding memcpy,
61+
// but that buffer is also being filled by image capture and displayed by lvgl
62+
// and that becomes unstable... it shows black artifacts and crashes sometimes...
63+
//uint8_t *temp_image = image;
64+
//image = bufinfo.buf;
65+
//qr->image = bufinfo.buf; // if this works then we can also eliminate quirc's ps_alloc()
6366
quirc_end(qr);
64-
qr->image = temp_image; // restore, because quirc will try to free it
67+
//qr->image = temp_image; // restore, because quirc will try to free it
6568

6669
/*
6770
// Pointer swap - NO memcpy, NO internal.h needed

0 commit comments

Comments
 (0)