/src/libjxl/lib/jxl/modular/encoding/dec_ma.h
Line | Count | Source |
1 | | // Copyright (c) the JPEG XL Project Authors. All rights reserved. |
2 | | // |
3 | | // Use of this source code is governed by a BSD-style |
4 | | // license that can be found in the LICENSE file. |
5 | | |
6 | | #ifndef LIB_JXL_MODULAR_ENCODING_DEC_MA_H_ |
7 | | #define LIB_JXL_MODULAR_ENCODING_DEC_MA_H_ |
8 | | |
9 | | #include <jxl/memory_manager.h> |
10 | | |
11 | | #include <cstddef> |
12 | | #include <cstdint> |
13 | | #include <vector> |
14 | | |
15 | | #include "lib/jxl/base/status.h" |
16 | | #include "lib/jxl/dec_bit_reader.h" |
17 | | #include "lib/jxl/modular/options.h" |
18 | | |
19 | | namespace jxl { |
20 | | |
21 | | // inner nodes |
22 | | struct PropertyDecisionNode { |
23 | | PropertyVal splitval; |
24 | | int16_t property; // -1: leaf node, lchild points to leaf node |
25 | | uint32_t lchild; |
26 | | uint32_t rchild; |
27 | | Predictor predictor; |
28 | | int64_t predictor_offset; |
29 | | uint32_t multiplier; |
30 | | |
31 | | PropertyDecisionNode(int p, int split_val, int lchild, int rchild, |
32 | | Predictor predictor, int64_t predictor_offset, |
33 | | uint32_t multiplier) |
34 | 4.37M | : splitval(split_val), |
35 | 4.37M | property(p), |
36 | 4.37M | lchild(lchild), |
37 | 4.37M | rchild(rchild), |
38 | 4.37M | predictor(predictor), |
39 | 4.37M | predictor_offset(predictor_offset), |
40 | 4.37M | multiplier(multiplier) {} |
41 | | PropertyDecisionNode() |
42 | 6.07k | : splitval(0), |
43 | 6.07k | property(-1), |
44 | 6.07k | lchild(0), |
45 | 6.07k | rchild(0), |
46 | 6.07k | predictor(Predictor::Zero), |
47 | 6.07k | predictor_offset(0), |
48 | 6.07k | multiplier(1) {} |
49 | | static PropertyDecisionNode Leaf(Predictor predictor, int64_t offset = 0, |
50 | 6.56k | uint32_t multiplier = 1) { |
51 | 6.56k | return PropertyDecisionNode(-1, 0, 0, 0, predictor, offset, multiplier); |
52 | 6.56k | } |
53 | | static PropertyDecisionNode Split(int p, int split_val, int lchild, |
54 | 4.00k | int rchild = -1) { |
55 | 4.00k | if (rchild == -1) rchild = lchild + 1; |
56 | 4.00k | return PropertyDecisionNode(p, split_val, lchild, rchild, Predictor::Zero, |
57 | 4.00k | 0, 1); |
58 | 4.00k | } |
59 | | }; |
60 | | |
61 | | using Tree = std::vector<PropertyDecisionNode>; |
62 | | |
63 | | Status DecodeTree(JxlMemoryManager *memory_manager, BitReader *br, Tree *tree, |
64 | | size_t tree_size_limit); |
65 | | |
66 | | } // namespace jxl |
67 | | |
68 | | #endif // LIB_JXL_MODULAR_ENCODING_DEC_MA_H_ |