| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 // Original code is licensed as follows: | 6 // Original code is licensed as follows: |
| 7 /* | 7 /* |
| 8 * Copyright 2009 ZXing authors | 8 * Copyright 2009 ZXing authors |
| 9 * | 9 * |
| 10 * Licensed under the Apache License, Version 2.0 (the "License"); | 10 * Licensed under the Apache License, Version 2.0 (the "License"); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 while (codeIndex < codewords[0]) { | 72 while (codeIndex < codewords[0]) { |
| 73 switch (code) { | 73 switch (code) { |
| 74 case TEXT_COMPACTION_MODE_LATCH: | 74 case TEXT_COMPACTION_MODE_LATCH: |
| 75 codeIndex = textCompaction(codewords, codeIndex, result); | 75 codeIndex = textCompaction(codewords, codeIndex, result); |
| 76 break; | 76 break; |
| 77 case BYTE_COMPACTION_MODE_LATCH: | 77 case BYTE_COMPACTION_MODE_LATCH: |
| 78 codeIndex = byteCompaction(code, codewords, codeIndex, result); | 78 codeIndex = byteCompaction(code, codewords, codeIndex, result); |
| 79 break; | 79 break; |
| 80 case NUMERIC_COMPACTION_MODE_LATCH: | 80 case NUMERIC_COMPACTION_MODE_LATCH: |
| 81 codeIndex = numericCompaction(codewords, codeIndex, result, e); | 81 codeIndex = numericCompaction(codewords, codeIndex, result, e); |
| 82 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 82 BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); |
| 83 break; | 83 break; |
| 84 case MODE_SHIFT_TO_BYTE_COMPACTION_MODE: | 84 case MODE_SHIFT_TO_BYTE_COMPACTION_MODE: |
| 85 codeIndex = byteCompaction(code, codewords, codeIndex, result); | 85 codeIndex = byteCompaction(code, codewords, codeIndex, result); |
| 86 break; | 86 break; |
| 87 case BYTE_COMPACTION_MODE_LATCH_6: | 87 case BYTE_COMPACTION_MODE_LATCH_6: |
| 88 codeIndex = byteCompaction(code, codewords, codeIndex, result); | 88 codeIndex = byteCompaction(code, codewords, codeIndex, result); |
| 89 break; | 89 break; |
| 90 case BEGIN_MACRO_PDF417_CONTROL_BLOCK: | 90 case BEGIN_MACRO_PDF417_CONTROL_BLOCK: |
| 91 codeIndex = decodeMacroBlock(codewords, codeIndex, resultMetadata, e); | 91 codeIndex = decodeMacroBlock(codewords, codeIndex, resultMetadata, e); |
| 92 if (e != BCExceptionNO) { | 92 if (e != BCExceptionNO) { |
| 93 delete resultMetadata; | 93 delete resultMetadata; |
| 94 return NULL; | 94 return nullptr; |
| 95 } | 95 } |
| 96 break; | 96 break; |
| 97 default: | 97 default: |
| 98 codeIndex--; | 98 codeIndex--; |
| 99 codeIndex = textCompaction(codewords, codeIndex, result); | 99 codeIndex = textCompaction(codewords, codeIndex, result); |
| 100 break; | 100 break; |
| 101 } | 101 } |
| 102 if (codeIndex < codewords.GetSize()) { | 102 if (codeIndex < codewords.GetSize()) { |
| 103 code = codewords[codeIndex++]; | 103 code = codewords[codeIndex++]; |
| 104 } else { | 104 } else { |
| 105 e = BCExceptionFormatInstance; | 105 e = BCExceptionFormatInstance; |
| 106 delete resultMetadata; | 106 delete resultMetadata; |
| 107 return NULL; | 107 return nullptr; |
| 108 } | 108 } |
| 109 } | 109 } |
| 110 if (result.GetLength() == 0) { | 110 if (result.GetLength() == 0) { |
| 111 e = BCExceptionFormatInstance; | 111 e = BCExceptionFormatInstance; |
| 112 delete resultMetadata; | 112 delete resultMetadata; |
| 113 return NULL; | 113 return nullptr; |
| 114 } | 114 } |
| 115 CFX_ByteArray rawBytes; | 115 CFX_ByteArray rawBytes; |
| 116 CBC_CommonDecoderResult* tempCd = new CBC_CommonDecoderResult(); | 116 CBC_CommonDecoderResult* tempCd = new CBC_CommonDecoderResult(); |
| 117 tempCd->Init(rawBytes, result, ecLevel, e); | 117 tempCd->Init(rawBytes, result, ecLevel, e); |
| 118 if (e != BCExceptionNO) { | 118 if (e != BCExceptionNO) { |
| 119 delete resultMetadata; | 119 delete resultMetadata; |
| 120 return NULL; | 120 return nullptr; |
| 121 } | 121 } |
| 122 tempCd->setOther(resultMetadata); | 122 tempCd->setOther(resultMetadata); |
| 123 return tempCd; | 123 return tempCd; |
| 124 } | 124 } |
| 125 int32_t CBC_DecodedBitStreamPaser::decodeMacroBlock( | 125 int32_t CBC_DecodedBitStreamPaser::decodeMacroBlock( |
| 126 CFX_Int32Array& codewords, | 126 CFX_Int32Array& codewords, |
| 127 int32_t codeIndex, | 127 int32_t codeIndex, |
| 128 CBC_PDF417ResultMetadata* resultMetadata, | 128 CBC_PDF417ResultMetadata* resultMetadata, |
| 129 int32_t& e) { | 129 int32_t& e) { |
| 130 if (codeIndex + NUMBER_OF_SEQUENCE_CODEWORDS > codewords[0]) { | 130 if (codeIndex + NUMBER_OF_SEQUENCE_CODEWORDS > codewords[0]) { |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 for (int32_t i = 0; i < count; i++) { | 483 for (int32_t i = 0; i < count; i++) { |
| 484 result = result * nineHundred + BigInteger(codewords[i]); | 484 result = result * nineHundred + BigInteger(codewords[i]); |
| 485 } | 485 } |
| 486 CFX_ByteString resultString(bigIntegerToString(result).c_str()); | 486 CFX_ByteString resultString(bigIntegerToString(result).c_str()); |
| 487 if (resultString.GetAt(0) != '1') { | 487 if (resultString.GetAt(0) != '1') { |
| 488 e = BCExceptionFormatInstance; | 488 e = BCExceptionFormatInstance; |
| 489 return ' '; | 489 return ' '; |
| 490 } | 490 } |
| 491 return resultString.Mid(1, resultString.GetLength() - 1); | 491 return resultString.Mid(1, resultString.GetLength() - 1); |
| 492 } | 492 } |
| OLD | NEW |