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 2006 Jeremias Maerki | 8 * Copyright 2006 Jeremias Maerki |
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 23 matching lines...) Expand all Loading... |
34 | 34 |
35 CBC_SymbolInfo* g_symbols[kSymbolsCount] = { | 35 CBC_SymbolInfo* g_symbols[kSymbolsCount] = { |
36 nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, | 36 nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, |
37 nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, | 37 nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, |
38 nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, | 38 nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, |
39 nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}; | 39 nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}; |
40 | 40 |
41 } // namespace | 41 } // namespace |
42 | 42 |
43 void CBC_SymbolInfo::Initialize() { | 43 void CBC_SymbolInfo::Initialize() { |
44 g_symbols[0] = new CBC_SymbolInfo(FALSE, 3, 5, 8, 8, 1); | 44 g_symbols[0] = new CBC_SymbolInfo(false, 3, 5, 8, 8, 1); |
45 g_symbols[1] = new CBC_SymbolInfo(FALSE, 5, 7, 10, 10, 1); | 45 g_symbols[1] = new CBC_SymbolInfo(false, 5, 7, 10, 10, 1); |
46 g_symbols[2] = new CBC_SymbolInfo(TRUE, 5, 7, 16, 6, 1); | 46 g_symbols[2] = new CBC_SymbolInfo(true, 5, 7, 16, 6, 1); |
47 g_symbols[3] = new CBC_SymbolInfo(FALSE, 8, 10, 12, 12, 1); | 47 g_symbols[3] = new CBC_SymbolInfo(false, 8, 10, 12, 12, 1); |
48 g_symbols[4] = new CBC_SymbolInfo(TRUE, 10, 11, 14, 6, 2); | 48 g_symbols[4] = new CBC_SymbolInfo(true, 10, 11, 14, 6, 2); |
49 g_symbols[5] = new CBC_SymbolInfo(FALSE, 12, 12, 14, 14, 1); | 49 g_symbols[5] = new CBC_SymbolInfo(false, 12, 12, 14, 14, 1); |
50 g_symbols[6] = new CBC_SymbolInfo(TRUE, 16, 14, 24, 10, 1); | 50 g_symbols[6] = new CBC_SymbolInfo(true, 16, 14, 24, 10, 1); |
51 g_symbols[7] = new CBC_SymbolInfo(FALSE, 18, 14, 16, 16, 1); | 51 g_symbols[7] = new CBC_SymbolInfo(false, 18, 14, 16, 16, 1); |
52 g_symbols[8] = new CBC_SymbolInfo(FALSE, 22, 18, 18, 18, 1); | 52 g_symbols[8] = new CBC_SymbolInfo(false, 22, 18, 18, 18, 1); |
53 g_symbols[9] = new CBC_SymbolInfo(TRUE, 22, 18, 16, 10, 2); | 53 g_symbols[9] = new CBC_SymbolInfo(true, 22, 18, 16, 10, 2); |
54 g_symbols[10] = new CBC_SymbolInfo(FALSE, 30, 20, 20, 20, 1); | 54 g_symbols[10] = new CBC_SymbolInfo(false, 30, 20, 20, 20, 1); |
55 g_symbols[11] = new CBC_SymbolInfo(TRUE, 32, 24, 16, 14, 2); | 55 g_symbols[11] = new CBC_SymbolInfo(true, 32, 24, 16, 14, 2); |
56 g_symbols[12] = new CBC_SymbolInfo(FALSE, 36, 24, 22, 22, 1); | 56 g_symbols[12] = new CBC_SymbolInfo(false, 36, 24, 22, 22, 1); |
57 g_symbols[13] = new CBC_SymbolInfo(FALSE, 44, 28, 24, 24, 1); | 57 g_symbols[13] = new CBC_SymbolInfo(false, 44, 28, 24, 24, 1); |
58 g_symbols[14] = new CBC_SymbolInfo(TRUE, 49, 28, 22, 14, 2); | 58 g_symbols[14] = new CBC_SymbolInfo(true, 49, 28, 22, 14, 2); |
59 g_symbols[15] = new CBC_SymbolInfo(FALSE, 62, 36, 14, 14, 4); | 59 g_symbols[15] = new CBC_SymbolInfo(false, 62, 36, 14, 14, 4); |
60 g_symbols[16] = new CBC_SymbolInfo(FALSE, 86, 42, 16, 16, 4); | 60 g_symbols[16] = new CBC_SymbolInfo(false, 86, 42, 16, 16, 4); |
61 g_symbols[17] = new CBC_SymbolInfo(FALSE, 114, 48, 18, 18, 4); | 61 g_symbols[17] = new CBC_SymbolInfo(false, 114, 48, 18, 18, 4); |
62 g_symbols[18] = new CBC_SymbolInfo(FALSE, 144, 56, 20, 20, 4); | 62 g_symbols[18] = new CBC_SymbolInfo(false, 144, 56, 20, 20, 4); |
63 g_symbols[19] = new CBC_SymbolInfo(FALSE, 174, 68, 22, 22, 4); | 63 g_symbols[19] = new CBC_SymbolInfo(false, 174, 68, 22, 22, 4); |
64 g_symbols[20] = new CBC_SymbolInfo(FALSE, 204, 84, 24, 24, 4, 102, 42); | 64 g_symbols[20] = new CBC_SymbolInfo(false, 204, 84, 24, 24, 4, 102, 42); |
65 g_symbols[21] = new CBC_SymbolInfo(FALSE, 280, 112, 14, 14, 16, 140, 56); | 65 g_symbols[21] = new CBC_SymbolInfo(false, 280, 112, 14, 14, 16, 140, 56); |
66 g_symbols[22] = new CBC_SymbolInfo(FALSE, 368, 144, 16, 16, 16, 92, 36); | 66 g_symbols[22] = new CBC_SymbolInfo(false, 368, 144, 16, 16, 16, 92, 36); |
67 g_symbols[23] = new CBC_SymbolInfo(FALSE, 456, 192, 18, 18, 16, 114, 48); | 67 g_symbols[23] = new CBC_SymbolInfo(false, 456, 192, 18, 18, 16, 114, 48); |
68 g_symbols[24] = new CBC_SymbolInfo(FALSE, 576, 224, 20, 20, 16, 144, 56); | 68 g_symbols[24] = new CBC_SymbolInfo(false, 576, 224, 20, 20, 16, 144, 56); |
69 g_symbols[25] = new CBC_SymbolInfo(FALSE, 696, 272, 22, 22, 16, 174, 68); | 69 g_symbols[25] = new CBC_SymbolInfo(false, 696, 272, 22, 22, 16, 174, 68); |
70 g_symbols[26] = new CBC_SymbolInfo(FALSE, 816, 336, 24, 24, 16, 136, 56); | 70 g_symbols[26] = new CBC_SymbolInfo(false, 816, 336, 24, 24, 16, 136, 56); |
71 g_symbols[27] = new CBC_SymbolInfo(FALSE, 1050, 408, 18, 18, 36, 175, 68); | 71 g_symbols[27] = new CBC_SymbolInfo(false, 1050, 408, 18, 18, 36, 175, 68); |
72 g_symbols[28] = new CBC_SymbolInfo(FALSE, 1304, 496, 20, 20, 36, 163, 62); | 72 g_symbols[28] = new CBC_SymbolInfo(false, 1304, 496, 20, 20, 36, 163, 62); |
73 g_symbols[29] = new CBC_DataMatrixSymbolInfo144(); | 73 g_symbols[29] = new CBC_DataMatrixSymbolInfo144(); |
74 } | 74 } |
75 | 75 |
76 void CBC_SymbolInfo::Finalize() { | 76 void CBC_SymbolInfo::Finalize() { |
77 for (size_t i = 0; i < kSymbolsCount; i++) { | 77 for (size_t i = 0; i < kSymbolsCount; i++) { |
78 delete g_symbols[i]; | 78 delete g_symbols[i]; |
79 g_symbols[i] = nullptr; | 79 g_symbols[i] = nullptr; |
80 } | 80 } |
81 } | 81 } |
82 | 82 |
83 CBC_SymbolInfo::CBC_SymbolInfo(FX_BOOL rectangular, | 83 CBC_SymbolInfo::CBC_SymbolInfo(bool rectangular, |
84 int32_t dataCapacity, | 84 int32_t dataCapacity, |
85 int32_t errorCodewords, | 85 int32_t errorCodewords, |
86 int32_t matrixWidth, | 86 int32_t matrixWidth, |
87 int32_t matrixHeight, | 87 int32_t matrixHeight, |
88 int32_t dataRegions) { | 88 int32_t dataRegions) { |
89 m_rectangular = rectangular; | 89 m_rectangular = rectangular; |
90 m_dataCapacity = dataCapacity; | 90 m_dataCapacity = dataCapacity; |
91 m_errorCodewords = errorCodewords; | 91 m_errorCodewords = errorCodewords; |
92 m_matrixWidth = matrixWidth; | 92 m_matrixWidth = matrixWidth; |
93 m_matrixHeight = matrixHeight; | 93 m_matrixHeight = matrixHeight; |
94 m_dataRegions = dataRegions; | 94 m_dataRegions = dataRegions; |
95 m_rsBlockData = dataCapacity; | 95 m_rsBlockData = dataCapacity; |
96 m_rsBlockError = errorCodewords; | 96 m_rsBlockError = errorCodewords; |
97 } | 97 } |
98 CBC_SymbolInfo::CBC_SymbolInfo(FX_BOOL rectangular, | 98 CBC_SymbolInfo::CBC_SymbolInfo(bool rectangular, |
99 int32_t dataCapacity, | 99 int32_t dataCapacity, |
100 int32_t errorCodewords, | 100 int32_t errorCodewords, |
101 int32_t matrixWidth, | 101 int32_t matrixWidth, |
102 int32_t matrixHeight, | 102 int32_t matrixHeight, |
103 int32_t dataRegions, | 103 int32_t dataRegions, |
104 int32_t rsBlockData, | 104 int32_t rsBlockData, |
105 int32_t rsBlockError) { | 105 int32_t rsBlockError) { |
106 m_rectangular = rectangular; | 106 m_rectangular = rectangular; |
107 m_dataCapacity = dataCapacity; | 107 m_dataCapacity = dataCapacity; |
108 m_errorCodewords = errorCodewords; | 108 m_errorCodewords = errorCodewords; |
109 m_matrixWidth = matrixWidth; | 109 m_matrixWidth = matrixWidth; |
110 m_matrixHeight = matrixHeight; | 110 m_matrixHeight = matrixHeight; |
111 m_dataRegions = dataRegions; | 111 m_dataRegions = dataRegions; |
112 m_rsBlockData = rsBlockData; | 112 m_rsBlockData = rsBlockData; |
113 m_rsBlockError = rsBlockError; | 113 m_rsBlockError = rsBlockError; |
114 } | 114 } |
115 CBC_SymbolInfo::~CBC_SymbolInfo() {} | 115 CBC_SymbolInfo::~CBC_SymbolInfo() {} |
116 | 116 |
117 CBC_SymbolInfo* CBC_SymbolInfo::lookup(int32_t dataCodewords, int32_t& e) { | 117 CBC_SymbolInfo* CBC_SymbolInfo::lookup(int32_t dataCodewords, int32_t& e) { |
118 return lookup(dataCodewords, FORCE_NONE, TRUE, e); | 118 return lookup(dataCodewords, FORCE_NONE, true, e); |
119 } | 119 } |
120 CBC_SymbolInfo* CBC_SymbolInfo::lookup(int32_t dataCodewords, | 120 CBC_SymbolInfo* CBC_SymbolInfo::lookup(int32_t dataCodewords, |
121 SymbolShapeHint shape, | 121 SymbolShapeHint shape, |
122 int32_t& e) { | 122 int32_t& e) { |
123 return lookup(dataCodewords, shape, TRUE, e); | 123 return lookup(dataCodewords, shape, true, e); |
124 } | 124 } |
125 CBC_SymbolInfo* CBC_SymbolInfo::lookup(int32_t dataCodewords, | 125 CBC_SymbolInfo* CBC_SymbolInfo::lookup(int32_t dataCodewords, |
126 FX_BOOL allowRectangular, | 126 bool allowRectangular, |
127 FX_BOOL fail, | 127 bool fail, |
128 int32_t& e) { | 128 int32_t& e) { |
129 SymbolShapeHint shape = allowRectangular ? FORCE_NONE : FORCE_SQUARE; | 129 SymbolShapeHint shape = allowRectangular ? FORCE_NONE : FORCE_SQUARE; |
130 return lookup(dataCodewords, shape, fail, e); | 130 return lookup(dataCodewords, shape, fail, e); |
131 } | 131 } |
132 CBC_SymbolInfo* CBC_SymbolInfo::lookup(int32_t dataCodewords, | 132 CBC_SymbolInfo* CBC_SymbolInfo::lookup(int32_t dataCodewords, |
133 SymbolShapeHint shape, | 133 SymbolShapeHint shape, |
134 FX_BOOL fail, | 134 bool fail, |
135 int32_t& e) { | 135 int32_t& e) { |
136 return lookup(dataCodewords, shape, nullptr, nullptr, fail, e); | 136 return lookup(dataCodewords, shape, nullptr, nullptr, fail, e); |
137 } | 137 } |
138 CBC_SymbolInfo* CBC_SymbolInfo::lookup(int32_t dataCodewords, | 138 CBC_SymbolInfo* CBC_SymbolInfo::lookup(int32_t dataCodewords, |
139 SymbolShapeHint shape, | 139 SymbolShapeHint shape, |
140 CBC_Dimension* minSize, | 140 CBC_Dimension* minSize, |
141 CBC_Dimension* maxSize, | 141 CBC_Dimension* maxSize, |
142 FX_BOOL fail, | 142 bool fail, |
143 int32_t& e) { | 143 int32_t& e) { |
144 for (size_t i = 0; i < kSymbolsCount; i++) { | 144 for (size_t i = 0; i < kSymbolsCount; i++) { |
145 CBC_SymbolInfo* symbol = g_symbols[i]; | 145 CBC_SymbolInfo* symbol = g_symbols[i]; |
146 if (shape == FORCE_SQUARE && symbol->m_rectangular) { | 146 if (shape == FORCE_SQUARE && symbol->m_rectangular) { |
147 continue; | 147 continue; |
148 } | 148 } |
149 if (shape == FORCE_RECTANGLE && !symbol->m_rectangular) { | 149 if (shape == FORCE_RECTANGLE && !symbol->m_rectangular) { |
150 continue; | 150 continue; |
151 } | 151 } |
152 if (minSize && (symbol->getSymbolWidth(e) < minSize->getWidth() || | 152 if (minSize && (symbol->getSymbolWidth(e) < minSize->getWidth() || |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 } | 219 } |
220 int32_t CBC_SymbolInfo::getInterleavedBlockCount() { | 220 int32_t CBC_SymbolInfo::getInterleavedBlockCount() { |
221 return m_dataCapacity / m_rsBlockData; | 221 return m_dataCapacity / m_rsBlockData; |
222 } | 222 } |
223 int32_t CBC_SymbolInfo::getDataLengthForInterleavedBlock(int32_t index) { | 223 int32_t CBC_SymbolInfo::getDataLengthForInterleavedBlock(int32_t index) { |
224 return m_rsBlockData; | 224 return m_rsBlockData; |
225 } | 225 } |
226 int32_t CBC_SymbolInfo::getErrorLengthForInterleavedBlock(int32_t index) { | 226 int32_t CBC_SymbolInfo::getErrorLengthForInterleavedBlock(int32_t index) { |
227 return m_rsBlockError; | 227 return m_rsBlockError; |
228 } | 228 } |
OLD | NEW |