Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: xfa/src/fxbarcode/oned/BC_OneDReader.cpp

Issue 1577503002: Merge to XFA: Switch most min/max macros to std::min/max. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: rebase Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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");
11 * you may not use this file except in compliance with the License. 11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at 12 * You may obtain a copy of the License at
13 * 13 *
14 * http://www.apache.org/licenses/LICENSE-2.0 14 * http://www.apache.org/licenses/LICENSE-2.0
15 * 15 *
16 * Unless required by applicable law or agreed to in writing, software 16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS, 17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and 19 * See the License for the specific language governing permissions and
20 * limitations under the License. 20 * limitations under the License.
21 */ 21 */
22 22
23 #include <algorithm>
24
23 #include "xfa/src/fxbarcode/barcode.h" 25 #include "xfa/src/fxbarcode/barcode.h"
24 #include "xfa/src/fxbarcode/BC_Reader.h" 26 #include "xfa/src/fxbarcode/BC_Reader.h"
25 #include "xfa/src/fxbarcode/BC_BinaryBitmap.h" 27 #include "xfa/src/fxbarcode/BC_BinaryBitmap.h"
26 #include "xfa/src/fxbarcode/common/BC_CommonBitArray.h" 28 #include "xfa/src/fxbarcode/common/BC_CommonBitArray.h"
27 #include "BC_OneDReader.h" 29 #include "BC_OneDReader.h"
28 const int32_t CBC_OneDReader::INTEGER_MATH_SHIFT = 8; 30 const int32_t CBC_OneDReader::INTEGER_MATH_SHIFT = 8;
29 const int32_t CBC_OneDReader::PATTERN_MATCH_RESULT_SCALE_FACTOR = 1 << 8; 31 const int32_t CBC_OneDReader::PATTERN_MATCH_RESULT_SCALE_FACTOR = 1 << 8;
30 CBC_OneDReader::CBC_OneDReader() {} 32 CBC_OneDReader::CBC_OneDReader() {}
31 CBC_OneDReader::~CBC_OneDReader() {} 33 CBC_OneDReader::~CBC_OneDReader() {}
32 CFX_ByteString CBC_OneDReader::Decode(CBC_BinaryBitmap* image, int32_t& e) { 34 CFX_ByteString CBC_OneDReader::Decode(CBC_BinaryBitmap* image, int32_t& e) {
33 CFX_ByteString strtemp = Decode(image, 0, e); 35 CFX_ByteString strtemp = Decode(image, 0, e);
34 BC_EXCEPTION_CHECK_ReturnValue(e, ""); 36 BC_EXCEPTION_CHECK_ReturnValue(e, "");
35 return strtemp; 37 return strtemp;
36 } 38 }
37 CFX_ByteString CBC_OneDReader::Decode(CBC_BinaryBitmap* image, 39 CFX_ByteString CBC_OneDReader::Decode(CBC_BinaryBitmap* image,
38 int32_t hints, 40 int32_t hints,
39 int32_t& e) { 41 int32_t& e) {
40 CFX_ByteString strtemp = DeDecode(image, hints, e); 42 CFX_ByteString strtemp = DeDecode(image, hints, e);
41 BC_EXCEPTION_CHECK_ReturnValue(e, ""); 43 BC_EXCEPTION_CHECK_ReturnValue(e, "");
42 return strtemp; 44 return strtemp;
43 } 45 }
44 CFX_ByteString CBC_OneDReader::DeDecode(CBC_BinaryBitmap* image, 46 CFX_ByteString CBC_OneDReader::DeDecode(CBC_BinaryBitmap* image,
45 int32_t hints, 47 int32_t hints,
46 int32_t& e) { 48 int32_t& e) {
47 int32_t height = image->GetHeight(); 49 int32_t height = image->GetHeight();
48 CBC_CommonBitArray* row = NULL; 50 CBC_CommonBitArray* row = NULL;
49 int32_t middle = height >> 1; 51 int32_t middle = height >> 1;
50 FX_BOOL tryHarder = FALSE; 52 FX_BOOL tryHarder = FALSE;
51 int32_t rowStep = FX_MAX(1, height >> (tryHarder ? 8 : 5)); 53 int32_t rowStep = std::max(1, height >> (tryHarder ? 8 : 5));
52 int32_t maxLines; 54 int32_t maxLines;
53 if (tryHarder) { 55 if (tryHarder) {
54 maxLines = height; 56 maxLines = height;
55 } else { 57 } else {
56 maxLines = 15; 58 maxLines = 15;
57 } 59 }
58 for (int32_t x = 0; x < maxLines; x++) { 60 for (int32_t x = 0; x < maxLines; x++) {
59 int32_t rowStepsAboveOrBelow = (x + 1) >> 1; 61 int32_t rowStepsAboveOrBelow = (x + 1) >> 1;
60 FX_BOOL isAbove = (x & 0x01) == 0; 62 FX_BOOL isAbove = (x & 0x01) == 0;
61 int32_t rowNumber = 63 int32_t rowNumber =
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 int32_t variance = counter > scaledPattern ? counter - scaledPattern 178 int32_t variance = counter > scaledPattern ? counter - scaledPattern
177 : scaledPattern - counter; 179 : scaledPattern - counter;
178 if (variance > maxIndividualVariance) { 180 if (variance > maxIndividualVariance) {
179 #undef max 181 #undef max
180 return FXSYS_IntMax; 182 return FXSYS_IntMax;
181 } 183 }
182 totalVariance += variance; 184 totalVariance += variance;
183 } 185 }
184 return totalVariance / total; 186 return totalVariance / total;
185 } 187 }
OLDNEW
« no previous file with comments | « xfa/src/fxbarcode/datamatrix/BC_DataMatrixDetector.cpp ('k') | xfa/src/fxbarcode/oned/BC_OneDimWriter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698