Skip to content

Commit

Permalink
Seek more clarify on Largest Reference/Base Index encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
martinthomson committed May 30, 2018
1 parent d2371df commit 5c3a6c1
Showing 1 changed file with 29 additions and 11 deletions.
40 changes: 29 additions & 11 deletions draft-ietf-quic-qpack.md
Original file line number Diff line number Diff line change
Expand Up @@ -550,18 +550,36 @@ the block. Blocking decoders use the Largest Reference to determine when it is
safe to process the rest of the block.

`Base Index` is used to resolve references in the dynamic table as described in
{{indexing}}. To save space, Base Index is encoded relative to Largest
Reference using a one-bit sign flag.
{{indexing}}.

baseIndex = largestReference + deltaBaseIndex
To save space, Base Index is encoded as a relative to the Base Index using a
one-bit sign and the `Delta Base Index` value. A sign bit set to 0 indicates
that the Base Index has a greater absolute index than the Largest Reference; the
value of Delta Base Index is added to the Largest Reference to determine the
absolute value of the Base Index. A sign bit of 1 indicates that the Base Index
is smaller than the Base Index.

If the encoder inserted entries to the table while the encoding the block,
Largest Reference will be greater than Base Index, so deltaBaseIndex will be
negative and encoded with S=1. If the block did not reference the most recent
entry in the table and did not insert any new entries, Largest Reference will be
less than Base Index, so deltaBaseIndex will be positive and encoded with S=0.
When Largest Reference and Base Index are equal, deltaBaseIndex is 0 and encoded
with S=0.
That is, after turning a sign bit of 1 to -1 and 0 to 1, the absolute Base Index
is:

~~~
baseIndex = largestReference + sign * deltaBaseIndex
~~~

If the encoder inserted entries to the table while the encoding the header
block, Largest Reference will be greater than Base Index, so the encoded
difference is negative and the sign bit will be 1. If the header block did not
reference the most recent entry in the table and did not insert any new entries,
Base Index will be greater than the Largest Reference, so the delta will be
positive and the sign bit will be 0.

When Largest Reference and Base Index are equal, the Delta Base Index is encoded
with a zero sign bit. A sign bit set to 1 when the Delta Base Index is 0 MUST
be treated as a decoder error.

A header block that does not reference the dynamic table can use any value for
Base Index and Largest Reference; sending zero values for both fields is the
most efficient.


### Instructions
Expand Down Expand Up @@ -697,7 +715,7 @@ represented as an 8-bit prefix string literal.

# Encoding Strategies

## Single pass encoding
## Single Pass Encoding

An encoder making a single pass over a list of headers must choose Base Index
before knowing Largest Reference. When trying to reference a header inserted to
Expand Down

0 comments on commit 5c3a6c1

Please sign in to comment.