Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. /* quirc -- QR-code recognition library
  2.  * Copyright (C) 2010-2012 Daniel Beer <dlbeer@gmail.com>
  3.  *
  4.  * Permission to use, copy, modify, and/or distribute this software for any
  5.  * purpose with or without fee is hereby granted, provided that the above
  6.  * copyright notice and this permission notice appear in all copies.
  7.  *
  8.  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9.  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10.  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11.  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13.  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14.  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15.  */
  16.  
  17. #ifndef QUIRC_INTERNAL_H_
  18. #define QUIRC_INTERNAL_H_
  19.  
  20. #include "quirc.h"
  21.  
  22. #define QUIRC_PIXEL_WHITE       0
  23. #define QUIRC_PIXEL_BLACK       1
  24. #define QUIRC_PIXEL_REGION      2
  25.  
  26. #ifndef QUIRC_MAX_REGIONS
  27. #define QUIRC_MAX_REGIONS       254
  28. #endif
  29. #define QUIRC_MAX_CAPSTONES     32
  30. #define QUIRC_MAX_GRIDS         8
  31. #define QUIRC_PERSPECTIVE_PARAMS        8
  32.  
  33. #if QUIRC_MAX_REGIONS < UINT8_MAX
  34. #define QUIRC_PIXEL_ALIAS_IMAGE 1
  35. typedef uint8_t quirc_pixel_t;
  36. #elif QUIRC_MAX_REGIONS < UINT16_MAX
  37. #define QUIRC_PIXEL_ALIAS_IMAGE 0
  38. typedef uint16_t quirc_pixel_t;
  39. #else
  40. #error "QUIRC_MAX_REGIONS > 65534 is not supported"
  41. #endif
  42.  
  43. struct quirc_region {
  44.         struct quirc_point      seed;
  45.         int                     count;
  46.         int                     capstone;
  47. };
  48.  
  49. struct quirc_capstone {
  50.         int                     ring;
  51.         int                     stone;
  52.  
  53.         struct quirc_point      corners[4];
  54.         struct quirc_point      center;
  55.         double                  c[QUIRC_PERSPECTIVE_PARAMS];
  56.  
  57.         int                     qr_grid;
  58. };
  59.  
  60. struct quirc_grid {
  61.         /* Capstone indices */
  62.         int                     caps[3];
  63.  
  64.         /* Alignment pattern region and corner */
  65.         int                     align_region;
  66.         struct quirc_point      align;
  67.  
  68.         /* Timing pattern endpoints */
  69.         struct quirc_point      tpep[3];
  70.         int                     hscan;
  71.         int                     vscan;
  72.  
  73.         /* Grid size and perspective transform */
  74.         int                     grid_size;
  75.         double                  c[QUIRC_PERSPECTIVE_PARAMS];
  76. };
  77.  
  78. struct quirc {
  79.         uint8_t                 *image;
  80.         quirc_pixel_t           *pixels;
  81.         int                     w;
  82.         int                     h;
  83.  
  84.         int                     num_regions;
  85.         struct quirc_region     regions[QUIRC_MAX_REGIONS];
  86.  
  87.         int                     num_capstones;
  88.         struct quirc_capstone   capstones[QUIRC_MAX_CAPSTONES];
  89.  
  90.         int                     num_grids;
  91.         struct quirc_grid       grids[QUIRC_MAX_GRIDS];
  92. };
  93.  
  94. /************************************************************************
  95.  * QR-code version information database
  96.  */
  97.  
  98. #define QUIRC_MAX_VERSION     40
  99. #define QUIRC_MAX_ALIGNMENT   7
  100.  
  101. struct quirc_rs_params {
  102.         int             bs; /* Small block size */
  103.         int             dw; /* Small data words */
  104.         int             ns; /* Number of small blocks */
  105. };
  106.  
  107. struct quirc_version_info {
  108.         int                             data_bytes;
  109.         int                             apat[QUIRC_MAX_ALIGNMENT];
  110.         struct quirc_rs_params          ecc[4];
  111. };
  112.  
  113. extern const struct quirc_version_info quirc_version_db[QUIRC_MAX_VERSION + 1];
  114.  
  115. #endif
  116.