| 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 2007 ZXing authors | 8 * Copyright 2007 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 } | 58 } |
| 59 CBC_QRCoderErrorCorrectionLevel* | 59 CBC_QRCoderErrorCorrectionLevel* |
| 60 CBC_QRCoderFormatInformation::GetErrorCorrectionLevel() { | 60 CBC_QRCoderFormatInformation::GetErrorCorrectionLevel() { |
| 61 return m_errorCorrectLevl; | 61 return m_errorCorrectLevl; |
| 62 } | 62 } |
| 63 CBC_QRCoderFormatInformation* | 63 CBC_QRCoderFormatInformation* |
| 64 CBC_QRCoderFormatInformation::DecodeFormatInformation( | 64 CBC_QRCoderFormatInformation::DecodeFormatInformation( |
| 65 int32_t maskedFormatInfo) { | 65 int32_t maskedFormatInfo) { |
| 66 CBC_QRCoderFormatInformation* formatInfo = | 66 CBC_QRCoderFormatInformation* formatInfo = |
| 67 DoDecodeFormatInformation(maskedFormatInfo); | 67 DoDecodeFormatInformation(maskedFormatInfo); |
| 68 if (formatInfo != NULL) { | 68 if (formatInfo) |
| 69 return formatInfo; | 69 return formatInfo; |
| 70 } | |
| 71 return DoDecodeFormatInformation(maskedFormatInfo ^ FORMAT_INFO_MASK_QR); | 70 return DoDecodeFormatInformation(maskedFormatInfo ^ FORMAT_INFO_MASK_QR); |
| 72 } | 71 } |
| 73 CBC_QRCoderFormatInformation* | 72 CBC_QRCoderFormatInformation* |
| 74 CBC_QRCoderFormatInformation::DoDecodeFormatInformation( | 73 CBC_QRCoderFormatInformation::DoDecodeFormatInformation( |
| 75 int32_t maskedFormatInfo) { | 74 int32_t maskedFormatInfo) { |
| 76 int32_t bestDifference = (int32_t)FXSYS_nan(); | 75 int32_t bestDifference = (int32_t)FXSYS_nan(); |
| 77 int32_t bestFormatInfo = 0; | 76 int32_t bestFormatInfo = 0; |
| 78 for (int32_t i = 0; i < 32; i++) { | 77 for (int32_t i = 0; i < 32; i++) { |
| 79 int32_t const* decodeInfo = &FORMAT_INFO_DECODE_LOOKUP[i][0]; | 78 int32_t const* decodeInfo = &FORMAT_INFO_DECODE_LOOKUP[i][0]; |
| 80 int32_t targetInfo = decodeInfo[0]; | 79 int32_t targetInfo = decodeInfo[0]; |
| 81 if (targetInfo == maskedFormatInfo) { | 80 if (targetInfo == maskedFormatInfo) { |
| 82 return new CBC_QRCoderFormatInformation(decodeInfo[1]); | 81 return new CBC_QRCoderFormatInformation(decodeInfo[1]); |
| 83 } | 82 } |
| 84 int32_t bitsDifference = NumBitsDiffering(maskedFormatInfo, targetInfo); | 83 int32_t bitsDifference = NumBitsDiffering(maskedFormatInfo, targetInfo); |
| 85 if (bitsDifference < bestDifference) { | 84 if (bitsDifference < bestDifference) { |
| 86 bestFormatInfo = decodeInfo[1]; | 85 bestFormatInfo = decodeInfo[1]; |
| 87 bestDifference = bitsDifference; | 86 bestDifference = bitsDifference; |
| 88 } | 87 } |
| 89 } | 88 } |
| 90 if (bestDifference <= 3) { | 89 if (bestDifference <= 3) { |
| 91 return new CBC_QRCoderFormatInformation(bestFormatInfo); | 90 return new CBC_QRCoderFormatInformation(bestFormatInfo); |
| 92 } | 91 } |
| 93 return NULL; | 92 return NULL; |
| 94 } | 93 } |
| OLD | NEW |