| 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 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 int32_t unadjustedCount = adjustRowNumbersByRow(); | 115 int32_t unadjustedCount = adjustRowNumbersByRow(); |
| 116 if (unadjustedCount == 0) { | 116 if (unadjustedCount == 0) { |
| 117 return 0; | 117 return 0; |
| 118 } | 118 } |
| 119 for (int32_t barcodeColumn = 1; barcodeColumn < m_barcodeColumnCount + 1; | 119 for (int32_t barcodeColumn = 1; barcodeColumn < m_barcodeColumnCount + 1; |
| 120 barcodeColumn++) { | 120 barcodeColumn++) { |
| 121 CFX_ArrayTemplate<CBC_Codeword*>* codewords = | 121 CFX_ArrayTemplate<CBC_Codeword*>* codewords = |
| 122 m_detectionResultColumns[barcodeColumn]->getCodewords(); | 122 m_detectionResultColumns[barcodeColumn]->getCodewords(); |
| 123 for (int32_t codewordsRow = 0; codewordsRow < codewords->GetSize(); | 123 for (int32_t codewordsRow = 0; codewordsRow < codewords->GetSize(); |
| 124 codewordsRow++) { | 124 codewordsRow++) { |
| 125 if (codewords->GetAt(codewordsRow) == NULL) { | 125 if (!codewords->GetAt(codewordsRow)) |
| 126 continue; | 126 continue; |
| 127 } | 127 |
| 128 if (!codewords->GetAt(codewordsRow)->hasValidRowNumber()) { | 128 if (!codewords->GetAt(codewordsRow)->hasValidRowNumber()) { |
| 129 adjustRowNumbers(barcodeColumn, codewordsRow, codewords); | 129 adjustRowNumbers(barcodeColumn, codewordsRow, codewords); |
| 130 } | 130 } |
| 131 } | 131 } |
| 132 } | 132 } |
| 133 return unadjustedCount; | 133 return unadjustedCount; |
| 134 } | 134 } |
| 135 int32_t CBC_DetectionResult::adjustRowNumbersByRow() { | 135 int32_t CBC_DetectionResult::adjustRowNumbersByRow() { |
| 136 adjustRowNumbersFromBothRI(); | 136 adjustRowNumbersFromBothRI(); |
| 137 int32_t unadjustedCount = adjustRowNumbersFromLRI(); | 137 int32_t unadjustedCount = adjustRowNumbersFromLRI(); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 } | 173 } |
| 174 int32_t CBC_DetectionResult::adjustRowNumbersFromRRI() { | 174 int32_t CBC_DetectionResult::adjustRowNumbersFromRRI() { |
| 175 if (!m_detectionResultColumns[m_barcodeColumnCount + 1]) { | 175 if (!m_detectionResultColumns[m_barcodeColumnCount + 1]) { |
| 176 return 0; | 176 return 0; |
| 177 } | 177 } |
| 178 int32_t unadjustedCount = 0; | 178 int32_t unadjustedCount = 0; |
| 179 CFX_ArrayTemplate<CBC_Codeword*>* codewords = | 179 CFX_ArrayTemplate<CBC_Codeword*>* codewords = |
| 180 m_detectionResultColumns.GetAt(m_barcodeColumnCount + 1)->getCodewords(); | 180 m_detectionResultColumns.GetAt(m_barcodeColumnCount + 1)->getCodewords(); |
| 181 for (int32_t codewordsRow = 0; codewordsRow < codewords->GetSize(); | 181 for (int32_t codewordsRow = 0; codewordsRow < codewords->GetSize(); |
| 182 codewordsRow++) { | 182 codewordsRow++) { |
| 183 if (codewords->GetAt(codewordsRow) == NULL) { | 183 if (!codewords->GetAt(codewordsRow)) |
| 184 continue; | 184 continue; |
| 185 } | 185 |
| 186 int32_t rowIndicatorRowNumber = | 186 int32_t rowIndicatorRowNumber = |
| 187 codewords->GetAt(codewordsRow)->getRowNumber(); | 187 codewords->GetAt(codewordsRow)->getRowNumber(); |
| 188 int32_t invalidRowCounts = 0; | 188 int32_t invalidRowCounts = 0; |
| 189 for (int32_t barcodeColumn = m_barcodeColumnCount + 1; | 189 for (int32_t barcodeColumn = m_barcodeColumnCount + 1; |
| 190 barcodeColumn > 0 && invalidRowCounts < ADJUST_ROW_NUMBER_SKIP; | 190 barcodeColumn > 0 && invalidRowCounts < ADJUST_ROW_NUMBER_SKIP; |
| 191 barcodeColumn--) { | 191 barcodeColumn--) { |
| 192 CBC_Codeword* codeword = m_detectionResultColumns.GetAt(barcodeColumn) | 192 CBC_Codeword* codeword = m_detectionResultColumns.GetAt(barcodeColumn) |
| 193 ->getCodewords() | 193 ->getCodewords() |
| 194 ->GetAt(codewordsRow); | 194 ->GetAt(codewordsRow); |
| 195 if (codeword) { | 195 if (codeword) { |
| 196 invalidRowCounts = adjustRowNumberIfValid(rowIndicatorRowNumber, | 196 invalidRowCounts = adjustRowNumberIfValid(rowIndicatorRowNumber, |
| 197 invalidRowCounts, codeword); | 197 invalidRowCounts, codeword); |
| 198 if (!codeword->hasValidRowNumber()) { | 198 if (!codeword->hasValidRowNumber()) { |
| 199 unadjustedCount++; | 199 unadjustedCount++; |
| 200 } | 200 } |
| 201 } | 201 } |
| 202 } | 202 } |
| 203 } | 203 } |
| 204 return unadjustedCount; | 204 return unadjustedCount; |
| 205 } | 205 } |
| 206 int32_t CBC_DetectionResult::adjustRowNumbersFromLRI() { | 206 int32_t CBC_DetectionResult::adjustRowNumbersFromLRI() { |
| 207 if (m_detectionResultColumns[0] == NULL) { | 207 if (!m_detectionResultColumns[0]) |
| 208 return 0; | 208 return 0; |
| 209 } | 209 |
| 210 int32_t unadjustedCount = 0; | 210 int32_t unadjustedCount = 0; |
| 211 CFX_ArrayTemplate<CBC_Codeword*>* codewords = | 211 CFX_ArrayTemplate<CBC_Codeword*>* codewords = |
| 212 m_detectionResultColumns.GetAt(0)->getCodewords(); | 212 m_detectionResultColumns.GetAt(0)->getCodewords(); |
| 213 for (int32_t codewordsRow = 0; codewordsRow < codewords->GetSize(); | 213 for (int32_t codewordsRow = 0; codewordsRow < codewords->GetSize(); |
| 214 codewordsRow++) { | 214 codewordsRow++) { |
| 215 if (codewords->GetAt(codewordsRow) == NULL) { | 215 if (!codewords->GetAt(codewordsRow)) |
| 216 continue; | 216 continue; |
| 217 } | 217 |
| 218 int32_t rowIndicatorRowNumber = | 218 int32_t rowIndicatorRowNumber = |
| 219 codewords->GetAt(codewordsRow)->getRowNumber(); | 219 codewords->GetAt(codewordsRow)->getRowNumber(); |
| 220 int32_t invalidRowCounts = 0; | 220 int32_t invalidRowCounts = 0; |
| 221 for (int32_t barcodeColumn = 1; barcodeColumn < m_barcodeColumnCount + 1 && | 221 for (int32_t barcodeColumn = 1; barcodeColumn < m_barcodeColumnCount + 1 && |
| 222 invalidRowCounts < ADJUST_ROW_NUMBER_SKIP; | 222 invalidRowCounts < ADJUST_ROW_NUMBER_SKIP; |
| 223 barcodeColumn++) { | 223 barcodeColumn++) { |
| 224 CBC_Codeword* codeword = | 224 CBC_Codeword* codeword = |
| 225 m_detectionResultColumns[barcodeColumn]->getCodewords()->GetAt( | 225 m_detectionResultColumns[barcodeColumn]->getCodewords()->GetAt( |
| 226 codewordsRow); | 226 codewordsRow); |
| 227 if (codeword) { | 227 if (codeword) { |
| 228 invalidRowCounts = adjustRowNumberIfValid(rowIndicatorRowNumber, | 228 invalidRowCounts = adjustRowNumberIfValid(rowIndicatorRowNumber, |
| 229 invalidRowCounts, codeword); | 229 invalidRowCounts, codeword); |
| 230 if (!codeword->hasValidRowNumber()) { | 230 if (!codeword->hasValidRowNumber()) { |
| 231 unadjustedCount++; | 231 unadjustedCount++; |
| 232 } | 232 } |
| 233 } | 233 } |
| 234 } | 234 } |
| 235 } | 235 } |
| 236 return unadjustedCount; | 236 return unadjustedCount; |
| 237 } | 237 } |
| 238 int32_t CBC_DetectionResult::adjustRowNumberIfValid( | 238 int32_t CBC_DetectionResult::adjustRowNumberIfValid( |
| 239 int32_t rowIndicatorRowNumber, | 239 int32_t rowIndicatorRowNumber, |
| 240 int32_t invalidRowCounts, | 240 int32_t invalidRowCounts, |
| 241 CBC_Codeword* codeword) { | 241 CBC_Codeword* codeword) { |
| 242 if (codeword == NULL) { | 242 if (!codeword) |
| 243 return invalidRowCounts; | 243 return invalidRowCounts; |
| 244 } | 244 |
| 245 if (!codeword->hasValidRowNumber()) { | 245 if (!codeword->hasValidRowNumber()) { |
| 246 if (codeword->isValidRowNumber(rowIndicatorRowNumber)) { | 246 if (codeword->isValidRowNumber(rowIndicatorRowNumber)) { |
| 247 codeword->setRowNumber(rowIndicatorRowNumber); | 247 codeword->setRowNumber(rowIndicatorRowNumber); |
| 248 invalidRowCounts = 0; | 248 invalidRowCounts = 0; |
| 249 } else { | 249 } else { |
| 250 ++invalidRowCounts; | 250 ++invalidRowCounts; |
| 251 } | 251 } |
| 252 } | 252 } |
| 253 return invalidRowCounts; | 253 return invalidRowCounts; |
| 254 } | 254 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 } | 291 } |
| 292 for (int32_t i = 0; i < otherCodewords.GetSize(); i++) { | 292 for (int32_t i = 0; i < otherCodewords.GetSize(); i++) { |
| 293 CBC_Codeword* otherCodeword = otherCodewords.GetAt(i); | 293 CBC_Codeword* otherCodeword = otherCodewords.GetAt(i); |
| 294 if (adjustRowNumber(codeword, otherCodeword)) { | 294 if (adjustRowNumber(codeword, otherCodeword)) { |
| 295 return; | 295 return; |
| 296 } | 296 } |
| 297 } | 297 } |
| 298 } | 298 } |
| 299 FX_BOOL CBC_DetectionResult::adjustRowNumber(CBC_Codeword* codeword, | 299 FX_BOOL CBC_DetectionResult::adjustRowNumber(CBC_Codeword* codeword, |
| 300 CBC_Codeword* otherCodeword) { | 300 CBC_Codeword* otherCodeword) { |
| 301 if (otherCodeword == NULL) { | 301 if (!otherCodeword) |
| 302 return FALSE; | 302 return FALSE; |
| 303 } | 303 |
| 304 if (otherCodeword->hasValidRowNumber() && | 304 if (otherCodeword->hasValidRowNumber() && |
| 305 otherCodeword->getBucket() == codeword->getBucket()) { | 305 otherCodeword->getBucket() == codeword->getBucket()) { |
| 306 codeword->setRowNumber(otherCodeword->getRowNumber()); | 306 codeword->setRowNumber(otherCodeword->getRowNumber()); |
| 307 return TRUE; | 307 return TRUE; |
| 308 } | 308 } |
| 309 return FALSE; | 309 return FALSE; |
| 310 } | 310 } |
| 311 int32_t CBC_DetectionResult::getBarcodeColumnCount() { | 311 int32_t CBC_DetectionResult::getBarcodeColumnCount() { |
| 312 return m_barcodeColumnCount; | 312 return m_barcodeColumnCount; |
| 313 } | 313 } |
| 314 int32_t CBC_DetectionResult::getBarcodeRowCount() { | 314 int32_t CBC_DetectionResult::getBarcodeRowCount() { |
| 315 return m_barcodeMetadata->getRowCount(); | 315 return m_barcodeMetadata->getRowCount(); |
| 316 } | 316 } |
| 317 int32_t CBC_DetectionResult::getBarcodeECLevel() { | 317 int32_t CBC_DetectionResult::getBarcodeECLevel() { |
| 318 return m_barcodeMetadata->getErrorCorrectionLevel(); | 318 return m_barcodeMetadata->getErrorCorrectionLevel(); |
| 319 } | 319 } |
| OLD | NEW |