Welcome to mirror list, hosted at ThFree Co, Russian Federation.

symbol_bit_decoder.h « bit_coders « compression « draco « src « draco « draco « extern - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 909d7174fb53961cefccecaf323cf016cd593dcc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#ifndef DRACO_COMPRESSION_BIT_CODERS_SYMBOL_BIT_DECODER_H_
#define DRACO_COMPRESSION_BIT_CODERS_SYMBOL_BIT_DECODER_H_

#include <algorithm>
#include <vector>

#include "draco/core/decoder_buffer.h"

namespace draco {

// Class for decoding bits using the symbol entropy encoding. Wraps
// |DecodeSymbols|. Note that this uses a symbol-based encoding scheme for
// encoding bits.
class SymbolBitDecoder {
 public:
  // Sets |source_buffer| as the buffer to decode bits from.
  bool StartDecoding(DecoderBuffer *source_buffer);

  // Decode one bit. Returns true if the bit is a 1, otherwise false.
  bool DecodeNextBit();

  // Decode the next |nbits| and return the sequence in |value|. |nbits| must be
  // > 0 and <= 32.
  void DecodeLeastSignificantBits32(int nbits, uint32_t *value);

  void EndDecoding() { Clear(); }

 private:
  void Clear();

  std::vector<uint32_t> symbols_;
};

}  // namespace draco

#endif  // DRACO_COMPRESSION_BIT_CODERS_SYMBOL_BIT_DECODER_H_