File: ba3b61feb918a2371b2a991e759bde7c380b6a23.patch

package info (click to toggle)
zxing-cpp 2.3.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 26,832 kB
  • sloc: cpp: 32,803; ansic: 18,360; php: 1,156; python: 215; makefile: 25; sh: 3
file content (61 lines) | stat: -rw-r--r-- 2,609 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
From ba3b61feb918a2371b2a991e759bde7c380b6a23 Mon Sep 17 00:00:00 2001
From: axxel <awagger@gmail.com>
Date: Thu, 24 Apr 2025 03:21:16 +0200
Subject: [PATCH] QRCode: fix decoding of Model 1 symbols with more than 1 data
 block

This is a fix for #940.

Modified in Debian to remove test file changes.
---
 core/src/qrcode/QRDataBlock.cpp      |  29 ++++++++++++++++++++-------
 4 files changed, 29 insertions(+), 13 deletions(-)

diff --git a/core/src/qrcode/QRDataBlock.cpp b/core/src/qrcode/QRDataBlock.cpp
index cedd8a303a..e38307328f 100644
--- a/core/src/qrcode/QRDataBlock.cpp
+++ b/core/src/qrcode/QRDataBlock.cpp
@@ -54,10 +54,16 @@ std::vector<DataBlock> DataBlock::GetDataBlocks(const ByteArray& rawCodewords, c
 	// The last elements of result may be 1 element longer;
 	// first fill out as many elements as all of them have
 	int rawCodewordsOffset = 0;
-	for (int i = 0; i < shorterBlocksNumDataCodewords; i++) {
-		for (int j = 0; j < numResultBlocks; j++) {
-			result[j]._codewords[i] = rawCodewords[rawCodewordsOffset++];
-		}
+	if (version.isModel1()) {
+		// in Model 1 symbols the data blocks are concatenated back to back
+		for (int j = 0; j < numResultBlocks; j++)
+			for (int i = 0; i < shorterBlocksNumDataCodewords; i++)
+				result[j]._codewords[i] = rawCodewords[rawCodewordsOffset++];
+	} else {
+		// in all others, the data blocks are interleaved
+		for (int i = 0; i < shorterBlocksNumDataCodewords; i++)
+			for (int j = 0; j < numResultBlocks; j++)
+				result[j]._codewords[i] = rawCodewords[rawCodewordsOffset++];
 	}
 	// Fill out the last data block in the longer ones
 	for (int j = longerBlocksStartAt; j < numResultBlocks; j++) {
@@ -65,10 +71,19 @@ std::vector<DataBlock> DataBlock::GetDataBlocks(const ByteArray& rawCodewords, c
 	}
 	// Now add in error correction blocks
 	int max = Size(result[0]._codewords);
-	for (int i = shorterBlocksNumDataCodewords; i < max; i++) {
+	if (version.isModel1()) {
 		for (int j = 0; j < numResultBlocks; j++) {
-			int iOffset = j < longerBlocksStartAt ? i : i + 1;
-			result[j]._codewords[iOffset] = rawCodewords[rawCodewordsOffset++];
+			for (int i = shorterBlocksNumDataCodewords; i < max; i++) {
+				int iOffset = j < longerBlocksStartAt ? i : i + 1;
+				result[j]._codewords[iOffset] = rawCodewords[rawCodewordsOffset++];
+			}
+		}
+	} else {
+		for (int i = shorterBlocksNumDataCodewords; i < max; i++) {
+			for (int j = 0; j < numResultBlocks; j++) {
+				int iOffset = j < longerBlocksStartAt ? i : i + 1;
+				result[j]._codewords[iOffset] = rawCodewords[rawCodewordsOffset++];
+			}
 		}
 	}
 	return result;