From 425d73c0586051c4f846a4aaa7ebd81abbf9fd4e Mon Sep 17 00:00:00 2001 From: David Teller Date: Mon, 13 May 2019 15:05:34 +0200 Subject: [PATCH] FIXUP: Got the order of probability tables wrong --- format.md | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/format.md b/format.md index 0cea36e..935311e 100644 --- a/format.md +++ b/format.md @@ -61,7 +61,10 @@ ProbabilityTable ::= ProbabilityTableUnreachable # Compression artifact. A t | ProbabilityTableIndexedSymbols # Used for enums, booleans, sums of interfaces. ``` -The order of probability tables is meaningful. +The probability tables are written down in an order extracted from the grammar and define a model +`table: (parent type, my type) -> [(value, probabilities)]`. + +FIXME: Specify how the order is extracted from the grammar. ``` ProbabilityTableUnreachable ::= 0x02 @@ -127,12 +130,4 @@ ListPength(parent) ::= Value((parent, 'list-length')) # List lengths are u32 val Primitive(parent) ::= bit* ``` -To determine how many bits need to be read to decode a `Primitive(parent)`, it is sufficient for a decoder to know the distribution of probabilities for `(parent, expected type)`. - -For this purpose, the decoder maintains a mapping `models: (parent, expected type) |-> distribution`. - -Initially, this mapping is empty. Whenever we encounter a `Primitive(parent)` for an expected type: - -- if `models(parent expected type)` is empty, read the next table in `ProbabilityPrelude`, and this becomes the value - result of `models(parent expected type)`; -- otherwise, use `models(parent expected type)`. +To determine how many bits need to be read to decode a `Primitive(parent)`, it is sufficient for a decoder to know the distribution of probabilities for `(parent, expected type)`, as stored in the `ProbabilityPrelude`. \ No newline at end of file