From 0e4cb52a8b457a58d8d8660437f0e6ac8e806fcd Mon Sep 17 00:00:00 2001 From: Joe Tsai Date: Thu, 29 Oct 2015 08:32:11 -0700 Subject: [PATCH] Clarify Section 7.1. * Provide exhaustive list of all the ways the last two bytes can be sourced from. * Also make a clear connection in this section that there are only 64 context IDs for literals. This is important for the indexing math in context maps to make sense. --- docs/draft-alakuijala-brotli-07.nroff | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/draft-alakuijala-brotli-07.nroff b/docs/draft-alakuijala-brotli-07.nroff index 1ab0a17..496cce8 100644 --- a/docs/draft-alakuijala-brotli-07.nroff +++ b/docs/draft-alakuijala-brotli-07.nroff @@ -1062,8 +1062,9 @@ code in the array of literal and distance prefix codes. The context for encoding the next literal is defined by the last two bytes in the stream (p1, p2, where p1 is the most recent -byte), regardless if these bytes are produced by backward -references or by literal insertions. At the start of the stream +byte), regardless of whether these bytes are produced by +uncompressed meta-blocks, backward references, static dictionary +references, or by literal insertions. At the start of the stream p1 and p2 are initialized to zero. There are four methods, called context modes, to compute the @@ -1159,6 +1160,10 @@ uncompressed byte the context IDs can be computed as follows: For Signed: Context ID = (Lut2[p1] << 3) | Lut2[p2] .fi +From the lookup tables defined above and the operations to compute the +context IDs, we can see that context IDs for literals are in the range +of 0..63. + The context modes LSB6, MSB6, UTF8, and Signed are denoted by integers 0, 1, 2, 3.