74 CBC_CommonByteMatrix* matrix) {
76 pdfium::span<
const uint8_t> array = matrix->GetArray();
77 size_t width = matrix->GetWidth();
78 size_t height = matrix->GetHeight();
79 for (size_t y = 0; y + 1 < height; y++) {
80 for (size_t x = 0; x + 1 < width; x++) {
81 int32_t value = array[y * width + x];
82 if (value == array[y * width + x + 1] &&
83 value == array[(y + 1) * width + x] &&
84 value == array[(y + 1) * width + x + 1]) {
94 CBC_CommonByteMatrix* matrix) {
96 pdfium::span<
const uint8_t> array = matrix->GetArray();
97 size_t width = matrix->GetWidth();
98 size_t height = matrix->GetHeight();
99 for (size_t y = 0; y < height; ++y) {
100 for (size_t x = 0; x < width; ++x) {
101 if (x == 0 && (y <= 6 || (y + 7 >= height && y + 1 <= height))) {
104 if (x + 7 == width && y <= 6) {
107 if (y == 0 && (x <= 6 || (x + 7 >= width && x + 1 <= width))) {
110 if (y + 7 == height && x <= 6) {
113 if (x + 6 < width && array[y * width + x] == 1 &&
114 array[y * width + x + 1] == 0 && array[y * width + x + 2] == 1 &&
115 array[y * width + x + 3] == 1 && array[y * width + x + 4] == 1 &&
116 array[y * width + x + 5] == 0 && array[y * width + x + 6] == 1 &&
117 ((x + 10 < width && array[y * width + x + 7] == 0 &&
118 array[y * width + x + 8] == 0 && array[y * width + x + 9] == 0 &&
119 array[y * width + x + 10] == 0) ||
120 (x >= 4 && array[y * width + x - 1] == 0 &&
121 array[y * width + x - 2] == 0 && array[y * width + x - 3] == 0 &&
122 array[y * width + x - 4] == 0))) {
125 if (y + 6 < height && array[y * width + x] == 1 &&
126 array[(y + 1) * width + x] == 0 && array[(y + 2) * width + x] == 1 &&
127 array[(y + 3) * width + x] == 1 && array[(y + 4) * width + x] == 1 &&
128 array[(y + 5) * width + x] == 0 && array[(y + 6) * width + x] == 1 &&
129 ((y + 10 < height && array[(y + 7) * width + x] == 0 &&
130 array[(y + 8) * width + x] == 0 &&
131 array[(y + 9) * width + x] == 0 &&
132 array[(y + 10) * width + x] == 0) ||
133 (y >= 4 && array[(y - 1) * width + x] == 0 &&
134 array[(y - 2) * width + x] == 0 &&
135 array[(y - 3) * width + x] == 0 &&
136 array[(y - 4) * width + x] == 0))) {
146 CBC_CommonByteMatrix* matrix) {
147 int32_t numDarkCells = 0;
148 pdfium::span<
const uint8_t> array = matrix->GetArray();
149 size_t width = matrix->GetWidth();
150 size_t height = matrix->GetHeight();
151 for (size_t y = 0; y < height; ++y) {
152 for (size_t x = 0; x < width; ++x) {
153 if (array[y * width + x] == 1)
157 size_t numTotalCells = matrix->GetHeight() * matrix->GetWidth();
158 double darkRatio =
static_cast<
double>(numDarkCells) / numTotalCells;
159 return abs(
static_cast<int32_t>(darkRatio * 100 - 50) / 5) * 5 * 10;
166 DCHECK(CBC_QRCoder::IsValidMaskPattern(maskPattern));
168 int32_t intermediate = 0;
170 switch (maskPattern) {
172 intermediate = (y + x) & 0x1;
175 intermediate = y & 0x1;
178 intermediate = x % 3;
181 intermediate = (y + x) % 3;
184 intermediate = ((y >> 1) + (x / 3)) & 0x1;
188 intermediate = (temp & 0x1) + (temp % 3);
192 intermediate = (((temp & 0x1) + (temp % 3)) & 0x1);
196 intermediate = (((temp % 3) + ((y + x) & 0x1)) & 0x1);
199 NOTREACHED_NORETURN();
201 return intermediate == 0;