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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 int32_t height = source->GetHeight(); | 80 int32_t height = source->GetHeight(); |
81 std::unique_ptr<CBC_CommonBitMatrix> matrix(new CBC_CommonBitMatrix()); | 81 std::unique_ptr<CBC_CommonBitMatrix> matrix(new CBC_CommonBitMatrix()); |
82 matrix->Init(width, height); | 82 matrix->Init(width, height); |
83 InitArrays(width); | 83 InitArrays(width); |
84 CFX_Int32Array localBuckets; | 84 CFX_Int32Array localBuckets; |
85 localBuckets.Copy(m_buckets); | 85 localBuckets.Copy(m_buckets); |
86 int32_t y; | 86 int32_t y; |
87 for (y = 1; y < 5; y++) { | 87 for (y = 1; y < 5; y++) { |
88 int32_t row = height * y / 5; | 88 int32_t row = height * y / 5; |
89 CFX_ByteArray* localLuminances = source->GetRow(row, m_luminance, e); | 89 CFX_ByteArray* localLuminances = source->GetRow(row, m_luminance, e); |
90 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 90 BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); |
91 int32_t right = (width << 2) / 5; | 91 int32_t right = (width << 2) / 5; |
92 int32_t x; | 92 int32_t x; |
93 for (x = width / 5; x < right; x++) { | 93 for (x = width / 5; x < right; x++) { |
94 int32_t pixel = (*localLuminances)[x] & 0xff; | 94 int32_t pixel = (*localLuminances)[x] & 0xff; |
95 localBuckets[pixel >> LUMINANCE_SHIFT]++; | 95 localBuckets[pixel >> LUMINANCE_SHIFT]++; |
96 } | 96 } |
97 } | 97 } |
98 int32_t blackPoint = EstimateBlackPoint(localBuckets, e); | 98 int32_t blackPoint = EstimateBlackPoint(localBuckets, e); |
99 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 99 BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); |
100 std::unique_ptr<CFX_ByteArray> localLuminances(source->GetMatrix()); | 100 std::unique_ptr<CFX_ByteArray> localLuminances(source->GetMatrix()); |
101 for (y = 0; y < height; y++) { | 101 for (y = 0; y < height; y++) { |
102 int32_t offset = y * width; | 102 int32_t offset = y * width; |
103 for (int32_t x = 0; x < width; x++) { | 103 for (int32_t x = 0; x < width; x++) { |
104 int32_t pixel = (*localLuminances)[offset + x] & 0xff; | 104 int32_t pixel = (*localLuminances)[offset + x] & 0xff; |
105 if (pixel < blackPoint) { | 105 if (pixel < blackPoint) { |
106 matrix->Set(x, y); | 106 matrix->Set(x, y); |
107 } | 107 } |
108 } | 108 } |
109 } | 109 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 int32_t fromFirst = x - firstPeak; | 164 int32_t fromFirst = x - firstPeak; |
165 int32_t score = fromFirst * fromFirst * (secondPeak - x) * | 165 int32_t score = fromFirst * fromFirst * (secondPeak - x) * |
166 (maxBucketCount - buckets[x]); | 166 (maxBucketCount - buckets[x]); |
167 if (score > bestValleyScore) { | 167 if (score > bestValleyScore) { |
168 bestValley = x; | 168 bestValley = x; |
169 bestValleyScore = score; | 169 bestValleyScore = score; |
170 } | 170 } |
171 } | 171 } |
172 return bestValley << LUMINANCE_SHIFT; | 172 return bestValley << LUMINANCE_SHIFT; |
173 } | 173 } |
OLD | NEW |