mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
commit 4da14d7ddecc0d8c322fc7ee372be67481fb0b99 Author: IcePixelx <41352111+PixieCore@users.noreply.github.com> Date: Sat Jan 15 20:13:11 2022 +0100 Cleaned up native server browser and commented functions. commit b366e4ce826c9c7dbeb2af26cb6c34656b2c93f2 Author: r-ex <67599507+r-ex@users.noreply.github.com> Date: Sat Jan 15 17:57:18 2022 +0000 sq server browser clean up (#63) * sq server browser clean up * Properly loop through std::vector on GetAvailableMaps. Co-authored-by: IcePixelx <41352111+PixieCore@users.noreply.github.com> commit 829e122cead5521d5ffa57daa7e9fbd10755d68f Author: IcePixelx <41352111+PixieCore@users.noreply.github.com> Date: Sat Jan 15 15:25:19 2022 +0100 SQ Serverbrowser V1 push. Clean-up following after @r-ex fixed SQ things. commit 29fe6be989f176321406e4e521da406e65229acd Author: IcePixelx <41352111+PixieCore@users.noreply.github.com> Date: Fri Jan 14 20:59:06 2022 +0100 Fix pre-compiled headers for imgui_utility.cpp commit f2f8a088bfbc8b7311f2efb402963eb3b0802a46 Author: Amos <48657826+Mauler125@users.noreply.github.com> Date: Fri Jan 14 20:51:32 2022 +0100 Fix compiler error caused merge from separate branch commit 1c5df4e178a29234139c3ebf06b25fcd795689ea Author: Amos <48657826+Mauler125@users.noreply.github.com> Date: Fri Jan 14 20:45:36 2022 +0100 Ansi terminal color support + big optimizations on all log systems + 'Warning()' hook * Ansi colors can now be enabled with the '-ansiclr- flag. * All loggers have been optimized and are all initialized only once at process startup. * New hook for 'Warning()' print function with warning level. commit 012a317c846ba4fcf727ffb97678ee080f2dd976 Author: Amos <48657826+Mauler125@users.noreply.github.com> Date: Fri Jan 14 15:39:09 2022 +0100 Update init.cpp commit a14480e7cfdb869d222da04275f2619ca1405ce3 Author: Amos <48657826+Mauler125@users.noreply.github.com> Date: Fri Jan 14 15:38:48 2022 +0100 Update stdafx.h commit bdc67e90cb5624ee5d9f8a3620fe64a0d80726a5 Author: Amos <48657826+Mauler125@users.noreply.github.com> Date: Fri Jan 14 15:37:08 2022 +0100 Set default spdlog level to trace commit 96ee434d4e58a79a091cb0fee0caa5d838f629df Author: Amos <48657826+Mauler125@users.noreply.github.com> Date: Fri Jan 14 15:36:51 2022 +0100 Fix missing header errors for SpdLog commit 6bbb16dcb9f821e6f71bbfa9f0b4b12167907f43 Author: IcePixelx <41352111+PixieCore@users.noreply.github.com> Date: Fri Jan 14 20:39:11 2022 +0100 Fix sendrequest crash. Due to htResults being null. commit 5612c7a3a7e38f725b17e98d17d06f146135feae Author: Amos <48657826+Mauler125@users.noreply.github.com> Date: Wed Jan 12 13:11:11 2022 +0100 This seems no longer needed for dedicated servers Shader/texture assets are no longer loaded where the pointer parameters to the asset unloading function won't be out of scope anymore commit e6254e3a036b26a70b4dc29df7f8a5082a0f5297 Author: Amos <48657826+Mauler125@users.noreply.github.com> Date: Wed Jan 12 13:09:06 2022 +0100 Fix issue with ImGui windows where input could loose focus and not work 'ImGui_ImplWin32_WndProcHandler' has to be called at all times from the HwndProc handler as it has to track all events to prevent issues with input. commit de3b3f53bd2c32015e9accaed873d06a722ab7da Author: Amos <48657826+Mauler125@users.noreply.github.com> Date: Wed Jan 12 02:53:07 2022 +0100 Optimizations + QoL improvements/cleanup * IConsole overlay now clears the oldest log entries to stay under the vector limit instead of clearing the whole vector. * IConsole code cleanup. * IBrowser code cleanup, reordered class methods. * Use ConVar utilities to get/set values for strings in IBrowser and IConsole. * New ConVar's for RUI console overlay to tweak colors. commit 44102abbcca2d088dcb253da8ec7c9b869064139 Author: Amos <48657826+Mauler125@users.noreply.github.com> Date: Mon Jan 10 02:47:19 2022 +0100 Execute dev configs when '-devsdk' parameter is passed commit 8d1023212abd8e2b250f5fb7b33fdfa329b07b40 Author: Amos <48657826+Mauler125@users.noreply.github.com> Date: Mon Jan 10 02:24:30 2022 +0100 Small alignment commit 38d9d431c9aaef1ede7b6ceb594aa9b9971c261f Author: Amos <48657826+Mauler125@users.noreply.github.com> Date: Mon Jan 10 02:03:31 2022 +0100 Fix potential bug where 'cm_return_false_cmdquery_all' cvar would never work commit c0f24e64ff04bacb8d5b51961de1687dfb75bc71 Author: Amos <48657826+Mauler125@users.noreply.github.com> Date: Mon Jan 10 01:31:25 2022 +0100 Rename global cvar pointer commit 0146f22e0a8bcd7ec137bb205d117cea49f533dc Author: Amos <48657826+Mauler125@users.noreply.github.com> Date: Mon Jan 10 01:20:44 2022 +0100 Implement CommandLine utilities commit 64c07af6e067bc85385a78981d29770eebd3eb6b Author: Amos <48657826+Mauler125@users.noreply.github.com> Date: Sun Jan 9 17:17:05 2022 +0100 Cleanup to use new ConVar utilities commit 19f5010bd26e010746436766c05515dff85d7695 Author: Amos <48657826+Mauler125@users.noreply.github.com> Date: Sun Jan 9 16:29:36 2022 +0100 Fix compiler error + rename debug dll's Rename for easier debugging and config separation commit c292d8ad46b22c7a34c6d3caf8143e131e8dd997 Author: Amos <48657826+Mauler125@users.noreply.github.com> Date: Sun Jan 9 16:14:17 2022 +0100 Implement new ConVar features Slight cleanup with new ConVar features to be used throughout the SDK commit 0177c17da94dc977f85babe2aa8168cefb56bf45 Author: Amos <48657826+Mauler125@users.noreply.github.com> Date: Sat Jan 8 02:05:33 2022 +0100 Draw simulation stats and GPU stats to debug text overlay commit 21a10e201b6ea7afd4ffdd7d6b9668806085b6a5 Author: IcePixelx <41352111+PixieCore@users.noreply.github.com> Date: Sun Jan 9 14:36:22 2022 +0100 Typos. commit ae09372cc79053f5515529e403402494ffa6dfe4 Author: IcePixelx <41352111+PixieCore@users.noreply.github.com> Date: Sun Jan 9 14:35:43 2022 +0100 Pylon system changes. commit 98a428ace9226442fa623a0870af9f7e12f35eb0 Author: Amos <48657826+Mauler125@users.noreply.github.com> Date: Fri Jan 7 01:03:35 2022 +0100 Fix S2 crash when launching a different version commit c98301d175b8b1b80b2f480bc29e0703cf12c350 Author: Amos <48657826+Mauler125@users.noreply.github.com> Date: Thu Jan 6 17:30:10 2022 +0100 Fix LZHAM recompiling pch for each implementation file commit b80be10c4dc2c1f27917cd68a2c4c47819ee5fe5 Author: Amos <48657826+Mauler125@users.noreply.github.com> Date: Thu Jan 6 15:08:39 2022 +0100 Compile LZHAM with the solution. Fix missing detours files for sdklauncher commit a0b7bbf3661cc9b4d2d0cdefe9050a78f1c2bc67 Author: Amos <48657826+Mauler125@users.noreply.github.com> Date: Thu Jan 6 02:22:28 2022 +0100 Compile Microsoft Detours with the solution commit 9a3175fb6df047445e26ca3d4692e42f01cbabc8 Author: Amos <48657826+Mauler125@users.noreply.github.com> Date: Thu Jan 6 01:51:55 2022 +0100 Fix console input text reclaim to reflect latest ImGui changes commit 556894b3e3d81e41fa461321a749f50aa0eb169f Author: Amos <48657826+Mauler125@users.noreply.github.com> Date: Wed Jan 5 23:50:14 2022 +0100 Add connect command fix back Accidentally removed. commit 1612c439d2bb68fea29b4804b67c7de7a2aeaed7 Author: Amos <48657826+Mauler125@users.noreply.github.com> Date: Wed Jan 5 23:44:01 2022 +0100 Fix project filters commit 47fdd4211d3088a84aeb93e425288928d1b37e70 Author: Amos <48657826+Mauler125@users.noreply.github.com> Date: Wed Jan 5 23:43:51 2022 +0100 Fix for S3 For some reason the same byte pattern wasn't found in the miles dll for the S3 game, even though they where identical. Changed the byte patterns to search for the last 2 bytes of the instruction as well and made the conditional jmp instructions, unconditional for making sure mileswin64.dll doesn't close the process when a debugger is found. commit d52bd5eeec4f9f86422b3864446521c4ca46f02b Author: Amos <48657826+Mauler125@users.noreply.github.com> Date: Wed Jan 5 22:56:49 2022 +0100 Initial support for S1 commit 7c3994dfc280d8312632c9256f40a776c13158a4 Author: IcePixelx <41352111+PixieCore@users.noreply.github.com> Date: Wed Jan 5 19:23:53 2022 +0100 dedicated refuselist commit c486c2d59354b3672709013c24454017fdce5cf2 Author: Amos <48657826+Mauler125@users.noreply.github.com> Date: Wed Jan 5 02:07:37 2022 +0100 Portability to S2 completed CServer functions are evolving quite heavily over these seasons, so these need a bit of work commit fbcea85631fe9ee1b378a3fc6657908230b85403 Author: Amos <48657826+Mauler125@users.noreply.github.com> Date: Tue Jan 4 12:11:59 2022 +0100 Fix compiler error caused by merging commits from different branches commit 84e7729ca045c05e4add7f05d09d032833e39a7b Author: Amos <48657826+Mauler125@users.noreply.github.com> Date: Tue Jan 4 11:53:54 2022 +0100 Add client and debug utilities + cleanup commit 477152b35443246dace6f5b4deccd52ea1cc6e9c Author: Amos <48657826+Mauler125@users.noreply.github.com> Date: Fri Dec 31 03:45:48 2021 +0100 Fix compiler error commit 5f664d8e6ba9a2e0bd72c29c5f4ba5279e29e75a Author: Amos <48657826+Mauler125@users.noreply.github.com> Date: Fri Dec 31 03:41:33 2021 +0100 Create signatures for all used Dedicated functions commit 2c7ced128d8c48a5abf8fd64dbb06909dc632f35 Author: Amos <48657826+Mauler125@users.noreply.github.com> Date: Thu Dec 30 22:13:15 2021 +0100 Heavy dedicated cleanup * Since the material mode is set to '2', all of the render loops and shader loading functions are no longer called. These have all been removed. * Added description for patches that missed them * Traced root caller/cause for certain patches to skip even more unnecessary code and save more memory. commit 22c0b5c867664a2524c18d865dbc54ff067dda22 Author: Amos <48657826+Mauler125@users.noreply.github.com> Date: Thu Dec 30 17:20:41 2021 +0100 Dedicated server improvements commit 6d4f7e345f38872ce45751604b40871b969cec8f Author: Amos <48657826+Mauler125@users.noreply.github.com> Date: Thu Dec 30 02:47:42 2021 +0100 Fix a typo commit 39a8a8fd30612522a274e1474c9a66e5019aeea3 Author: Amos <48657826+Mauler125@users.noreply.github.com> Date: Thu Dec 30 02:36:43 2021 +0100 Implement patch to enable 'DrawAllOverlays()'. commit 83129e88f8a6033f8f4c13e3cac639097068cb3c Author: Amos <48657826+Mauler125@users.noreply.github.com> Date: Wed Dec 29 22:59:34 2021 +0100 Fix LLVM compiler error commit c48ed7f7a53a9985e3c2642db3639007d7c9129a Author: Amos <48657826+Mauler125@users.noreply.github.com> Date: Wed Dec 29 18:06:37 2021 +0100 Rename dedicated variables commit d1ba2bd56720a0776824a8e309d7d859704244bc Author: IcePixelx <41352111+PixieCore@users.noreply.github.com> Date: Wed Dec 29 15:35:48 2021 +0100 Fixed changelevel, needs more research tho. commit 46950125716c05171f25a12d8805811112e90551 Author: Amos <48657826+Mauler125@users.noreply.github.com> Date: Wed Dec 29 13:58:03 2021 +0100 Fix 'C_PropDoor' not spawning properly on the server commit 6a9a00735a9d4b8c415acc248c83e6e8d6dc2ff1 Author: Amos <48657826+Mauler125@users.noreply.github.com> Date: Wed Dec 29 13:57:16 2021 +0100 Rename hooked command callbacks commit b514f928a69a9c4ac1d3d1e5c662f93a1f0d131d Author: Amos <48657826+Mauler125@users.noreply.github.com> Date: Wed Dec 29 02:16:21 2021 +0100 Use a separate executable for dedicated server The dedicated server still has directx dll imports which will cause issues with ReShade or 3DMigoto, or trying to load it on a headless machine with no directx installed. The imports have to be cleared to avoid issues. The most convenient approach is to do this with a separate exe rather then patching it in runtime. commit bc8f9400d3911e360757059700a31510e329546d Author: Amos <48657826+Mauler125@users.noreply.github.com> Date: Wed Dec 29 00:18:56 2021 +0100 Fix collisions for headless dedicated server commit 0e36aa647ffb15ca4f8c76b0431f7c3a83741d80 Author: Amos <48657826+Mauler125@users.noreply.github.com> Date: Tue Dec 28 20:19:17 2021 +0100 Dedicated without ShaderApi and DirectX pre-alpha The instruction at 'CalcPropStaticFrustumCull' [0x14028F3B0 + 0x5C7] moves RSP + 0x70 into the R13 register. RSP + 0x70 seems to contain a pointer to collission data for that particular prop model. When running NoShaderApi() and passing the dedicated server the '-noshaderapi' command line parameter, RSP + 0x70 will be a nullptr. This has to be fixed to have prop static collissions on the server.
482 lines
16 KiB
C++
482 lines
16 KiB
C++
// File: lzham_lzcomp_internal.h
|
|
// See Copyright Notice and license at the end of include/lzham.h
|
|
#pragma once
|
|
#include "../include/lzham_match_accel.h"
|
|
#include "../include/lzham_symbol_codec.h"
|
|
#include "../include/lzham_lzbase.h"
|
|
|
|
namespace lzham
|
|
{
|
|
typedef lzham::vector<uint8> byte_vec;
|
|
|
|
const uint cMaxParseGraphNodes = 3072;
|
|
const uint cMaxParseThreads = 8;
|
|
|
|
enum compression_level
|
|
{
|
|
cCompressionLevelFastest,
|
|
cCompressionLevelFaster,
|
|
cCompressionLevelDefault,
|
|
cCompressionLevelBetter,
|
|
cCompressionLevelUber,
|
|
|
|
cCompressionLevelCount
|
|
};
|
|
|
|
struct comp_settings
|
|
{
|
|
uint m_fast_bytes;
|
|
bool m_fast_adaptive_huffman_updating;
|
|
bool m_use_polar_codes;
|
|
uint m_match_accel_max_matches_per_probe;
|
|
uint m_match_accel_max_probes;
|
|
};
|
|
|
|
class lzcompressor : public CLZBase
|
|
{
|
|
public:
|
|
lzcompressor();
|
|
|
|
struct init_params
|
|
{
|
|
enum
|
|
{
|
|
cMinDictSizeLog2 = CLZBase::cMinDictSizeLog2,
|
|
cMaxDictSizeLog2 = CLZBase::cMaxDictSizeLog2,
|
|
cDefaultBlockSize = 1024U*512U
|
|
};
|
|
|
|
init_params() :
|
|
m_pTask_pool(NULL),
|
|
m_max_helper_threads(0),
|
|
m_compression_level(cCompressionLevelDefault),
|
|
m_dict_size_log2(22),
|
|
m_block_size(cDefaultBlockSize),
|
|
m_num_cachelines(0),
|
|
m_cacheline_size(0),
|
|
m_lzham_compress_flags(0),
|
|
m_pSeed_bytes(0),
|
|
m_num_seed_bytes(0)
|
|
{
|
|
}
|
|
|
|
task_pool* m_pTask_pool;
|
|
uint m_max_helper_threads;
|
|
|
|
compression_level m_compression_level;
|
|
uint m_dict_size_log2;
|
|
|
|
uint m_block_size;
|
|
|
|
uint m_num_cachelines;
|
|
uint m_cacheline_size;
|
|
|
|
uint m_lzham_compress_flags;
|
|
|
|
const void *m_pSeed_bytes;
|
|
uint m_num_seed_bytes;
|
|
};
|
|
|
|
bool init(const init_params& params);
|
|
void clear();
|
|
|
|
// sync, or sync+dictionary flush
|
|
bool flush(lzham_flush_t flush_type);
|
|
|
|
bool reset();
|
|
|
|
bool put_bytes(const void* pBuf, uint buf_len);
|
|
|
|
const byte_vec& get_compressed_data() const { return m_comp_buf; }
|
|
byte_vec& get_compressed_data() { return m_comp_buf; }
|
|
|
|
uint32 get_src_adler32() const { return m_src_adler32; }
|
|
uint32 get_src_crc32() const { return m_src_crc32; }
|
|
|
|
private:
|
|
class state;
|
|
|
|
enum
|
|
{
|
|
cLitComplexity = 1,
|
|
cRep0Complexity = 2,
|
|
cRep3Complexity = 5,
|
|
|
|
cLongMatchComplexity = 6,
|
|
cLongMatchComplexityLenThresh = 9,
|
|
|
|
cShortMatchComplexity = 7
|
|
};
|
|
|
|
struct lzdecision
|
|
{
|
|
int m_pos; // dict position where decision was evaluated
|
|
int m_len; // 0 if literal, 1+ if match
|
|
int m_dist; // <0 if match rep, else >=1 is match dist
|
|
|
|
inline lzdecision() { }
|
|
inline lzdecision(int pos, int len, int dist) : m_pos(pos), m_len(len), m_dist(dist) { }
|
|
|
|
inline void init(int pos, int len, int dist) { m_pos = pos; m_len = len; m_dist = dist; }
|
|
|
|
inline bool is_lit() const { return !m_len; }
|
|
inline bool is_match() const { return m_len > 0; } // may be a rep or full match
|
|
inline bool is_full_match() const { return (m_len > 0) && (m_dist >= 1); }
|
|
inline uint get_len() const { return math::maximum<uint>(m_len, 1); }
|
|
inline bool is_rep() const { return m_dist < 0; }
|
|
inline bool is_rep0() const { return m_dist == -1; }
|
|
|
|
uint get_match_dist(const state& s) const;
|
|
|
|
inline uint get_complexity() const
|
|
{
|
|
if (is_lit())
|
|
return cLitComplexity;
|
|
else if (is_rep())
|
|
{
|
|
LZHAM_ASSUME(cRep0Complexity == 2);
|
|
return 1 + -m_dist; // 2, 3, 4, or 5
|
|
}
|
|
else if (get_len() >= cLongMatchComplexityLenThresh)
|
|
return cLongMatchComplexity;
|
|
else
|
|
return cShortMatchComplexity;
|
|
}
|
|
|
|
inline uint get_min_codable_len() const
|
|
{
|
|
if (is_lit() || is_rep0())
|
|
return 1;
|
|
else
|
|
return CLZBase::cMinMatchLen;
|
|
}
|
|
};
|
|
|
|
struct lzpriced_decision : lzdecision
|
|
{
|
|
lzpriced_decision() { }
|
|
|
|
inline lzpriced_decision(int pos, int len, int dist) : lzdecision(pos, len, dist) { }
|
|
inline lzpriced_decision(int pos, int len, int dist, bit_cost_t cost) : lzdecision(pos, len, dist), m_cost(cost) { }
|
|
|
|
inline void init(int pos, int len, int dist, bit_cost_t cost) { lzdecision::init(pos, len, dist); m_cost = cost; }
|
|
|
|
inline bit_cost_t get_cost() const { return m_cost; }
|
|
|
|
bit_cost_t m_cost;
|
|
};
|
|
|
|
struct state_base
|
|
{
|
|
uint m_cur_ofs;
|
|
uint m_cur_state;
|
|
uint m_match_hist[CLZBase::cMatchHistSize];
|
|
|
|
inline bool operator== (const state_base &rhs) const
|
|
{
|
|
if (m_cur_state != rhs.m_cur_state)
|
|
return false;
|
|
for (uint i = 0; i < CLZBase::cMatchHistSize; i++)
|
|
if (m_match_hist[i] != rhs.m_match_hist[i])
|
|
return false;
|
|
return true;
|
|
}
|
|
|
|
void partial_advance(const lzdecision& lzdec);
|
|
|
|
inline void save_partial_state(state_base& dst)
|
|
{
|
|
dst.m_cur_ofs = m_cur_ofs;
|
|
dst.m_cur_state = m_cur_state;
|
|
memcpy(dst.m_match_hist, m_match_hist, sizeof(m_match_hist));
|
|
}
|
|
|
|
inline void restore_partial_state(const state_base& src)
|
|
{
|
|
m_cur_ofs = src.m_cur_ofs;
|
|
m_cur_state = src.m_cur_state;
|
|
memcpy(m_match_hist, src.m_match_hist, sizeof(m_match_hist));
|
|
}
|
|
};
|
|
|
|
class state : public state_base
|
|
{
|
|
public:
|
|
state();
|
|
|
|
void clear();
|
|
|
|
bool init(CLZBase& lzbase, bool fast_adaptive_huffman_updating, bool use_polar_codes);
|
|
void reset();
|
|
|
|
bit_cost_t get_cost(CLZBase& lzbase, const search_accelerator& dict, const lzdecision& lzdec) const;
|
|
bit_cost_t get_len2_match_cost(CLZBase& lzbase, uint dict_pos, uint len2_match_dist, uint is_match_model_index);
|
|
bit_cost_t get_lit_cost(const search_accelerator& dict, uint dict_pos, uint lit_pred0, uint is_match_model_index) const;
|
|
|
|
// Returns actual cost.
|
|
void get_rep_match_costs(uint dict_pos, bit_cost_t *pBitcosts, uint match_hist_index, int min_len, int max_len, uint is_match_model_index) const;
|
|
void get_full_match_costs(CLZBase& lzbase, uint dict_pos, bit_cost_t *pBitcosts, uint match_dist, int min_len, int max_len, uint is_match_model_index) const;
|
|
|
|
bit_cost_t update_stats(CLZBase& lzbase, const search_accelerator& dict, const lzdecision& lzdec);
|
|
|
|
bool advance(CLZBase& lzbase, const search_accelerator& dict, const lzdecision& lzdec);
|
|
bool encode(symbol_codec& codec, CLZBase& lzbase, const search_accelerator& dict, const lzdecision& lzdec);
|
|
|
|
void print(symbol_codec& codec, CLZBase& lzbase, const search_accelerator& dict, const lzdecision& lzdec);
|
|
|
|
bool encode_eob(symbol_codec& codec, const search_accelerator& dict, uint dict_pos);
|
|
bool encode_reset_state_partial(symbol_codec& codec, const search_accelerator& dict, uint dict_pos);
|
|
|
|
void update_match_hist(uint match_dist);
|
|
int find_match_dist(uint match_hist) const;
|
|
|
|
void reset_state_partial();
|
|
void start_of_block(const search_accelerator& dict, uint cur_ofs, uint block_index);
|
|
|
|
void reset_update_rate();
|
|
|
|
uint get_pred_char(const search_accelerator& dict, int pos, int backward_ofs) const;
|
|
|
|
inline bool will_reference_last_match(const lzdecision& lzdec) const
|
|
{
|
|
return (!lzdec.is_match()) && (m_cur_state >= CLZBase::cNumLitStates);
|
|
}
|
|
|
|
uint m_block_start_dict_ofs;
|
|
|
|
adaptive_bit_model m_is_match_model[CLZBase::cNumStates * (1 << CLZBase::cNumIsMatchContextBits)];
|
|
|
|
adaptive_bit_model m_is_rep_model[CLZBase::cNumStates];
|
|
adaptive_bit_model m_is_rep0_model[CLZBase::cNumStates];
|
|
adaptive_bit_model m_is_rep0_single_byte_model[CLZBase::cNumStates];
|
|
adaptive_bit_model m_is_rep1_model[CLZBase::cNumStates];
|
|
adaptive_bit_model m_is_rep2_model[CLZBase::cNumStates];
|
|
|
|
#if LZHAM_USE_ALL_ARITHMETIC_CODING
|
|
typedef adaptive_arith_data_model sym_data_model;
|
|
#else
|
|
typedef quasi_adaptive_huffman_data_model sym_data_model;
|
|
#endif
|
|
|
|
sym_data_model m_lit_table[1 << CLZBase::cNumLitPredBits];
|
|
sym_data_model m_delta_lit_table[1 << CLZBase::cNumDeltaLitPredBits];
|
|
|
|
sym_data_model m_main_table;
|
|
sym_data_model m_rep_len_table[2];
|
|
sym_data_model m_large_len_table[2];
|
|
sym_data_model m_dist_lsb_table;
|
|
};
|
|
|
|
class tracked_stat
|
|
{
|
|
public:
|
|
tracked_stat() { clear(); }
|
|
|
|
void clear() { m_num = 0; m_total = 0.0f; m_total2 = 0.0f; m_min_val = 9e+99; m_max_val = -9e+99; }
|
|
|
|
void update(double val) { m_num++; m_total += val; m_total2 += val * val; m_min_val = LZHAM_MIN(m_min_val, val); m_max_val = LZHAM_MAX(m_max_val, val); }
|
|
|
|
tracked_stat &operator += (double val) { update(val); return *this; }
|
|
operator double() const { return m_total; }
|
|
|
|
uint64 get_number_of_values() { return m_num; }
|
|
uint32 get_number_of_values32() { return static_cast<uint32>(LZHAM_MIN(UINT_MAX, m_num)); }
|
|
double get_total() const { return m_total; }
|
|
double get_average() const { return m_num ? m_total / m_num : 0.0f; };
|
|
double get_std_dev() const { return m_num ? sqrt( m_num * m_total2 - m_total * m_total ) / m_num: 0.0f; }
|
|
double get_min_val() const { return m_num ? m_min_val : 0.0f; }
|
|
double get_max_val() const { return m_num ? m_max_val : 0.0f; }
|
|
|
|
private:
|
|
uint64 m_num;
|
|
double m_total;
|
|
double m_total2;
|
|
double m_min_val;
|
|
double m_max_val;
|
|
};
|
|
|
|
struct coding_stats
|
|
{
|
|
coding_stats() { clear(); }
|
|
|
|
void clear();
|
|
|
|
void update(const lzdecision& lzdec, const state& cur_state, const search_accelerator& dict, bit_cost_t cost);
|
|
void print();
|
|
|
|
uint m_total_bytes;
|
|
uint m_total_contexts;
|
|
double m_total_cost;
|
|
|
|
tracked_stat m_context_stats;
|
|
|
|
double m_total_match_bits_cost;
|
|
double m_worst_match_bits_cost;
|
|
double m_total_is_match0_bits_cost;
|
|
double m_total_is_match1_bits_cost;
|
|
|
|
uint m_total_truncated_matches;
|
|
uint m_match_truncation_len_hist[CLZBase::cMaxMatchLen + 1];
|
|
uint m_match_truncation_hist[CLZBase::cMaxMatchLen + 1];
|
|
uint m_match_type_truncation_hist[CLZBase::cNumStates][5];
|
|
uint m_match_type_was_not_truncated_hist[CLZBase::cNumStates][5];
|
|
|
|
uint m_total_nonmatches;
|
|
uint m_total_matches;
|
|
|
|
tracked_stat m_lit_stats;
|
|
tracked_stat m_delta_lit_stats;
|
|
|
|
tracked_stat m_rep_stats[CLZBase::cMatchHistSize];
|
|
tracked_stat m_rep0_len1_stats;
|
|
tracked_stat m_rep0_len2_plus_stats;
|
|
|
|
tracked_stat m_full_match_stats[cMaxMatchLen + 1];
|
|
|
|
uint m_total_far_len2_matches;
|
|
uint m_total_near_len2_matches;
|
|
|
|
uint m_total_update_rate_resets;
|
|
|
|
uint m_max_len2_dist;
|
|
};
|
|
|
|
init_params m_params;
|
|
comp_settings m_settings;
|
|
|
|
int64 m_src_size;
|
|
uint32 m_src_adler32;
|
|
uint32 m_src_crc32;
|
|
|
|
search_accelerator m_accel;
|
|
|
|
symbol_codec m_codec;
|
|
|
|
coding_stats m_stats;
|
|
|
|
byte_vec m_block_buf;
|
|
byte_vec m_comp_buf;
|
|
|
|
uint m_step;
|
|
|
|
uint m_block_start_dict_ofs;
|
|
|
|
uint m_block_index;
|
|
|
|
bool m_finished;
|
|
bool m_use_task_pool;
|
|
|
|
struct node_state
|
|
{
|
|
LZHAM_FORCE_INLINE void clear()
|
|
{
|
|
m_total_cost = cBitCostMax; //math::cNearlyInfinite;
|
|
m_total_complexity = UINT_MAX;
|
|
}
|
|
|
|
// the lzdecision that led from parent to this node_state
|
|
lzdecision m_lzdec;
|
|
|
|
// This is either the state of the parent node (optimal parsing), or the state of the child node (extreme parsing).
|
|
state::state_base m_saved_state;
|
|
|
|
// Total cost to arrive at this node state.
|
|
bit_cost_t m_total_cost;
|
|
uint m_total_complexity;
|
|
|
|
// Parent node index.
|
|
int16 m_parent_index;
|
|
|
|
// Parent node state index (only valid when extreme parsing).
|
|
int8 m_parent_state_index;
|
|
};
|
|
|
|
struct node
|
|
{
|
|
LZHAM_FORCE_INLINE void clear()
|
|
{
|
|
m_num_node_states = 0;
|
|
}
|
|
|
|
uint m_num_node_states;
|
|
enum { cMaxNodeStates = 4 };
|
|
node_state m_node_states[cMaxNodeStates];
|
|
|
|
void add_state(int parent_index, int parent_state_index, const lzdecision &lzdec, state &parent_state, bit_cost_t total_cost, uint total_complexity);
|
|
};
|
|
|
|
state m_start_of_block_state; // state at start of block
|
|
|
|
state m_state; // main thread's current coding state
|
|
|
|
struct raw_parse_thread_state
|
|
{
|
|
uint m_start_ofs;
|
|
uint m_bytes_to_match;
|
|
|
|
state m_initial_state;
|
|
|
|
node m_nodes[cMaxParseGraphNodes + 1];
|
|
|
|
lzham::vector<lzdecision> m_best_decisions;
|
|
bool m_emit_decisions_backwards;
|
|
|
|
lzham::vector<lzpriced_decision> m_temp_decisions;
|
|
|
|
uint m_max_greedy_decisions;
|
|
uint m_greedy_parse_total_bytes_coded;
|
|
bool m_greedy_parse_gave_up;
|
|
|
|
bool m_issue_reset_state_partial;
|
|
bool m_failed;
|
|
};
|
|
|
|
struct parse_thread_state : raw_parse_thread_state
|
|
{
|
|
uint8 m_unused_alignment_array[128 - (sizeof(raw_parse_thread_state) & 127)];
|
|
};
|
|
|
|
uint m_num_parse_threads;
|
|
parse_thread_state m_parse_thread_state[cMaxParseThreads + 1]; // +1 extra for the greedy parser thread (only used for delta compression)
|
|
|
|
volatile atomic32_t m_parse_jobs_remaining;
|
|
semaphore m_parse_jobs_complete;
|
|
|
|
enum { cMaxBlockHistorySize = 6, cBlockHistoryCompRatioScale = 1000U };
|
|
struct block_history
|
|
{
|
|
uint m_comp_size;
|
|
uint m_src_size;
|
|
uint m_ratio;
|
|
bool m_raw_block;
|
|
bool m_reset_update_rate;
|
|
};
|
|
block_history m_block_history[cMaxBlockHistorySize];
|
|
uint m_block_history_size;
|
|
uint m_block_history_next;
|
|
void update_block_history(uint comp_size, uint src_size, uint ratio, bool raw_block, bool reset_update_rate);
|
|
uint get_recent_block_ratio();
|
|
uint get_min_block_ratio();
|
|
uint get_max_block_ratio();
|
|
uint get_total_recent_reset_update_rate();
|
|
|
|
bool send_zlib_header();
|
|
bool init_seed_bytes();
|
|
bool send_final_block();
|
|
bool send_configuration();
|
|
bool extreme_parse(parse_thread_state &parse_state);
|
|
bool optimal_parse(parse_thread_state &parse_state);
|
|
int enumerate_lz_decisions(uint ofs, const state& cur_state, lzham::vector<lzpriced_decision>& decisions, uint min_match_len, uint max_match_len);
|
|
bool greedy_parse(parse_thread_state &parse_state);
|
|
void parse_job_callback(uint64 data, void* pData_ptr);
|
|
bool compress_block(const void* pBuf, uint buf_len);
|
|
bool compress_block_internal(const void* pBuf, uint buf_len);
|
|
bool code_decision(lzdecision lzdec, uint& cur_ofs, uint& bytes_to_match);
|
|
bool send_sync_block(lzham_flush_t flush_type);
|
|
};
|
|
|
|
} // namespace lzham
|
|
|
|
|
|
|