2021-02-07 17:22:50 +00:00
|
|
|
#ifndef VOXEL_COMPRESSED_DATA_H
|
|
|
|
#define VOXEL_COMPRESSED_DATA_H
|
|
|
|
|
2021-05-31 16:48:49 +01:00
|
|
|
#include "../util/span.h"
|
2022-04-16 00:07:23 +01:00
|
|
|
#include <cstdint>
|
2021-02-07 17:22:50 +00:00
|
|
|
|
2022-01-03 01:50:58 +00:00
|
|
|
namespace zylann::voxel::CompressedData {
|
2021-02-07 17:22:50 +00:00
|
|
|
|
|
|
|
// Compressed data starts with a single byte telling which compression format is used.
|
|
|
|
// What follows depends on it.
|
|
|
|
|
|
|
|
enum Compression {
|
|
|
|
// No compression. All following bytes can be read as-is.
|
|
|
|
// Could be used for debugging.
|
|
|
|
COMPRESSION_NONE = 0,
|
2022-02-26 22:52:31 +00:00
|
|
|
// [deprecated]
|
|
|
|
// The next uint32_t will be the size of decompressed data in big endian format.
|
2021-02-07 17:22:50 +00:00
|
|
|
// All following bytes are compressed data using LZ4 defaults.
|
|
|
|
// This is the fastest compression format.
|
2022-02-26 22:52:31 +00:00
|
|
|
COMPRESSION_LZ4_BE = 1,
|
|
|
|
// The next uint32_t will be the size of decompressed data (little endian).
|
|
|
|
// All following bytes are compressed data using LZ4 defaults.
|
|
|
|
// This is the fastest compression format.
|
|
|
|
COMPRESSION_LZ4 = 2,
|
|
|
|
COMPRESSION_COUNT = 3
|
2021-02-07 17:22:50 +00:00
|
|
|
};
|
|
|
|
|
2021-05-31 16:48:49 +01:00
|
|
|
bool compress(Span<const uint8_t> src, std::vector<uint8_t> &dst, Compression comp);
|
|
|
|
bool decompress(Span<const uint8_t> src, std::vector<uint8_t> &dst);
|
2021-02-07 17:22:50 +00:00
|
|
|
|
2022-01-03 01:50:58 +00:00
|
|
|
} // namespace zylann::voxel::CompressedData
|
2021-02-07 17:22:50 +00:00
|
|
|
|
|
|
|
#endif // VOXEL_COMPRESSED_DATA_H
|