libdmtx 0.7.8.7
libdmtx is a software library that enables programs to read and write Data Matrix barcodes of the modern ECC200 variety.
Loading...
Searching...
No Matches
dmtxreedsol.c File Reference

libdmtx - Data Matrix Encoding/Decoding Library Copyright 2011 Mike Laughton. More...

#include <assert.h>
#include "dmtx.h"
#include "dmtxstatic.h"

Go to the source code of this file.

Macros

#define NN   255
 
#define MAX_ERROR_WORD_COUNT   68
 
#define DMTX_CHECK_BOUNDS(l, i)
 
#define GfAdd(a, b)
 
#define GfMult(a, b)
 
#define GfMultAntilog(a, b)
 
#define CHKPASS
 
#define CHKPASS
 
#define CHKPASS
 
#define CHKPASS
 
#define CHKPASS
 
#define CHKPASS
 
#define CHKPASS
 

Functions

static DmtxPassFail rsEncode (DmtxMessage *message, int sizeIdx)
 Encode xyz.
 
static DmtxPassFail rsDecode (unsigned char *code, int sizeIdx, int fix)
 Decode xyz.
 
static DmtxPassFail rsGenPoly (DmtxByteList *gen, int errorWordCount)
 Populate generator polynomial.
 
static DmtxBoolean rsComputeSyndromes (DmtxByteList *syn, const DmtxByteList *rec, int blockErrorWords)
 Populate generator polynomial.
 
static DmtxBoolean rsFindErrorLocatorPoly (DmtxByteList *elpOut, const DmtxByteList *syn, int errorWordCount, int maxCorrectable)
 Find the error location polynomial using Berlekamp-Massey.
 
static DmtxBoolean rsFindErrorLocations (DmtxByteList *loc, const DmtxByteList *elp)
 Find roots of the error locator polynomial (Chien Search).
 
static DmtxPassFail rsRepairErrors (DmtxByteList *rec, const DmtxByteList *loc, const DmtxByteList *elp, const DmtxByteList *syn)
 Find the error values and repair.
 

Variables

static DmtxByte log301 []
 
static DmtxByte antilog301 []
 

Detailed Description

libdmtx - Data Matrix Encoding/Decoding Library Copyright 2011 Mike Laughton.

All rights reserved. Copyright 2012-2016 Vadim A. Misbakh-Soloviov. All rights reserved.

See LICENSE file in the main project directory for full terms of use and distribution.


Portions of this file were derived from the Reed-Solomon

encoder/decoder released by Simon Rockliff in June 1991.

Contact: Vadim A. Misbakh-Soloviov dmtx@.nosp@m.mva..nosp@m.name Mike Laughton mike@.nosp@m.drag.nosp@m.onfly.nosp@m.logi.nosp@m.c.com

Definition in file dmtxreedsol.c.

Macro Definition Documentation

◆ CHKPASS [1/7]

#define CHKPASS
Value:
{ \
if (passFail == DmtxFail) \
return DmtxFail; \
}
#define DmtxFail
Definition dmtx.h:44

Definition at line 71 of file dmtxreedsol.c.

◆ CHKPASS [2/7]

#define CHKPASS
Value:
{ \
if (passFail == DmtxFail) \
return DmtxFail; \
}

Definition at line 71 of file dmtxreedsol.c.

◆ CHKPASS [3/7]

#define CHKPASS
Value:
{ \
if (passFail == DmtxFail) \
return DmtxFail; \
}

Definition at line 71 of file dmtxreedsol.c.

◆ CHKPASS [4/7]

#define CHKPASS
Value:
{ \
if (passFail == DmtxFail) \
return DmtxTrue; \
}
#define DmtxTrue
Definition dmtx.h:47

Definition at line 71 of file dmtxreedsol.c.

◆ CHKPASS [5/7]

#define CHKPASS
Value:
{ \
if (passFail == DmtxFail) \
return DmtxFalse; \
}
#define DmtxFalse
Definition dmtx.h:48

Definition at line 71 of file dmtxreedsol.c.

◆ CHKPASS [6/7]

#define CHKPASS
Value:
{ \
if (passFail == DmtxFail) \
return DmtxFalse; \
}

Definition at line 71 of file dmtxreedsol.c.

◆ CHKPASS [7/7]

#define CHKPASS
Value:
{ \
if (passFail == DmtxFail) \
return DmtxFail; \
}

Definition at line 71 of file dmtxreedsol.c.

◆ DMTX_CHECK_BOUNDS

