mirror of
https://github.com/wolfpld/tracy.git
synced 2026-06-08 08:33:48 +00:00
Use zstd dict for packing/unpacking frame images.
This only affects run-time memory usage and needs an offline calculation of the dictionary. Results vary depending on similarity of image blocks. agora 34.96 MB -> 28.21 MB agora2 40.75 MB -> 34.14 MB android-vk 36.21 MB -> 18.44 MB astar3 44.72 MB -> 43.38 MB clipper1 134.36 MB -> 52.16 MB fi 50.82 MB -> 40.79 MB fi-big 537.74 MB -> 469.54 MB test 23.26 MB -> 1.87 MB
This commit is contained in:
@@ -11,6 +11,7 @@ TextureCompression::TextureCompression()
|
||||
, m_bufSize( 0 )
|
||||
, m_cctx( ZSTD_createCCtx() )
|
||||
, m_dctx( ZSTD_createDCtx() )
|
||||
, m_dict( nullptr )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -19,6 +20,7 @@ TextureCompression::~TextureCompression()
|
||||
delete[] m_buf;
|
||||
ZSTD_freeCCtx( m_cctx );
|
||||
ZSTD_freeDCtx( m_dctx );
|
||||
ZSTD_freeDDict( m_dict );
|
||||
}
|
||||
|
||||
uint32_t TextureCompression::Pack( struct ZSTD_CCtx_s* ctx, char*& buf, size_t& bufsz, const char* image, uint32_t inBytes )
|
||||
@@ -67,7 +69,14 @@ const char* TextureCompression::Unpack( const FrameImage& image )
|
||||
m_buf = new char[outsz];
|
||||
}
|
||||
assert( m_dctx );
|
||||
ZSTD_decompressDCtx( m_dctx, m_buf, outsz, image.ptr, image.csz );
|
||||
if( m_dict )
|
||||
{
|
||||
ZSTD_decompress_usingDDict( m_dctx, m_buf, outsz, image.ptr, image.csz, m_dict );
|
||||
}
|
||||
else
|
||||
{
|
||||
ZSTD_decompressDCtx( m_dctx, m_buf, outsz, image.ptr, image.csz );
|
||||
}
|
||||
return m_buf;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user