qrencode  4.1.1
About: libqrencode is a fast and compact library and command-line utility for encoding data in a QR Code symbol.
  Fossies Dox: qrencode-4.1.1.tar.bz2  ("unofficial" and yet experimental doxygen-generated source code documentation)  

mask.c File Reference
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <errno.h>
#include "qrencode.h"
#include "qrspec.h"
#include "mask.h"
Include dependency graph for mask.c:

Go to the source code of this file.

Macros

#define N1   (3)
 Demerit coefficients. More...
 
#define N2   (3)
 
#define N3   (40)
 
#define N4   (10)
 
#define MASKMAKER(__exp__)
 
#define maskNum   (8)
 

Typedefs

typedef int MaskMaker(int, const unsigned char *, unsigned char *)
 

Functions

STATIC_IN_RELEASE int Mask_writeFormatInformation (int width, unsigned char *frame, int mask, QRecLevel level)
 
static int Mask_mask0 (int width, const unsigned char *s, unsigned char *d)
 
static int Mask_mask1 (int width, const unsigned char *s, unsigned char *d)
 
static int Mask_mask2 (int width, const unsigned char *s, unsigned char *d)
 
static int Mask_mask3 (int width, const unsigned char *s, unsigned char *d)
 
static int Mask_mask4 (int width, const unsigned char *s, unsigned char *d)
 
static int Mask_mask5 (int width, const unsigned char *s, unsigned char *d)
 
static int Mask_mask6 (int width, const unsigned char *s, unsigned char *d)
 
static int Mask_mask7 (int width, const unsigned char *s, unsigned char *d)
 
unsigned char * Mask_makeMask (int width, unsigned char *frame, int mask, QRecLevel level)
 
STATIC_IN_RELEASE int Mask_calcN1N3 (int length, int *runLength)
 
STATIC_IN_RELEASE int Mask_calcN2 (int width, unsigned char *frame)
 
STATIC_IN_RELEASE int Mask_calcRunLengthH (int width, unsigned char *frame, int *runLength)
 
STATIC_IN_RELEASE int Mask_calcRunLengthV (int width, unsigned char *frame, int *runLength)
 
STATIC_IN_RELEASE int Mask_evaluateSymbol (int width, unsigned char *frame)
 
unsigned char * Mask_mask (int width, unsigned char *frame, QRecLevel level)
 

Variables

static MaskMakermaskMakers [(8)]
 

Macro Definition Documentation

◆ MASKMAKER

#define MASKMAKER (   __exp__)
Value:
int x, y;\
int b = 0;\
\
for(y = 0; y < width; y++) {\
for(x = 0; x < width; x++) {\
if(*s & 0x80) {\
*d = *s;\
} else {\
*d = *s ^ ((__exp__) == 0);\
}\
b += (int)(*d & 1);\
s++; d++;\
}\
}\
return b;

Definition at line 86 of file mask.c.

◆ maskNum

#define maskNum   (8)

Definition at line 143 of file mask.c.

◆ N1

#define N1   (3)

Demerit coefficients.

See Section 8.8.2, pp.45, JIS X0510:2004.

Definition at line 81 of file mask.c.

◆ N2

#define N2   (3)

Definition at line 82 of file mask.c.

◆ N3

#define N3   (40)

Definition at line 83 of file mask.c.

◆ N4

#define N4   (10)

Definition at line 84 of file mask.c.

Typedef Documentation

◆ MaskMaker

typedef int MaskMaker(int, const unsigned char *, unsigned char *)

Definition at line 144 of file mask.c.

Function Documentation

◆ Mask_calcN1N3()

STATIC_IN_RELEASE int Mask_calcN1N3 ( int  length,
int *  runLength 
)

Definition at line 188 of file mask.c.

References N1, and N3.

Referenced by Mask_evaluateSymbol().

◆ Mask_calcN2()

STATIC_IN_RELEASE int Mask_calcN2 ( int  width,
unsigned char *  frame 
)

Definition at line 221 of file mask.c.

References N2.

Referenced by Mask_evaluateSymbol().

◆ Mask_calcRunLengthH()

STATIC_IN_RELEASE int Mask_calcRunLengthH ( int  width,
unsigned char *  frame,
int *  runLength 
)

Definition at line 244 of file mask.c.

Referenced by Mask_evaluateSymbol().

