9 Commits
Author SHA1 Message Date
Tianjie Xu 77833b6477 Allow bsdiff to accept multiple compressors
We modified the patch writer to have the capability to produce the smallest
patch if multiple compressors are given. This type is supported for bsdf2
format only.

Example usage:
bsdiff --format=bsdf2 --type=bz2:brotli <src_file> <tgt_file> <patch_file>

Test: diff & patch an apk file

Change-Id: Icd4322f21975b82c5ee09f8feb9321f52c9813a4
2018-03-13 19:10:13 -07:00
Tianjie Xu 2e70b558e7 Rename the variable 'quality' to 'brotli_quality'
Right now the quality is only used in the brotli compressor. And it
would be ambiguous if we add another compressor in the future; since the
compressors may have different interpretion on the quality value.

Test: unit tests pass; run bsdiff
Change-Id: I23af06a135b2b47df5209171f7db0773ac02a326
2018-03-02 16:47:09 -08:00
Alex Deymo e790a3b766 Add flags to bsdiff main to generate the Endsley format.
This patch adds a format flag option in bsdiff main program to
support generating a patch in Endsley format from the command line.
This is helpful to generate patches for performance analysis of the
different settings and patch formats.

Bug: 71854816
Test: Ran bsdiff with --format=endsley

Change-Id: Iba4a3beb4b4cbb82ea1bd5b64d229b1aad871b37
2018-02-16 01:15:07 +01:00
Alex Deymo cdd45ca1c8 munmap() buffers after running bsdiff in main.
We were technically leaking mmap'ed memory in the main program. This
was not really a problem in normal execution of the binary because the
process would finish right after it, but releasing the mmap() helps
find actual leaks when instrumenting the code with asan tools.

Bug: None
Test: ran bsdiff over a sample file.
Change-Id: I5fac808ba6d0ba9b2331e40a764cac1a3620062f
2018-02-14 20:47:10 +01:00
Alex Deymo 383f677d7e Allow to set the minimum required match length.
The minimum required match length plays an important role in the
current algorithm. This algorithm requires that the current match
has at least 8 mismatches over a region where we find a new match,
therefore imposing a minimum match length of at least 8 bytes.
This patch allows to increase this minium value to avoid using small
matches that only match a very small region. A larger value can
improve the patch size, depending on the data, but a too large value
will cause the algorithm to miss matches that were otherwise benefical.

Bug: 73107113
Test: Added unittests. Ran it with different minlen values.

Change-Id: Iac594fc1cd7ecd5cfdc676bdb6ebe7c626de6dcd
2018-02-12 17:20:51 +01:00
Tianjie Xu 1f1cdb2b6b Add an argument parser in bsdiff
Add a parser of format, type and quality in the bsdiff main function.
This allow the bsdiff binary to choose between the BSDFF40|BSDF2 patch
format and compress the patch with desired algorithms.

Bug: 34220646
Test: unittest pass; generate brotli compressed patches with bsdiff
binary
Change-Id: Ia4f7941e4eca7e6047e2749315127d1cf4a988ee
2018-01-18 12:32:09 -08:00
Alex Deymo e445830222 Cleanup bsdiff public API.
The original function used to generate a patch from two files is no
longer used elsewhere so this patch removes it in favour of the newer
version that takes the streams from memory buffers and uses a patch
writer to generate the patch.

Bug: None.
Test: Ran `bsdiff` manually, verified bspatch applied correctly.

Change-Id: I17aac1d3dd405d733ff6dc35abe8e683adea0d4f
2017-10-27 13:52:46 +02:00
Alex Deymo ddf9db5293 Update Makefile to build shared libraries.
The Makefile didn't build libbspatch and libbsdiff. This patch includes
those libraries in the Makefile and moves the header files exposed by
those to an include/bsdiff subdirectory following the Android
convention so calling program can include "bsdiff/bspatch.h" avoiding
any collision with other libraries.

The Android.mk is updated to export the new include path while keeping
the old style until calling programs are updated.

The new Makefile allows Chromium OS to build the new libraries.

Bug: None
Test: FEATURES=test emerge-link bsdiff; sudo emerge bsdiff
Test: mmma external/bsdiff

Change-Id: I2ea9251eb224e9418fe236e4c4c9c5621853f590
2017-05-03 18:29:10 -07:00
Alex Deymo 20891f9c24 Convert C sources to C++.
To help refactoring the FILE* access behind an interface and better
integrate with unittest code, this patch moves the C sources to C++.
Minor changes to make this conform to C++ were included.

Bug: 24478450
Test: `make all test && ./unittests`; mm

Change-Id: I27d7fb0660efc18ea0cb84ff544c9dd9c4803050
2015-10-13 02:15:02 -07:00