* Correct errors whenever it is possible using Reed-Solomom algorithm * * @param codewords, erasures, numECCodewords * @return 0. * @throws FormatException */
| 99 | * @throws FormatException |
| 100 | */ |
| 101 | void 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 | } |
nothing calls this directly
no test coverage detected