1
0
mirror of https://github.com/chylex/Brotli-Builder.git synced 2024-11-25 07:42:56 +01:00
Brotli-Builder/BrotliLib/Brotli/Parameters/Heuristics/ContextMapHeuristics.cs

24 lines
1.0 KiB
C#

using BrotliLib.Brotli.Components.Header;
namespace BrotliLib.Brotli.Parameters.Heuristics{
public static class ContextMapHeuristics{
public delegate bool DecideFeature(ContextMap contextMap);
public delegate ContextMap.RunResolution DecideRuns(ContextMap.RunDecider decider);
public static class MTF{
public static DecideFeature Disable { get; } = _ => false;
public static DecideFeature Enable { get; } = _ => true;
}
public static class RLE{
public static DecideRuns Disable { get; } = decider => decider.Resolve(run => run.Reject());
public static DecideRuns KeepAll { get; } = decider => decider.Resolve(run => run.Accept());
public static DecideRuns SplitOneAboveBoundary { get; } = decider => decider.Resolve(original => {
var nextDown = new ContextMap.Run(original.Length - 1);
return original.Code == nextDown.Code ? original.Accept() : nextDown.Accept();
});
}
}
}