#define DMTX_CHECK_BOUNDS ( l,
i )
Value:
DmtxAssert((i) >= 0 && (i) < (l)->length && (l)->length <= (l)->capacity)
static struct @0 l
#define DmtxAssert(expr)
Definition dmtxstatic.h:96

Definition at line 29 of file dmtxreedsol.c.

◆ GfAdd

#define GfAdd ( a,
b )
Value:
((a) ^ (b))

Definition at line 32 of file dmtxreedsol.c.

◆ GfMult

#define GfMult ( a,
b )
Value:
(((a) == 0 || (b) == 0) ? 0 : antilog301[(log301[(a)] + log301[(b)]) % NN])
#define NN
Definition dmtxreedsol.c:26
static DmtxByte antilog301[]
Definition dmtxreedsol.c:56
static DmtxByte log301[]
Definition dmtxreedsol.c:41

Definition at line 35 of file dmtxreedsol.c.

◆ GfMultAntilog

#define GfMultAntilog ( a,
b )
Value:
(((a) == 0) ? 0 : antilog301[(log301[(a)] + (b)) % NN])

Definition at line 38 of file dmtxreedsol.c.

◆ MAX_ERROR_WORD_COUNT

#define MAX_ERROR_WORD_COUNT   68

Definition at line 27 of file dmtxreedsol.c.

◆ NN

#define NN   255

Definition at line 26 of file dmtxreedsol.c.

Function Documentation

◆ rsComputeSyndromes()

static DmtxBoolean rsComputeSyndromes ( DmtxByteList * syn,
const DmtxByteList * rec,
int blockErrorWords )
static

Populate generator polynomial.

Assume we have received bits grouped into mm-bit symbols in rec[i], i=0..(nn-1), and rec[i] is index form (ie as powers of alpha). We first compute the 2*tt syndromes by substituting alpha**i into rec(X) and evaluating, storing the syndromes in syn[i], i=1..2tt (leave syn[0] zero).

Parameters
syn
rec
blockErrorWords
Returns
Are error(s) present? (DmtxPass|DmtxFail)

Definition at line 298 of file dmtxreedsol.c.

◆ rsDecode()

static DmtxPassFail rsDecode ( unsigned char * code,
int sizeIdx,
int fix )
static

Decode xyz.

More detailed description.

Parameters
code
sizeIdx
fix
Returns
Function success (DmtxPass|DmtxFail)

Definition at line 148 of file dmtxreedsol.c.

◆ rsEncode()

static DmtxPassFail rsEncode ( DmtxMessage * message,
int sizeIdx )
static

Encode xyz.

More detailed description.

Parameters
message
sizeIdx
Returns
Function success (DmtxPass|DmtxFail)

Definition at line 83 of file dmtxreedsol.c.

◆ rsFindErrorLocations()

static DmtxBoolean rsFindErrorLocations ( DmtxByteList * loc,
const DmtxByteList * elp )
static

Find roots of the error locator polynomial (Chien Search).

If the degree of elp is <= tt, we substitute alpha**i, i=1..n into the elp to get the roots, hence the inverse roots, the error location numbers. If the number of errors located does not equal the degree of the elp, we have more than tt errors and cannot correct them.

Parameters
loc
elp
Returns
Is block repairable? (DmtxTrue|DmtxFalse)

Definition at line 437 of file dmtxreedsol.c.

◆ rsFindErrorLocatorPoly()

static DmtxBoolean rsFindErrorLocatorPoly ( DmtxByteList * elpOut,
const DmtxByteList * syn,
int errorWordCount,
int maxCorrectable )
static

Find the error location polynomial using Berlekamp-Massey.

More detailed description.

Parameters
elpOut
syn
errorWordCount
maxCorrectable
Returns
Is block repairable? (DmtxTrue|DmtxFalse)

Definition at line 339 of file dmtxreedsol.c.

◆ rsGenPoly()

static DmtxPassFail rsGenPoly ( DmtxByteList * gen,
int errorWordCount )
static

Populate generator polynomial.

More detailed description.

Parameters
gen
errorWordCount
Returns
Function success (DmtxPass|DmtxFail)

Definition at line 258 of file dmtxreedsol.c.

◆ rsRepairErrors()

static DmtxPassFail rsRepairErrors ( DmtxByteList * rec,
const DmtxByteList * loc,
const DmtxByteList * elp,
const DmtxByteList * syn )
static

Find the error values and repair.

