public (MetaBlock, BrotliEncodeInfo) Encode(BrotliEncodeInfo info) { var bytes = CollectionHelper.SliceAtMost(info.Bytes, DataLength.MaxUncompressedBytes); var mb = new MetaBlock.Uncompressed(bytes); return(mb, info.WithOutputtedMetaBock(mb)); }
public BuildUncompressedMetaBlock(IBuildingBlockContext context, MetaBlock.Uncompressed metaBlock) { InitializeComponent(); this.context = context; this.textBoxUncompressedText.SetPlainTextMode(); this.textBoxUncompressedText.Text = Encoding.UTF8.GetString(metaBlock.UncompressedData); this.textBoxUncompressedText.TextChanged += textBoxUncompressedText_TextChanged; }
public (MetaBlock, BrotliEncodeInfo) Encode(BrotliEncodeInfo info) { (literalTree, literalRatio) = Huffman.EstimateLiteralRatio(new ArraySegment <byte>(input, ip, blockSize)); var builder = info.NewBuilder(); var nextStep = NextStep.EmitCommands; while (true) { switch (nextStep) { case NextStep.EmitCommands: nextStep = EmitCommands(); break; case NextStep.EmitCommandsNextHash: nextStep = EmitCommandsNextHash(); break; case NextStep.Trawl: nextStep = Trawl(builder); break; case NextStep.EmitRemainder: nextStep = EmitRemainder(builder); break; case NextStep.OutputCompressed: OnNextBlock(); return(builder.Build(info, new BrotliCompressionParameters.Builder(info.CompressionParameters) { GenerateLiteralTree = _ => literalTree }.Build())); case NextStep.OutputUncompressed: var metaBlock = new MetaBlock.Uncompressed(input, metaBlockStart, outputTo - metaBlockStart); inputSize -= metaBlock.DataLength.UncompressedBytes; nextIpStart = outputTo; nextEmit = nextIpStart; OnNextBlock(); return(metaBlock, info.WithOutputtedMetaBock(metaBlock)); } } }
protected sealed override IList <(MetaBlock MetaBlock, BrotliGlobalState NextState)> TransformUncompressed(MetaBlock.Uncompressed original, BrotliGlobalState state, BrotliCompressionParameters parameters) { return(base.TransformUncompressed(original, state, parameters)); }