diff --git a/bpsf/ksal-bpsf-zstd.patch b/bpsf/ksal-bpsf-zstd.patch index 7d72a18d6299b5225fa6819b8dae48831ad49c32..308f267cda56a1c8c904893933f3827f22488449 100644 --- a/bpsf/ksal-bpsf-zstd.patch +++ b/bpsf/ksal-bpsf-zstd.patch @@ -1,9 +1,9 @@ diff --git a/lib/bpsf.c b/lib/bpsf.c new file mode 100644 -index 00000000..d3f11e79 +index 00000000..53f1279e --- /dev/null +++ b/lib/bpsf.c -@@ -0,0 +1,345 @@ +@@ -0,0 +1,362 @@ +/* +* 版权所有 (c) 华为技术有限公司 2025 +*/ @@ -60,7 +60,7 @@ index 00000000..d3f11e79 + return HUF_build_table(dst, dst_capacity, src, srcSize, CTable); +} + -+size_t BPSF_loadHUFTable(const BYTE *src, HUF_DTable *dtable) { ++size_t BPSF_loadHUFTable(const BYTE *src, HUF_DTable *dtable, size_t dtable_size) { + return HUF_load_table(src, dtable); +} + @@ -251,11 +251,15 @@ index 00000000..d3f11e79 + FSE_READMOVE0(ml_state, 0, ml_m_bits); + + for (int i_seq = 0; i_seq < nbSeq; ++i_seq) { -+ ZSTD_seqSymbol ll_item = ll_table[ll_state]; -+ ZSTD_seqSymbol of_item = of_table[of_state]; -+ ZSTD_seqSymbol ml_item = ml_table[ml_state]; ++ // ZSTD_seqSymbol ll_item = ll_table[ll_state]; ++ // ZSTD_seqSymbol of_item = of_table[of_state]; ++ // ZSTD_seqSymbol ml_item = ml_table[ml_state]; + S32 of, ml, ll; ++ ZSTD_seqSymbol ll_item, of_item, ml_item; + ++ ZSTD_memcpy((void*)&ll_item, (void*)(ll_table+ll_state), sizeof(ZSTD_seqSymbol)); ++ ZSTD_memcpy((void*)&of_item, (void*)(of_table+of_state), sizeof(ZSTD_seqSymbol)); ++ ZSTD_memcpy((void*)&ml_item, (void*)(ml_table+ml_state), sizeof(ZSTD_seqSymbol)); + { + int8_t c = trailbit_u64(data); + p_src -= (c>>3); @@ -349,12 +353,25 @@ index 00000000..d3f11e79 + *reconstructed_size = p_dst - p_dst_start; + return 0; +} ++ ++void BPSF_hashReset(ZSTD_CCtx *cCtx) { ++ XXH64_reset(&cCtx->xxhState, 0); ++} ++ ++void BPSF_hashUpdate(ZSTD_CCtx *cCtx, const uint8_t *src, size_t srcSize) { ++ XXH64_update(&cCtx->xxhState, (const void*) src, srcSize); ++} ++ ++uint16_t BPSF_hashDigest(ZSTD_CCtx *cCtx) { ++ U16 const checksum = (U16) XXH64_digest(&cCtx->xxhState); ++ return checksum; ++} diff --git a/lib/bpsf.h b/lib/bpsf.h new file mode 100644 -index 00000000..b2c2e84f +index 00000000..48a12ec6 --- /dev/null +++ b/lib/bpsf.h -@@ -0,0 +1,58 @@ +@@ -0,0 +1,63 @@ +/* +* 版权所有 (c) 华为技术有限公司 2025 +*/ @@ -386,7 +403,7 @@ index 00000000..b2c2e84f +// Huffman +size_t BPSF_build_HUFTable(uint8_t* dst, size_t dst_capacity, const uint8_t* src, size_t srcSize, HUF_CElt* CTable); + -+size_t BPSF_loadHUFTable(const uint8_t* src, HUF_DTable* dtable); ++size_t BPSF_loadHUFTable(const uint8_t* src, HUF_DTable* dtable, size_t dtable_size); + +// FSE encode +ZSTD_symbolEncodingTypeStats_t BPSF_buildSeqsStats(const seqStore_t *seqStorePtr, size_t nbSeq, const ZSTD_fseCTables_t *prevEntropy, @@ -411,6 +428,11 @@ index 00000000..b2c2e84f +size_t BPSF_decodeSeqs_and_reconstruct(ZSTD_DCtx* dctx, const uint8_t* seqStart, size_t seqSize, + int nbSeq, uint8_t *p_dst, size_t max_dst_len, + size_t dict_size, size_t *reconstructed_size); ++void BPSF_hashReset(ZSTD_CCtx *cCtx); ++ ++void BPSF_hashUpdate(ZSTD_CCtx *cCtx, const uint8_t *src, size_t srcSize); ++ ++uint16_t BPSF_hashDigest(ZSTD_CCtx *cCtx); + +#endif // BPSF_BPSF_H \ No newline at end of file diff --git a/bpsf/libksal_bpsf_zstd_so_create.sh b/bpsf/libksal_bpsf_zstd_so_create.sh index 6200647c3b637542150136ff878db8f94b54dabe..ac5251f6faa880f769478abd3e8faab5d9da7665 100644 --- a/bpsf/libksal_bpsf_zstd_so_create.sh +++ b/bpsf/libksal_bpsf_zstd_so_create.sh @@ -13,6 +13,18 @@ else echo "[ --- release build in progress ---]" fi +files=$(ls libksal-release*.rpm 2>/dev/null) + +if [ -z "$files" ]; then + echo "libksal-release rpm package not foun, please check" + exit 1 +else + filename=$(echo $files | awk '{print $1}') + version=$(echo $filename | sed -r 's/.*libksal-release-([0-9.]+)\..*/\1/') + export VERSION=$version + echo "detect version: $VERSION" +fi + packagename="ksal_bpsf" packagever=$(cat ./ksal_bpsf.spec | grep 'Version:' | head -1 | awk '{print $2}') @@ -25,16 +37,16 @@ include_file=./usr/include/ksal/ksal_bpsf.h include_log_file=./usr/include/ksal/bpsf_log.h if [ "$version_type" = "debug" ]; then - rpm2cpio libksal-release-1.11.0.oe1.aarch64.rpm | cpio -idv $static_library_debug - rpm2cpio libksal-release-1.11.0.oe1.aarch64.rpm | cpio -idv $include_file - rpm2cpio libksal-release-1.11.0.oe1.aarch64.rpm | cpio -idv $include_log_file + rpm2cpio $files | cpio -idv $static_library_debug + rpm2cpio $files | cpio -idv $include_file + rpm2cpio $files | cpio -idv $include_log_file cp $static_library_debug ./ cp $include_file ./ cp $include_log_file ./ else - rpm2cpio libksal-release-1.11.0.oe1.aarch64.rpm | cpio -idv $static_library - rpm2cpio libksal-release-1.11.0.oe1.aarch64.rpm | cpio -idv $include_file - rpm2cpio libksal-release-1.11.0.oe1.aarch64.rpm | cpio -idv $include_log_file + rpm2cpio $files | cpio -idv $static_library + rpm2cpio $files | cpio -idv $include_file + rpm2cpio $files | cpio -idv $include_log_file cp $static_library ./ cp $include_file ./ cp $include_log_file ./ diff --git a/lib/bpsf.c b/lib/bpsf.c index d3f11e799dbad84bdc4eace230974c8bfa1c8134..96798830f1b2cfc28f9b32c57ff63745f9dc5468 100644 --- a/lib/bpsf.c +++ b/lib/bpsf.c @@ -245,11 +245,15 @@ size_t BPSF_decodeSeqs_and_reconstruct(ZSTD_DCtx* dctx, const uint8_t* seqStart, FSE_READMOVE0(ml_state, 0, ml_m_bits); for (int i_seq = 0; i_seq < nbSeq; ++i_seq) { - ZSTD_seqSymbol ll_item = ll_table[ll_state]; - ZSTD_seqSymbol of_item = of_table[of_state]; - ZSTD_seqSymbol ml_item = ml_table[ml_state]; + // ZSTD_seqSymbol ll_item = ll_table[ll_state]; + // ZSTD_seqSymbol of_item = of_table[of_state]; + // ZSTD_seqSymbol ml_item = ml_table[ml_state]; S32 of, ml, ll; + ZSTD_seqSymbol ll_item, of_item, ml_item; + ZSTD_memcpy((void*)&ll_item, (void*)(ll_table+ll_state), sizeof(ZSTD_seqSymbol)); + ZSTD_memcpy((void*)&of_item, (void*)(of_table+of_state), sizeof(ZSTD_seqSymbol)); + ZSTD_memcpy((void*)&ml_item, (void*)(ml_table+ml_state), sizeof(ZSTD_seqSymbol)); { int8_t c = trailbit_u64(data); p_src -= (c>>3); @@ -343,3 +347,16 @@ size_t BPSF_decodeSeqs_and_reconstruct(ZSTD_DCtx* dctx, const uint8_t* seqStart, *reconstructed_size = p_dst - p_dst_start; return 0; } + +void BPSF_hashReset(ZSTD_CCtx *cCtx) { + XXH64_reset(&cCtx->xxhState, 0); +} + +void BPSF_hashUpdate(ZSTD_CCtx *cCtx, const uint8_t *src, size_t srcSize) { + XXH64_update(&cCtx->xxhState, (const void*) src, srcSize); +} + +uint16_t BPSF_hashDigest(ZSTD_CCtx *cCtx) { + U16 const checksum = (U16) XXH64_digest(&cCtx->xxhState); + return checksum; +} diff --git a/lib/bpsf.h b/lib/bpsf.h index b2c2e84fb5dce0691973454c1c93b8248685d22f..f4a86bf0ff992b67d02f9571f9120fa3a1567d7b 100644 --- a/lib/bpsf.h +++ b/lib/bpsf.h @@ -29,7 +29,7 @@ U32 BPSF_update_window(ZSTD_window_t* window, const uint8_t* src, size_t srcSize // Huffman size_t BPSF_build_HUFTable(uint8_t* dst, size_t dst_capacity, const uint8_t* src, size_t srcSize, HUF_CElt* CTable); -size_t BPSF_loadHUFTable(const uint8_t* src, HUF_DTable* dtable); +size_t BPSF_loadHUFTable(const uint8_t* src, HUF_DTable* dtable, size_t dtable_size); // FSE encode ZSTD_symbolEncodingTypeStats_t BPSF_buildSeqsStats(const seqStore_t *seqStorePtr, size_t nbSeq, const ZSTD_fseCTables_t *prevEntropy, @@ -54,5 +54,10 @@ void ZSTD_setLiteralDict(ZSTD_DCtx* dctx, const uint8_t* litPtr, size_t litSize) size_t BPSF_decodeSeqs_and_reconstruct(ZSTD_DCtx* dctx, const uint8_t* seqStart, size_t seqSize, int nbSeq, uint8_t *p_dst, size_t max_dst_len, size_t dict_size, size_t *reconstructed_size); +void BPSF_hashReset(ZSTD_CCtx *cCtx); + +void BPSF_hashUpdate(ZSTD_CCtx *cCtx, const uint8_t *src, size srcSize); + +uint16_t BPSF_hashDigest(ZSTD_CCtx *cCtx); #endif // BPSF_BPSF_H \ No newline at end of file