1 unstable release
Uses old Rust 2015
0.0.2 | Nov 21, 2014 |
---|
#6 in #gpx
11KB
265 lines
Rust gpx reader
###Reads GuitarPro 6 compressed gpx file with BCFZ compression.
In order to decompress BCFZ file, you need to implement BitStream reader, capable of reading bit-by-bit from a stream.
The format itself is pretty simple: File has a BCFZ header following 32 le bit integer specifying expected decompressed data length. The rest of a file consists of 2 types of data chunks (uncompressed, raw data and compressed). Read 1 bit from a bitstream. If bit is 0, uncompressed chunk follows:
- Next 2 le bits are length in bytes.
- Read length bytes from a bitstream.
- Put those bytes into a decompressed data buffer.
If bit is 1, then compressed chunk follows:
- Next 4 be bits are word size.
- Read word size bits to get offset.
- Read word size bits to get length.
- Read length bytes from offset (from the end of the current position in the decompressed data buffer).
- Put those bytes into a decompressed data buffer.
Sometimes there file may end before your data buffer reaches expected decompressed data lenght, it's likely safe to assume the file was read correct.