Grok  7.6.3
TagTree.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016-2021 Grok Image Compression Inc.
3  *
4  * This source code is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Affero General Public License, version 3,
6  * as published by the Free Software Foundation.
7  *
8  * This source code is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Affero General Public License for more details.
12  *
13  * You should have received a copy of the GNU Affero General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  *
17  * This source code incorporates work covered by the BSD 2-clause license.
18  * Please see the LICENSE file in the root directory for details.
19  *
20  */
21 
22 #pragma once
23 
24 namespace grk {
25 
26 const uint32_t tag_tree_uninitialized_node_value = 999;
27 
31 struct TagTreeNode {
32 
34  parent(nullptr), value(0), low(0), known(0) {
35  }
36 
38  int64_t value;
39  int64_t low;
40  uint32_t known;
41 };
42 
46 class TagTree {
47 
48 public:
49 
56  TagTree(uint64_t numleafsh, uint64_t numleafsv);
57  ~TagTree();
58 
66  bool init(uint64_t num_leafs_h, uint64_t num_leafs_v);
67 
71  void reset();
77  void setvalue(uint64_t leafno, int64_t value);
85  bool compress(BitIO *bio, uint64_t leafno, int64_t threshold);
93  void decompress(BitIO *bio, uint64_t leafno, int64_t threshold,
94  uint8_t *decompressed);
95 
103  void decodeValue(BitIO *bio, uint64_t leafno, int64_t threshold,
104  uint64_t *value);
105 
106 private:
107 
108  uint64_t numleafsh;
109  uint64_t numleafsv;
110  uint64_t numnodes;
112  uint64_t nodes_size; /* maximum size taken by nodes */
113 
114 };
115 
116 }
117 
grk::TagTree::setvalue
void setvalue(uint64_t leafno, int64_t value)
Set the value of a leaf of a tag tree.
Definition: TagTree.cpp:170
grk::tag_tree_uninitialized_node_value
const uint32_t tag_tree_uninitialized_node_value
Definition: TagTree.h:26
grk::TagTreeNode::value
int64_t value
Definition: TagTree.h:38
grk::TagTree::nodes_size
uint64_t nodes_size
Definition: TagTree.h:112
grk::TagTree
Tag tree.
Definition: TagTree.h:46
grk::BitIO::write
bool write(uint32_t v, uint32_t n)
Write bits.
Definition: BitIO.cpp:110
grk::GRK_WARN
void GRK_WARN(const char *fmt,...)
Definition: logger.cpp:49
grk::TagTreeNode::parent
TagTreeNode * parent
Definition: TagTree.h:37
grk::TagTree::numleafsh
uint64_t numleafsh
Definition: TagTree.h:108
grk::TagTree::~TagTree
~TagTree()
Definition: TagTree.cpp:85
grk::TagTree::numleafsv
uint64_t numleafsv
Definition: TagTree.h:109
grk::TagTreeNode
Tag node.
Definition: TagTree.h:31
grk::TagTree::decompress
void decompress(BitIO *bio, uint64_t leafno, int64_t threshold, uint8_t *decompressed)
Decompress the value of a leaf of the tag tree up to a given threshold.
Definition: TagTree.cpp:220
grk::TagTree::init
bool init(uint64_t num_leafs_h, uint64_t num_leafs_v)
Reinitialises a tag tree.
Definition: TagTree.cpp:96
grk::TagTree::compress
bool compress(BitIO *bio, uint64_t leafno, int64_t threshold)
Encode the value of a leaf of the tag tree up to a given threshold.
Definition: TagTree.cpp:179
grk::TagTreeNode::low
int64_t low
Definition: TagTree.h:39
grk::TagTreeNode::known
uint32_t known
Definition: TagTree.h:40
grk::TagTree::numnodes
uint64_t numnodes
Definition: TagTree.h:110
grk
Copyright (C) 2016-2021 Grok Image Compression Inc.
Definition: BitIO.cpp:23
grk::BitIO
Definition: BitIO.h:32
grk_includes.h
grk::TagTree::decodeValue
void decodeValue(BitIO *bio, uint64_t leafno, int64_t threshold, uint64_t *value)
Decompress the value of a leaf of the tag tree up to a given threshold.
Definition: TagTree.cpp:227
grk::BitIO::read
void read(uint32_t *bits, uint32_t n)
Read bits.
Definition: BitIO.cpp:119
grk::TagTreeNode::TagTreeNode
TagTreeNode()
Definition: TagTree.h:33
grk::TagTree::reset
void reset()
Reset a tag tree (set all leaves to 0)
Definition: TagTree.cpp:161
grk::TagTree::nodes
TagTreeNode * nodes
Definition: TagTree.h:111
grk::TagTree::TagTree
TagTree(uint64_t numleafsh, uint64_t numleafsv)
Create a tag tree.
Definition: TagTree.cpp:27