K. Moon | 832a694 | 2022-10-31 20:11:31 +0000 | [diff] [blame] | 1 | // Copyright 2014 The PDFium Authors |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | |
Dan Sinclair | e778668 | 2017-03-29 15:18:41 -0400 | [diff] [blame] | 7 | #ifndef FXBARCODE_DATAMATRIX_BC_SYMBOLINFO_H_ |
| 8 | #define FXBARCODE_DATAMATRIX_BC_SYMBOLINFO_H_ |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 9 | |
Tom Sepez | 1e7fd16 | 2021-07-27 20:44:31 +0000 | [diff] [blame] | 10 | #include <stddef.h> |
| 11 | #include <stdint.h> |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 12 | |
Tom Sepez | 1438873 | 2022-01-12 21:16:13 +0000 | [diff] [blame] | 13 | #include "core/fxcrt/unowned_ptr.h" |
| 14 | |
Lei Zhang | a861a7b | 2017-05-23 14:37:27 -0700 | [diff] [blame] | 15 | class CBC_SymbolInfo { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 16 | public: |
Lei Zhang | a897780 | 2020-04-23 19:17:49 +0000 | [diff] [blame] | 17 | struct Data { |
| 18 | int16_t data_capacity; |
| 19 | int16_t error_codewords; |
Lei Zhang | 4f5d377 | 2020-04-23 20:25:39 +0000 | [diff] [blame] | 20 | int16_t rs_block_data; |
| 21 | int8_t rs_block_error; |
Lei Zhang | a897780 | 2020-04-23 19:17:49 +0000 | [diff] [blame] | 22 | int8_t matrix_width; |
| 23 | int8_t matrix_height; |
| 24 | int8_t data_regions; |
Lei Zhang | a897780 | 2020-04-23 19:17:49 +0000 | [diff] [blame] | 25 | }; |
| 26 | |
Lei Zhang | a861a7b | 2017-05-23 14:37:27 -0700 | [diff] [blame] | 27 | virtual ~CBC_SymbolInfo(); |
weili | 29b8ad0 | 2016-06-14 18:20:04 -0700 | [diff] [blame] | 28 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 29 | static void Initialize(); |
| 30 | static void Finalize(); |
Lei Zhang | 4f5d377 | 2020-04-23 20:25:39 +0000 | [diff] [blame] | 31 | static const CBC_SymbolInfo* Lookup(size_t data_codewords, |
| 32 | bool allow_rectangular); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 33 | |
Lei Zhang | 5dc591f | 2020-04-24 18:09:57 +0000 | [diff] [blame] | 34 | int32_t GetSymbolDataWidth() const; |
| 35 | int32_t GetSymbolDataHeight() const; |
| 36 | int32_t GetSymbolWidth() const; |
| 37 | int32_t GetSymbolHeight() const; |
| 38 | virtual size_t GetInterleavedBlockCount() const; |
| 39 | size_t GetDataLengthForInterleavedBlock() const; |
| 40 | size_t GetErrorLengthForInterleavedBlock() const; |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 41 | |
Lei Zhang | 5dc591f | 2020-04-24 18:09:57 +0000 | [diff] [blame] | 42 | size_t data_capacity() const { return data_->data_capacity; } |
| 43 | size_t error_codewords() const { return data_->error_codewords; } |
| 44 | int32_t matrix_width() const { return data_->matrix_width; } |
| 45 | int32_t matrix_height() const { return data_->matrix_height; } |
Lei Zhang | abc83aa | 2017-05-22 18:47:12 -0700 | [diff] [blame] | 46 | |
| 47 | protected: |
Lei Zhang | a897780 | 2020-04-23 19:17:49 +0000 | [diff] [blame] | 48 | explicit CBC_SymbolInfo(const Data* data); |
thestig | 6dc1d77 | 2016-06-09 18:39:33 -0700 | [diff] [blame] | 49 | |
Lei Zhang | abc83aa | 2017-05-22 18:47:12 -0700 | [diff] [blame] | 50 | private: |
Lei Zhang | 5dc591f | 2020-04-24 18:09:57 +0000 | [diff] [blame] | 51 | int32_t GetHorizontalDataRegions() const; |
| 52 | int32_t GetVerticalDataRegions() const; |
Lei Zhang | 4f5d377 | 2020-04-23 20:25:39 +0000 | [diff] [blame] | 53 | bool is_rectangular() const { |
| 54 | return data_->matrix_width != data_->matrix_height; |
| 55 | } |
Lei Zhang | abc83aa | 2017-05-22 18:47:12 -0700 | [diff] [blame] | 56 | |
Tom Sepez | 1438873 | 2022-01-12 21:16:13 +0000 | [diff] [blame] | 57 | UnownedPtr<const Data> const data_; |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 58 | }; |
| 59 | |
Dan Sinclair | e778668 | 2017-03-29 15:18:41 -0400 | [diff] [blame] | 60 | #endif // FXBARCODE_DATAMATRIX_BC_SYMBOLINFO_H_ |