◆ Mask_calcRunLengthV()

STATIC_IN_RELEASE int Mask_calcRunLengthV ( int  width,
unsigned char *  frame,
int *  runLength 
)

Definition at line 272 of file mask.c.

Referenced by Mask_evaluateSymbol().

◆ Mask_evaluateSymbol()

STATIC_IN_RELEASE int Mask_evaluateSymbol ( int  width,
unsigned char *  frame 
)

Definition at line 300 of file mask.c.

References Mask_calcN1N3(), Mask_calcN2(), Mask_calcRunLengthH(), Mask_calcRunLengthV(), and QRSPEC_WIDTH_MAX.

Referenced by Mask_mask().

◆ Mask_makeMask()

unsigned char * Mask_makeMask ( int  width,
unsigned char *  frame,
int  mask,
QRecLevel  level 
)

Definition at line 164 of file mask.c.

References level, Mask_writeFormatInformation(), maskMakers, and maskNum.

Referenced by QRcode_encodeMask().

◆ Mask_mask()

unsigned char * Mask_mask ( int  width,
unsigned char *  frame,
QRecLevel  level 
)

Definition at line 322 of file mask.c.

References level, Mask_evaluateSymbol(), Mask_writeFormatInformation(), maskMakers, maskNum, and N4.

Referenced by QRcode_encodeMask().

◆ Mask_mask0()

static int Mask_mask0 ( int  width,
const unsigned char *  s,
unsigned char *  d 
)
static

Definition at line 103 of file mask.c.

References MASKMAKER.

◆ Mask_mask1()

static int Mask_mask1 ( int  width,
const unsigned char *  s,
unsigned char *  d 
)
static

Definition at line 108 of file mask.c.

References MASKMAKER.

◆ Mask_mask2()

static int Mask_mask2 ( int  width,
const unsigned char *  s,
unsigned char *  d 
)
static

Definition at line 113 of file mask.c.

References MASKMAKER.

◆ Mask_mask3()

static int Mask_mask3 ( int  width,
const unsigned char *  s,
unsigned char *  d 
)
static

Definition at line 118 of file mask.c.

References MASKMAKER.

◆ Mask_mask4()

static int Mask_mask4 ( int  width,
const unsigned char *  s,
unsigned char *  d 
)
static

Definition at line 123 of file mask.c.

References MASKMAKER.

◆ Mask_mask5()

static int Mask_mask5 ( int  width,
const unsigned char *  s,
unsigned char *  d 
)
static

Definition at line 128 of file mask.c.

References MASKMAKER.

◆ Mask_mask6()

static int Mask_mask6 ( int  width,
const unsigned char *  s,
unsigned char *  d 
)
static

Definition at line 133 of file mask.c.

References MASKMAKER.

◆ Mask_mask7()

static int Mask_mask7 ( int  width,
const unsigned char *  s,
unsigned char *  d 
)
static

Definition at line 138 of file mask.c.

References MASKMAKER.

◆ Mask_writeFormatInformation()

STATIC_IN_RELEASE int Mask_writeFormatInformation ( int  width,
unsigned char *  frame,
int  mask,
QRecLevel  level 
)

Definition at line 34 of file mask.c.

References level, and QRspec_getFormatInfo().

Referenced by Mask_makeMask(), and Mask_mask().

Variable Documentation

◆ maskMakers

MaskMaker* maskMakers[(8)]
static
Initial value:
= {
}
static int Mask_mask0(int width, const unsigned char *s, unsigned char *d)
Definition: mask.c:103
static int Mask_mask3(int width, const unsigned char *s, unsigned char *d)
Definition: mask.c:118
static int Mask_mask7(int width, const unsigned char *s, unsigned char *d)
Definition: mask.c:138
static int Mask_mask2(int width, const unsigned char *s, unsigned char *d)
Definition: mask.c:113
static int Mask_mask5(int width, const unsigned char *s, unsigned char *d)
Definition: mask.c:128
static int Mask_mask6(int width, const unsigned char *s, unsigned char *d)
Definition: mask.c:133
static int Mask_mask4(int width, const unsigned char *s, unsigned char *d)
Definition: mask.c:123
static int Mask_mask1(int width, const unsigned char *s, unsigned char *d)
Definition: mask.c:108

Definition at line 145 of file mask.c.

Referenced by Mask_makeMask(), and Mask_mask().