diff --git a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuChromoSamplePosition.cs b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuChromoSamplePosition.cs index f08d2ab0b8..9405e671df 100644 --- a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuChromoSamplePosition.cs +++ b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuChromoSamplePosition.cs @@ -3,6 +3,9 @@ namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit; +/// +/// Identifies the position of chroma samples relative to luma samples. +/// internal enum ObuChromoSamplePosition : byte { /// @@ -11,12 +14,12 @@ internal enum ObuChromoSamplePosition : byte Unknown = 0, /// - /// Horizontally co-located with luma(0, 0) sample, between two vertical samples. + /// The chroma sample is horizontally co-located with the top-left luma sample and lies between two luma rows. /// Vertical = 1, /// - /// Co-located with luma(0, 0) sample + /// The chroma sample is co-located with the top-left luma sample. /// Colocated = 2, diff --git a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuColorConfig.cs b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuColorConfig.cs index 24e7237a29..62783cbde4 100644 --- a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuColorConfig.cs +++ b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuColorConfig.cs @@ -3,10 +3,19 @@ namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit; +/// +/// Contains the color configuration signaled by an AV1 sequence header. +/// internal class ObuColorConfig { + /// + /// Stores whether the sequence uses a single monochrome plane. + /// private bool isMonochrome; + /// + /// Gets or sets a value indicating whether color-description syntax is present. + /// public bool IsColorDescriptionPresent { get; set; } /// @@ -23,29 +32,62 @@ internal class ObuColorConfig get => this.isMonochrome; set { + // Plane count is derived from the monochrome flag throughout the decoder, so update + // both values atomically rather than allowing the two pieces of state to diverge. this.PlaneCount = value ? 1 : Av1Constants.MaxPlanes; this.isMonochrome = value; } } + /// + /// Gets or sets the color-primary chromaticities. + /// public ObuColorPrimaries ColorPrimaries { get; set; } + /// + /// Gets or sets the transfer characteristics. + /// public ObuTransferCharacteristics TransferCharacteristics { get; set; } + /// + /// Gets or sets the matrix coefficients used to derive luma and chroma components. + /// public ObuMatrixCoefficients MatrixCoefficients { get; set; } + /// + /// Gets or sets a value indicating whether samples use the full numeric range. + /// public bool ColorRange { get; set; } + /// + /// Gets or sets a value indicating whether chroma is subsampled horizontally. + /// public bool SubSamplingX { get; set; } + /// + /// Gets or sets a value indicating whether chroma is subsampled vertically. + /// public bool SubSamplingY { get; set; } + /// + /// Gets or sets a value indicating whether the U and V planes use separate quantizer deltas. + /// public bool HasSeparateUvDelta { get; set; } + /// + /// Gets or sets the chroma sample position for vertically subsampled images. + /// public ObuChromoSamplePosition ChromaSamplePosition { get; set; } + /// + /// Gets or sets the encoded sample bit depth. + /// public Av1BitDepth BitDepth { get; set; } + /// + /// Gets the color format represented by the monochrome and chroma-subsampling flags. + /// + /// The corresponding AV1 color format. public Av1ColorFormat GetColorFormat() { Av1ColorFormat format = Av1ColorFormat.Yuv400; diff --git a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuColorPrimaries.cs b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuColorPrimaries.cs index 3136bba383..2bc013e4a2 100644 --- a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuColorPrimaries.cs +++ b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuColorPrimaries.cs @@ -3,19 +3,73 @@ namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit; +/// +/// Identifies the CICP color-primary chromaticities signaled by an AV1 sequence. +/// internal enum ObuColorPrimaries { - None = 0, + /// + /// The reserved zero value. + /// + Reserved = 0, + + /// + /// ITU-R BT.709 primaries. + /// Bt709 = 1, + + /// + /// Unspecified primaries. + /// Unspecified = 2, + + /// + /// ITU-R BT.470 System M primaries. + /// Bt470M = 4, + + /// + /// ITU-R BT.470 System B and G primaries. + /// Bt470BG = 5, + + /// + /// ITU-R BT.601 primaries. + /// Bt601 = 6, + + /// + /// SMPTE 240M primaries. + /// Smpte240 = 7, + + /// + /// Generic film primaries. + /// GenericFilm = 8, + + /// + /// ITU-R BT.2020 and BT.2100 primaries. + /// Bt2020 = 9, + + /// + /// SMPTE ST 428 CIE XYZ primaries. + /// Xyz = 10, + + /// + /// SMPTE RP 431-2 primaries. + /// Smpte431 = 11, + + /// + /// SMPTE EG 432-1 primaries. + /// Smpte432 = 12, + + /// + /// EBU Tech. 3213-E primaries. + /// Ebu3213 = 22, } diff --git a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuConstraintDirectionalEnhancementFilterParameters.cs b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuConstraintDirectionalEnhancementFilterParameters.cs index f952fae216..0141302d12 100644 --- a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuConstraintDirectionalEnhancementFilterParameters.cs +++ b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuConstraintDirectionalEnhancementFilterParameters.cs @@ -3,13 +3,28 @@ namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit; +/// +/// Contains the constrained directional enhancement filter parameters for an AV1 frame. +/// internal class ObuConstraintDirectionalEnhancementFilterParameters { + /// + /// Gets or sets the number of bits used to select a filter-strength entry. + /// public int BitCount { get; internal set; } + /// + /// Gets or sets the filter damping value. + /// public int Damping { get; internal set; } + /// + /// Gets or sets the primary and secondary luma strengths for each filter entry. + /// public int[] YStrength { get; set; } = new int[16]; + /// + /// Gets or sets the primary and secondary chroma strengths for each filter entry. + /// public int[] UvStrength { get; set; } = new int[16]; } diff --git a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuDecoderModelInfo.cs b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuDecoderModelInfo.cs index bc7f96d9ef..d0dee62824 100644 --- a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuDecoderModelInfo.cs +++ b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuDecoderModelInfo.cs @@ -3,6 +3,9 @@ namespace SixLabors.ImageSharp.Formats.Heif.Av1; +/// +/// Contains the field widths and decoding-clock units used by the AV1 decoder model. +/// internal class ObuDecoderModelInfo { /// diff --git a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuDeltaParameters.cs b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuDeltaParameters.cs index c92485eaf1..75ba543b63 100644 --- a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuDeltaParameters.cs +++ b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuDeltaParameters.cs @@ -3,11 +3,23 @@ namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit; +/// +/// Contains the delta-quantizer or delta-loop-filter signaling parameters for an AV1 frame. +/// internal class ObuDeltaParameters { + /// + /// Gets or sets a value indicating whether per-block delta values are present. + /// public bool IsPresent { get; internal set; } + /// + /// Gets or sets the delta-value resolution. + /// public int Resolution { get; internal set; } + /// + /// Gets or sets a value indicating whether separate loop-filter deltas are signaled for multiple filter targets. + /// public bool IsMulti { get; internal set; } } diff --git a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuFilmGrainParameters.cs b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuFilmGrainParameters.cs index 42a3b6578d..0fcddb47c9 100644 --- a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuFilmGrainParameters.cs +++ b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuFilmGrainParameters.cs @@ -3,6 +3,9 @@ namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit; +/// +/// Contains the parameters used to synthesize AV1 film grain for a decoded frame. +/// internal class ObuFilmGrainParameters { /// diff --git a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuFrameHeader.cs b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuFrameHeader.cs index adc759267f..7fb868d423 100644 --- a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuFrameHeader.cs +++ b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuFrameHeader.cs @@ -5,94 +5,228 @@ using SixLabors.ImageSharp.Formats.Heif.Av1.Transform; namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit; +/// +/// Stores the decoded syntax and derived state for one AV1 frame header. +/// internal class ObuFrameHeader { + /// + /// Gets or sets a value indicating whether motion vectors use integer-sample precision. + /// public bool ForceIntegerMotionVector { get; set; } + /// + /// Gets or sets a value indicating whether intra-block copy is permitted. + /// public bool AllowIntraBlockCopy { get; set; } + /// + /// Gets or sets a value indicating whether reference-frame motion vectors may be used. + /// public bool UseReferenceFrameMotionVectors { get; set; } + /// + /// Gets or sets a value indicating whether motion vectors may use high precision. + /// public bool AllowHighPrecisionMotionVector { get; set; } + /// + /// Gets or sets the decoded tile layout. + /// public ObuTileGroupHeader TilesInfo { get; set; } = new ObuTileGroupHeader(); + /// + /// Gets or sets a value indicating whether every segment uses lossless coding. + /// public bool CodedLossless { get; set; } + /// + /// Gets or sets the lossless-coding flag for each segment. + /// public bool[] LosslessArray { get; set; } = new bool[Av1Constants.MaxSegmentCount]; + /// + /// Gets or sets the frame quantization parameters. + /// public ObuQuantizationParameters QuantizationParameters { get; set; } = new ObuQuantizationParameters(); + /// + /// Gets or sets the frame segmentation parameters. + /// public ObuSegmentationParameters SegmentationParameters { get; set; } = new ObuSegmentationParameters(); + /// + /// Gets or sets a value indicating whether coding is lossless and no super-resolution scaling is applied. + /// public bool AllLossless { get; set; } + /// + /// Gets or sets a value indicating whether warped motion is permitted. + /// public bool AllowWarpedMotion { get; set; } + /// + /// Gets or sets the permitted reference prediction mode. + /// public ObuReferenceMode ReferenceMode { get; set; } + /// + /// Gets or sets the film-grain synthesis parameters. + /// public ObuFilmGrainParameters FilmGrainParameters { get; set; } = new ObuFilmGrainParameters(); + /// + /// Gets or sets a value indicating whether the reduced transform set is used. + /// public bool UseReducedTransformSet { get; set; } + /// + /// Gets or sets the loop-filter parameters. + /// public ObuLoopFilterParameters LoopFilterParameters { get; set; } = new ObuLoopFilterParameters(); + /// + /// Gets or sets the loop-restoration parameters. + /// public ObuLoopRestorationParameters LoopRestorationParameters { get; set; } = new ObuLoopRestorationParameters(); + /// + /// Gets or sets the constrained directional enhancement filter parameters. + /// public ObuConstraintDirectionalEnhancementFilterParameters CdefParameters { get; set; } = new ObuConstraintDirectionalEnhancementFilterParameters(); + /// + /// Gets or sets the number of mode-information columns in one stored row. + /// public int ModeInfoStride { get; set; } + /// + /// Gets or sets a value indicating whether the frame-end probability update is disabled. + /// public bool DisableFrameEndUpdateCdf { get; set; } + /// + /// Gets or sets the skip-mode parameters. + /// public ObuSkipModeParameters SkipModeParameters { get; set; } = new ObuSkipModeParameters(); + /// + /// Gets or sets the transform-size selection mode. + /// public Av1TransformMode TransformMode { get; set; } + /// + /// Gets or sets the loop-filter delta parameters. + /// public ObuDeltaParameters DeltaLoopFilterParameters { get; set; } = new ObuDeltaParameters(); + /// + /// Gets or sets the quantizer delta parameters. + /// public ObuDeltaParameters DeltaQParameters { get; set; } = new ObuDeltaParameters(); + /// + /// Gets a value indicating whether the frame uses intra prediction only. + /// public bool IsIntra => this.FrameType is ObuFrameType.IntraOnlyFrame or ObuFrameType.KeyFrame; + /// + /// Gets or sets the decoded and rendered frame dimensions. + /// internal ObuFrameSize FrameSize { get; set; } = new ObuFrameSize(); + /// + /// Gets or sets the frame width in mode-information units. + /// internal int ModeInfoColumnCount { get; set; } + /// + /// Gets or sets the frame height in mode-information units. + /// internal int ModeInfoRowCount { get; set; } + /// + /// Gets or sets a value indicating whether an existing reference frame is displayed without decoding a new frame. + /// internal bool ShowExistingFrame { get; set; } + /// + /// Gets or sets the coded frame type. + /// internal ObuFrameType FrameType { get; set; } + /// + /// Gets or sets the validity state of each reference-frame slot. + /// internal bool[] ReferenceValid { get; set; } = new bool[Av1Constants.ReferenceFrameCount]; + /// + /// Gets or sets the stored order-hint state for each reference-frame slot. + /// internal bool[] ReferenceOrderHint { get; set; } = new bool[Av1Constants.ReferenceFrameCount]; + /// + /// Gets or sets a value indicating whether the decoded frame is immediately displayed. + /// internal bool ShowFrame { get; set; } + /// + /// Gets or sets a value indicating whether the frame may be displayed by a later header. + /// internal bool ShowableFrame { get; set; } + /// + /// Gets or sets the reference map index selected when showing an existing frame. + /// internal uint FrameToShowMapIdx { get; set; } + /// + /// Gets or sets the display frame identifier. + /// internal uint DisplayFrameId { get; set; } + /// + /// Gets or sets a value indicating whether the frame can be decoded without state from earlier frames. + /// internal bool ErrorResilientMode { get; set; } + /// + /// Gets or sets a value indicating whether screen-content coding tools are permitted. + /// internal bool AllowScreenContentTools { get; set; } + /// + /// Gets or sets a value indicating whether probability adaptation is disabled for this frame. + /// internal bool DisableCdfUpdate { get; set; } + /// + /// Gets or sets the identifier of the current frame. + /// internal uint CurrentFrameId { get; set; } + /// + /// Gets or sets the reference-map index selected for each inter reference. + /// internal uint[] ReferenceFrameIndex { get; set; } = new uint[Av1Constants.ReferenceFrameCount]; + /// + /// Gets or sets the frame order hint. + /// internal uint OrderHint { get; set; } + /// + /// Gets or sets the reference frame supplying the initial probability context. + /// internal uint PrimaryReferenceFrame { get; set; } = Av1Constants.PrimaryReferenceFrameNone; + /// + /// Gets or sets the bit mask of reference slots refreshed by this frame. + /// internal uint RefreshFrameFlags { get; set; } - // 5.9.31. Temporal point info syntax + /// + /// Gets or sets the presentation time signaled by temporal point information. + /// internal uint FramePresentationTime { get; set; } } diff --git a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuFrameSize.cs b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuFrameSize.cs index 7075b50b82..3f5ef3e4b6 100644 --- a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuFrameSize.cs +++ b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuFrameSize.cs @@ -3,17 +3,38 @@ namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit; +/// +/// Contains the coded, upscaled, and rendered dimensions of an AV1 frame. +/// internal class ObuFrameSize { + /// + /// Gets or sets the coded frame width. + /// internal int FrameWidth { get; set; } + /// + /// Gets or sets the coded frame height. + /// internal int FrameHeight { get; set; } + /// + /// Gets or sets the denominator used by AV1 super-resolution scaling. + /// internal int SuperResolutionDenominator { get; set; } + /// + /// Gets or sets the frame width after super-resolution upscaling. + /// internal int SuperResolutionUpscaledWidth { get; set; } + /// + /// Gets or sets the intended display width. + /// internal int RenderWidth { get; set; } + /// + /// Gets or sets the intended display height. + /// internal int RenderHeight { get; set; } } diff --git a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuFrameType.cs b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuFrameType.cs index eb2414edc7..c06d954548 100644 --- a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuFrameType.cs +++ b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuFrameType.cs @@ -3,10 +3,28 @@ namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit; +/// +/// Identifies the AV1 frame type signaled by a frame header. +/// internal enum ObuFrameType { + /// + /// A key frame that is decoded without reference to another frame. + /// KeyFrame = 0, + + /// + /// An inter frame that can refer to previously decoded frames. + /// InterFrame = 1, + + /// + /// An intra-only frame that does not refresh all reference slots. + /// IntraOnlyFrame = 2, + + /// + /// A switch frame that permits switching between coded sequences. + /// SwitchFrame = 3, } diff --git a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuHeader.cs b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuHeader.cs index f55d3eb501..35277bbe70 100644 --- a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuHeader.cs +++ b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuHeader.cs @@ -3,19 +3,43 @@ namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit; +/// +/// Contains the parsed header and payload size of an AV1 open bitstream unit. +/// internal class ObuHeader { + /// + /// Gets or sets the number of bytes occupied by the OBU header and its size field. + /// public int Size { get; set; } + /// + /// Gets or sets the OBU payload type. + /// public ObuType Type { get; set; } + /// + /// Gets or sets a value indicating whether the OBU carries an explicit payload-size field. + /// public bool HasSize { get; set; } + /// + /// Gets or sets a value indicating whether the OBU carries temporal and spatial identifiers. + /// public bool HasExtension { get; set; } + /// + /// Gets or sets the temporal-layer identifier. + /// public int TemporalId { get; set; } + /// + /// Gets or sets the spatial-layer identifier. + /// public int SpatialId { get; set; } + /// + /// Gets or sets the OBU payload size, in bytes. + /// public int PayloadSize { get; set; } } diff --git a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuLoopFilterParameters.cs b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuLoopFilterParameters.cs index ad32d0c01d..c334384b01 100644 --- a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuLoopFilterParameters.cs +++ b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuLoopFilterParameters.cs @@ -3,27 +3,57 @@ namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit; +/// +/// Contains the AV1 deblocking-loop-filter parameters for a frame. +/// internal class ObuLoopFilterParameters { + /// + /// Initializes a new instance of the class with the AV1 default reference and mode deltas. + /// public ObuLoopFilterParameters() { this.ReferenceDeltas = [1, 0, 0, 0, 0, -1, -1, -1]; this.ModeDeltas = [0, 0]; } + /// + /// Gets or sets the horizontal and vertical luma filter levels. + /// public int[] FilterLevel { get; internal set; } = new int[2]; + /// + /// Gets or sets the U-plane filter level. + /// public int FilterLevelU { get; internal set; } + /// + /// Gets or sets the V-plane filter level. + /// public int FilterLevelV { get; internal set; } + /// + /// Gets or sets the filter sharpness level. + /// public int SharpnessLevel { get; internal set; } + /// + /// Gets or sets a value indicating whether reference-frame and mode deltas are enabled. + /// public bool ReferenceDeltaModeEnabled { get; internal set; } + /// + /// Gets or sets a value indicating whether reference-frame and mode deltas are updated by this frame. + /// public bool ReferenceDeltaModeUpdate { get; internal set; } + /// + /// Gets the filter-level deltas for the AV1 reference-frame categories. + /// public int[] ReferenceDeltas { get; } + /// + /// Gets the filter-level deltas for the AV1 prediction modes. + /// public int[] ModeDeltas { get; } } diff --git a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuLoopRestorationItem.cs b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuLoopRestorationItem.cs index ade31a6606..02ea3734a9 100644 --- a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuLoopRestorationItem.cs +++ b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuLoopRestorationItem.cs @@ -3,9 +3,18 @@ namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit; +/// +/// Contains the loop-restoration type and unit size for one color plane. +/// internal class ObuLoopRestorationItem { + /// + /// Gets or sets the restoration-unit size, in samples. + /// internal int Size { get; set; } + /// + /// Gets or sets the restoration filter type. + /// internal ObuRestorationType Type { get; set; } = ObuRestorationType.None; } diff --git a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuLoopRestorationParameters.cs b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuLoopRestorationParameters.cs index 18db716813..e28537a050 100644 --- a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuLoopRestorationParameters.cs +++ b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuLoopRestorationParameters.cs @@ -3,23 +3,46 @@ namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit; +/// +/// Contains the AV1 loop-restoration configuration for a frame. +/// internal class ObuLoopRestorationParameters { + /// + /// Initializes a new instance of the class. + /// internal ObuLoopRestorationParameters() { + // AV1 addresses restoration state by plane, so all three plane entries must exist even + // when the active color configuration uses fewer planes. this.Items = new ObuLoopRestorationItem[3]; this.Items[0] = new(); this.Items[1] = new(); this.Items[2] = new(); } + /// + /// Gets or sets a value indicating whether any plane uses loop restoration. + /// internal bool UsesLoopRestoration { get; set; } + /// + /// Gets or sets a value indicating whether either chroma plane uses loop restoration. + /// internal bool UsesChromaLoopRestoration { get; set; } + /// + /// Gets the loop-restoration configuration for each plane. + /// internal ObuLoopRestorationItem[] Items { get; } + /// + /// Gets or sets the luma restoration-unit size shift. + /// internal int UnitShift { get; set; } + /// + /// Gets or sets the chroma restoration-unit size shift relative to luma. + /// internal int UVShift { get; set; } } diff --git a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuMatrixCoefficients.cs b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuMatrixCoefficients.cs index f076a794cc..c35ca4ad1b 100644 --- a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuMatrixCoefficients.cs +++ b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuMatrixCoefficients.cs @@ -3,20 +3,78 @@ namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit; +/// +/// Identifies the CICP matrix coefficients used to derive luma and chroma components. +/// internal enum ObuMatrixCoefficients { + /// + /// The identity matrix used for GBR component ordering. + /// Identity = 0, + + /// + /// ITU-R BT.709 coefficients. + /// Bt709 = 1, + + /// + /// Unspecified coefficients. + /// Unspecified = 2, + + /// + /// United States FCC 73.628 coefficients. + /// Fcc = 4, + + /// + /// ITU-R BT.470 System B and G coefficients. + /// Bt470BG = 5, + + /// + /// ITU-R BT.601 coefficients. + /// Bt601 = 6, + + /// + /// SMPTE 240M coefficients. + /// Smpte240 = 7, + + /// + /// SMPTE YCgCo coefficients. + /// SmpteYCgCo = 8, + + /// + /// ITU-R BT.2020 non-constant-luminance coefficients. + /// Bt2020NonConstantLuminance = 9, + + /// + /// ITU-R BT.2020 constant-luminance coefficients. + /// Bt2020ConstantLuminance = 10, + + /// + /// SMPTE ST 2085 YDzDx coefficients. + /// Smpte2085 = 11, + + /// + /// Chromaticity-derived non-constant-luminance coefficients. + /// ChromaticityDerivedNonConstantLuminance = 12, - ChromaticityDerivedConstandLuminance = 13, + + /// + /// Chromaticity-derived constant-luminance coefficients. + /// + ChromaticityDerivedConstantLuminance = 13, + + /// + /// ITU-R BT.2100 ICtCp coefficients. + /// Bt2100ICtCp = 14, } diff --git a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuMetadataType.cs b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuMetadataType.cs index d6788f1745..1021c11bae 100644 --- a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuMetadataType.cs +++ b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuMetadataType.cs @@ -3,11 +3,38 @@ namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit; +/// +/// Identifies the payload carried by an AV1 metadata OBU. +/// internal enum ObuMetadataType { - ItutT35, - HdrCll, - HdrMdcv, - Scalability, - Timecode + /// + /// The reserved zero value. + /// + Reserved = 0, + + /// + /// Content light-level metadata. + /// + HdrCll = 1, + + /// + /// Mastering-display color-volume metadata. + /// + HdrMdcv = 2, + + /// + /// Scalability-structure metadata. + /// + Scalability = 3, + + /// + /// ITU-T T.35 terminal-provider metadata. + /// + ItutT35 = 4, + + /// + /// Timecode metadata. + /// + Timecode = 5, } diff --git a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuOperatingPoint.cs b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuOperatingPoint.cs index a398124e39..eb6091731d 100644 --- a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuOperatingPoint.cs +++ b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuOperatingPoint.cs @@ -3,27 +3,44 @@ namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit; +/// +/// Contains the sequence-level constraints for an AV1 operating point. +/// internal class ObuOperatingPoint { + /// + /// Gets or sets the operating-point index. + /// internal int OperatorIndex { get; set; } + /// + /// Gets or sets the AV1 sequence-level index. + /// internal int SequenceLevelIndex { get; set; } + /// + /// Gets or sets the sequence tier. + /// internal int SequenceTier { get; set; } + /// + /// Gets or sets a value indicating whether decoder-model timing is present for this operating point. + /// internal bool IsDecoderModelInfoPresent { get; set; } + /// + /// Gets or sets a value indicating whether an initial display delay is present for this operating point. + /// internal bool IsInitialDisplayDelayPresent { get; set; } + /// + /// Gets or sets the initial display delay minus one, in decoded frames. + /// internal uint InitialDisplayDelay { get; set; } /// - /// Gets or sets of sets the Idc bitmask. The bitmask that indicates which spatial and temporal layers should be decoded for - /// operating point i.Bit k is equal to 1 if temporal layer k should be decoded(for k between 0 and 7). Bit j+8 is equal to 1 if - /// spatial layer j should be decoded(for j between 0 and 3). - /// However, if operating_point_idc[i] is equal to 0 then the coded video sequence has no scalability information in OBU - /// extension headers and the operating point applies to the entire coded video sequence.This means that all OBUs must be decoded. - /// It is a requirement of bitstream conformance that operating_point_idc[i] is not equal to operating_point_idc[j] for j = 0..(i- 1). + /// Gets or sets the bitmask selecting temporal and spatial layers for the operating point. + /// A value of zero selects the complete coded sequence. /// internal uint Idc { get; set; } } diff --git a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuOrderHintInfo.cs b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuOrderHintInfo.cs index f540a297fa..523291960f 100644 --- a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuOrderHintInfo.cs +++ b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuOrderHintInfo.cs @@ -3,13 +3,28 @@ namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit; +/// +/// Contains the sequence-level order-hint and dependent prediction-tool settings. +/// internal class ObuOrderHintInfo { + /// + /// Gets or sets a value indicating whether order hints are enabled. + /// public bool EnableOrderHint { get; internal set; } + /// + /// Gets or sets a value indicating whether joint compound prediction is enabled. + /// internal bool EnableJointCompound { get; set; } + /// + /// Gets or sets a value indicating whether reference-frame motion vectors are enabled. + /// internal bool EnableReferenceFrameMotionVectors { get; set; } + /// + /// Gets or sets the number of bits used to encode order hints. + /// internal int OrderHintBits { get; set; } } diff --git a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuQuantizationParameters.cs b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuQuantizationParameters.cs index a3924eeeec..0ef92bee89 100644 --- a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuQuantizationParameters.cs +++ b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuQuantizationParameters.cs @@ -3,19 +3,43 @@ namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit; +/// +/// Contains the AV1 quantization parameters for a frame. +/// internal class ObuQuantizationParameters { + /// + /// Gets or sets the base quantizer index. + /// public int BaseQIndex { get; set; } + /// + /// Gets or sets the effective quantizer index for each segment. + /// public int[] QIndex { get; set; } = new int[Av1Constants.MaxSegmentCount]; + /// + /// Gets or sets a value indicating whether quantization matrices are enabled. + /// public bool IsUsingQMatrix { get; internal set; } + /// + /// Gets or sets the DC quantizer-index deltas for the Y, U, and V planes. + /// public int[] DeltaQDc { get; internal set; } = new int[3]; + /// + /// Gets or sets the AC quantizer-index deltas for the Y, U, and V planes. + /// public int[] DeltaQAc { get; internal set; } = new int[3]; + /// + /// Gets or sets the quantization-matrix level for the Y, U, and V planes. + /// public int[] QMatrix { get; internal set; } = new int[3]; + /// + /// Gets or sets a value indicating whether the U and V planes use separate quantizer deltas. + /// public bool HasSeparateUvDelta { get; internal set; } } diff --git a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuReferenceMode.cs b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuReferenceMode.cs index a76bc7601e..f61336cccd 100644 --- a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuReferenceMode.cs +++ b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuReferenceMode.cs @@ -3,8 +3,18 @@ namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit; +/// +/// Identifies whether inter blocks use only single references or can select compound references. +/// internal enum ObuReferenceMode { - ReferenceModeSelect, - SingleReference, + /// + /// Only single-reference prediction is permitted. + /// + SingleReference = 0, + + /// + /// Each eligible block selects single- or compound-reference prediction. + /// + ReferenceModeSelect = 1, } diff --git a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuRestorationType.cs b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuRestorationType.cs index bf90f5021d..ffed1502ef 100644 --- a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuRestorationType.cs +++ b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuRestorationType.cs @@ -3,10 +3,28 @@ namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit; +/// +/// Identifies the loop-restoration mode encoded by the two-bit frame-restoration syntax. +/// internal enum ObuRestorationType : uint { + /// + /// Loop restoration is disabled. + /// None = 0, + + /// + /// Each restoration unit selects its filter type. + /// Switchable = 1, - Weiner = 2, + + /// + /// Separable Wiener filtering is used. + /// + Wiener = 2, + + /// + /// Self-guided restoration projection is used. + /// SgrProj = 3, } diff --git a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuSegmentationLevelFeature.cs b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuSegmentationLevelFeature.cs index 93af8e0a1c..26175de29d 100644 --- a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuSegmentationLevelFeature.cs +++ b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuSegmentationLevelFeature.cs @@ -3,14 +3,48 @@ namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit; +/// +/// Identifies a feature that AV1 can configure independently for each segment. +/// internal enum ObuSegmentationLevelFeature { + /// + /// Adjusts the segment quantizer index. + /// AlternativeQuantizer, + + /// + /// Adjusts the vertical luma loop-filter level. + /// AlternativeLoopFilterYVertical, + + /// + /// Adjusts the horizontal luma loop-filter level. + /// AlternativeLoopFilterYHorizontal, + + /// + /// Adjusts the U-plane loop-filter level. + /// AlternativeLoopFilterU, + + /// + /// Adjusts the V-plane loop-filter level. + /// AlternativeLoopFilterV, + + /// + /// Selects a reference frame for the segment. + /// ReferenceFrame, + + /// + /// Marks every block in the segment as skipped. + /// Skip, + + /// + /// Uses the global motion vector for the segment. + /// GlobalMotionVector, } diff --git a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuSegmentationParameters.cs b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuSegmentationParameters.cs index a31235322c..0adb53d687 100644 --- a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuSegmentationParameters.cs +++ b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuSegmentationParameters.cs @@ -3,39 +3,62 @@ namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit; +/// +/// Contains the AV1 segmentation state and per-segment feature values for a frame. +/// internal class ObuSegmentationParameters { + /// + /// Gets or sets the effective quantization-matrix level for each plane and segment. + /// public int[][] QMLevel { get; internal set; } = new int[3][]; + /// + /// Gets or sets the enabled state of every feature for every segment. + /// public bool[,] FeatureEnabled { get; internal set; } = new bool[Av1Constants.MaxSegmentCount, Av1Constants.SegmentationLevelMax]; + /// + /// Gets or sets a value indicating whether segmentation is enabled for the frame. + /// public bool Enabled { get; internal set; } + /// + /// Gets or sets the value of every feature for every segment. + /// public int[,] FeatureData { get; internal set; } = new int[Av1Constants.MaxSegmentCount, Av1Constants.SegmentationLevelMax]; + /// + /// Gets or sets a value indicating whether segment identifiers are decoded before skip-mode decisions. + /// public bool SegmentIdPrecedesSkip { get; internal set; } + /// + /// Gets or sets the greatest segment identifier that has at least one active feature. + /// public int LastActiveSegmentId { get; internal set; } /// - /// Gets or sets the SegmentationUpdateMap. A value of 1 indicates that the segmentation map are updated during the decoding of this - /// frame. SegmentationUpdateMap equal to 0 means that the segmentation map from the previous frame is used. + /// Gets or sets a value indicating whether the segmentation map is updated while decoding the frame. /// public int SegmentationUpdateMap { get; internal set; } /// - /// Gets or sets the SegmentationTemporalUpdate. A value of 1 indicates that the updates to the segmentation map are coded relative to the - /// existing segmentation map. SegmentationTemporalUpdate equal to 0 indicates that the new segmentation map is coded - /// without reference to the existing segmentation map. + /// Gets or sets a value indicating whether segmentation-map updates are coded relative to the existing map. /// public int SegmentationTemporalUpdate { get; internal set; } /// - /// Gets or sets SegmentationUpdateData. A value of 1 indicates that new parameters are about to be specified for each segment. - /// SegmentationUpdateData equal to 0 indicates that the segmentation parameters should keep their existing values. + /// Gets or sets a value indicating whether the frame supplies new per-segment feature data. /// public int SegmentationUpdateData { get; internal set; } + /// + /// Determines whether a feature is active for a segment. + /// + /// The segment identifier. + /// The feature to inspect. + /// when the feature is active; otherwise, . internal bool IsFeatureActive(int segmentId, ObuSegmentationLevelFeature feature) => this.FeatureEnabled[segmentId, (int)feature]; } diff --git a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuSequenceHeader.cs b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuSequenceHeader.cs index ac87eefe74..0fa97ada0c 100644 --- a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuSequenceHeader.cs +++ b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuSequenceHeader.cs @@ -3,93 +3,215 @@ namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit; +/// +/// Stores AV1 sequence capabilities, dimensions, timing, and color configuration. +/// internal class ObuSequenceHeader { + /// + /// Backs while its dependent geometry is updated. + /// private bool use128x128Superblock; + /// + /// Gets or sets a value indicating whether filter-intra prediction is enabled. + /// public bool EnableFilterIntra { get; set; } + /// + /// Gets or sets a value indicating whether constrained directional enhancement filtering is enabled. + /// public bool EnableCdef { get; set; } + /// + /// Gets or sets a value indicating whether the sequence contains one still picture. + /// public bool IsStillPicture { get; set; } + /// + /// Gets or sets a value indicating whether the reduced still-picture header syntax is used. + /// public bool IsReducedStillPictureHeader { get; set; } + /// + /// Gets or sets the sequence profile. + /// public ObuSequenceProfile SequenceProfile { get; set; } + /// + /// Gets or sets the signaled operating points. + /// public ObuOperatingPoint[] OperatingPoint { get; set; } = new ObuOperatingPoint[1]; + /// + /// Gets or sets the decoder-buffer model information when present. + /// public ObuDecoderModelInfo? DecoderModelInfo { get; set; } + /// + /// Gets or sets a value indicating whether operating points may carry initial display delays. + /// public bool InitialDisplayDelayPresentFlag { get; set; } + /// + /// Gets or sets a value indicating whether decoder-model information is present. + /// public bool DecoderModelInfoPresentFlag { get; set; } + /// + /// Gets or sets a value indicating whether sequence timing information is present. + /// public bool TimingInfoPresentFlag { get; set; } + /// + /// Gets or sets the sequence timing information when present. + /// public ObuTimingInfo? TimingInfo { get; set; } + /// + /// Gets or sets a value indicating whether frame identifiers are signaled. + /// public bool IsFrameIdNumbersPresent { get; set; } + /// + /// Gets or sets the number of bits used to signal frame widths minus one. + /// public int FrameWidthBits { get; set; } + /// + /// Gets or sets the number of bits used to signal frame heights minus one. + /// public int FrameHeightBits { get; set; } + /// + /// Gets or sets the maximum decoded frame width in pixels. + /// public int MaxFrameWidth { get; set; } + /// + /// Gets or sets the maximum decoded frame height in pixels. + /// public int MaxFrameHeight { get; set; } + /// + /// Gets or sets a value indicating whether 128x128 superblocks are used. + /// public bool Use128x128Superblock { get => this.use128x128Superblock; set { this.use128x128Superblock = value; + + // Superblock selection controls every downstream partition-grid unit, so update the derived geometry atomically. this.SuperblockSize = value ? Av1BlockSize.Block128x128 : Av1BlockSize.Block64x64; this.SuperblockSizeLog2 = value ? 7 : 6; this.SuperblockModeInfoSize = 1 << (this.SuperblockSizeLog2 - Av1Constants.ModeInfoSizeLog2); } } + /// + /// Gets the selected superblock dimensions. + /// public Av1BlockSize SuperblockSize { get; private set; } + /// + /// Gets the superblock width and height in mode-information units. + /// public int SuperblockModeInfoSize { get; private set; } + /// + /// Gets the base-two logarithm of the superblock size in pixels. + /// public int SuperblockSizeLog2 { get; private set; } + /// + /// Gets or sets the filter-intra capability level. + /// public int FilterIntraLevel { get; set; } + /// + /// Gets or sets a value indicating whether intra edge filtering is enabled. + /// public bool EnableIntraEdgeFilter { get; set; } + /// + /// Gets or sets the order-hint capabilities. + /// public ObuOrderHintInfo OrderHintInfo { get; set; } = new ObuOrderHintInfo(); + /// + /// Gets or sets a value indicating whether order hints are enabled. + /// public bool EnableOrderHint { get; set; } + /// + /// Gets or sets a value indicating whether inter-intra compound prediction is enabled. + /// public bool EnableInterIntraCompound { get; set; } + /// + /// Gets or sets a value indicating whether masked compound prediction is enabled. + /// public bool EnableMaskedCompound { get; set; } + /// + /// Gets or sets a value indicating whether warped motion is enabled. + /// public bool EnableWarpedMotion { get; set; } + /// + /// Gets or sets a value indicating whether independent horizontal and vertical interpolation filters are enabled. + /// public bool EnableDualFilter { get; set; } + /// + /// Gets or sets the sequence-level integer-motion-vector selection. + /// public int ForceIntegerMotionVector { get; set; } + /// + /// Gets or sets the sequence-level screen-content-tools selection. + /// public int ForceScreenContentTools { get; set; } + /// + /// Gets or sets a value indicating whether frame super-resolution is enabled. + /// public bool EnableSuperResolution { get; set; } + /// + /// Gets or sets the constrained directional enhancement filter capability level. + /// public int CdefLevel { get; set; } + /// + /// Gets or sets a value indicating whether loop restoration is enabled. + /// public bool EnableRestoration { get; set; } + /// + /// Gets or sets the decoded color configuration. + /// public ObuColorConfig ColorConfig { get; set; } = new ObuColorConfig(); + /// + /// Gets or sets a value indicating whether frame headers may carry film-grain parameters. + /// public bool AreFilmGrainingParametersPresent { get; set; } + /// + /// Gets or sets the total number of bits in a frame identifier. + /// public int FrameIdLength { get; set; } + /// + /// Gets or sets the number of bits in a delta frame identifier. + /// public int DeltaFrameIdLength { get; set; } + /// + /// Gets or sets the additional frame-identifier bit count signaled by the sequence header. + /// public uint AdditionalFrameIdLength { get; set; } } diff --git a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuSequenceProfile.cs b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuSequenceProfile.cs index f1ac85edb3..2bd5af9b3e 100644 --- a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuSequenceProfile.cs +++ b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuSequenceProfile.cs @@ -3,9 +3,23 @@ namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit; +/// +/// Identifies the AV1 sequence profile and its permitted bit-depth and chroma formats. +/// internal enum ObuSequenceProfile : uint { + /// + /// The Main profile. + /// Main = 0, + + /// + /// The High profile. + /// High = 1, + + /// + /// The Professional profile. + /// Professional = 2, } diff --git a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuSkipModeParameters.cs b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuSkipModeParameters.cs index 29a87a5f23..eb394a3b27 100644 --- a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuSkipModeParameters.cs +++ b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuSkipModeParameters.cs @@ -3,9 +3,18 @@ namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit; +/// +/// Contains the availability and enabled state of AV1 skip mode for a frame. +/// internal class ObuSkipModeParameters { + /// + /// Gets or sets a value indicating whether the frame is permitted to use skip mode. + /// public bool SkipModeAllowed { get; set; } + /// + /// Gets or sets a value indicating whether skip mode is enabled for the frame. + /// public bool SkipModeFlag { get; internal set; } } diff --git a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuTileGroupHeader.cs b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuTileGroupHeader.cs index a5f1867b66..69c1554290 100644 --- a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuTileGroupHeader.cs +++ b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuTileGroupHeader.cs @@ -3,37 +3,88 @@ namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit; +/// +/// Contains the tile layout derived from an AV1 frame header. +/// internal class ObuTileGroupHeader { + /// + /// Gets or sets the maximum tile width, in superblocks. + /// internal int MaxTileWidthSuperblock { get; set; } + /// + /// Gets or sets the maximum tile height, in superblocks. + /// internal int MaxTileHeightSuperblock { get; set; } + /// + /// Gets or sets the minimum base-2 logarithm of the tile-column count. + /// internal int MinLog2TileColumnCount { get; set; } + /// + /// Gets or sets the maximum base-2 logarithm of the tile-column count. + /// internal int MaxLog2TileColumnCount { get; set; } + /// + /// Gets or sets the maximum base-2 logarithm of the tile-row count. + /// internal int MaxLog2TileRowCount { get; set; } + /// + /// Gets or sets the minimum base-2 logarithm of the total tile count. + /// internal int MinLog2TileCount { get; set; } + /// + /// Gets or sets a value indicating whether tile columns and rows use uniform spacing. + /// public bool HasUniformTileSpacing { get; set; } + /// + /// Gets or sets the base-2 logarithm of the tile-column count. + /// internal int TileColumnCountLog2 { get; set; } + /// + /// Gets or sets the number of tile columns. + /// internal int TileColumnCount { get; set; } + /// + /// Gets or sets the starting superblock column for each tile column. + /// internal int[] TileColumnStartModeInfo { get; set; } = new int[Av1Constants.MaxTileRowCount + 1]; + /// + /// Gets or sets the minimum base-2 logarithm of the tile-row count. + /// internal int MinLog2TileRowCount { get; set; } + /// + /// Gets or sets the base-2 logarithm of the tile-row count. + /// internal int TileRowCountLog2 { get; set; } + /// + /// Gets or sets the starting superblock row for each tile row. + /// internal int[] TileRowStartModeInfo { get; set; } = new int[Av1Constants.MaxTileColumnCount + 1]; + /// + /// Gets or sets the number of tile rows. + /// internal int TileRowCount { get; set; } + /// + /// Gets or sets the tile whose entropy context is retained after frame decoding. + /// internal uint ContextUpdateTileId { get; set; } + /// + /// Gets or sets the number of bytes used to signal each tile size. + /// internal int TileSizeBytes { get; set; } } diff --git a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuTimingInfo.cs b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuTimingInfo.cs index d366157e78..370cbf4d68 100644 --- a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuTimingInfo.cs +++ b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuTimingInfo.cs @@ -3,6 +3,9 @@ namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit; +/// +/// Contains the timing syntax signaled by an AV1 sequence header. +/// internal class ObuTimingInfo { /// diff --git a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuTransferCharacteristics.cs b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuTransferCharacteristics.cs index 0fa71e5922..739f1a72c3 100644 --- a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuTransferCharacteristics.cs +++ b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuTransferCharacteristics.cs @@ -3,23 +3,93 @@ namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit; +/// +/// Identifies the CICP transfer characteristics signaled by an AV1 sequence. +/// internal enum ObuTransferCharacteristics { + /// + /// ITU-R BT.709 transfer characteristics. + /// Bt709 = 1, + + /// + /// Unspecified transfer characteristics. + /// Unspecified = 2, + + /// + /// ITU-R BT.470 System M transfer characteristics. + /// Bt470M = 4, + + /// + /// ITU-R BT.470 System B and G transfer characteristics. + /// Bt470BG = 5, + + /// + /// ITU-R BT.601 transfer characteristics. + /// Bt601 = 6, + + /// + /// SMPTE 240M transfer characteristics. + /// Smpte240 = 7, + + /// + /// Linear light. + /// Linear = 8, + + /// + /// Logarithmic transfer with a 100:1 range. + /// Log100 = 9, + + /// + /// Logarithmic transfer with a 100 times square-root-of-ten to one range. + /// Log100Sqrt10 = 10, + + /// + /// IEC 61966-2-4 transfer characteristics. + /// Iec61966 = 11, + + /// + /// ITU-R BT.1361 transfer characteristics. + /// Bt1361 = 12, + + /// + /// IEC 61966-2-1 sRGB or sYCC transfer characteristics. + /// Srgb = 13, + + /// + /// ITU-R BT.2020 transfer characteristics for 10-bit systems. + /// Bt202010Bit = 14, + + /// + /// ITU-R BT.2020 transfer characteristics for 12-bit systems. + /// Bt202012Bit = 15, + + /// + /// SMPTE ST 2084 perceptual-quantizer transfer characteristics. + /// Smpte2084 = 16, - Smpte248 = 17, + + /// + /// SMPTE ST 428 transfer characteristics. + /// + Smpte428 = 17, + + /// + /// ITU-R BT.2100 hybrid-log-gamma transfer characteristics. + /// Hlg = 18, } diff --git a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuType.cs b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuType.cs index 34285ef2f0..404837c0da 100644 --- a/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuType.cs +++ b/src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuType.cs @@ -3,16 +3,58 @@ namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit; +/// +/// Identifies an AV1 open bitstream unit payload. +/// internal enum ObuType { + /// + /// The reserved zero value. + /// None = 0, + + /// + /// A sequence header. + /// SequenceHeader = 1, + + /// + /// A temporal delimiter. + /// TemporalDelimiter = 2, + + /// + /// A frame header without tile data. + /// FrameHeader = 3, - RedundantFrameHeader = 7, + + /// + /// One or more encoded tiles. + /// TileGroup = 4, + + /// + /// Metadata associated with the coded sequence. + /// Metadata = 5, + + /// + /// A frame header followed by tile data. + /// Frame = 6, + + /// + /// A repeated copy of the current frame header. + /// + RedundantFrameHeader = 7, + + /// + /// A list of tiles for large-scale tile decoding. + /// TileList = 8, + + /// + /// Padding bytes. + /// Padding = 15, }