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

Method correctErrors

deps/zxing/core/src/zxing/pdf417/decoder/3Decoder.cpp:101–118  ·  view source on GitHub ↗

* Correct errors whenever it is possible using Reed-Solomom algorithm * * @param codewords, erasures, numECCodewords * @return 0. * @throws FormatException */

Source from the content-addressed store, hash-verified

99 * @throws FormatException
100 */
101void Decoder::correctErrors(ArrayRef<int> codewords,
102 ArrayRef<int> erasures, int numECCodewords) {
103 if (erasures->size() > numECCodewords / 2 + MAX_ERRORS ||
104 numECCodewords < 0 || numECCodewords > MAX_EC_CODEWORDS) {
105 throw FormatException("PDF:Decoder:correctErrors: Too many errors or EC Codewords corrupted");
106 }
107
108 Ref<ErrorCorrection> errorCorrection(new ErrorCorrection);
109 errorCorrection->decode(codewords, numECCodewords, erasures);
110
111 // 2012-06-27 HFN if, despite of error correction, there are still codewords with invalid
112 // value, throw an exception here:
113 for (int i = 0; i < codewords->size(); i++) {
114 if (codewords[i]<0) {
115 throw FormatException("PDF:Decoder:correctErrors: Error correction did not succeed!");
116 }
117 }
118}

Callers

nothing calls this directly

Calls 3

FormatExceptionClass · 0.85
sizeMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected