mirror of
https://github.com/chylex/Brotli-Builder.git
synced 2024-11-24 22:42:50 +01:00
26 lines
1.0 KiB
C#
26 lines
1.0 KiB
C#
using BrotliLib.Brotli;
|
|
using BrotliLib.Brotli.Components;
|
|
using BrotliLib.Brotli.Encode;
|
|
using BrotliLib.Brotli.Encode.Build;
|
|
using BrotliLib.Brotli.Parameters;
|
|
using BrotliLib.Brotli.Utils;
|
|
|
|
namespace BrotliImpl.Transformers{
|
|
public class TransformSplitInsertCopyLengths : BrotliTransformerCompressed{
|
|
protected override (MetaBlock, BrotliGlobalState) Transform(MetaBlock.Compressed original, BrotliGlobalState state, BrotliCompressionParameters parameters){
|
|
if (original.Data.InsertCopyCommands.Count <= 1 || original.Data.BlockSwitchCommands[Category.InsertCopy].Count > 0){
|
|
return (original, state);
|
|
}
|
|
|
|
var builder = new CompressedMetaBlockBuilder(original, state);
|
|
var icBlocks = builder.BlockTypes[Category.InsertCopy];
|
|
var icCommands = builder.GetTotalBlockLength(Category.InsertCopy);
|
|
|
|
icBlocks.SetInitialLength(icCommands / 2)
|
|
.AddFinalBlock(1);
|
|
|
|
return builder.Build(parameters);
|
|
}
|
|
}
|
|
}
|