MCPcopy Create free account
hub / github.com/creatale/node-dv / decode

Method decode

deps/zxing/core/src/zxing/pdf417/decoder/ec/ErrorCorrection.cpp:47–104  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45}
46
47void ErrorCorrection::decode(ArrayRef<int> received,
48 int numECCodewords,
49 ArrayRef<int> erasures)
50{
51 Ref<ModulusPoly> poly (new ModulusPoly(field_, received));
52 ArrayRef<int> S( new Array<int>(numECCodewords));
53 bool error = false;
54 for (int i = numECCodewords; i > 0; i--) {
55 int eval = poly->evaluateAt(field_.exp(i));
56 S[numECCodewords - i] = eval;
57 if (eval != 0) {
58 error = true;
59 }
60 }
61
62 if (error) {
63
64 Ref<ModulusPoly> knownErrors = field_.getOne();
65 for (int i=0;i<erasures->size();i++) {
66 int b = field_.exp(received->size() - 1 - erasures[i]);
67 // Add (1 - bx) term:
68 ArrayRef<int> one_minus_b_x(new Array<int>(2));
69 one_minus_b_x[1]=field_.subtract(0,b);
70 one_minus_b_x[0]=1;
71 Ref<ModulusPoly> term (new ModulusPoly(field_,one_minus_b_x));
72 knownErrors = knownErrors->multiply(term);
73 }
74
75 Ref<ModulusPoly> syndrome (new ModulusPoly(field_, S));
76 //syndrome = syndrome.multiply(knownErrors);
77
78 vector<Ref<ModulusPoly> > sigmaOmega (
79 runEuclideanAlgorithm(field_.buildMonomial(numECCodewords, 1), syndrome, numECCodewords));
80 Ref<ModulusPoly> sigma = sigmaOmega[0];
81 Ref<ModulusPoly> omega = sigmaOmega[1];
82
83 //sigma = sigma.multiply(knownErrors);
84
85 ArrayRef<int> errorLocations = findErrorLocations(sigma);
86 ArrayRef<int> errorMagnitudes = findErrorMagnitudes(omega, sigma, errorLocations);
87
88 for (int i = 0; i < errorLocations->size(); i++) {
89 int position = received->size() - 1 - field_.log(errorLocations[i]);
90 if (position < 0) {
91 throw ReedSolomonException("Bad error location!");
92 }
93 received[position] = field_.subtract(received[position], errorMagnitudes[i]);
94#if (defined (DEBUG) && defined _WIN32)
95 {
96 WCHAR szmsg[256];
97 swprintf(szmsg,L"ErrorCorrection::decode: fix @ %d, new value = %d\n",
98 position, received[position]);
99 OutputDebugString(szmsg);
100 }
101#endif
102 }
103 }
104}

Callers

nothing calls this directly

Calls 9

evaluateAtMethod · 0.45
expMethod · 0.45
getOneMethod · 0.45
sizeMethod · 0.45
subtractMethod · 0.45
multiplyMethod · 0.45
buildMonomialMethod · 0.45
logMethod · 0.45

Tested by

no test coverage detected