static void symbol_handler (zbar_decoder_t *dcode) { zbar_image_scanner_t *iscn = zbar_decoder_get_userdata(dcode); zbar_symbol_type_t type = zbar_decoder_get_type(dcode); /* FIXME assert(type == ZBAR_PARTIAL) */ /* FIXME debug flag to save/display all PARTIALs */ if(type <= ZBAR_PARTIAL) return; #ifdef ENABLE_QRCODE if(type == ZBAR_QRCODE) { qr_handler(iscn); return; } #else assert(type != ZBAR_QRCODE); #endif const char *data = zbar_decoder_get_data(dcode); unsigned datalen = zbar_decoder_get_data_length(dcode); int x = 0, y = 0; if(TEST_CFG(iscn, ZBAR_CFG_POSITION)) { /* tmp position fixup */ int w = zbar_scanner_get_width(iscn->scn); int u = iscn->umin + iscn->du * zbar_scanner_get_edge(iscn->scn, w, 0); if(iscn->dx) { x = u; y = iscn->v; } else { x = iscn->v; y = u; } } /* FIXME need better symbol matching */ zbar_symbol_t *sym; for(sym = iscn->syms->head; sym; sym = sym->next) if(sym->type == type && sym->datalen == datalen && !memcmp(sym->data, data, datalen)) { sym->quality++; if(TEST_CFG(iscn, ZBAR_CFG_POSITION)) /* add new point to existing set */ /* FIXME should be polygon */ sym_add_point(sym, x, y); return; } sym = _zbar_image_scanner_alloc_sym(iscn, type, datalen + 1); /* FIXME grab decoder buffer */ memcpy(sym->data, data, datalen + 1); /* initialize first point */ if(TEST_CFG(iscn, ZBAR_CFG_POSITION)) sym_add_point(sym, x, y); _zbar_image_scanner_add_sym(iscn, sym); }
zbar_symbol_type_t zbar_decode_width (zbar_decoder_t *dcode, unsigned w) { zbar_symbol_type_t tmp, sym = ZBAR_NONE; dcode->w[dcode->idx & (DECODE_WINDOW - 1)] = w; dprintf(1, " decode[%x]: w=%d (%g)\n", dcode->idx, w, (w / 32.)); /* each decoder processes width stream in parallel */ #ifdef ENABLE_EAN if((dcode->ean.enable) && (tmp = _zbar_decode_ean(dcode))) sym = tmp; #endif #ifdef ENABLE_QRCODE if(TEST_CFG(dcode->qrf.config, ZBAR_CFG_ENABLE) && (tmp = _zbar_find_qr(dcode)) > ZBAR_PARTIAL) sym = tmp; #endif #ifdef ENABLE_CODE39 if(TEST_CFG(dcode->code39.config, ZBAR_CFG_ENABLE) && (tmp = _zbar_decode_code39(dcode)) > ZBAR_PARTIAL) sym = tmp; #endif #ifdef ENABLE_CODE128 if(TEST_CFG(dcode->code128.config, ZBAR_CFG_ENABLE) && (tmp = _zbar_decode_code128(dcode)) > ZBAR_PARTIAL) sym = tmp; #endif #ifdef ENABLE_I25 if(TEST_CFG(dcode->i25.config, ZBAR_CFG_ENABLE) && (tmp = _zbar_decode_i25(dcode)) > ZBAR_PARTIAL) sym = tmp; #endif #ifdef ENABLE_PDF417 if(TEST_CFG(dcode->pdf417.config, ZBAR_CFG_ENABLE) && (tmp = _zbar_decode_pdf417(dcode)) > ZBAR_PARTIAL) sym = tmp; #endif dcode->idx++; dcode->type = sym; if(sym) { if(dcode->lock && sym > ZBAR_PARTIAL && sym != ZBAR_QRCODE) release_lock(dcode, sym); if(dcode->handler) dcode->handler(dcode); } return(sym); }
static inline int decoder_set_config_bool (zbar_decoder_t *dcode, zbar_symbol_type_t sym, zbar_config_t cfg, int val) { unsigned *config = (void*)decoder_get_configp(dcode, sym); if(!config || cfg >= ZBAR_CFG_NUM) return(1); if(!val) *config &= ~(1 << cfg); else if(val == 1) *config |= (1 << cfg); else return(1); #ifdef ENABLE_EAN dcode->ean.enable = TEST_CFG(dcode->ean.ean13_config | dcode->ean.ean2_config | dcode->ean.ean5_config | dcode->ean.ean8_config | dcode->ean.upca_config | dcode->ean.upce_config | dcode->ean.isbn10_config | dcode->ean.isbn13_config, ZBAR_CFG_ENABLE); #endif return(0); }
zebra_symbol_type_t zebra_decode_width (zebra_decoder_t *dcode, unsigned w) { zebra_symbol_type_t sym; dcode->w[dcode->idx & (DECODE_WINDOW - 1)] = w; dprintf(1, " decode[%x]: w=%d (%g)\n", dcode->idx, w, (w / 32.)); /* each decoder processes width stream in parallel */ sym = dcode->type = ZEBRA_NONE; #ifdef ENABLE_EAN if((dcode->ean.enable) && (sym = _zebra_decode_ean(dcode))) dcode->type = sym; #endif #ifdef ENABLE_CODE39 if(TEST_CFG(dcode->code39.config, ZEBRA_CFG_ENABLE) && (sym = _zebra_decode_code39(dcode)) > ZEBRA_PARTIAL) dcode->type = sym; #endif #ifdef ENABLE_CODE128 if(TEST_CFG(dcode->code128.config, ZEBRA_CFG_ENABLE) && (sym = _zebra_decode_code128(dcode)) > ZEBRA_PARTIAL) dcode->type = sym; #endif #ifdef ENABLE_I25 if(TEST_CFG(dcode->i25.config, ZEBRA_CFG_ENABLE) && (sym = _zebra_decode_i25(dcode)) > ZEBRA_PARTIAL) dcode->type = sym; #endif #ifdef ENABLE_PDF417 if(TEST_CFG(dcode->pdf417.config, ZEBRA_CFG_ENABLE) && (sym = _zebra_decode_pdf417(dcode)) > ZEBRA_PARTIAL) dcode->type = sym; #endif dcode->idx++; if(dcode->type) { if(dcode->handler) dcode->handler(dcode); if(dcode->lock && dcode->type > ZEBRA_PARTIAL) dcode->lock = 0; } return(dcode->type); }
int zebra_decoder_set_config (zebra_decoder_t *dcode, zebra_symbol_type_t sym, zebra_config_t cfg, int val) { unsigned *config = NULL; switch(sym) { case ZEBRA_NONE: zebra_decoder_set_config(dcode, ZEBRA_EAN13, cfg, val); zebra_decoder_set_config(dcode, ZEBRA_EAN8, cfg, val); zebra_decoder_set_config(dcode, ZEBRA_UPCA, cfg, val); zebra_decoder_set_config(dcode, ZEBRA_UPCE, cfg, val); zebra_decoder_set_config(dcode, ZEBRA_ISBN10, cfg, val); zebra_decoder_set_config(dcode, ZEBRA_ISBN13, cfg, val); zebra_decoder_set_config(dcode, ZEBRA_I25, cfg, val); zebra_decoder_set_config(dcode, ZEBRA_CODE39, cfg, val); zebra_decoder_set_config(dcode, ZEBRA_CODE128, cfg, val); zebra_decoder_set_config(dcode, ZEBRA_PDF417, cfg, val); return(0); #ifdef ENABLE_EAN case ZEBRA_EAN13: config = &dcode->ean.ean13_config; break; case ZEBRA_EAN8: config = &dcode->ean.ean8_config; break; case ZEBRA_UPCA: config = &dcode->ean.upca_config; break; case ZEBRA_UPCE: config = &dcode->ean.upce_config; break; case ZEBRA_ISBN10: config = &dcode->ean.isbn10_config; break; case ZEBRA_ISBN13: config = &dcode->ean.isbn13_config; break; #endif #ifdef ENABLE_I25 case ZEBRA_I25: config = &dcode->i25.config; break; #endif #ifdef ENABLE_CODE39 case ZEBRA_CODE39: config = &dcode->code39.config; break; #endif #ifdef ENABLE_CODE128 case ZEBRA_CODE128: config = &dcode->code128.config; break; #endif #ifdef ENABLE_PDF417 case ZEBRA_PDF417: config = &dcode->pdf417.config; break; #endif /* FIXME handle addons */ default: return(1); } if(!config || cfg >= ZEBRA_CFG_NUM) return(1); if(!val) *config &= ~(1 << cfg); else if(val == 1) *config |= (1 << cfg); else return(1); #ifdef ENABLE_EAN dcode->ean.enable = TEST_CFG(dcode->ean.ean13_config | dcode->ean.ean8_config | dcode->ean.upca_config | dcode->ean.upce_config | dcode->ean.isbn10_config | dcode->ean.isbn13_config, ZEBRA_CFG_ENABLE); #endif return(0); }
static inline int decoder_set_config_bool (zbar_decoder_t *dcode, zbar_symbol_type_t sym, zbar_config_t cfg, int val) { unsigned *config = NULL; switch(sym) { #ifdef ENABLE_EAN case ZBAR_EAN13: config = &dcode->ean.ean13_config; break; case ZBAR_EAN8: config = &dcode->ean.ean8_config; break; case ZBAR_UPCA: config = &dcode->ean.upca_config; break; case ZBAR_UPCE: config = &dcode->ean.upce_config; break; case ZBAR_ISBN10: config = &dcode->ean.isbn10_config; break; case ZBAR_ISBN13: config = &dcode->ean.isbn13_config; break; #endif #ifdef ENABLE_I25 case ZBAR_I25: config = &dcode->i25.config; break; #endif #ifdef ENABLE_CODE39 case ZBAR_CODE39: config = &dcode->code39.config; break; #endif #ifdef ENABLE_CODE128 case ZBAR_CODE128: config = &dcode->code128.config; break; #endif #ifdef ENABLE_PDF417 case ZBAR_PDF417: config = &dcode->pdf417.config; break; #endif #ifdef ENABLE_QRCODE case ZBAR_QRCODE: config = &dcode->qrf.config; break; #endif /* FIXME handle addons */ default: return(1); } if(!config || cfg >= ZBAR_CFG_NUM) return(1); if(!val) *config &= ~(1 << cfg); else if(val == 1) *config |= (1 << cfg); else return(1); #ifdef ENABLE_EAN dcode->ean.enable = TEST_CFG(dcode->ean.ean13_config | dcode->ean.ean8_config | dcode->ean.upca_config | dcode->ean.upce_config | dcode->ean.isbn10_config | dcode->ean.isbn13_config, ZBAR_CFG_ENABLE); #endif return(0); }
static void symbol_handler (zbar_decoder_t *dcode) { zbar_image_scanner_t *iscn = zbar_decoder_get_userdata(dcode); zbar_symbol_type_t type = zbar_decoder_get_type(dcode); int x = 0, y = 0, dir; const char *data; unsigned datalen; zbar_symbol_t *sym; #ifdef ENABLE_QRCODE if(type == ZBAR_QRCODE) { qr_handler(iscn); return; } #else assert(type != ZBAR_QRCODE); #endif if(TEST_CFG(iscn, ZBAR_CFG_POSITION)) { /* tmp position fixup */ int w = zbar_scanner_get_width(iscn->scn); int u = iscn->umin + iscn->du * zbar_scanner_get_edge(iscn->scn, w, 0); if(iscn->dx) { x = u; y = iscn->v; } else { x = iscn->v; y = u; } } /* FIXME debug flag to save/display all PARTIALs */ if(type <= ZBAR_PARTIAL) { zprintf(256, "partial symbol @(%d,%d)\n", x, y); return; } data = zbar_decoder_get_data(dcode); datalen = zbar_decoder_get_data_length(dcode); /* FIXME need better symbol matching */ for(sym = iscn->syms->head; sym; sym = sym->next) if(sym->type == type && sym->datalen == datalen && !memcmp(sym->data, data, datalen)) { sym->quality++; zprintf(224, "dup symbol @(%d,%d): dup %s: %.20s\n", x, y, zbar_get_symbol_name(type), data); if(TEST_CFG(iscn, ZBAR_CFG_POSITION)) /* add new point to existing set */ /* FIXME should be polygon */ sym_add_point(sym, x, y); return; } sym = _zbar_image_scanner_alloc_sym(iscn, type, datalen + 1); sym->configs = zbar_decoder_get_configs(dcode, type); sym->modifiers = zbar_decoder_get_modifiers(dcode); /* FIXME grab decoder buffer */ memcpy(sym->data, data, datalen + 1); /* initialize first point */ if(TEST_CFG(iscn, ZBAR_CFG_POSITION)) { zprintf(192, "new symbol @(%d,%d): %s: %.20s\n", x, y, zbar_get_symbol_name(type), data); sym_add_point(sym, x, y); } dir = zbar_decoder_get_direction(dcode); if(dir) sym->orient = (iscn->dy != 0) + ((iscn->du ^ dir) & 2); _zbar_image_scanner_add_sym(iscn, sym); }