|
8 | 8 | #include "qrscan.h"
|
9 | 9 | #include "sensitive.h"
|
10 | 10 | #include "utils/malloc_ext.h"
|
| 11 | +#include "utils/util.h" |
11 | 12 |
|
12 | 13 | #define SCAN_EXTRA_MARGIN 20
|
13 |
| -#define MIN(a, b) (a < b ? a : b) |
14 | 14 |
|
15 | 15 | // Inspect qrcodes and try to extract payload - whether any were seen and any
|
16 | 16 | // string data extracted are stored in the qr_data struct passed.
|
@@ -132,10 +132,10 @@ bool scan_qr(const size_t width, const size_t height, const uint8_t* data, const
|
132 | 132 | JADE_ASSERT(qr_data->ds);
|
133 | 133 |
|
134 | 134 | // Also correctly size the internal image buffer since we know the size of the camera images/display.
|
135 |
| - const size_t ideal_scan_box_size |
136 |
| - = MIN(camera_displayed_image_width(), camera_displayed_image_height()) + SCAN_EXTRA_MARGIN; |
137 |
| - const size_t scan_width = MIN(ideal_scan_box_size, CAMERA_IMAGE_WIDTH); |
138 |
| - const size_t scan_height = MIN(ideal_scan_box_size, CAMERA_IMAGE_HEIGHT); |
| 135 | + const uint16_t ideal_scan_box_size |
| 136 | + = min_u16(camera_displayed_image_width(), camera_displayed_image_height()) + SCAN_EXTRA_MARGIN; |
| 137 | + const uint16_t scan_width = min_u16(ideal_scan_box_size, CAMERA_IMAGE_WIDTH); |
| 138 | + const uint16_t scan_height = min_u16(ideal_scan_box_size, CAMERA_IMAGE_HEIGHT); |
139 | 139 | const int qret = quirc_resize(qr_data->q, scan_width, scan_height);
|
140 | 140 | JADE_ASSERT(qret == 0);
|
141 | 141 | qr_data->len = 0;
|
@@ -176,10 +176,10 @@ bool jade_camera_scan_qr(
|
176 | 176 |
|
177 | 177 | // Also correctly size the internal image buffer since we know the size of the camera images/display.
|
178 | 178 | // This image buffer is then reused for every camera image frame processed.
|
179 |
| - const size_t ideal_scan_box_size |
180 |
| - = MIN(camera_displayed_image_width(), camera_displayed_image_height()) + SCAN_EXTRA_MARGIN; |
181 |
| - const size_t scan_width = MIN(ideal_scan_box_size, CAMERA_IMAGE_WIDTH); |
182 |
| - const size_t scan_height = MIN(ideal_scan_box_size, CAMERA_IMAGE_HEIGHT); |
| 179 | + const uint16_t ideal_scan_box_size |
| 180 | + = min_u16(camera_displayed_image_width(), camera_displayed_image_height()) + SCAN_EXTRA_MARGIN; |
| 181 | + const uint16_t scan_width = min_u16(ideal_scan_box_size, CAMERA_IMAGE_WIDTH); |
| 182 | + const uint16_t scan_height = min_u16(ideal_scan_box_size, CAMERA_IMAGE_HEIGHT); |
183 | 183 | const int qret = quirc_resize(qr_data->q, scan_width, scan_height);
|
184 | 184 | JADE_ASSERT(qret == 0);
|
185 | 185 | qr_data->len = 0;
|
|
0 commit comments