1 /* (c) GPL 2007 Karel 'Clock' Kulhavy, Twibright Labs */
3 #define MIN(x,y) ((x)<(y)?(x):(y))
4 #define MAX(x,y) ((x)>(y)?(x):(y))
6 #define BORDER 2 /* In pixels. Thickness of the border */
7 #define CHALF 3 /* Size of the cross half. Size of the cross is CHALF*2 x CHALF*2.
9 #define CPITCH 24 /* Distance between cross centers */
11 /* XCROSSES A4 65, US Letter 67. */
12 #define XCROSSES 32 /* Number of crosses horizontally */
13 /* YCROSSES A4 93, US Letter 87. */
14 #define YCROSSES 46 /* Number of crosses vertically */
16 #define DATA_WIDTH (CPITCH*(XCROSSES-1)+2*CHALF) /* The rectangle occupied by
17 the data and crosses */
18 #define DATA_HEIGHT (CPITCH*(YCROSSES-1)+2*CHALF)
19 #define WIDTH (2*BORDER+DATA_WIDTH) /* In pixels, including the border */
20 /* In pixels, including the border and the label */
22 #define TEXT_WIDTH 13 /* Width of a single letter */
24 /* Definitions for seq2xy */
26 /* Properties of the narrow horizontal strip, with crosses */
27 #define NARROWHEIGHT (2*CHALF)
28 #define GAPWIDTH (CPITCH-2*CHALF)
29 #define NARROWWIDTH (GAPWIDTH*(XCROSSES-1)) /* Useful width */
30 #define NARROWPIXELS (NARROWHEIGHT*NARROWWIDTH) /* Useful pixels */
32 /* Properties of the wide horizontal strip, without crosses */
33 #define WIDEHEIGHT GAPWIDTH
34 #define WIDEWIDTH (WIDTH-2*BORDER)
35 #define WIDEPIXELS (WIDEHEIGHT*WIDEWIDTH)
37 /* Amount of raw payload pixels in one narrow-wide strip pair */
38 #define REPHEIGHT (NARROWHEIGHT+WIDEHEIGHT)
39 #define REPPIXELS (WIDEPIXELS+NARROWPIXELS)
41 /* Total bits before hamming including the unused */
42 #define TOTALBITS ((long)REPPIXELS*(YCROSSES-1)+NARROWPIXELS)
44 /* Hamming codes with parity */
45 #define FEC_ORDER 1 /* Can be 2 to 5 inclusive.
53 #define FEC_LARGEBITS 24
54 #define FEC_SMALLBITS 12
57 #define FEC_LARGEBITS (1<<FEC_ORDER)
58 #define FEC_SMALLBITS (FEC_LARGEBITS-1-FEC_ORDER)
61 /* Hamming net channel capacity */
62 #define FEC_SYMS (TOTALBITS/FEC_LARGEBITS)
63 #define NETBITS (FEC_SYMS*FEC_SMALLBITS) /* Net payload bits */
64 #define USEDBITS (FEC_SYMS*FEC_LARGEBITS) /* Used raw bits to store
67 /* Functions from common.c */
68 extern unsigned long parity(unsigned long in
);
69 extern int is_cross(unsigned x
, unsigned y
);
70 extern void seq2xy(int *x
, int *y
, unsigned seq
);
72 /* Counts number of '1' bits */
73 unsigned ones(unsigned long in
);
76 unsigned long golay(unsigned long in
);
77 extern unsigned long golay_codes
[4096];