From 2b5ea52b7c70f99ecc532fe0e92cbf3e18c33dba Mon Sep 17 00:00:00 2001 From: Berlin_Peng Date: Thu, 28 Aug 2025 14:57:50 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E8=B0=83=E6=95=B4bpsf=E7=9A=84patch?= =?UTF-8?q?=E9=83=A8=E5=88=86=202.=20=E5=A2=9E=E5=8A=A0=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=E5=AF=B9ksal=E7=9A=84=E5=8C=85=E7=9A=84=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E6=A3=80=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bpsf/ksal-bpsf-zstd.patch | 40 ++++++++++++++++++++++------- bpsf/libksal_bpsf_zstd_so_create.sh | 24 ++++++++++++----- lib/bpsf.c | 23 ++++++++++++++--- lib/bpsf.h | 7 ++++- 4 files changed, 75 insertions(+), 19 deletions(-) diff --git a/bpsf/ksal-bpsf-zstd.patch b/bpsf/ksal-bpsf-zstd.patch index 7d72a18d6..308f267cd 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 6200647c3..ac5251f6f 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 d3f11e799..96798830f 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 b2c2e84fb..f4a86bf0f 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 -- Gitee