Solve for the error value at the error location and correct the error. The procedure is that found in Lin and Costello. For the cases where the number of errors is known to be too large to correct, the information symbols as received are output (the advantage of systematic encoding is that hopefully some of the information symbols will be okay and that if we are in luck, the errors are in the parity part of the transmitted codeword).

Parameters
rec
loc
elp
syn

Definition at line 485 of file dmtxreedsol.c.

Variable Documentation

◆ antilog301

DmtxByte antilog301[]
static
Initial value:
= {
1, 2, 4, 8, 16, 32, 64, 128, 45, 90, 180, 69, 138, 57, 114, 228, 229, 231, 227, 235, 251, 219,
155, 27, 54, 108, 216, 157, 23, 46, 92, 184, 93, 186, 89, 178, 73, 146, 9, 18, 36, 72, 144, 13,
26, 52, 104, 208, 141, 55, 110, 220, 149, 7, 14, 28, 56, 112, 224, 237, 247, 195, 171, 123, 246, 193,
175, 115, 230, 225, 239, 243, 203, 187, 91, 182, 65, 130, 41, 82, 164, 101, 202, 185, 95, 190, 81, 162,
105, 210, 137, 63, 126, 252, 213, 135, 35, 70, 140, 53, 106, 212, 133, 39, 78, 156, 21, 42, 84, 168,
125, 250, 217, 159, 19, 38, 76, 152, 29, 58, 116, 232, 253, 215, 131, 43, 86, 172, 117, 234, 249, 223,
147, 11, 22, 44, 88, 176, 77, 154, 25, 50, 100, 200, 189, 87, 174, 113, 226, 233, 255, 211, 139, 59,
118, 236, 245, 199, 163, 107, 214, 129, 47, 94, 188, 85, 170, 121, 242, 201, 191, 83, 166, 97, 194, 169,
127, 254, 209, 143, 51, 102, 204, 181, 71, 142, 49, 98, 196, 165, 103, 206, 177, 79, 158, 17, 34, 68,
136, 61, 122, 244, 197, 167, 99, 198, 161, 111, 222, 145, 15, 30, 60, 120, 240, 205, 183, 67, 134, 33,
66, 132, 37, 74, 148, 5, 10, 20, 40, 80, 160, 109, 218, 153, 31, 62, 124, 248, 221, 151, 3, 6,
12, 24, 48, 96, 192, 173, 119, 238, 241, 207, 179, 75, 150, 0}

Definition at line 56 of file dmtxreedsol.c.

◆ log301

DmtxByte log301[]
static
Initial value:
= {
255, 0, 1, 240, 2, 225, 241, 53, 3, 38, 226, 133, 242, 43, 54, 210, 4, 195, 39, 114, 227, 106,
134, 28, 243, 140, 44, 23, 55, 118, 211, 234, 5, 219, 196, 96, 40, 222, 115, 103, 228, 78, 107, 125,
135, 8, 29, 162, 244, 186, 141, 180, 45, 99, 24, 49, 56, 13, 119, 153, 212, 199, 235, 91, 6, 76,
220, 217, 197, 11, 97, 184, 41, 36, 223, 253, 116, 138, 104, 193, 229, 86, 79, 171, 108, 165, 126, 145,
136, 34, 9, 74, 30, 32, 163, 84, 245, 173, 187, 204, 142, 81, 181, 190, 46, 88, 100, 159, 25, 231,
50, 207, 57, 147, 14, 67, 120, 128, 154, 248, 213, 167, 200, 63, 236, 110, 92, 176, 7, 161, 77, 124,
221, 102, 218, 95, 198, 90, 12, 152, 98, 48, 185, 179, 42, 209, 37, 132, 224, 52, 254, 239, 117, 233,
139, 22, 105, 27, 194, 113, 230, 206, 87, 158, 80, 189, 172, 203, 109, 175, 166, 62, 127, 247, 146, 66,
137, 192, 35, 252, 10, 183, 75, 216, 31, 83, 33, 73, 164, 144, 85, 170, 246, 65, 174, 61, 188, 202,
205, 157, 143, 169, 82, 72, 182, 215, 191, 251, 47, 178, 89, 151, 101, 94, 160, 123, 26, 112, 232, 21,
51, 238, 208, 131, 58, 69, 148, 18, 15, 16, 68, 17, 121, 149, 129, 19, 155, 59, 249, 70, 214, 250,
168, 71, 201, 156, 64, 60, 237, 130, 111, 20, 93, 122, 177, 150}

Definition at line 41 of file dmtxreedsol.c.