ZBar bar code reader . http://zbar.sourceforge.net/ ZBar is licensed under the GNU LGPL 2.1 to enable development of both open source and commercial projects.

Dependents:   GR-PEACH_Camera_in_barcode levkov_ov7670

LICENSE

The ZBar Bar Code Reader is Copyright (C) 2007-2009 Jeff Brown <spadix@users.sourceforge.net> The QR Code reader is Copyright (C) 1999-2009 Timothy B. Terriberry <tterribe@xiph.org>

You can redistribute this library and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

ISAAC is based on the public domain implementation by Robert J. Jenkins Jr., and is itself public domain.

Portions of the bit stream reader are copyright (C) The Xiph.Org Foundation 1994-2008, and are licensed under a BSD-style license.

The Reed-Solomon decoder is derived from an implementation (C) 1991-1995 Henry Minsky (hqm@ua.com, hqm@ai.mit.edu), and is licensed under the LGPL with permission.

Committer:
RyoheiHagimoto
Date:
Tue Apr 19 02:19:39 2016 +0000
Revision:
1:500d42699c34
Parent:
0:56c5742b9e2b
Add copying.txt and license.txt

Who changed what in which revision?

UserRevisionLine numberNew contents of line
RyoheiHagimoto 0:56c5742b9e2b 1 /*------------------------------------------------------------------------
RyoheiHagimoto 0:56c5742b9e2b 2 * Copyright 2007-2009 (c) Jeff Brown <spadix@users.sourceforge.net>
RyoheiHagimoto 0:56c5742b9e2b 3 *
RyoheiHagimoto 0:56c5742b9e2b 4 * This file is part of the ZBar Bar Code Reader.
RyoheiHagimoto 0:56c5742b9e2b 5 *
RyoheiHagimoto 0:56c5742b9e2b 6 * The ZBar Bar Code Reader is free software; you can redistribute it
RyoheiHagimoto 0:56c5742b9e2b 7 * and/or modify it under the terms of the GNU Lesser Public License as
RyoheiHagimoto 0:56c5742b9e2b 8 * published by the Free Software Foundation; either version 2.1 of
RyoheiHagimoto 0:56c5742b9e2b 9 * the License, or (at your option) any later version.
RyoheiHagimoto 0:56c5742b9e2b 10 *
RyoheiHagimoto 0:56c5742b9e2b 11 * The ZBar Bar Code Reader is distributed in the hope that it will be
RyoheiHagimoto 0:56c5742b9e2b 12 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
RyoheiHagimoto 0:56c5742b9e2b 13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
RyoheiHagimoto 0:56c5742b9e2b 14 * GNU Lesser Public License for more details.
RyoheiHagimoto 0:56c5742b9e2b 15 *
RyoheiHagimoto 0:56c5742b9e2b 16 * You should have received a copy of the GNU Lesser Public License
RyoheiHagimoto 0:56c5742b9e2b 17 * along with the ZBar Bar Code Reader; if not, write to the Free
RyoheiHagimoto 0:56c5742b9e2b 18 * Software Foundation, Inc., 51 Franklin St, Fifth Floor,
RyoheiHagimoto 0:56c5742b9e2b 19 * Boston, MA 02110-1301 USA
RyoheiHagimoto 0:56c5742b9e2b 20 *
RyoheiHagimoto 0:56c5742b9e2b 21 * http://sourceforge.net/projects/zbar
RyoheiHagimoto 0:56c5742b9e2b 22 *------------------------------------------------------------------------*/
RyoheiHagimoto 0:56c5742b9e2b 23 #ifndef _IMAGE_H_
RyoheiHagimoto 0:56c5742b9e2b 24 #define _IMAGE_H_
RyoheiHagimoto 0:56c5742b9e2b 25
RyoheiHagimoto 0:56c5742b9e2b 26 #include <config.h>
RyoheiHagimoto 0:56c5742b9e2b 27 #ifdef HAVE_INTTYPES_H
RyoheiHagimoto 0:56c5742b9e2b 28 # include <inttypes.h>
RyoheiHagimoto 0:56c5742b9e2b 29 #endif
RyoheiHagimoto 0:56c5742b9e2b 30 #include <stdlib.h>
RyoheiHagimoto 0:56c5742b9e2b 31 #include <assert.h>
RyoheiHagimoto 0:56c5742b9e2b 32
RyoheiHagimoto 0:56c5742b9e2b 33 #include <zbar.h>
RyoheiHagimoto 0:56c5742b9e2b 34 #include "error.h"
RyoheiHagimoto 0:56c5742b9e2b 35 #include "symbol.h"
RyoheiHagimoto 0:56c5742b9e2b 36 #include "refcnt.h"
RyoheiHagimoto 0:56c5742b9e2b 37
RyoheiHagimoto 0:56c5742b9e2b 38 /* adapted from v4l2 spec */
RyoheiHagimoto 0:56c5742b9e2b 39 #define fourcc(a, b, c, d) \
RyoheiHagimoto 0:56c5742b9e2b 40 ((uint32_t)(a) | ((uint32_t)(b) << 8) | \
RyoheiHagimoto 0:56c5742b9e2b 41 ((uint32_t)(c) << 16) | ((uint32_t)(d) << 24))
RyoheiHagimoto 0:56c5742b9e2b 42
RyoheiHagimoto 0:56c5742b9e2b 43 /* unpack size/location of component */
RyoheiHagimoto 0:56c5742b9e2b 44 #define RGB_SIZE(c) ((c) >> 5)
RyoheiHagimoto 0:56c5742b9e2b 45 #define RGB_OFFSET(c) ((c) & 0x1f)
RyoheiHagimoto 0:56c5742b9e2b 46
RyoheiHagimoto 0:56c5742b9e2b 47 /* coarse image format categorization.
RyoheiHagimoto 0:56c5742b9e2b 48 * to limit conversion variations
RyoheiHagimoto 0:56c5742b9e2b 49 */
RyoheiHagimoto 0:56c5742b9e2b 50 typedef enum zbar_format_group_e {
RyoheiHagimoto 0:56c5742b9e2b 51 ZBAR_FMT_GRAY,
RyoheiHagimoto 0:56c5742b9e2b 52 ZBAR_FMT_YUV_PLANAR,
RyoheiHagimoto 0:56c5742b9e2b 53 ZBAR_FMT_YUV_PACKED,
RyoheiHagimoto 0:56c5742b9e2b 54 ZBAR_FMT_RGB_PACKED,
RyoheiHagimoto 0:56c5742b9e2b 55 ZBAR_FMT_YUV_NV,
RyoheiHagimoto 0:56c5742b9e2b 56 ZBAR_FMT_JPEG,
RyoheiHagimoto 0:56c5742b9e2b 57
RyoheiHagimoto 0:56c5742b9e2b 58 /* enum size */
RyoheiHagimoto 0:56c5742b9e2b 59 ZBAR_FMT_NUM
RyoheiHagimoto 0:56c5742b9e2b 60 } zbar_format_group_t;
RyoheiHagimoto 0:56c5742b9e2b 61
RyoheiHagimoto 0:56c5742b9e2b 62
RyoheiHagimoto 0:56c5742b9e2b 63 struct zbar_image_s {
RyoheiHagimoto 0:56c5742b9e2b 64 uint32_t format; /* fourcc image format code */
RyoheiHagimoto 0:56c5742b9e2b 65 unsigned width, height; /* image size */
RyoheiHagimoto 0:56c5742b9e2b 66 const void *data; /* image sample data */
RyoheiHagimoto 0:56c5742b9e2b 67 unsigned long datalen; /* allocated/mapped size of data */
RyoheiHagimoto 0:56c5742b9e2b 68 void *userdata; /* user specified data associated w/image */
RyoheiHagimoto 0:56c5742b9e2b 69
RyoheiHagimoto 0:56c5742b9e2b 70 /* cleanup handler */
RyoheiHagimoto 0:56c5742b9e2b 71 zbar_image_cleanup_handler_t *cleanup;
RyoheiHagimoto 0:56c5742b9e2b 72 refcnt_t refcnt; /* reference count */
RyoheiHagimoto 0:56c5742b9e2b 73 zbar_video_t *src; /* originator */
RyoheiHagimoto 0:56c5742b9e2b 74 int srcidx; /* index used by originator */
RyoheiHagimoto 0:56c5742b9e2b 75 zbar_image_t *next; /* internal image lists */
RyoheiHagimoto 0:56c5742b9e2b 76
RyoheiHagimoto 0:56c5742b9e2b 77 unsigned seq; /* page/frame sequence number */
RyoheiHagimoto 0:56c5742b9e2b 78 zbar_symbol_set_t *syms; /* decoded result set */
RyoheiHagimoto 0:56c5742b9e2b 79 };
RyoheiHagimoto 0:56c5742b9e2b 80
RyoheiHagimoto 0:56c5742b9e2b 81 /* description of an image format */
RyoheiHagimoto 0:56c5742b9e2b 82 typedef struct zbar_format_def_s {
RyoheiHagimoto 0:56c5742b9e2b 83 uint32_t format; /* fourcc */
RyoheiHagimoto 0:56c5742b9e2b 84 zbar_format_group_t group; /* coarse categorization */
RyoheiHagimoto 0:56c5742b9e2b 85 union {
RyoheiHagimoto 0:56c5742b9e2b 86 uint8_t gen[4]; /* raw bytes */
RyoheiHagimoto 0:56c5742b9e2b 87 struct {
RyoheiHagimoto 0:56c5742b9e2b 88 uint8_t bpp; /* bits per pixel */
RyoheiHagimoto 0:56c5742b9e2b 89 uint8_t red, green, blue; /* size/location a la RGB_BITS() */
RyoheiHagimoto 0:56c5742b9e2b 90 } rgb;
RyoheiHagimoto 0:56c5742b9e2b 91 struct {
RyoheiHagimoto 0:56c5742b9e2b 92 uint8_t xsub2, ysub2; /* chroma subsampling in each axis */
RyoheiHagimoto 0:56c5742b9e2b 93 uint8_t packorder; /* channel ordering flags
RyoheiHagimoto 0:56c5742b9e2b 94 * bit0: 0=UV, 1=VU
RyoheiHagimoto 0:56c5742b9e2b 95 * bit1: 0=Y/chroma, 1=chroma/Y
RyoheiHagimoto 0:56c5742b9e2b 96 */
RyoheiHagimoto 0:56c5742b9e2b 97 } yuv;
RyoheiHagimoto 0:56c5742b9e2b 98 uint32_t cmp; /* quick compare equivalent formats */
RyoheiHagimoto 0:56c5742b9e2b 99 } p;
RyoheiHagimoto 0:56c5742b9e2b 100 } zbar_format_def_t;
RyoheiHagimoto 0:56c5742b9e2b 101
RyoheiHagimoto 0:56c5742b9e2b 102
RyoheiHagimoto 0:56c5742b9e2b 103 extern int _zbar_best_format(uint32_t, uint32_t*, const uint32_t*);
RyoheiHagimoto 0:56c5742b9e2b 104 extern const zbar_format_def_t *_zbar_format_lookup(uint32_t);
RyoheiHagimoto 0:56c5742b9e2b 105 extern void _zbar_image_free(zbar_image_t*);
RyoheiHagimoto 0:56c5742b9e2b 106
RyoheiHagimoto 0:56c5742b9e2b 107 #ifdef DEBUG_SVG
RyoheiHagimoto 0:56c5742b9e2b 108 extern int zbar_image_write_png(const zbar_image_t*, const char*);
RyoheiHagimoto 0:56c5742b9e2b 109 #else
RyoheiHagimoto 0:56c5742b9e2b 110 # define zbar_image_write_png(...)
RyoheiHagimoto 0:56c5742b9e2b 111 #endif
RyoheiHagimoto 0:56c5742b9e2b 112
RyoheiHagimoto 0:56c5742b9e2b 113 static inline void _zbar_image_refcnt (zbar_image_t *img,
RyoheiHagimoto 0:56c5742b9e2b 114 int delta)
RyoheiHagimoto 0:56c5742b9e2b 115 {
RyoheiHagimoto 0:56c5742b9e2b 116 if(!_zbar_refcnt(&img->refcnt, delta) && delta <= 0) {
RyoheiHagimoto 0:56c5742b9e2b 117 if(img->cleanup)
RyoheiHagimoto 0:56c5742b9e2b 118 img->cleanup(img);
RyoheiHagimoto 0:56c5742b9e2b 119 if(!img->src)
RyoheiHagimoto 0:56c5742b9e2b 120 _zbar_image_free(img);
RyoheiHagimoto 0:56c5742b9e2b 121 }
RyoheiHagimoto 0:56c5742b9e2b 122 }
RyoheiHagimoto 0:56c5742b9e2b 123
RyoheiHagimoto 0:56c5742b9e2b 124 static inline void _zbar_image_swap_symbols (zbar_image_t *a,
RyoheiHagimoto 0:56c5742b9e2b 125 zbar_image_t *b)
RyoheiHagimoto 0:56c5742b9e2b 126 {
RyoheiHagimoto 0:56c5742b9e2b 127 zbar_symbol_set_t *tmp = a->syms;
RyoheiHagimoto 0:56c5742b9e2b 128 a->syms = b->syms;
RyoheiHagimoto 0:56c5742b9e2b 129 b->syms = tmp;
RyoheiHagimoto 0:56c5742b9e2b 130 }
RyoheiHagimoto 0:56c5742b9e2b 131
RyoheiHagimoto 0:56c5742b9e2b 132 #endif
RyoheiHagimoto 0:56c5742b9e2b 133