mirror of
https://github.com/chylex/Brotli-Builder.git
synced 2025-08-16 03:31:45 +02:00
BrotliBuilder
BrotliCalc
BrotliImpl
Combined
Encoders
EncodeGreedySearch.cs
EncodeLiterals.cs
EncodeUncompressedOnly.cs
Transformers
Utils
BrotliImpl.csproj
MetaBlockSizeTracker.cs
BrotliLib
Paper
UnitTests
.gitignore
BrotliBuilder.sln
LICENSE
README.md
21 lines
789 B
C#
21 lines
789 B
C#
using BrotliLib.Brotli.Components;
|
|
using BrotliLib.Brotli.Components.Data;
|
|
using BrotliLib.Brotli.Components.Header;
|
|
using BrotliLib.Brotli.Encode;
|
|
using BrotliLib.Collections;
|
|
|
|
namespace BrotliImpl.Encoders{
|
|
/// <summary>
|
|
/// Encodes bytes into a series of compressed meta-blocks, where each contains a single insert&copy command with each byte stored as a literal.
|
|
/// </summary>
|
|
public class EncodeLiterals : IBrotliEncoder{
|
|
public (MetaBlock, BrotliEncodeInfo) Encode(BrotliEncodeInfo info){
|
|
var bytes = CollectionHelper.SliceAtMost(info.Bytes, DataLength.MaxUncompressedBytes).ToArray();
|
|
|
|
return info.NewBuilder()
|
|
.AddInsert(Literal.FromBytes(bytes))
|
|
.Build(info);
|
|
}
|
|
}
|
|
}
|