mirror of
https://github.com/opencv/opencv.git
synced 2025-06-17 23:51:16 +08:00
Update version quirc
This commit is contained in:
parent
d991c22090
commit
b7253e3280
3
3rdparty/quirc/include/quirc_internal.h
vendored
3
3rdparty/quirc/include/quirc_internal.h
vendored
@ -32,8 +32,10 @@
|
|||||||
#define QUIRC_PERSPECTIVE_PARAMS 8
|
#define QUIRC_PERSPECTIVE_PARAMS 8
|
||||||
|
|
||||||
#if QUIRC_MAX_REGIONS < UINT8_MAX
|
#if QUIRC_MAX_REGIONS < UINT8_MAX
|
||||||
|
#define QUIRC_PIXEL_ALIAS_IMAGE 1
|
||||||
typedef uint8_t quirc_pixel_t;
|
typedef uint8_t quirc_pixel_t;
|
||||||
#elif QUIRC_MAX_REGIONS < UINT16_MAX
|
#elif QUIRC_MAX_REGIONS < UINT16_MAX
|
||||||
|
#define QUIRC_PIXEL_ALIAS_IMAGE 0
|
||||||
typedef uint16_t quirc_pixel_t;
|
typedef uint16_t quirc_pixel_t;
|
||||||
#else
|
#else
|
||||||
#error "QUIRC_MAX_REGIONS > 65534 is not supported"
|
#error "QUIRC_MAX_REGIONS > 65534 is not supported"
|
||||||
@ -77,7 +79,6 @@ struct quirc_grid {
|
|||||||
struct quirc {
|
struct quirc {
|
||||||
uint8_t *image;
|
uint8_t *image;
|
||||||
quirc_pixel_t *pixels;
|
quirc_pixel_t *pixels;
|
||||||
int *row_average; /* used by threshold() */
|
|
||||||
int w;
|
int w;
|
||||||
int h;
|
int h;
|
||||||
|
|
||||||
|
2
3rdparty/quirc/src/decode.c
vendored
2
3rdparty/quirc/src/decode.c
vendored
@ -874,7 +874,7 @@ static quirc_decode_error_t decode_payload(struct quirc_data *data,
|
|||||||
done:
|
done:
|
||||||
|
|
||||||
/* Add nul terminator to all payloads */
|
/* Add nul terminator to all payloads */
|
||||||
if ((unsigned)data->payload_len >= sizeof(data->payload))
|
if (data->payload_len >= (int) sizeof(data->payload))
|
||||||
data->payload_len--;
|
data->payload_len--;
|
||||||
data->payload[data->payload_len] = 0;
|
data->payload[data->payload_len] = 0;
|
||||||
|
|
||||||
|
22
3rdparty/quirc/src/quirc.c
vendored
22
3rdparty/quirc/src/quirc.c
vendored
@ -39,9 +39,8 @@ void quirc_destroy(struct quirc *q)
|
|||||||
free(q->image);
|
free(q->image);
|
||||||
/* q->pixels may alias q->image when their type representation is of the
|
/* q->pixels may alias q->image when their type representation is of the
|
||||||
same size, so we need to be careful here to avoid a double free */
|
same size, so we need to be careful here to avoid a double free */
|
||||||
if (sizeof(*q->image) != sizeof(*q->pixels))
|
if (!QUIRC_PIXEL_ALIAS_IMAGE)
|
||||||
free(q->pixels);
|
free(q->pixels);
|
||||||
free(q->row_average);
|
|
||||||
free(q);
|
free(q);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,7 +48,6 @@ int quirc_resize(struct quirc *q, int w, int h)
|
|||||||
{
|
{
|
||||||
uint8_t *image = NULL;
|
uint8_t *image = NULL;
|
||||||
quirc_pixel_t *pixels = NULL;
|
quirc_pixel_t *pixels = NULL;
|
||||||
int *row_average = NULL;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* XXX: w and h should be size_t (or at least unsigned) as negatives
|
* XXX: w and h should be size_t (or at least unsigned) as negatives
|
||||||
@ -82,35 +80,27 @@ int quirc_resize(struct quirc *q, int w, int h)
|
|||||||
(void)memcpy(image, q->image, min);
|
(void)memcpy(image, q->image, min);
|
||||||
|
|
||||||
/* alloc a new buffer for q->pixels if needed */
|
/* alloc a new buffer for q->pixels if needed */
|
||||||
if (sizeof(*q->image) != sizeof(*q->pixels)) {
|
if (!QUIRC_PIXEL_ALIAS_IMAGE) {
|
||||||
pixels = calloc(newdim, sizeof(quirc_pixel_t));
|
pixels = calloc(newdim, sizeof(quirc_pixel_t));
|
||||||
if (!pixels)
|
if (!pixels)
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* alloc a new buffer for q->row_average */
|
|
||||||
row_average = calloc(w, sizeof(int));
|
|
||||||
if (!row_average)
|
|
||||||
goto fail;
|
|
||||||
|
|
||||||
/* alloc succeeded, update `q` with the new size and buffers */
|
/* alloc succeeded, update `q` with the new size and buffers */
|
||||||
q->w = w;
|
q->w = w;
|
||||||
q->h = h;
|
q->h = h;
|
||||||
free(q->image);
|
free(q->image);
|
||||||
q->image = image;
|
q->image = image;
|
||||||
if (sizeof(*q->image) != sizeof(*q->pixels)) {
|
if (!QUIRC_PIXEL_ALIAS_IMAGE) {
|
||||||
free(q->pixels);
|
free(q->pixels);
|
||||||
q->pixels = pixels;
|
q->pixels = pixels;
|
||||||
}
|
}
|
||||||
free(q->row_average);
|
|
||||||
q->row_average = row_average;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
fail:
|
fail:
|
||||||
free(image);
|
free(image);
|
||||||
free(pixels);
|
free(pixels);
|
||||||
free(row_average);
|
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -133,6 +123,8 @@ static const char *const error_table[] = {
|
|||||||
|
|
||||||
const char *quirc_strerror(quirc_decode_error_t err)
|
const char *quirc_strerror(quirc_decode_error_t err)
|
||||||
{
|
{
|
||||||
if ((int)err < 8) { return error_table[err]; }
|
if ((int)err >= 0 && (int)err < sizeof(error_table) / sizeof(error_table[0]))
|
||||||
else { return "Unknown error"; }
|
return error_table[err];
|
||||||
|
|
||||||
|
return "Unknown error";
|
||||||
}
|
}
|
||||||
|
11
3rdparty/quirc/src/version_db.c
vendored
11
3rdparty/quirc/src/version_db.c
vendored
@ -17,16 +17,7 @@
|
|||||||
#include <quirc_internal.h>
|
#include <quirc_internal.h>
|
||||||
|
|
||||||
const struct quirc_version_info quirc_version_db[QUIRC_MAX_VERSION + 1] = {
|
const struct quirc_version_info quirc_version_db[QUIRC_MAX_VERSION + 1] = {
|
||||||
{ /* 0 */
|
{0},
|
||||||
.data_bytes = 0,
|
|
||||||
.apat = {0},
|
|
||||||
.ecc = {
|
|
||||||
{.bs = 0, .dw = 0, .ns = 0},
|
|
||||||
{.bs = 0, .dw = 0, .ns = 0},
|
|
||||||
{.bs = 0, .dw = 0, .ns = 0},
|
|
||||||
{.bs = 0, .dw = 0, .ns = 0}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{ /* Version 1 */
|
{ /* Version 1 */
|
||||||
.data_bytes = 26,
|
.data_bytes = 26,
|
||||||
.apat = {0},
|
.apat = {0},
|
||||||
|
Loading…
Reference in New Issue
Block a user