Skip to content

Commit

Permalink
fixup! added an example for lzss decoder
Browse files Browse the repository at this point in the history
  • Loading branch information
andreagilardoni committed May 31, 2024
1 parent 4c4a6f9 commit b4bf799
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
26 changes: 10 additions & 16 deletions src/lzss/decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@

namespace arduino { namespace lzss {

enum status: uint8_t {
DONE,
IN_PROGRESS,
NOT_COMPLETED
};

constexpr int DefaultEI = 11; /* typically 10..13 */
constexpr int DefaultEJ = 4; /* typically 4..5 */
constexpr int DefaultN = (1 << DefaultEI); /* buffer size */
Expand All @@ -46,16 +40,16 @@ namespace arduino { namespace lzss {
GenericDecoder(std::function<int()> getc_cbk, std::function<void(const uint8_t)> putc_cbk);

/**
* this enum describes the result of the computation of a single FSM computation
* DONE: the decompression is completed
* IN_PROGRESS: the decompression cycle completed successfully, ready to compute next
* NOT_COMPLETED: the current cycle didn't complete because the available data is not enough
*/
// enum status: uint8_t {
// DONE,
// IN_PROGRESS,
// NOT_COMPLETED
// };
* this enum describes the result of the computation of a single FSM computation for LZSS decoder
* DONE: the decompression is completed
* IN_PROGRESS: the decompression cycle completed successfully, ready to compute next
* NOT_COMPLETED: the current cycle didn't complete because the available data is not enough
*/
enum status: uint8_t {
DONE,
IN_PROGRESS,
NOT_COMPLETED
};

/**
* decode the provided buffer until buffer ends, then pause the process
Expand Down
4 changes: 2 additions & 2 deletions src/lzss/decoder.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ GenericDecoder<EI, EJ, N, F>::GenericDecoder(std::function<void(const uint8_t)>
}

template<int EI, int EJ, int N, int F>
status GenericDecoder<EI, EJ, N, F>::handle_state() {
typename GenericDecoder<EI, EJ, N, F>::status GenericDecoder<EI, EJ, N, F>::handle_state() {
status res = IN_PROGRESS;

int c = getbit(bits_required(this->state));
Expand Down Expand Up @@ -102,7 +102,7 @@ status GenericDecoder<EI, EJ, N, F>::handle_state() {
}

template<int EI, int EJ, int N, int F>
status GenericDecoder<EI, EJ, N, F>::decompress(uint8_t* const buffer, uint32_t size) {
typename GenericDecoder<EI, EJ, N, F>::status GenericDecoder<EI, EJ, N, F>::decompress(uint8_t* const buffer, uint32_t size) {
if(!get_char_cbk) {
this->in_buffer = buffer;
this->available += size;
Expand Down

0 comments on commit b4bf799

Please sign in to comment.