mirror of
https://git.mirrors.martin98.com/https://github.com/google/draco
synced 2025-07-25 19:34:24 +08:00

- Improved compression for triangular meshes (~10%) - Added WebAssembly decoder - Code cleanup + robustness fixes
37 lines
1018 B
C++
37 lines
1018 B
C++
#ifndef DRACO_CORE_SYMBOL_BIT_ENCODER_H_
|
|
#define DRACO_CORE_SYMBOL_BIT_ENCODER_H_
|
|
|
|
#include <algorithm>
|
|
#include <vector>
|
|
|
|
#include "core/encoder_buffer.h"
|
|
|
|
namespace draco {
|
|
|
|
// Class for encoding bits using the symbol entropy encoding. Wraps
|
|
// |EncodeSymbols|. Note that this uses a symbol-based encoding scheme for
|
|
// encoding bits.
|
|
class SymbolBitEncoder {
|
|
public:
|
|
// Must be called before any Encode* function is called.
|
|
void StartEncoding() { Clear(); }
|
|
|
|
// Encode one bit. If |bit| is true encode a 1, otherwise encode a 0.
|
|
void EncodeBit(bool bit) { EncodeLeastSignificantBits32(1, bit ? 1 : 0); }
|
|
|
|
// Encode |nibts| LSBs of |value| as a symbol. |nbits| must be > 0 and <= 32.
|
|
void EncodeLeastSignificantBits32(int nbits, uint32_t value);
|
|
|
|
// Ends the bit encoding and stores the result into the target_buffer.
|
|
void EndEncoding(EncoderBuffer *target_buffer);
|
|
|
|
private:
|
|
void Clear();
|
|
|
|
std::vector<uint32_t> symbols_;
|
|
};
|
|
|
|
} // namespace draco
|
|
|
|
#endif // DRACO_CORE_SYMBOL_BIT_ENCODER_H_
|