aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>2019-11-04 22:54:22 -0300
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>2020-03-13 10:49:04 +0100
commit488bac3f9be27a27cffb6d21a95887ed0d4568c9 (patch)
tree0fcc1e2db9d7fd5e8d12e59810c1c5b1f2865da6
parentbd2cdb9393938a9d27ff8bce38c23dd10f7064af (diff)
config: add boolean option for raw binary decoding
When decoders encounter binary data, they attempt to guess the encoding of the data and convert it to text. This destroys other types of data. The new boolean decoder configuration option ZBAR_CFG_BINARY suppresses this automatic character set conversion. The decoders that support it will output the raw binary data. Signed-off-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
-rw-r--r--include/zbar.h1
-rw-r--r--python/zbarmodule.c1
-rw-r--r--zbar/config.c2
-rw-r--r--zbar/img_scanner.c1
-rw-r--r--zbar/symbol.c1
-rw-r--r--zbarcam/zbarcam-qt.cpp1
6 files changed, 7 insertions, 0 deletions
diff --git a/include/zbar.h b/include/zbar.h
index 0e9cbf8..0d0604a 100644
--- a/include/zbar.h
+++ b/include/zbar.h
@@ -171,6 +171,7 @@ typedef enum zbar_config_e {
ZBAR_CFG_ADD_CHECK, /**< enable check digit when optional */
ZBAR_CFG_EMIT_CHECK, /**< return check digit when present */
ZBAR_CFG_ASCII, /**< enable full ASCII character set */
+ ZBAR_CFG_BINARY, /**< don't convert binary data to text */
ZBAR_CFG_NUM, /**< number of boolean decoder configs */
ZBAR_CFG_MIN_LEN = 0x20, /**< minimum data length for valid decode */
diff --git a/python/zbarmodule.c b/python/zbarmodule.c
index b3899f2..7451c29 100644
--- a/python/zbarmodule.c
+++ b/python/zbarmodule.c
@@ -70,6 +70,7 @@ static const enumdef config_defs[] = {
{ "ADD_CHECK", ZBAR_CFG_ADD_CHECK },
{ "EMIT_CHECK", ZBAR_CFG_EMIT_CHECK },
{ "ASCII", ZBAR_CFG_ASCII },
+ { "BINARY", ZBAR_CFG_BINARY },
{ "MIN_LEN", ZBAR_CFG_MIN_LEN },
{ "MAX_LEN", ZBAR_CFG_MAX_LEN },
{ "UNCERTAINTY", ZBAR_CFG_UNCERTAINTY },
diff --git a/zbar/config.c b/zbar/config.c
index 8167314..07148c8 100644
--- a/zbar/config.c
+++ b/zbar/config.c
@@ -143,6 +143,8 @@ int zbar_parse_config (const char *cfgstr,
*cfg = ZBAR_CFG_MAX_LEN;
else if(!strncmp(cfgstr, "ascii", len))
*cfg = ZBAR_CFG_ASCII;
+ else if(!strncmp(cfgstr, "binary", len))
+ *cfg = ZBAR_CFG_BINARY;
else if(!strncmp(cfgstr, "add-check", len))
*cfg = ZBAR_CFG_ADD_CHECK;
else if(!strncmp(cfgstr, "emit-check", len))
diff --git a/zbar/img_scanner.c b/zbar/img_scanner.c
index 82f1289..47930a4 100644
--- a/zbar/img_scanner.c
+++ b/zbar/img_scanner.c
@@ -519,6 +519,7 @@ zbar_image_scanner_t *zbar_image_scanner_create ()
zbar_image_scanner_set_config(iscn, 0, ZBAR_CFG_UNCERTAINTY, 2);
zbar_image_scanner_set_config(iscn, 0, ZBAR_CFG_TEST_INVERTED, 0);
zbar_image_scanner_set_config(iscn, ZBAR_QRCODE, ZBAR_CFG_UNCERTAINTY, 0);
+ zbar_image_scanner_set_config(iscn, ZBAR_QRCODE, ZBAR_CFG_BINARY, 0);
zbar_image_scanner_set_config(iscn, ZBAR_CODE128, ZBAR_CFG_UNCERTAINTY, 0);
zbar_image_scanner_set_config(iscn, ZBAR_CODE93, ZBAR_CFG_UNCERTAINTY, 0);
zbar_image_scanner_set_config(iscn, ZBAR_CODE39, ZBAR_CFG_UNCERTAINTY, 0);
diff --git a/zbar/symbol.c b/zbar/symbol.c
index 4a1b2c7..27dbc87 100644
--- a/zbar/symbol.c
+++ b/zbar/symbol.c
@@ -67,6 +67,7 @@ const char *zbar_get_config_name (zbar_config_t cfg)
case ZBAR_CFG_ADD_CHECK: return("ADD_CHECK");
case ZBAR_CFG_EMIT_CHECK: return("EMIT_CHECK");
case ZBAR_CFG_ASCII: return("ASCII");
+ case ZBAR_CFG_BINARY: return("BINARY");
case ZBAR_CFG_MIN_LEN: return("MIN_LEN");
case ZBAR_CFG_MAX_LEN: return("MAX_LEN");
case ZBAR_CFG_UNCERTAINTY: return("UNCERTAINTY");
diff --git a/zbarcam/zbarcam-qt.cpp b/zbarcam/zbarcam-qt.cpp
index b9fba87..f6d11a8 100644
--- a/zbarcam/zbarcam-qt.cpp
+++ b/zbarcam/zbarcam-qt.cpp
@@ -113,6 +113,7 @@ static const struct settings_s settings[] = {
{ "max-length", zbar::ZBAR_CFG_MAX_LEN, false },
{ "uncertainty", zbar::ZBAR_CFG_UNCERTAINTY, false },
{ "ascii", zbar::ZBAR_CFG_ASCII, true },
+ { "binary", zbar::ZBAR_CFG_BINARY, true },
{ "add-check", zbar::ZBAR_CFG_ADD_CHECK, true },
{ "emit-check", zbar::ZBAR_CFG_EMIT_CHECK, true },
{ "position", zbar::ZBAR_CFG_POSITION, true },

Privacy Policy