@@ -794,35 +794,45 @@ void OrochiUtils::launch2D( oroFunction func, int nx, int ny, const void** args,
794794 OROASSERT ( e == oroSuccess, 0 );
795795}
796796
797- void OrochiUtils::DecompressPrecompiled (std::vector<unsigned char >& out, const unsigned char * compressedInput, size_t compressedInput_sizeByte, size_t uncompressed_sizeByte )
797+ void OrochiUtils::HandlePrecompiled (std::vector<unsigned char >& out, const CompressedBuffer& buffer )
798798{
799- if ( uncompressed_sizeByte > 0 ) // if the input data is actually compressed
800- {
801799 #ifdef ORO_LINK_ZSTD
802- out.assign (uncompressed_sizeByte ,0 );
800+ out.assign (buffer. uncompressedSize ,0 );
803801
804802 size_t decompressedSize = ZSTD_decompress (
805803 out.data (), // final uncompressed buffer
806804 out.size (), // final size
807- compressedInput , // compressed buffer
808- compressedInput_sizeByte // compressed buffer - size
805+ buffer. data , // compressed buffer
806+ buffer. size // compressed buffer - size
809807 );
810808
811- if ( decompressedSize != uncompressed_sizeByte )
809+ if ( decompressedSize != buffer. uncompressedSize )
812810 throw std::runtime_error ( " ERROR: ZSTD_decompress FAILED." );
813811 #else
814-
815812 throw std::runtime_error ( " ERROR: ZSTD is not part of this build." );
816-
817813 #endif
814+ return ;
815+ }
818816
819- }
820- else // if the input data is NOT compressed, buypass this decompress process.
821- {
822- out = std::vector<unsigned char >(compressedInput, compressedInput + compressedInput_sizeByte );
823- }
817+
818+ void OrochiUtils::HandlePrecompiled (std::vector<unsigned char >& out, const RawBuffer& buffer)
819+ {
820+ out = std::vector<unsigned char >(buffer.data , buffer.data + buffer.size );
824821 return ;
825822}
826823
827824
825+ void OrochiUtils::HandlePrecompiled (std::vector<unsigned char >& out, const unsigned char * rawData, size_t rawData_sizeByte, std::optional<size_t > uncompressed_sizeByte)
826+ {
827+ if (uncompressed_sizeByte.has_value ()) {
828+ // if the input buffer is compressed :
829+ CompressedBuffer buffer{ rawData, rawData_sizeByte, uncompressed_sizeByte.value () };
830+ HandlePrecompiled (out, buffer );
831+ } else {
832+ // if the input buffer is not compressed
833+ RawBuffer buffer{ rawData, rawData_sizeByte };
834+ HandlePrecompiled (out, buffer );
835+ }
836+ }
837+
828838
0 commit comments