Broken LZ4 algorithm! The decompression seems to work now (needs improvement?) but the conversion tools emit 64K block sizes which is unhelpfull for us
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#ifndef __JABYENGINE_LZ4_DECOMPRESSOR_HPP__
|
||||
#define __JABYENGINE_LZ4_DECOMPRESSOR_HPP__
|
||||
#include "../../stddef.h"
|
||||
#include "array_range.hpp"
|
||||
#include "types.hpp"
|
||||
|
||||
namespace JabyEngine {
|
||||
@@ -24,12 +25,37 @@ namespace JabyEngine {
|
||||
};
|
||||
|
||||
private:
|
||||
struct State {};
|
||||
struct State {
|
||||
enum struct Step {
|
||||
ReadToken,
|
||||
ObtainLiteralLength,
|
||||
CopyLiterals,
|
||||
ObtainMatchOffset,
|
||||
ObtainMatchLength,
|
||||
CopyMatch,
|
||||
};
|
||||
|
||||
Step step = Step::ReadToken;
|
||||
size_t literal_length = 0;
|
||||
size_t match_length = 0;
|
||||
uint16_t match_offset = 0xFFFF;
|
||||
|
||||
State() = default;
|
||||
};
|
||||
|
||||
private:
|
||||
uint8_t* dst_adr = nullptr;
|
||||
State state;
|
||||
|
||||
static bool obtain_any_length(ArrayRange<const uint8_t>& data, uint32_t &dst_length);
|
||||
|
||||
pair<bool, Result> read_token(ArrayRange<const uint8_t>& data);
|
||||
pair<bool, Result> obtain_literal_length(ArrayRange<const uint8_t>& data);
|
||||
pair<bool, Result> copy_literals(ArrayRange<const uint8_t>& data);
|
||||
pair<bool, Result> obtain_match_offset(ArrayRange<const uint8_t>& data);
|
||||
pair<bool, Result> obtain_match_length(ArrayRange<const uint8_t>& data);
|
||||
pair<bool, Result> copy_match(ArrayRange<const uint8_t>& data);
|
||||
|
||||
public:
|
||||
LZ4Decompressor() = default;
|
||||
LZ4Decompressor(uint8_t* dst_adr) : LZ4Decompressor() {
|
||||
@@ -39,7 +65,7 @@ namespace JabyEngine {
|
||||
void setup(uint8_t* dst_adr);
|
||||
void reset();
|
||||
|
||||
Result process(const uint8_t* data, size_t size);
|
||||
Result process(ArrayRange<const uint8_t> data);
|
||||
};
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user