mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-17 16:32:11 +01:00
Tweak std/bzip2's "inverse of T" description
This commit is contained in:
1 parent
84ef91dda8
commit
2422997ee5
2 files changed
+22
-25
No files matched your search
+19
-22
@@ -241,13 +241,13 @@ value (relative to each cumulative count) to all the 'a' elements in *L*
|
||||
(assigning 0, 1 and 2), all the 'b' elements (assigning 3), all the 'c'
|
||||
elements (assinging 4) and all the 'r' elements (assigning 5).
|
||||
|
||||
Index L T
|
||||
0 c 4
|
||||
1 a 0
|
||||
2 r 5
|
||||
3 a 1
|
||||
4 a 2
|
||||
5 b 3
|
||||
Index L T
|
||||
0 c 4
|
||||
1 a 0
|
||||
2 r 5
|
||||
3 a 1
|
||||
4 a 2
|
||||
5 b 3
|
||||
|
||||
Starting with the *I* value given in the (g) bitslice, which was 1, calculate
|
||||
*I*, *T[I]*, *T[T[I]]*, *T[T[T[I]]]*, etc to give [1, 0, 4, 2, 5, 3]. Indexing
|
||||
@@ -258,23 +258,20 @@ uncompressed text.
|
||||
## Alternative BWT Inversion
|
||||
|
||||
It's not in the BWT technical report, but instead of walking *I*, *T[I]*,
|
||||
*T[T[I]]*, etc, an alternative but equivalent algorithm starts with the *Index
|
||||
L T* table but then sorts the rows by *T*, modifying the *Index* and *T*
|
||||
columns (to produce *Index2* and *T2*) but leaving the *L* column unchanged.
|
||||
For example *Index == 4* matches *T == 2*, so *T2 == 2* matches *Index2 == 4*.
|
||||
*T[T[I]]*, etc, an alternative but equivalent algorithm works on *U*, the
|
||||
inverse of the *T* vector. For example *T[4] == 2* and so *U[2] == 4*.
|
||||
|
||||
Index2 L T2
|
||||
1 c 0
|
||||
3 a 1
|
||||
4 r 2
|
||||
5 a 3
|
||||
0 a 4
|
||||
2 b 5
|
||||
Index L T F U
|
||||
0 c 4 a 1
|
||||
1 a 0 a 3
|
||||
2 r 5 a 4
|
||||
3 a 1 b 5
|
||||
4 a 2 c 0
|
||||
5 b 3 r 2
|
||||
|
||||
Our original *I* value was 1, and when *T2* is 1, *Index2* is 3. Call this
|
||||
value *I2*. Calculate *I2*, *Index2[I2]*, *Index2[Index2[I2]]*, etc to give [3,
|
||||
5, 2, 4, 0, 1]. Indexing *L* with these values gives "abraca", the uncompressed
|
||||
text (without being reversed).
|
||||
Calculate *U[I]*, *U[U[I]]*, *U[U[U[I]]]*, etc to give [3, 5, 2, 4, 0, 1].
|
||||
Indexing *L* with these values gives "abraca", the uncompressed text (without
|
||||
being reversed).
|
||||
|
||||
|
||||
## Final Run Length Encoding
|
||||
|
||||
@@ -67,7 +67,7 @@ pub struct decoder? implements base.io_transformer(
|
||||
|
||||
// bwt is the Burrows Wheeler Transform state. Per the README.md file, each
|
||||
// entry is a row with the low 8 bits holding the L column and the high 20
|
||||
// bits holding the Index2 column. The middle 4 bits are unused.
|
||||
// bits holding the U column. The middle 4 bits are unused.
|
||||
//
|
||||
// The read_code_lengths and build_huffman_tree methods also re-purpose
|
||||
// this buffer to temporarily hold up to 258 symbols' code lengths.
|
||||
@@ -727,8 +727,8 @@ pri func decoder.invert_bwt!() {
|
||||
i += 1
|
||||
} endwhile
|
||||
|
||||
// Second data pass, but per the README.md file, calculate the Index2
|
||||
// column instead of the T column calculated by SRC-RR-124.pdf.
|
||||
// Second data pass, but per the README.md file, calculate the U column
|
||||
// instead of the BWT technical report's T column.
|
||||
i = 0
|
||||
while i < this.block_size {
|
||||
assert i < 900000 via "a < b: a < c; c <= b"(c: this.block_size)
|
||||
|
||||
Reference in new issue
Block a user