protected virtual IEnumerable <object?[]> OnError(BrotliFileGroup group, T file, Exception ex)
            {
                var row = new object?[Columns.Length];

                row[0] = file.Name;
                yield return(row);
            }
        protected override IEnumerable <object[]> GenerateRows(BrotliFileGroup group, BrotliFile.Compressed file)
        {
            var quality = file.Identifier;
            var reader  = file.Reader;

            MetaBlock?metaBlock;
            int       index = 0;

            while ((metaBlock = reader.NextMetaBlock()) != null)
            {
                var row = new List <object> {
                    file.Name, quality, index++, GetMetaBlockType(metaBlock), metaBlock.DataLength.UncompressedBytes
                };

                if (metaBlock is MetaBlock.Compressed c)
                {
                    ExtractMetadata(row, c.Header, c.Data);
                }
                else
                {
                    while (row.Count < Columns.Length)
                    {
                        row.Add("");
                    }
                }

                yield return(row.ToArray());
            }
        }
        protected override IEnumerable <object[]> GenerateRows(BrotliFileGroup group, BrotliFile.Compressed file)
        {
            var quality = file.Identifier;
            var reader  = file.Reader;

            MetaBlock?metaBlock;
            int       index = 0;

            while ((metaBlock = reader.NextMetaBlock()) != null)
            {
                if (metaBlock is MetaBlock.Compressed c)
                {
                    var rowStart = new List <object> {
                        file.Name, quality, index
                    };

                    foreach (var category in Categories.LID)
                    {
                        var rowFinal = new List <object>(rowStart)
                        {
                            category.Id()
                        };
                        var blockID = 0;

                        rowFinal.Add(blockID);
                        rowFinal.Add(0);
                        rowFinal.Add(c.Header.BlockTypes[category].InitialLength);
                        yield return(rowFinal.ToArray());

                        foreach (var command in c.Data.BlockSwitchCommands[category])
                        {
                            rowFinal[^ 3] = ++blockID;
Beispiel #4
0
        protected override IEnumerable <object?[]> GenerateRows(BrotliFileGroup group, BrotliFile.Compressed file)
        {
            int?originalBytes = file.SizeBytes;
            var rebuildBytes  = group.CountBytesAndValidate(file.Transforming(new TransformRebuild()));

            return(new List <object?[]> {
                new object?[] { file.Name, file.Identifier, originalBytes, rebuildBytes, rebuildBytes - originalBytes } // subtraction propagates null
            });
        }
        protected override IEnumerable <object?[]> GenerateRows(BrotliFileGroup group, BrotliFile.Uncompressed file)
        {
            int?uncompressedBytes = file.SizeBytes;
            int encodeBytes       = group.CountBytesAndValidate(file.Encoding(encoder !));

            return(new List <object?[]> {
                new object?[] { file.Name, uncompressedBytes, encodeBytes, encodeBytes - uncompressedBytes } // subtraction propagates null
            });
        }
        protected override void MapFile(BrotliFileGroup group, BrotliFile.Compressed file, FileStream output)
        {
            using var stream = new StreamWriter(output, Encoding.UTF8)
                  {
                      NewLine = "\n"
                  };

            file.WriteMarkers(stream, includeBitCounts, markerLevel);
        }
        protected override IEnumerable <object[]> GenerateRows(BrotliFileGroup group, BrotliFile.Uncompressed file)
        {
            int?[] sizes = new int?[13];
            sizes[0] = file.SizeBytes;

            foreach (var compressed in group.Compressed)
            {
                if (int.TryParse(compressed.Identifier, out int level) && level >= 0 && level <= 11)
                {
                    sizes[level + 1] = compressed.SizeBytes;
                }
            }

            yield return(sizes.Cast <object>().Prepend(file.Name).ToArray());
        }
        protected override IEnumerable <object?[]> GenerateRows(BrotliFileGroup group, BrotliFile.Compressed file)
        {
            var checkingTransformer = new ReferenceChecker(file.Reader, file.Transforming(transformer !));

            int?originalBytes    = file.SizeBytes;
            int transformedBytes = group.CountBytesAndValidate(checkingTransformer);

            if (!checkingTransformer.IsDifferent)
            {
                return(new List <object[]>());
            }

            int rebuildBytes = group.CountBytesAndValidate(file.Transforming(new TransformRebuild()));

            return(new List <object?[]> {
                new object?[] { file.Name, file.Identifier, originalBytes, rebuildBytes, transformedBytes, transformedBytes - originalBytes, transformedBytes - rebuildBytes } // subtraction propagates null
            });
        }
        protected override IEnumerable <object[]> GenerateRows(BrotliFileGroup group, BrotliFile.Compressed file)
        {
            var quality = file.Identifier;
            var reader  = file.Reader;

            MetaBlock?metaBlock;
            int       index = 0;

            while ((metaBlock = reader.NextMetaBlock()) != null)
            {
                if (metaBlock is MetaBlock.Compressed c)
                {
                    var row = new List <object> {
                        file.Name, quality, index, metaBlock.DataLength.UncompressedBytes
                    };
                    ExtractMetadata(row, c.Header);
                    yield return(row.ToArray());
                }

                ++index;
            }
        }
        protected override IEnumerable <object?[]> GenerateRows(BrotliFileGroup group, BrotliFile.Compressed file)
        {
            var original = group.Uncompressed.Contents;

            var reader = file.Reader;
            var output = new BrotliOutputStored();

            reader.AddOutputCallback(output);
            while (reader.NextMetaBlock() != null)
            {
            }
            reader.RemoveOutputCallback(output);

            if (!CollectionHelper.Equal(output.AsBytes, original))
            {
                throw new MismatchedOutputBytesException();
            }

            return(new List <object?[]> {
                new object?[] { file.Name, file.Identifier, "OK" }
            });
        }
 protected override IEnumerable <object?[]> OnError(BrotliFileGroup group, BrotliFile.Compressed file, Exception ex)
 {
     return(new List <object?[]> {
         new object?[] { file.Name, file.Identifier, ex is MismatchedOutputBytesException ? "Mismatch" : "Error" }
     });
 }
 protected abstract void MapFile(BrotliFileGroup group, T file, FileStream output);
Beispiel #13
0
 protected override IEnumerable <object?[]> OnError(BrotliFileGroup group, BrotliFile.Compressed file, Exception ex)
 {
     return(new List <object?[]> {
         new object?[] { file.Name, file.Identifier, file.SizeBytes, null, null }
     });
 }
Beispiel #14
0
 protected override void MapFile(BrotliFileGroup group, BrotliFile.Uncompressed file, FileStream output)
 {
     output.Write(file.Contents);
 }
 protected abstract IEnumerable <object?[]> GenerateRows(BrotliFileGroup group, T file);
Beispiel #16
0
 protected override void MapFile(BrotliFileGroup group, BrotliFile.Compressed file, FileStream output)
 {
     output.Write(group.SerializeAndValidate(file.Transforming(transformer !)).ToByteArray());
 }
Beispiel #17
0
 protected override void MapFile(BrotliFileGroup group, BrotliFile.Uncompressed file, FileStream output)
 {
     output.Write(group.SerializeAndValidate(file.Encoding(encoder !)).ToByteArray());
 }