| 41 | const int Decoder::MAX_EC_CODEWORDS = 512; |
| 42 | |
| 43 | Ref<DecoderResult> Decoder::decode(Ref<BitMatrix> bits, DecodeHints const& hints) { |
| 44 | (void)hints; |
| 45 | // Construct a parser to read the data codewords and error-correction level |
| 46 | BitMatrixParser parser(bits); |
| 47 | ArrayRef<int> codewords(parser.readCodewords()); |
| 48 | if (codewords->size() == 0) { |
| 49 | throw FormatException("PDF:Decoder:decode: cannot read codewords"); |
| 50 | } |
| 51 | |
| 52 | int ecLevel = parser.getECLevel(); |
| 53 | int numECCodewords = 1 << (ecLevel + 1); |
| 54 | ArrayRef<int> erasures = parser.getErasures(); |
| 55 | |
| 56 | correctErrors(codewords, erasures, numECCodewords); |
| 57 | verifyCodewordCount(codewords, numECCodewords); |
| 58 | |
| 59 | // Decode the codewords |
| 60 | return DecodedBitStreamParser::decode(codewords); |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * Verify that all is OK with the codeword array. |
no test coverage detected