sisong / HDiffPatch

a C\C++ library and command-line tools for Diff & Patch between binary files or directories(folder); cross-platform; runs fast; create small delta/differential; support large files and limit memory requires when diff & patch.
Other
1.52k stars 280 forks source link

如果知道文件格式,只对差异部分hdiif,是不是可以减小输出大小 #300

Closed rebelmx4 closed 2 years ago

rebelmx4 commented 2 years ago

1.如果我知道需要对比的文件格式(例如文件格式是unreal 4 pak格式),知道文件的哪些段是相同的,然后我自己组织保留,增加,修改数据。其中修改部分使用HDiff。这样做是不是可以减小最终输出的大小。 2.如果我想用hdiff比较old的[start1,end1]和new的[start2, end2],输出到out从start3可以的位置。 使用hpatch_TFileStreamInput_setOffset,hpatch_TFileStreamInput_setEndOffset分别设置old,new,hpatch_TFileStreamOutput_setOffset设置out 这样写对吗 3.matchBlockSize 该怎么理解

sisong commented 2 years ago
  1. 不建议这样做;大小影响比较小。 (收益应该有一点的,但可能开发代价较大,我个人觉得不太划算)
  2. 大概是这个意思,你可以试试。
  3. “matchBlockSize ” 是将old数据按matchBlockSize固定大小来分成很多块,进行hash,然后拿new数据来匹配这些hash,所以matchBlockSize越大,内存占用越小,匹配越快,但漏匹配的概率增大。