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

Side by Side Diff: xfa/src/fxbarcode/pdf417/BC_PDF417ScanningDecoder.cpp

Issue 1726373002: Remove foo != NULL checks in xfa/src/fxbarcode. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: rebase Created 4 years, 10 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 2013 ZXing authors 8 * Copyright 2013 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 int32_t minCodewordWidth, 63 int32_t minCodewordWidth,
64 int32_t maxCodewordWidth, 64 int32_t maxCodewordWidth,
65 int32_t& e) { 65 int32_t& e) {
66 CBC_BoundingBox* boundingBox = new CBC_BoundingBox( 66 CBC_BoundingBox* boundingBox = new CBC_BoundingBox(
67 image, imageTopLeft, imageBottomLeft, imageTopRight, imageBottomRight, e); 67 image, imageTopLeft, imageBottomLeft, imageTopRight, imageBottomRight, e);
68 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 68 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
69 CBC_DetectionResultRowIndicatorColumn* leftRowIndicatorColumn = NULL; 69 CBC_DetectionResultRowIndicatorColumn* leftRowIndicatorColumn = NULL;
70 CBC_DetectionResultRowIndicatorColumn* rightRowIndicatorColumn = NULL; 70 CBC_DetectionResultRowIndicatorColumn* rightRowIndicatorColumn = NULL;
71 CBC_DetectionResult* detectionResult = NULL; 71 CBC_DetectionResult* detectionResult = NULL;
72 for (int32_t i = 0; i < 2; i++) { 72 for (int32_t i = 0; i < 2; i++) {
73 if (imageTopLeft != NULL) { 73 if (imageTopLeft) {
74 leftRowIndicatorColumn = 74 leftRowIndicatorColumn =
75 getRowIndicatorColumn(image, boundingBox, *imageTopLeft, TRUE, 75 getRowIndicatorColumn(image, boundingBox, *imageTopLeft, TRUE,
76 minCodewordWidth, maxCodewordWidth); 76 minCodewordWidth, maxCodewordWidth);
77 } 77 }
78 if (imageTopRight != NULL) { 78 if (imageTopRight) {
79 rightRowIndicatorColumn = 79 rightRowIndicatorColumn =
80 getRowIndicatorColumn(image, boundingBox, *imageTopRight, FALSE, 80 getRowIndicatorColumn(image, boundingBox, *imageTopRight, FALSE,
81 minCodewordWidth, maxCodewordWidth); 81 minCodewordWidth, maxCodewordWidth);
82 } 82 }
83 detectionResult = merge(leftRowIndicatorColumn, rightRowIndicatorColumn, e); 83 detectionResult = merge(leftRowIndicatorColumn, rightRowIndicatorColumn, e);
84 if (e != BCExceptionNO) { 84 if (e != BCExceptionNO) {
85 e = BCExceptiontNotFoundInstance; 85 e = BCExceptiontNotFoundInstance;
86 delete leftRowIndicatorColumn; 86 delete leftRowIndicatorColumn;
87 delete rightRowIndicatorColumn; 87 delete rightRowIndicatorColumn;
88 delete boundingBox; 88 delete boundingBox;
(...skipping 12 matching lines...) Expand all
101 } 101 }
102 int32_t maxBarcodeColumn = detectionResult->getBarcodeColumnCount() + 1; 102 int32_t maxBarcodeColumn = detectionResult->getBarcodeColumnCount() + 1;
103 detectionResult->setDetectionResultColumn(0, leftRowIndicatorColumn); 103 detectionResult->setDetectionResultColumn(0, leftRowIndicatorColumn);
104 detectionResult->setDetectionResultColumn(maxBarcodeColumn, 104 detectionResult->setDetectionResultColumn(maxBarcodeColumn,
105 rightRowIndicatorColumn); 105 rightRowIndicatorColumn);
106 FX_BOOL leftToRight = leftRowIndicatorColumn != NULL; 106 FX_BOOL leftToRight = leftRowIndicatorColumn != NULL;
107 for (int32_t barcodeColumnCount = 1; barcodeColumnCount <= maxBarcodeColumn; 107 for (int32_t barcodeColumnCount = 1; barcodeColumnCount <= maxBarcodeColumn;
108 barcodeColumnCount++) { 108 barcodeColumnCount++) {
109 int32_t barcodeColumn = leftToRight ? barcodeColumnCount 109 int32_t barcodeColumn = leftToRight ? barcodeColumnCount
110 : maxBarcodeColumn - barcodeColumnCount; 110 : maxBarcodeColumn - barcodeColumnCount;
111 if (detectionResult->getDetectionResultColumn(barcodeColumn) != NULL) { 111 if (detectionResult->getDetectionResultColumn(barcodeColumn)) {
112 continue; 112 continue;
113 } 113 }
114 CBC_DetectionResultColumn* detectionResultColumn = NULL; 114 CBC_DetectionResultColumn* detectionResultColumn = NULL;
115 if (barcodeColumn == 0 || barcodeColumn == maxBarcodeColumn) { 115 if (barcodeColumn == 0 || barcodeColumn == maxBarcodeColumn) {
116 detectionResultColumn = new CBC_DetectionResultRowIndicatorColumn( 116 detectionResultColumn = new CBC_DetectionResultRowIndicatorColumn(
117 boundingBox, barcodeColumn == 0); 117 boundingBox, barcodeColumn == 0);
118 } else { 118 } else {
119 detectionResultColumn = new CBC_DetectionResultColumn(boundingBox); 119 detectionResultColumn = new CBC_DetectionResultColumn(boundingBox);
120 } 120 }
121 detectionResult->setDetectionResultColumn(barcodeColumn, 121 detectionResult->setDetectionResultColumn(barcodeColumn,
122 detectionResultColumn); 122 detectionResultColumn);
123 int32_t startColumn = -1; 123 int32_t startColumn = -1;
124 int32_t previousStartColumn = startColumn; 124 int32_t previousStartColumn = startColumn;
125 for (int32_t imageRow = boundingBox->getMinY(); 125 for (int32_t imageRow = boundingBox->getMinY();
126 imageRow <= boundingBox->getMaxY(); imageRow++) { 126 imageRow <= boundingBox->getMaxY(); imageRow++) {
127 startColumn = 127 startColumn =
128 getStartColumn(detectionResult, barcodeColumn, imageRow, leftToRight); 128 getStartColumn(detectionResult, barcodeColumn, imageRow, leftToRight);
129 if (startColumn < 0 || startColumn > boundingBox->getMaxX()) { 129 if (startColumn < 0 || startColumn > boundingBox->getMaxX()) {
130 if (previousStartColumn == -1) { 130 if (previousStartColumn == -1) {
131 continue; 131 continue;
132 } 132 }
133 startColumn = previousStartColumn; 133 startColumn = previousStartColumn;
134 } 134 }
135 CBC_Codeword* codeword = detectCodeword( 135 CBC_Codeword* codeword = detectCodeword(
136 image, boundingBox->getMinX(), boundingBox->getMaxX(), leftToRight, 136 image, boundingBox->getMinX(), boundingBox->getMaxX(), leftToRight,
137 startColumn, imageRow, minCodewordWidth, maxCodewordWidth); 137 startColumn, imageRow, minCodewordWidth, maxCodewordWidth);
138 if (codeword != NULL) { 138 if (codeword) {
139 detectionResultColumn->setCodeword(imageRow, codeword); 139 detectionResultColumn->setCodeword(imageRow, codeword);
140 previousStartColumn = startColumn; 140 previousStartColumn = startColumn;
141 minCodewordWidth = minCodewordWidth < codeword->getWidth() 141 minCodewordWidth = minCodewordWidth < codeword->getWidth()
142 ? minCodewordWidth 142 ? minCodewordWidth
143 : codeword->getWidth(); 143 : codeword->getWidth();
144 maxCodewordWidth = maxCodewordWidth > codeword->getWidth() 144 maxCodewordWidth = maxCodewordWidth > codeword->getWidth()
145 ? maxCodewordWidth 145 ? maxCodewordWidth
146 : codeword->getWidth(); 146 : codeword->getWidth();
147 } 147 }
148 } 148 }
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 for (int32_t i = 0; i < 2; i++) { 303 for (int32_t i = 0; i < 2; i++) {
304 int32_t increment = i == 0 ? 1 : -1; 304 int32_t increment = i == 0 ? 1 : -1;
305 int32_t startColumn = (int32_t)startPoint.GetX(); 305 int32_t startColumn = (int32_t)startPoint.GetX();
306 for (int32_t imageRow = (int32_t)startPoint.GetY(); 306 for (int32_t imageRow = (int32_t)startPoint.GetY();
307 imageRow <= boundingBox->getMaxY() && 307 imageRow <= boundingBox->getMaxY() &&
308 imageRow >= boundingBox->getMinY(); 308 imageRow >= boundingBox->getMinY();
309 imageRow += increment) { 309 imageRow += increment) {
310 CBC_Codeword* codeword = 310 CBC_Codeword* codeword =
311 detectCodeword(image, 0, image->GetWidth(), leftToRight, startColumn, 311 detectCodeword(image, 0, image->GetWidth(), leftToRight, startColumn,
312 imageRow, minCodewordWidth, maxCodewordWidth); 312 imageRow, minCodewordWidth, maxCodewordWidth);
313 if (codeword != NULL) { 313 if (codeword) {
314 rowIndicatorColumn->setCodeword(imageRow, codeword); 314 rowIndicatorColumn->setCodeword(imageRow, codeword);
315 if (leftToRight) { 315 if (leftToRight) {
316 startColumn = codeword->getStartX(); 316 startColumn = codeword->getStartX();
317 } else { 317 } else {
318 startColumn = codeword->getEndX(); 318 startColumn = codeword->getEndX();
319 } 319 }
320 } 320 }
321 } 321 }
322 } 322 }
323 return rowIndicatorColumn; 323 return rowIndicatorColumn;
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 CBC_DetectionResult* detectionResult, 508 CBC_DetectionResult* detectionResult,
509 int32_t barcodeColumn, 509 int32_t barcodeColumn,
510 int32_t imageRow, 510 int32_t imageRow,
511 FX_BOOL leftToRight) { 511 FX_BOOL leftToRight) {
512 int32_t offset = leftToRight ? 1 : -1; 512 int32_t offset = leftToRight ? 1 : -1;
513 CBC_Codeword* codeword = NULL; 513 CBC_Codeword* codeword = NULL;
514 if (isValidBarcodeColumn(detectionResult, barcodeColumn - offset)) { 514 if (isValidBarcodeColumn(detectionResult, barcodeColumn - offset)) {
515 codeword = detectionResult->getDetectionResultColumn(barcodeColumn - offset) 515 codeword = detectionResult->getDetectionResultColumn(barcodeColumn - offset)
516 ->getCodeword(imageRow); 516 ->getCodeword(imageRow);
517 } 517 }
518 if (codeword != NULL) { 518 if (codeword) {
519 return leftToRight ? codeword->getEndX() : codeword->getStartX(); 519 return leftToRight ? codeword->getEndX() : codeword->getStartX();
520 } 520 }
521 codeword = detectionResult->getDetectionResultColumn(barcodeColumn) 521 codeword = detectionResult->getDetectionResultColumn(barcodeColumn)
522 ->getCodewordNearby(imageRow); 522 ->getCodewordNearby(imageRow);
523 if (codeword != NULL) { 523 if (codeword) {
524 return leftToRight ? codeword->getStartX() : codeword->getEndX(); 524 return leftToRight ? codeword->getStartX() : codeword->getEndX();
525 } 525 }
526 if (isValidBarcodeColumn(detectionResult, barcodeColumn - offset)) { 526 if (isValidBarcodeColumn(detectionResult, barcodeColumn - offset)) {
527 codeword = detectionResult->getDetectionResultColumn(barcodeColumn - offset) 527 codeword = detectionResult->getDetectionResultColumn(barcodeColumn - offset)
528 ->getCodewordNearby(imageRow); 528 ->getCodewordNearby(imageRow);
529 } 529 }
530 if (codeword != NULL) { 530 if (codeword) {
531 return leftToRight ? codeword->getEndX() : codeword->getStartX(); 531 return leftToRight ? codeword->getEndX() : codeword->getStartX();
532 } 532 }
533 int32_t skippedColumns = 0; 533 int32_t skippedColumns = 0;
534 while (isValidBarcodeColumn(detectionResult, barcodeColumn - offset)) { 534 while (isValidBarcodeColumn(detectionResult, barcodeColumn - offset)) {
535 barcodeColumn -= offset; 535 barcodeColumn -= offset;
536 for (int32_t i = 0; 536 for (int32_t i = 0;
537 i < detectionResult->getDetectionResultColumn(barcodeColumn) 537 i < detectionResult->getDetectionResultColumn(barcodeColumn)
538 ->getCodewords() 538 ->getCodewords()
539 ->GetSize(); 539 ->GetSize();
540 i++) { 540 i++) {
541 CBC_Codeword* previousRowCodeword = 541 CBC_Codeword* previousRowCodeword =
542 (CBC_Codeword*)detectionResult->getDetectionResultColumn( 542 (CBC_Codeword*)detectionResult->getDetectionResultColumn(
543 barcodeColumn) 543 barcodeColumn)
544 ->getCodewords() 544 ->getCodewords()
545 ->GetAt(i); 545 ->GetAt(i);
546 if (previousRowCodeword != NULL) { 546 if (previousRowCodeword) {
547 return (leftToRight ? previousRowCodeword->getEndX() 547 return (leftToRight ? previousRowCodeword->getEndX()
548 : previousRowCodeword->getStartX()) + 548 : previousRowCodeword->getStartX()) +
549 offset * skippedColumns * (previousRowCodeword->getEndX() - 549 offset * skippedColumns * (previousRowCodeword->getEndX() -
550 previousRowCodeword->getStartX()); 550 previousRowCodeword->getStartX());
551 } 551 }
552 } 552 }
553 skippedColumns++; 553 skippedColumns++;
554 } 554 }
555 return leftToRight ? detectionResult->getBoundingBox()->getMinX() 555 return leftToRight ? detectionResult->getBoundingBox()->getMinX()
556 : detectionResult->getBoundingBox()->getMaxX(); 556 : detectionResult->getBoundingBox()->getMaxX();
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 int32_t result = getCodewordBucketNumber(*array); 743 int32_t result = getCodewordBucketNumber(*array);
744 delete array; 744 delete array;
745 return result; 745 return result;
746 } 746 }
747 int32_t CBC_PDF417ScanningDecoder::getCodewordBucketNumber( 747 int32_t CBC_PDF417ScanningDecoder::getCodewordBucketNumber(
748 CFX_Int32Array& moduleBitCount) { 748 CFX_Int32Array& moduleBitCount) {
749 return (moduleBitCount.GetAt(0) - moduleBitCount.GetAt(2) + 749 return (moduleBitCount.GetAt(0) - moduleBitCount.GetAt(2) +
750 moduleBitCount.GetAt(4) - moduleBitCount.GetAt(6) + 9) % 750 moduleBitCount.GetAt(4) - moduleBitCount.GetAt(6) + 9) %
751 9; 751 9;
752 } 752 }
OLDNEW
« no previous file with comments | « xfa/src/fxbarcode/pdf417/BC_PDF417Detector.cpp ('k') | xfa/src/fxbarcode/qrcode/BC_QRAlignmentPatternFinder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698