mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-22 00:47:28 +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'
|
(assigning 0, 1 and 2), all the 'b' elements (assigning 3), all the 'c'
|
||||||
elements (assinging 4) and all the 'r' elements (assigning 5).
|
elements (assinging 4) and all the 'r' elements (assigning 5).
|
||||||
|
|
||||||
Index L T
|
Index L T
|
||||||
0 c 4
|
0 c 4
|
||||||
1 a 0
|
1 a 0
|
||||||
2 r 5
|
2 r 5
|
||||||
3 a 1
|
3 a 1
|
||||||
4 a 2
|
4 a 2
|
||||||
5 b 3
|
5 b 3
|
||||||
|
|
||||||
Starting with the *I* value given in the (g) bitslice, which was 1, calculate
|
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
|
*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
|
## Alternative BWT Inversion
|
||||||
|
|
||||||
It's not in the BWT technical report, but instead of walking *I*, *T[I]*,
|
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
|
*T[T[I]]*, etc, an alternative but equivalent algorithm works on *U*, the
|
||||||
L T* table but then sorts the rows by *T*, modifying the *Index* and *T*
|
inverse of the *T* vector. For example *T[4] == 2* and so *U[2] == 4*.
|
||||||
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*.
|
|
||||||
|
|
||||||
Index2 L T2
|
Index L T F U
|
||||||
1 c 0
|
0 c 4 a 1
|
||||||
3 a 1
|
1 a 0 a 3
|
||||||
4 r 2
|
2 r 5 a 4
|
||||||
5 a 3
|
3 a 1 b 5
|
||||||
0 a 4
|
4 a 2 c 0
|
||||||
2 b 5
|
5 b 3 r 2
|
||||||
|
|
||||||
Our original *I* value was 1, and when *T2* is 1, *Index2* is 3. Call this
|
Calculate *U[I]*, *U[U[I]]*, *U[U[U[I]]]*, etc to give [3, 5, 2, 4, 0, 1].
|
||||||
value *I2*. Calculate *I2*, *Index2[I2]*, *Index2[Index2[I2]]*, etc to give [3,
|
Indexing *L* with these values gives "abraca", the uncompressed text (without
|
||||||
5, 2, 4, 0, 1]. Indexing *L* with these values gives "abraca", the uncompressed
|
being reversed).
|
||||||
text (without being reversed).
|
|
||||||
|
|
||||||
|
|
||||||
## Final Run Length Encoding
|
## 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
|
// 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
|
// 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
|
// The read_code_lengths and build_huffman_tree methods also re-purpose
|
||||||
// this buffer to temporarily hold up to 258 symbols' code lengths.
|
// this buffer to temporarily hold up to 258 symbols' code lengths.
|
||||||
@@ -727,8 +727,8 @@ pri func decoder.invert_bwt!() {
|
|||||||
i += 1
|
i += 1
|
||||||
} endwhile
|
} endwhile
|
||||||
|
|
||||||
// Second data pass, but per the README.md file, calculate the Index2
|
// Second data pass, but per the README.md file, calculate the U column
|
||||||
// column instead of the T column calculated by SRC-RR-124.pdf.
|
// instead of the BWT technical report's T column.
|
||||||
i = 0
|
i = 0
|
||||||
while i < this.block_size {
|
while i < this.block_size {
|
||||||
assert i < 900000 via "a < b: a < c; c <= b"(c: this.block_size)
|
assert i < 900000 via "a < b: a < c; c <= b"(c: this.block_size)
|
||||||
|
|||||||
Reference in new issue
Block a user