diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index f03153f3..cc89cd1f 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -5199,6 +5199,20 @@ const char* Worker::GetFailureString( Worker::Failure failure ) return s_failureReasons[(int)failure]; } +void Worker::PackFrameImage( char*& buf, size_t& bufsz, const char* image, uint16_t w, uint16_t h, uint32_t& csz ) const +{ + const auto insz = size_t( w ) * size_t( h ) / 2; + const auto maxout = LZ4_COMPRESSBOUND( insz ); + if( bufsz < maxout ) + { + bufsz = maxout; + delete[] buf; + buf = new char[maxout]; + } + const auto outsz = LZ4_compress_default( image, buf, insz, maxout ); + csz = uint32_t( outsz ); +} + const char* Worker::PackFrameImage( const char* image, uint16_t w, uint16_t h, uint32_t& csz ) { const auto insz = size_t( w ) * size_t( h ) / 2; diff --git a/server/TracyWorker.hpp b/server/TracyWorker.hpp index 83b49a18..81ca893c 100644 --- a/server/TracyWorker.hpp +++ b/server/TracyWorker.hpp @@ -393,6 +393,7 @@ public: const FailureData& GetFailureData() const { return m_failureData; } static const char* GetFailureString( Failure failure ); + void PackFrameImage( char*& buf, size_t& bufsz, const char* image, uint16_t w, uint16_t h, uint32_t& csz ) const; const char* PackFrameImage( const char* image, uint16_t w, uint16_t h, uint32_t& csz ); const char* UnpackFrameImage( const FrameImage& image );