blob: 9aa9ed76fa7127ed29edebbd3affe79ae16a96db [file] [log] [blame]
K. Moon832a6942022-10-31 20:11:31 +00001// Copyright 2014 The PDFium Authors
Dan Sinclair1770c022016-03-14 14:14:16 -04002// 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 Sinclaire7786682017-03-29 15:18:41 -04007#ifndef FXBARCODE_DATAMATRIX_BC_SYMBOLINFO_H_
8#define FXBARCODE_DATAMATRIX_BC_SYMBOLINFO_H_
Dan Sinclair1770c022016-03-14 14:14:16 -04009
Tom Sepez1e7fd162021-07-27 20:44:31 +000010#include <stddef.h>
11#include <stdint.h>
Dan Sinclair1770c022016-03-14 14:14:16 -040012
Tom Sepez14388732022-01-12 21:16:13 +000013#include "core/fxcrt/unowned_ptr.h"
14
Lei Zhanga861a7b2017-05-23 14:37:27 -070015class CBC_SymbolInfo {
Dan Sinclair1770c022016-03-14 14:14:16 -040016 public:
Lei Zhanga8977802020-04-23 19:17:49 +000017 struct Data {
18 int16_t data_capacity;
19 int16_t error_codewords;
Lei Zhang4f5d3772020-04-23 20:25:39 +000020 int16_t rs_block_data;
21 int8_t rs_block_error;
Lei Zhanga8977802020-04-23 19:17:49 +000022 int8_t matrix_width;
23 int8_t matrix_height;
24 int8_t data_regions;
Lei Zhanga8977802020-04-23 19:17:49 +000025 };
26
Lei Zhanga861a7b2017-05-23 14:37:27 -070027 virtual ~CBC_SymbolInfo();
weili29b8ad02016-06-14 18:20:04 -070028
Dan Sinclair1770c022016-03-14 14:14:16 -040029 static void Initialize();
30 static void Finalize();
Lei Zhang4f5d3772020-04-23 20:25:39 +000031 static const CBC_SymbolInfo* Lookup(size_t data_codewords,
32 bool allow_rectangular);
Dan Sinclair1770c022016-03-14 14:14:16 -040033
Lei Zhang5dc591f2020-04-24 18:09:57 +000034 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 Sinclair1770c022016-03-14 14:14:16 -040041
Lei Zhang5dc591f2020-04-24 18:09:57 +000042 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 Zhangabc83aa2017-05-22 18:47:12 -070046
47 protected:
Lei Zhanga8977802020-04-23 19:17:49 +000048 explicit CBC_SymbolInfo(const Data* data);
thestig6dc1d772016-06-09 18:39:33 -070049
Lei Zhangabc83aa2017-05-22 18:47:12 -070050 private:
Lei Zhang5dc591f2020-04-24 18:09:57 +000051 int32_t GetHorizontalDataRegions() const;
52 int32_t GetVerticalDataRegions() const;
Lei Zhang4f5d3772020-04-23 20:25:39 +000053 bool is_rectangular() const {
54 return data_->matrix_width != data_->matrix_height;
55 }
Lei Zhangabc83aa2017-05-22 18:47:12 -070056
Tom Sepez14388732022-01-12 21:16:13 +000057 UnownedPtr<const Data> const data_;
Dan Sinclair1770c022016-03-14 14:14:16 -040058};
59
Dan Sinclaire7786682017-03-29 15:18:41 -040060#endif // FXBARCODE_DATAMATRIX_BC_SYMBOLINFO_H_