123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- #pragma once
- #include "openmpt/all/BuildSettings.hpp"
- #include <vector>
- #include <iosfwd>
- #include "Snd_defs.h"
- #include "BitReader.h"
- OPENMPT_NAMESPACE_BEGIN
- struct ModSample;
- class ITCompression
- {
- public:
- ITCompression(const ModSample &sample, bool it215, std::ostream *f, SmpLength maxLength = 0);
- size_t GetCompressedSize() const { return packedTotalLength; }
- static constexpr size_t bufferSize = 2 + 0xFFFF;
- static constexpr size_t blockSize = 0x8000;
- protected:
- std::vector<int8> bwt;
- std::vector<uint8> packedData;
- std::ostream *file = nullptr;
- std::vector<int8> sampleData8;
- std::vector<int16> sampleData16;
- const ModSample &mptSample;
- size_t packedLength = 0;
- size_t packedTotalLength = 0;
- SmpLength baseLength = 0;
-
- int8 bitPos = 0;
- int8 remBits = 0;
- uint8 byteVal = 0;
- const bool is215;
- template<typename Properties>
- void Compress(const typename Properties::sample_t *mptSampleData, SmpLength maxLength);
- template<typename T>
- static void CopySample(T *target, const T *source, SmpLength offset, SmpLength length, SmpLength skip);
- template<typename T>
- void Deltafy(T *sampleData);
- template<typename Properties>
- void CompressBlock(const typename Properties::sample_t *data, SmpLength offset, SmpLength actualLength, typename Properties::sample_t *sampleData);
- static int8 GetWidthChangeSize(int8 w, bool is16);
- template<typename Properties>
- void SquishRecurse(int8 sWidth, int8 lWidth, int8 rWidth, int8 width, SmpLength offset, SmpLength length, const typename Properties::sample_t *sampleData);
- static int8 ConvertWidth(int8 curWidth, int8 newWidth);
- void WriteBits(int8 width, int v);
- void WriteByte(uint8 v);
- };
- class ITDecompression
- {
- public:
- ITDecompression(FileReader &file, ModSample &sample, bool it215);
- protected:
- BitReader bitFile;
- ModSample &mptSample;
- SmpLength writtenSamples = 0;
- SmpLength writePos = 0;
- SmpLength curLength = 0;
- unsigned int mem1 = 0, mem2 = 0;
-
- const bool is215;
- template<typename Properties>
- void Uncompress(typename Properties::sample_t *target);
- static void ChangeWidth(int &curWidth, int width);
- template<typename Properties>
- void Write(int v, int topbit, typename Properties::sample_t *target);
- };
- OPENMPT_NAMESPACE_END
|