Project
Loading...
Searching...
No Matches
LowRangeDecoderTable.h
Go to the documentation of this file.
1// Copyright 2019-2023 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
15
16#ifndef RANS_INTERNAL_CONTAINERS_LOWRANGEDECODERTABLE_H_
17#define RANS_INTERNAL_CONTAINERS_LOWRANGEDECODERTABLE_H_
18
19#include <vector>
20#include <type_traits>
21#include <fairlogger/Logger.h>
22#include <variant>
23
29
30namespace o2::rans
31{
32
33template <typename source_T>
35{
36 public:
40 using value_type = std::pair<source_type, const symbol_type&>;
41 using size_type = std::size_t;
42 using difference_type = std::ptrdiff_t;
43
44 private:
46
47 public:
48 LowRangeDecoderTable() noexcept = default;
49
50 template <typename container_T>
51 explicit LowRangeDecoderTable(const RenormedHistogramConcept<container_T>& renormedHistogram) : mSymbolTable{renormedHistogram}, mRLUT{renormedHistogram} {};
52
53 [[nodiscard]] inline size_type size() const noexcept { return mRLUT.size(); };
54
55 [[nodiscard]] inline bool isEscapeSymbol(count_type cumul) const noexcept { return mRLUT.isIncompressible(cumul); };
56
57 [[nodiscard]] inline bool hasEscapeSymbol() const noexcept { return mSymbolTable.hasEscapeSymbol(); };
58
59 [[nodiscard]] inline const symbol_type& getEscapeSymbol() const noexcept { return mSymbolTable.getEscapeSymbol(); };
60
61 [[nodiscard]] inline const value_type operator[](count_type cumul) const noexcept
62 {
63 assert(cumul < this->size());
64 source_type symbol = mRLUT[cumul];
65 return {symbol, *mSymbolTable.lookupUnsafe(symbol)};
66 };
67
68 [[nodiscard]] inline size_type getPrecision() const noexcept { return this->mSymbolTable.getPrecision(); };
69
70 private:
71 symbolTable_type mSymbolTable;
73};
74
75} // namespace o2::rans
76
77#endif /* RANS_INTERNAL_CONTAINERS_LOWRANGEDECODERTABLE_H_ */
Lookup table containing statistical information for each symbol in the alphabet required for encoding...
Histogram renormed to sum of frequencies being 2^P for use in fast rans coding.
Maps rANS state information back to source symbol, used for decoding.
Contains statistical information for one source symbol, required for encoding/decoding.
common helper classes and functions
size_type getPrecision() const noexcept
const_pointer lookupUnsafe(source_type sourceSymbol) const
const_reference getEscapeSymbol() const noexcept
bool hasEscapeSymbol() const noexcept
size_type size() const noexcept
bool isEscapeSymbol(count_type cumul) const noexcept
const value_type operator[](count_type cumul) const noexcept
size_type getPrecision() const noexcept
LowRangeDecoderTable() noexcept=default
bool hasEscapeSymbol() const noexcept
const symbol_type & getEscapeSymbol() const noexcept
std::pair< source_type, const symbol_type & > value_type
uint32_t count_t
Definition defaults.h:34