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

Side by Side Diff: xfa/src/fxbarcode/oned/BC_OnedCode128Reader.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/common/BC_CommonBitArray.h" 27 #include "xfa/src/fxbarcode/common/BC_CommonBitArray.h"
26 #include "BC_OneDReader.h" 28 #include "BC_OneDReader.h"
27 #include "BC_OnedCode128Reader.h" 29 #include "BC_OnedCode128Reader.h"
28 const int32_t CBC_OnedCode128Reader::CODE_PATTERNS[107][7] = { 30 const int32_t CBC_OnedCode128Reader::CODE_PATTERNS[107][7] = {
29 {2, 1, 2, 2, 2, 2, 0}, {2, 2, 2, 1, 2, 2, 0}, {2, 2, 2, 2, 2, 1, 0}, 31 {2, 1, 2, 2, 2, 2, 0}, {2, 2, 2, 1, 2, 2, 0}, {2, 2, 2, 2, 2, 1, 0},
30 {1, 2, 1, 2, 2, 3, 0}, {1, 2, 1, 3, 2, 2, 0}, {1, 3, 1, 2, 2, 2, 0}, 32 {1, 2, 1, 2, 2, 3, 0}, {1, 2, 1, 3, 2, 2, 0}, {1, 3, 1, 2, 2, 2, 0},
31 {1, 2, 2, 2, 1, 3, 0}, {1, 2, 2, 3, 1, 2, 0}, {1, 3, 2, 2, 1, 2, 0}, 33 {1, 2, 2, 2, 1, 3, 0}, {1, 2, 2, 3, 1, 2, 0}, {1, 3, 2, 2, 1, 2, 0},
32 {2, 2, 1, 2, 1, 3, 0}, {2, 2, 1, 3, 1, 2, 0}, {2, 3, 1, 2, 1, 2, 0}, 34 {2, 2, 1, 2, 1, 3, 0}, {2, 2, 1, 3, 1, 2, 0}, {2, 3, 1, 2, 1, 2, 0},
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 startCode++) { 110 startCode++) {
109 int32_t variance = PatternMatchVariance( 111 int32_t variance = PatternMatchVariance(
110 &counters, &CODE_PATTERNS[startCode][0], MAX_INDIVIDUAL_VARIANCE); 112 &counters, &CODE_PATTERNS[startCode][0], MAX_INDIVIDUAL_VARIANCE);
111 if (variance < bestVariance) { 113 if (variance < bestVariance) {
112 bestVariance = variance; 114 bestVariance = variance;
113 bestMatch = startCode; 115 bestMatch = startCode;
114 } 116 }
115 } 117 }
116 if (bestMatch >= 0) { 118 if (bestMatch >= 0) {
117 FX_BOOL btemp2 = 119 FX_BOOL btemp2 =
118 row->IsRange(FX_MAX(0, patternStart - (i - patternStart) / 2), 120 row->IsRange(std::max(0, patternStart - (i - patternStart) / 2),
119 patternStart, FALSE, e); 121 patternStart, FALSE, e);
120 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 122 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
121 if (btemp2) { 123 if (btemp2) {
122 CFX_Int32Array* result = new CFX_Int32Array; 124 CFX_Int32Array* result = new CFX_Int32Array;
123 result->SetSize(3); 125 result->SetSize(3);
124 (*result)[0] = patternStart; 126 (*result)[0] = patternStart;
125 (*result)[1] = i; 127 (*result)[1] = i;
126 (*result)[2] = bestMatch; 128 (*result)[2] = bestMatch;
127 return result; 129 return result;
128 } 130 }
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 } 333 }
332 if (unshift) { 334 if (unshift) {
333 codeSet = codeSet == CODE_CODE_A ? CODE_CODE_B : CODE_CODE_A; 335 codeSet = codeSet == CODE_CODE_A ? CODE_CODE_B : CODE_CODE_A;
334 } 336 }
335 } 337 }
336 int32_t width = row->GetSize(); 338 int32_t width = row->GetSize();
337 while (nextStart < width && row->Get(nextStart)) { 339 while (nextStart < width && row->Get(nextStart)) {
338 nextStart++; 340 nextStart++;
339 } 341 }
340 FX_BOOL boolT1 = row->IsRange( 342 FX_BOOL boolT1 = row->IsRange(
341 nextStart, FX_MIN(width, nextStart + (nextStart - lastStart) / 2), FALSE, 343 nextStart, std::min(width, nextStart + (nextStart - lastStart) / 2),
342 e); 344 FALSE, e);
343 BC_EXCEPTION_CHECK_ReturnValue(e, ""); 345 BC_EXCEPTION_CHECK_ReturnValue(e, "");
344 if (!boolT1) { 346 if (!boolT1) {
345 e = BCExceptionNotFound; 347 e = BCExceptionNotFound;
346 return ""; 348 return "";
347 } 349 }
348 checksumTotal -= multiplier * lastCode; 350 checksumTotal -= multiplier * lastCode;
349 if (checksumTotal % 103 != lastCode) { 351 if (checksumTotal % 103 != lastCode) {
350 e = BCExceptionChecksumException; 352 e = BCExceptionChecksumException;
351 return ""; 353 return "";
352 } 354 }
353 int32_t resultLength = result.GetLength(); 355 int32_t resultLength = result.GetLength();
354 if (resultLength > 0 && lastCharacterWasPrintable) { 356 if (resultLength > 0 && lastCharacterWasPrintable) {
355 if (codeSet == CODE_CODE_C) { 357 if (codeSet == CODE_CODE_C) {
356 result = result.Mid(0, result.GetLength() - 2); 358 result = result.Mid(0, result.GetLength() - 2);
357 } else { 359 } else {
358 result = result.Mid(0, result.GetLength() - 1); 360 result = result.Mid(0, result.GetLength() - 1);
359 } 361 }
360 } 362 }
361 if (result.GetLength() == 0) { 363 if (result.GetLength() == 0) {
362 e = BCExceptionFormatException; 364 e = BCExceptionFormatException;
363 return ""; 365 return "";
364 } 366 }
365 return result; 367 return result;
366 } 368 }
OLDNEW
« no previous file with comments | « xfa/src/fxbarcode/oned/BC_OnedCodaBarReader.cpp ('k') | xfa/src/fxbarcode/oned/BC_OnedCode39Reader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698