BEEP-8 Helper Lib 1.0.0
Loading...
Searching...
No Matches
huffman.h
Go to the documentation of this file.
1// MIT License
2
3// Copyright (c) 2022 ZooK
4
5// Permission is hereby granted, free of charge, to any person obtaining a copy
6// of this software and associated documentation files (the "Software"), to deal
7// in the Software without restriction, including without limitation the rights
8// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9// copies of the Software, and to permit persons to whom the Software is
10// furnished to do so, subject to the following conditions:
11
12// The above copyright notice and this permission notice shall be included in all
13// copies or substantial portions of the Software.
14
15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21// SOFTWARE.
114#pragma once
115
116#include <memory>
117#include <b8/type.h>
118#include <pipe.h>
119
120namespace Huffman {
121constexpr u8 Signature = 0x77;
122
130 std::shared_ptr<Pipe::CPipe> _pipe_in = std::make_shared<Pipe::CNullPipe>();
131 std::shared_ptr<Pipe::CPipe> _pipe_out = std::make_shared<Pipe::CNullPipe>();
132 void _Output(std::shared_ptr<Pipe::CPipe> pipe_mem_huf_packed_);
133
134public:
140 void SetIn(std::shared_ptr<Pipe::CPipe> pipe_in_);
141
147 void SetOut(std::shared_ptr<Pipe::CPipe> pipe_out_);
148
152 void Encode();
153};
154
162 std::shared_ptr< Pipe::CPipe > _pipe_in = std::make_shared< Pipe::CNullPipe >();
163 std::shared_ptr< Pipe::CPipe > _pipe_out = std::make_shared< Pipe::CNullPipe >();
164public:
170 DECODE_OK,
171 DECODE_ERR_INVALID_SIGNATURE,
172 DECODE_INVALID_DATA,
173 };
174private:
180 CHuffmanDecoder::DecodeResult _DoDecodeFlat();
181
182public:
188 void SetIn ( std::shared_ptr< Pipe::CPipe > pipe_in_ );
189
195 void SetOut( std::shared_ptr< Pipe::CPipe > pipe_out_ );
196
203};
204
205} // namespace Huffman
Class for Huffman decoding.
Definition huffman.h:161
void SetIn(std::shared_ptr< Pipe::CPipe > pipe_in_)
Sets the input pipe for the decoder.
Definition huffman.cpp:609
CHuffmanDecoder::DecodeResult Decode()
Performs Huffman decoding on the input data.
Definition huffman.cpp:540
DecodeResult
Enumeration for the result of the decoding process.
Definition huffman.h:169
void SetOut(std::shared_ptr< Pipe::CPipe > pipe_out_)
Sets the output pipe for the decoder.
Definition huffman.cpp:613
Class for Huffman encoding.
Definition huffman.h:129
void SetIn(std::shared_ptr< Pipe::CPipe > pipe_in_)
Sets the input pipe for the encoder.
Definition huffman.cpp:342
void SetOut(std::shared_ptr< Pipe::CPipe > pipe_out_)
Sets the output pipe for the encoder.
Definition huffman.cpp:346
void Encode()
Performs Huffman encoding on the input data.
Definition huffman.cpp:357
Module for data pipeline processing using pipes.
@ Huffman
Huffman encoding only.
Definition zpack.h:77