SLikeNet 0.1.3

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DS_HuffmanEncodingTree.h
Go to the documentation of this file.
1 /*
2 * Original work: Copyright (c) 2014, Oculus VR, Inc.
3 * All rights reserved.
4 *
5 * This source code is licensed under the BSD-style license found in the
6 * RakNet License.txt file in the licenses directory of this source tree. An additional grant
7 * of patent rights can be found in the RakNet Patents.txt file in the same directory.
8 *
9 *
10 * Modified work: Copyright (c) 2017, SLikeSoft UG (haftungsbeschränkt)
11 *
12 * This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style
13 * license found in the license.txt file in the root directory of this source tree.
14 */
15
19
20
21 #ifndef __HUFFMAN_ENCODING_TREE
22 #define __HUFFMAN_ENCODING_TREE
23
24 #include "memoryoverride.h"
25 #include "DS_HuffmanEncodingTreeNode.h"
26 #include "BitStream.h"
27 #include "Export.h"
28 #include "DS_LinkedList.h"
29
30 namespace SLNet
31 {
32
34 class RAK_DLL_EXPORT HuffmanEncodingTree
35 {
36
37 public:
38 HuffmanEncodingTree();
39 ~HuffmanEncodingTree();
40
45 void EncodeArray( unsigned char *input, size_t sizeInBytes, SLNet::BitStream * output );
46
47 // \brief Decodes an array encoded by EncodeArray().
48 unsigned DecodeArray(SLNet::BitStream * input, BitSize_t sizeInBits, size_t maxCharsToWrite, unsigned char *output );
49 void DecodeArray( unsigned char *input, BitSize_t sizeInBits, SLNet::BitStream * output );
50
52 void GenerateFromFrequencyTable( unsigned int frequencyTable[ 256 ] );
53
55 void FreeMemory( void );
56
57 private:
58
60
61 HuffmanEncodingTreeNode *root;
62
64
65
66 struct CharacterEncoding
67 {
68 unsigned char* encoding;
69 unsigned short bitLength;
70 };
71
72 CharacterEncoding encodingTable[ 256 ];
73
74 void InsertNodeIntoSortedList( HuffmanEncodingTreeNode * node, DataStructures::LinkedList<HuffmanEncodingTreeNode *> *huffmanEncodingTreeNodeList ) const;
75 };
76
77 } // namespace SLNet
78
79 #endif