Ejemplo n.º 1
0
            public Loaded(BrotliFileStructure file, BitStream bits, BrotliOutputStored output, MarkerRoot?markerRoot)
            {
                this.File = file;

                this.TotalCompressedBits = markerRoot?.TotalBits ?? bits.Length; // use markers to account for padding whenever possible
                this.TotalOutputBytes    = output.OutputSize;
            }
Ejemplo n.º 2
0
        public BrotliFileStructure Apply(byte[] bytes, BrotliDictionary dictionary)
        {
            var fileParameters = new BrotliFileParameters.Builder {
                WindowSize = DetermineWindowSize(bytes),
                Dictionary = dictionary
            }.Build();

            var compressionParameters = SetupCompressionParameters(bytes);

            var bfs        = new BrotliFileStructure(fileParameters);
            var encoder    = CreateEncoder(bytes, fileParameters);
            var encodeInfo = new BrotliEncodeInfo(fileParameters, compressionParameters, bytes);

            do
            {
                var(metaBlock, newEncodeInfo) = encoder.Encode(encodeInfo);

                if (Transformers.Count == 0)
                {
                    bfs.MetaBlocks.Add(metaBlock);
                    encodeInfo = newEncodeInfo;
                }
                else
                {
                    var(transformedMetaBlocks, transformedState) = ApplyTransformerChain(encodeInfo.State, metaBlock, compressionParameters);

                    bfs.MetaBlocks.AddRange(transformedMetaBlocks);
                    encodeInfo = newEncodeInfo.WithState(transformedState);
                }
            }while(!encodeInfo.IsFinished);

            FinalizeStructure(bfs);
            return(bfs);
        }
Ejemplo n.º 3
0
        public BuildFileStructure(IBuildingBlockContext context, BrotliFileStructure brotliFile)
        {
            InitializeComponent();

            this.context           = context;
            this.context.Notified += context_Notified;
            this.brotliFile        = brotliFile;

            RegenerateElementList(selectMetaBlock: null, notifyParent: false);
        }
Ejemplo n.º 4
0
 public HasStructure(BrotliFileStructure file, Stopwatch?stopwatch) : base(stopwatch)
 {
     this.File = file;
 }
Ejemplo n.º 5
0
 protected override void FinalizeStructure(BrotliFileStructure structure)
 {
     structure.MetaBlocks.Add(new MetaBlock.LastEmpty());
 }
Ejemplo n.º 6
0
 protected virtual void FinalizeStructure(BrotliFileStructure structure)
 {
     structure.Fixup();
 }
Ejemplo n.º 7
0
 public Compressed(string path, string name, string identifier) : base(path, name)
 {
     this.Identifier    = identifier;
     this.structureLazy = new Lazy <BrotliFileStructure>(() => BrotliFileStructure.FromBytes(Contents, Parameters.File.Dictionary), isThreadSafe: true);
 }
Ejemplo n.º 8
0
 public BrotliFileStructure Encode(IBrotliEncoder encoder)
 {
     return(BrotliFileStructure.FromEncoder(Parameters.File, Parameters.Compression, Contents, encoder));
 }
Ejemplo n.º 9
0
 public int CountBytesAndValidate(BrotliFileStructure bfs)
 {
     return((7 + SerializeAndValidate(bfs).Length) / 8);
 }
Ejemplo n.º 10
0
 public BitStream SerializeAndValidate(BrotliFileStructure bfs)
 {
     return(Validate(bfs.Serialize(Parameters.Serialization)));
 }
Ejemplo n.º 11
0
 public void ResetToEmpty()
 {
     LoadStructure(BrotliFileStructure.NewEmpty());
 }