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

Side by Side Diff: xfa/fxbarcode/oned/BC_OnedCode128Reader.cpp

Issue 2048983002: Get rid of NULLs in xfa/fxbarcode/ (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: nits Created 4 years, 6 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");
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 &counters, &CODE_PATTERNS[startCode][0], MAX_INDIVIDUAL_VARIANCE); 98 &counters, &CODE_PATTERNS[startCode][0], MAX_INDIVIDUAL_VARIANCE);
99 if (variance < bestVariance) { 99 if (variance < bestVariance) {
100 bestVariance = variance; 100 bestVariance = variance;
101 bestMatch = startCode; 101 bestMatch = startCode;
102 } 102 }
103 } 103 }
104 if (bestMatch >= 0) { 104 if (bestMatch >= 0) {
105 FX_BOOL btemp2 = 105 FX_BOOL btemp2 =
106 row->IsRange(std::max(0, patternStart - (i - patternStart) / 2), 106 row->IsRange(std::max(0, patternStart - (i - patternStart) / 2),
107 patternStart, FALSE, e); 107 patternStart, FALSE, e);
108 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 108 BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
109 if (btemp2) { 109 if (btemp2) {
110 CFX_Int32Array* result = new CFX_Int32Array; 110 CFX_Int32Array* result = new CFX_Int32Array;
111 result->SetSize(3); 111 result->SetSize(3);
112 (*result)[0] = patternStart; 112 (*result)[0] = patternStart;
113 (*result)[1] = i; 113 (*result)[1] = i;
114 (*result)[2] = bestMatch; 114 (*result)[2] = bestMatch;
115 return result; 115 return result;
116 } 116 }
117 } 117 }
118 patternStart += counters[0] + counters[1]; 118 patternStart += counters[0] + counters[1];
119 for (int32_t y = 2; y < patternLength; y++) { 119 for (int32_t y = 2; y < patternLength; y++) {
120 counters[y - 2] = counters[y]; 120 counters[y - 2] = counters[y];
121 } 121 }
122 counters[patternLength - 2] = 0; 122 counters[patternLength - 2] = 0;
123 counters[patternLength - 1] = 0; 123 counters[patternLength - 1] = 0;
124 counterPosition--; 124 counterPosition--;
125 } else { 125 } else {
126 counterPosition++; 126 counterPosition++;
127 } 127 }
128 counters[counterPosition] = 1; 128 counters[counterPosition] = 1;
129 isWhite = !isWhite; 129 isWhite = !isWhite;
130 } 130 }
131 } 131 }
132 e = BCExceptionNotFound; 132 e = BCExceptionNotFound;
133 return NULL; 133 return nullptr;
134 } 134 }
135 int32_t CBC_OnedCode128Reader::DecodeCode(CBC_CommonBitArray* row, 135 int32_t CBC_OnedCode128Reader::DecodeCode(CBC_CommonBitArray* row,
136 CFX_Int32Array* counters, 136 CFX_Int32Array* counters,
137 int32_t rowOffset, 137 int32_t rowOffset,
138 int32_t& e) { 138 int32_t& e) {
139 RecordPattern(row, rowOffset, counters, e); 139 RecordPattern(row, rowOffset, counters, e);
140 BC_EXCEPTION_CHECK_ReturnValue(e, 0); 140 BC_EXCEPTION_CHECK_ReturnValue(e, 0);
141 int32_t bestVariance = MAX_AVG_VARIANCE; 141 int32_t bestVariance = MAX_AVG_VARIANCE;
142 int32_t bestMatch = -1; 142 int32_t bestMatch = -1;
143 for (int32_t d = 0; d < 107; d++) { 143 for (int32_t d = 0; d < 107; d++) {
(...skipping 25 matching lines...) Expand all
169 case 104: 169 case 104:
170 codeSet = CODE_CODE_B; 170 codeSet = CODE_CODE_B;
171 break; 171 break;
172 case 105: 172 case 105:
173 codeSet = CODE_CODE_C; 173 codeSet = CODE_CODE_C;
174 break; 174 break;
175 default: 175 default:
176 if (startPatternInfo) { 176 if (startPatternInfo) {
177 startPatternInfo->RemoveAll(); 177 startPatternInfo->RemoveAll();
178 delete startPatternInfo; 178 delete startPatternInfo;
179 startPatternInfo = NULL; 179 startPatternInfo = nullptr;
180 } 180 }
181 e = BCExceptionFormatException; 181 e = BCExceptionFormatException;
182 return ""; 182 return "";
183 } 183 }
184 FX_BOOL done = FALSE; 184 FX_BOOL done = FALSE;
185 FX_BOOL isNextShifted = FALSE; 185 FX_BOOL isNextShifted = FALSE;
186 CFX_ByteString result; 186 CFX_ByteString result;
187 int32_t lastStart = (*startPatternInfo)[0]; 187 int32_t lastStart = (*startPatternInfo)[0];
188 int32_t nextStart = (*startPatternInfo)[1]; 188 int32_t nextStart = (*startPatternInfo)[1];
189 if (startPatternInfo) { 189 if (startPatternInfo) {
190 startPatternInfo->RemoveAll(); 190 startPatternInfo->RemoveAll();
191 delete startPatternInfo; 191 delete startPatternInfo;
192 startPatternInfo = NULL; 192 startPatternInfo = nullptr;
193 } 193 }
194 CFX_Int32Array counters; 194 CFX_Int32Array counters;
195 counters.SetSize(6); 195 counters.SetSize(6);
196 int32_t lastCode = 0; 196 int32_t lastCode = 0;
197 int32_t code = 0; 197 int32_t code = 0;
198 int32_t checksumTotal = startCode; 198 int32_t checksumTotal = startCode;
199 int32_t multiplier = 0; 199 int32_t multiplier = 0;
200 FX_BOOL lastCharacterWasPrintable = TRUE; 200 FX_BOOL lastCharacterWasPrintable = TRUE;
201 while (!done) { 201 while (!done) {
202 FX_BOOL unshift = isNextShifted; 202 FX_BOOL unshift = isNextShifted;
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 } else { 340 } else {
341 result = result.Mid(0, result.GetLength() - 1); 341 result = result.Mid(0, result.GetLength() - 1);
342 } 342 }
343 } 343 }
344 if (result.GetLength() == 0) { 344 if (result.GetLength() == 0) {
345 e = BCExceptionFormatException; 345 e = BCExceptionFormatException;
346 return ""; 346 return "";
347 } 347 }
348 return result; 348 return result;
349 } 349 }
OLDNEW
« no previous file with comments | « xfa/fxbarcode/oned/BC_OnedCodaBarWriter.cpp ('k') | xfa/fxbarcode/oned/BC_OnedCode128Writer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698