mirror of
https://github.com/chylex/Brotli-Builder.git
synced 2024-11-24 22:42:50 +01:00
29 lines
925 B
C#
29 lines
925 B
C#
// Assume the block types have already been setup.
|
||
Assert(builder.BlockTypes[Category.Distance].TypeCount == 𝟑);
|
||
|
||
var contextMap = new ContextMapBuilder.Distances(blockTypeCount: 𝟑);
|
||
// [ 0,0,0,0 | 0,0,0,0 | 0,0,0,0 ]
|
||
|
||
contextMap.Set(blockType: 𝟎, values: new byte[]{ 𝟎, 𝟏, 𝟐, 𝟑 });
|
||
// [ 0,1,2,3 | 0,0,0,0 | 0,0,0,0 ]
|
||
// * * * *
|
||
|
||
contextMap.Set(blockType: 𝟎, index: 𝟏, value: 𝟎);
|
||
// [ 0,0,2,3 | 0,0,0,0 | 0,0,0,0 ]
|
||
// *
|
||
|
||
contextMap.Set(blockType: 𝟎, range: new IntRange(𝟐, 𝟑), value: 𝟏);
|
||
// [ 0,0,1,1 | 0,0,0,0 | 0,0,0,0 ]
|
||
// * *
|
||
|
||
contextMap.RepeatFirstBlockType(separateTreesPerBlockType: false);
|
||
// [ 0,0,1,1 | 0,0,1,1 | 0,0,1,1 ]
|
||
// * * * * * * * *
|
||
|
||
contextMap.RepeatFirstBlockType(separateTreesPerBlockType: true);
|
||
// [ 0,0,1,1 | 2,2,3,3 | 4,4,5,5 ]
|
||
// * * * * * * * *
|
||
|
||
// Build and assign.
|
||
builder.DistanceCtxMap = contextMap.Build();
|