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