athena/include/LZ77/LZLookupTable.hpp

40 lines
1.0 KiB
C++
Raw Normal View History

2014-09-09 16:36:29 +00:00
#ifndef LZLOOKUPTABLE_HPP
#define LZLOOKUPTABLE_HPP
#include <map>
#include <deque>
#include <vector>
#include <cstdint>
2016-03-04 23:00:12 +00:00
#include <athena/Types.hpp>
2014-09-09 16:36:29 +00:00
struct LZLengthOffset
{
atUint32 length;//The number of bytes compressed
atUint16 offset;//How far back in sliding window where bytes that match the lookAheadBuffer is located
bool compare_equal(const LZLengthOffset& lo_pair)
{
return length == lo_pair.length && offset == lo_pair.offset;
}
};
class LZLookupTable
{
public:
LZLookupTable();
2015-05-19 03:24:56 +00:00
LZLookupTable(atInt32 minimumMatch, atInt32 slidingWindow = 4096, atInt32 lookAheadWindow = 18);
2014-09-09 16:36:29 +00:00
~LZLookupTable();
LZLengthOffset search(atUint8* curPos, const atUint8* dataBegin, const atUint8* dataEnd);
void setLookAheadWindow(atInt32 lookAheadWindow);
private:
typedef std::multimap<std::vector<uint8_t>, int32_t> LookupTable;
2015-05-19 03:24:56 +00:00
LookupTable table;
2014-09-09 16:36:29 +00:00
atInt32 m_minimumMatch;
atInt32 m_slidingWindow;
atInt32 m_lookAheadWindow;
std::vector<uint8_t> m_buffer;
2015-05-19 03:24:56 +00:00
2014-09-09 16:36:29 +00:00
};
#endif // LZLOOKUPTABLE_HPP