tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

dec_ma.h (2061B)


      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      : splitval(split_val),
     35        property(p),
     36        lchild(lchild),
     37        rchild(rchild),
     38        predictor(predictor),
     39        predictor_offset(predictor_offset),
     40        multiplier(multiplier) {}
     41  PropertyDecisionNode()
     42      : splitval(0),
     43        property(-1),
     44        lchild(0),
     45        rchild(0),
     46        predictor(Predictor::Zero),
     47        predictor_offset(0),
     48        multiplier(1) {}
     49  static PropertyDecisionNode Leaf(Predictor predictor, int64_t offset = 0,
     50                                   uint32_t multiplier = 1) {
     51    return PropertyDecisionNode(-1, 0, 0, 0, predictor, offset, multiplier);
     52  }
     53  static PropertyDecisionNode Split(int p, int split_val, int lchild,
     54                                    int rchild = -1) {
     55    if (rchild == -1) rchild = lchild + 1;
     56    return PropertyDecisionNode(p, split_val, lchild, rchild, Predictor::Zero,
     57                                0, 1);
     58  }
     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_