public AvifWriter(IReadOnlyList <CompressedAV1Image> colorImages, IReadOnlyList <CompressedAV1Image> alphaImages, AvifMetadata metadata, ImageGridMetadata imageGridMetadata, YUVChromaSubsampling chromaSubsampling, ColorInformationBox colorInformationBox, ProgressEventHandler progressEventHandler, uint progressDone, uint progressTotal, IByteArrayPool arrayPool) { this.state = new AvifWriterState(colorImages, alphaImages, imageGridMetadata, metadata, arrayPool); this.arrayPool = arrayPool; this.colorImageIsGrayscale = chromaSubsampling == YUVChromaSubsampling.Subsampling400; this.colorInformationBox = colorInformationBox; this.progressCallback = progressEventHandler; this.progressDone = progressDone; this.progressTotal = progressTotal; this.fileTypeBox = new FileTypeBox(chromaSubsampling); this.metaBox = new MetaBox(this.state.PrimaryItemId, this.state.Items.Count, this.state.MediaDataBoxContentSize > uint.MaxValue, this.state.ItemDataBox); PopulateMetaBox(); }
private void Parse() { while (this.reader.Position < this.reader.Length) { Box header = new Box(this.reader); if (header.Type == BoxTypes.FileType) { if (this.fileTypeBox != null) { ExceptionUtil.ThrowFormatException("The file contains multiple FileType boxes."); } EndianBinaryReaderSegment segment = this.reader.CreateSegment(header.DataStartOffset, header.DataLength); this.fileTypeBox = new FileTypeBox(segment, header); this.fileTypeBox.CheckForAvifCompatibility(); } else if (header.Type == BoxTypes.Meta) { if (this.metaBox != null) { ExceptionUtil.ThrowFormatException("The file contains multiple Meta boxes."); } EndianBinaryReaderSegment segment = this.reader.CreateSegment(header.DataStartOffset, header.DataLength); this.metaBox = new MetaBox(segment, header); } else { // Skip any other boxes this.reader.Position = header.End; } } CheckForRequiredBoxes(); }