diff options
Diffstat (limited to 'src/lib/util/huffman.h')
-rw-r--r-- | src/lib/util/huffman.h | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/src/lib/util/huffman.h b/src/lib/util/huffman.h index a2bed42bbf9..2814eb127dd 100644 --- a/src/lib/util/huffman.h +++ b/src/lib/util/huffman.h @@ -44,20 +44,20 @@ enum huffman_error class huffman_context_base { protected: - typedef UINT16 lookup_value; + typedef uint16_t lookup_value; // a node in the huffman tree struct node_t { node_t * m_parent; // pointer to parent node - UINT32 m_count; // number of hits on this node - UINT32 m_weight; // assigned weight of this node - UINT32 m_bits; // bits used to encode the node - UINT8 m_numbits; // number of bits needed for this node + uint32_t m_count; // number of hits on this node + uint32_t m_weight; // assigned weight of this node + uint32_t m_bits; // bits used to encode the node + uint8_t m_numbits; // number of bits needed for this node }; // construction/destruction - huffman_context_base(int numcodes, int maxbits, lookup_value *lookup, UINT32 *histo, node_t *nodes); + huffman_context_base(int numcodes, int maxbits, lookup_value *lookup, uint32_t *histo, node_t *nodes); // tree creation huffman_error compute_tree_from_histo(); @@ -73,18 +73,18 @@ protected: // internal helpers void write_rle_tree_bits(bitstream_out &bitbuf, int value, int repcount, int numbits); static int CLIB_DECL tree_node_compare(const void *item1, const void *item2); - int build_tree(UINT32 totaldata, UINT32 totalweight); + int build_tree(uint32_t totaldata, uint32_t totalweight); huffman_error assign_canonical_codes(); void build_lookup_table(); protected: // internal state - UINT32 m_numcodes; // number of total codes being processed - UINT8 m_maxbits; // maximum bits per code - UINT8 m_prevdata; // value of the previous data (for delta-RLE encoding) + uint32_t m_numcodes; // number of total codes being processed + uint8_t m_maxbits; // maximum bits per code + uint8_t m_prevdata; // value of the previous data (for delta-RLE encoding) int m_rleremaining; // number of RLE bytes remaining (for delta-RLE encoding) lookup_value * m_lookup; // pointer to the lookup table - UINT32 * m_datahisto; // histogram of data values + uint32_t * m_datahisto; // histogram of data values node_t * m_huffnode; // array of nodes }; @@ -102,8 +102,8 @@ public: // single item operations void histo_reset() { memset(m_datahisto_array, 0, sizeof(m_datahisto_array)); } - void histo_one(UINT32 data); - void encode_one(bitstream_out &bitbuf, UINT32 data); + void histo_one(uint32_t data); + void encode_one(bitstream_out &bitbuf, uint32_t data); // expose tree computation and export using huffman_context_base::compute_tree_from_histo; @@ -112,7 +112,7 @@ public: private: // array versions of the info we need - UINT32 m_datahisto_array[_NumCodes]; + uint32_t m_datahisto_array[_NumCodes]; node_t m_huffnode_array[_NumCodes * 2]; }; @@ -129,7 +129,7 @@ public: : huffman_context_base(_NumCodes, _MaxBits, m_lookup_array, nullptr, m_huffnode_array) { } // single item operations - UINT32 decode_one(bitstream_in &bitbuf); + uint32_t decode_one(bitstream_in &bitbuf); // expose tree import using huffman_context_base::import_tree_rle; @@ -152,7 +152,7 @@ public: huffman_8bit_encoder(); // operations - huffman_error encode(const UINT8 *source, UINT32 slength, UINT8 *dest, UINT32 destlength, UINT32 &complength); + huffman_error encode(const uint8_t *source, uint32_t slength, uint8_t *dest, uint32_t destlength, uint32_t &complength); }; @@ -166,7 +166,7 @@ public: huffman_8bit_decoder(); // operations - huffman_error decode(const UINT8 *source, UINT32 slength, UINT8 *dest, UINT32 destlength); + huffman_error decode(const uint8_t *source, uint32_t slength, uint8_t *dest, uint32_t destlength); }; @@ -180,7 +180,7 @@ public: //------------------------------------------------- template<int _NumCodes, int _MaxBits> -inline void huffman_encoder<_NumCodes, _MaxBits>::histo_one(UINT32 data) +inline void huffman_encoder<_NumCodes, _MaxBits>::histo_one(uint32_t data) { m_datahisto[data]++; } @@ -192,7 +192,7 @@ inline void huffman_encoder<_NumCodes, _MaxBits>::histo_one(UINT32 data) //------------------------------------------------- template<int _NumCodes, int _MaxBits> -inline void huffman_encoder<_NumCodes, _MaxBits>::encode_one(bitstream_out &bitbuf, UINT32 data) +inline void huffman_encoder<_NumCodes, _MaxBits>::encode_one(bitstream_out &bitbuf, uint32_t data) { // write the data node_t &node = m_huffnode[data]; @@ -206,10 +206,10 @@ inline void huffman_encoder<_NumCodes, _MaxBits>::encode_one(bitstream_out &bitb //------------------------------------------------- template<int _NumCodes, int _MaxBits> -inline UINT32 huffman_decoder<_NumCodes, _MaxBits>::decode_one(bitstream_in &bitbuf) +inline uint32_t huffman_decoder<_NumCodes, _MaxBits>::decode_one(bitstream_in &bitbuf) { // peek ahead to get maxbits worth of data - UINT32 bits = bitbuf.peek(m_maxbits); + uint32_t bits = bitbuf.peek(m_maxbits); // look it up, then remove the actual number of bits for this code lookup_value lookup = m_lookup[bits]; |