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 2008 ZXing authors | 8 * Copyright 2008 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 14 matching lines...) Expand all Loading... |
25 #include "xfa/src/fxbarcode/qrcode/BC_QRCoder.h" | 25 #include "xfa/src/fxbarcode/qrcode/BC_QRCoder.h" |
26 #include "xfa/src/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h" | 26 #include "xfa/src/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h" |
27 #include "xfa/src/fxbarcode/qrcode/BC_QRCoderMaskUtil.h" | 27 #include "xfa/src/fxbarcode/qrcode/BC_QRCoderMaskUtil.h" |
28 CBC_QRCoderMaskUtil::CBC_QRCoderMaskUtil() {} | 28 CBC_QRCoderMaskUtil::CBC_QRCoderMaskUtil() {} |
29 CBC_QRCoderMaskUtil::~CBC_QRCoderMaskUtil() {} | 29 CBC_QRCoderMaskUtil::~CBC_QRCoderMaskUtil() {} |
30 int32_t CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule1( | 30 int32_t CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule1( |
31 CBC_CommonByteMatrix* matrix) { | 31 CBC_CommonByteMatrix* matrix) { |
32 return ApplyMaskPenaltyRule1Internal(matrix, TRUE) + | 32 return ApplyMaskPenaltyRule1Internal(matrix, TRUE) + |
33 ApplyMaskPenaltyRule1Internal(matrix, FALSE); | 33 ApplyMaskPenaltyRule1Internal(matrix, FALSE); |
34 } | 34 } |
| 35 |
35 int32_t CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule2( | 36 int32_t CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule2( |
36 CBC_CommonByteMatrix* matrix) { | 37 CBC_CommonByteMatrix* matrix) { |
37 int32_t penalty = 0; | 38 int32_t penalty = 0; |
38 uint8_t* array = matrix->GetArray(); | 39 uint8_t* array = matrix->GetArray(); |
39 int32_t width = matrix->GetWidth(); | 40 int32_t width = matrix->GetWidth(); |
40 int32_t height = matrix->GetHeight(); | 41 int32_t height = matrix->GetHeight(); |
41 for (int32_t y = 0; y < height - 1; y++) { | 42 for (int32_t y = 0; y < height - 1; y++) { |
42 for (int32_t x = 0; x < width - 1; x++) { | 43 for (int32_t x = 0; x < width - 1; x++) { |
43 int32_t value = array[y * width + x]; | 44 int32_t value = array[y * width + x]; |
44 if (value == array[y * width + x + 1] && | 45 if (value == array[y * width + x + 1] && |
45 value == array[(y + 1) * width + x] && | 46 value == array[(y + 1) * width + x] && |
46 value == array[(y + 1) * width + x + 1]) { | 47 value == array[(y + 1) * width + x + 1]) { |
47 penalty++; | 48 penalty++; |
48 } | 49 } |
49 } | 50 } |
50 } | 51 } |
51 return 3 * penalty; | 52 return 3 * penalty; |
52 } | 53 } |
| 54 |
53 int32_t CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule3( | 55 int32_t CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule3( |
54 CBC_CommonByteMatrix* matrix) { | 56 CBC_CommonByteMatrix* matrix) { |
55 int32_t penalty = 0; | 57 int32_t penalty = 0; |
56 uint8_t* array = matrix->GetArray(); | 58 uint8_t* array = matrix->GetArray(); |
57 int32_t width = matrix->GetWidth(); | 59 int32_t width = matrix->GetWidth(); |
58 int32_t height = matrix->GetHeight(); | 60 int32_t height = matrix->GetHeight(); |
59 for (int32_t y = 0; y < height; ++y) { | 61 for (int32_t y = 0; y < height; ++y) { |
60 for (int32_t x = 0; x < width; ++x) { | 62 for (int32_t x = 0; x < width; ++x) { |
61 if (x == 0 && | 63 if (x == 0 && |
62 ((y >= 0 && y <= 6) || (y >= height - 7 && y <= height - 1))) { | 64 ((y >= 0 && y <= 6) || (y >= height - 7 && y <= height - 1))) { |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 } | 188 } |
187 } else { | 189 } else { |
188 numSameBitCells = 1; | 190 numSameBitCells = 1; |
189 prevBit = bit; | 191 prevBit = bit; |
190 } | 192 } |
191 } | 193 } |
192 numSameBitCells = 0; | 194 numSameBitCells = 0; |
193 } | 195 } |
194 return penalty; | 196 return penalty; |
195 } | 197 } |
OLD | NEW |