Browse Source

Document AV1 OBU data models

pull/2633/head
James Jackson-South 2 months ago
parent
commit
20746bc57d
  1. 7
      src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuChromoSamplePosition.cs
  2. 42
      src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuColorConfig.cs
  3. 56
      src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuColorPrimaries.cs
  4. 15
      src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuConstraintDirectionalEnhancementFilterParameters.cs
  5. 3
      src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuDecoderModelInfo.cs
  6. 12
      src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuDeltaParameters.cs
  7. 3
      src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuFilmGrainParameters.cs
  8. 136
      src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuFrameHeader.cs
  9. 21
      src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuFrameSize.cs
  10. 18
      src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuFrameType.cs
  11. 24
      src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuHeader.cs
  12. 30
      src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuLoopFilterParameters.cs
  13. 9
      src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuLoopRestorationItem.cs
  14. 23
      src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuLoopRestorationParameters.cs
  15. 60
      src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuMatrixCoefficients.cs
  16. 37
      src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuMetadataType.cs
  17. 29
      src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuOperatingPoint.cs
  18. 15
      src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuOrderHintInfo.cs
  19. 24
      src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuQuantizationParameters.cs
  20. 14
      src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuReferenceMode.cs
  21. 20
      src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuRestorationType.cs
  22. 34
      src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuSegmentationLevelFeature.cs
  23. 37
      src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuSegmentationParameters.cs
  24. 122
      src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuSequenceHeader.cs
  25. 14
      src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuSequenceProfile.cs
  26. 9
      src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuSkipModeParameters.cs
  27. 51
      src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuTileGroupHeader.cs
  28. 3
      src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuTimingInfo.cs
  29. 72
      src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuTransferCharacteristics.cs
  30. 44
      src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuType.cs

7
src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuChromoSamplePosition.cs

@ -3,6 +3,9 @@
namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit;
/// <summary>
/// Identifies the position of chroma samples relative to luma samples.
/// </summary>
internal enum ObuChromoSamplePosition : byte
{
/// <summary>
@ -11,12 +14,12 @@ internal enum ObuChromoSamplePosition : byte
Unknown = 0,
/// <summary>
/// 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.
/// </summary>
Vertical = 1,
/// <summary>
/// Co-located with luma(0, 0) sample
/// The chroma sample is co-located with the top-left luma sample.
/// </summary>
Colocated = 2,

42
src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuColorConfig.cs

@ -3,10 +3,19 @@
namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit;
/// <summary>
/// Contains the color configuration signaled by an AV1 sequence header.
/// </summary>
internal class ObuColorConfig
{
/// <summary>
/// Stores whether the sequence uses a single monochrome plane.
/// </summary>
private bool isMonochrome;
/// <summary>
/// Gets or sets a value indicating whether color-description syntax is present.
/// </summary>
public bool IsColorDescriptionPresent { get; set; }
/// <summary>
@ -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;
}
}
/// <summary>
/// Gets or sets the color-primary chromaticities.
/// </summary>
public ObuColorPrimaries ColorPrimaries { get; set; }
/// <summary>
/// Gets or sets the transfer characteristics.
/// </summary>
public ObuTransferCharacteristics TransferCharacteristics { get; set; }
/// <summary>
/// Gets or sets the matrix coefficients used to derive luma and chroma components.
/// </summary>
public ObuMatrixCoefficients MatrixCoefficients { get; set; }
/// <summary>
/// Gets or sets a value indicating whether samples use the full numeric range.
/// </summary>
public bool ColorRange { get; set; }
/// <summary>
/// Gets or sets a value indicating whether chroma is subsampled horizontally.
/// </summary>
public bool SubSamplingX { get; set; }
/// <summary>
/// Gets or sets a value indicating whether chroma is subsampled vertically.
/// </summary>
public bool SubSamplingY { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the U and V planes use separate quantizer deltas.
/// </summary>
public bool HasSeparateUvDelta { get; set; }
/// <summary>
/// Gets or sets the chroma sample position for vertically subsampled images.
/// </summary>
public ObuChromoSamplePosition ChromaSamplePosition { get; set; }
/// <summary>
/// Gets or sets the encoded sample bit depth.
/// </summary>
public Av1BitDepth BitDepth { get; set; }
/// <summary>
/// Gets the color format represented by the monochrome and chroma-subsampling flags.
/// </summary>
/// <returns>The corresponding AV1 color format.</returns>
public Av1ColorFormat GetColorFormat()
{
Av1ColorFormat format = Av1ColorFormat.Yuv400;

56
src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuColorPrimaries.cs

@ -3,19 +3,73 @@
namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit;
/// <summary>
/// Identifies the CICP color-primary chromaticities signaled by an AV1 sequence.
/// </summary>
internal enum ObuColorPrimaries
{
None = 0,
/// <summary>
/// The reserved zero value.
/// </summary>
Reserved = 0,
/// <summary>
/// ITU-R BT.709 primaries.
/// </summary>
Bt709 = 1,
/// <summary>
/// Unspecified primaries.
/// </summary>
Unspecified = 2,
/// <summary>
/// ITU-R BT.470 System M primaries.
/// </summary>
Bt470M = 4,
/// <summary>
/// ITU-R BT.470 System B and G primaries.
/// </summary>
Bt470BG = 5,
/// <summary>
/// ITU-R BT.601 primaries.
/// </summary>
Bt601 = 6,
/// <summary>
/// SMPTE 240M primaries.
/// </summary>
Smpte240 = 7,
/// <summary>
/// Generic film primaries.
/// </summary>
GenericFilm = 8,
/// <summary>
/// ITU-R BT.2020 and BT.2100 primaries.
/// </summary>
Bt2020 = 9,
/// <summary>
/// SMPTE ST 428 CIE XYZ primaries.
/// </summary>
Xyz = 10,
/// <summary>
/// SMPTE RP 431-2 primaries.
/// </summary>
Smpte431 = 11,
/// <summary>
/// SMPTE EG 432-1 primaries.
/// </summary>
Smpte432 = 12,
/// <summary>
/// EBU Tech. 3213-E primaries.
/// </summary>
Ebu3213 = 22,
}

15
src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuConstraintDirectionalEnhancementFilterParameters.cs

@ -3,13 +3,28 @@
namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit;
/// <summary>
/// Contains the constrained directional enhancement filter parameters for an AV1 frame.
/// </summary>
internal class ObuConstraintDirectionalEnhancementFilterParameters
{
/// <summary>
/// Gets or sets the number of bits used to select a filter-strength entry.
/// </summary>
public int BitCount { get; internal set; }
/// <summary>
/// Gets or sets the filter damping value.
/// </summary>
public int Damping { get; internal set; }
/// <summary>
/// Gets or sets the primary and secondary luma strengths for each filter entry.
/// </summary>
public int[] YStrength { get; set; } = new int[16];
/// <summary>
/// Gets or sets the primary and secondary chroma strengths for each filter entry.
/// </summary>
public int[] UvStrength { get; set; } = new int[16];
}

3
src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuDecoderModelInfo.cs

@ -3,6 +3,9 @@
namespace SixLabors.ImageSharp.Formats.Heif.Av1;
/// <summary>
/// Contains the field widths and decoding-clock units used by the AV1 decoder model.
/// </summary>
internal class ObuDecoderModelInfo
{
/// <summary>

12
src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuDeltaParameters.cs

@ -3,11 +3,23 @@
namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit;
/// <summary>
/// Contains the delta-quantizer or delta-loop-filter signaling parameters for an AV1 frame.
/// </summary>
internal class ObuDeltaParameters
{
/// <summary>
/// Gets or sets a value indicating whether per-block delta values are present.
/// </summary>
public bool IsPresent { get; internal set; }
/// <summary>
/// Gets or sets the delta-value resolution.
/// </summary>
public int Resolution { get; internal set; }
/// <summary>
/// Gets or sets a value indicating whether separate loop-filter deltas are signaled for multiple filter targets.
/// </summary>
public bool IsMulti { get; internal set; }
}

3
src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuFilmGrainParameters.cs

@ -3,6 +3,9 @@
namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit;
/// <summary>
/// Contains the parameters used to synthesize AV1 film grain for a decoded frame.
/// </summary>
internal class ObuFilmGrainParameters
{
/// <summary>

136
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;
/// <summary>
/// Stores the decoded syntax and derived state for one AV1 frame header.
/// </summary>
internal class ObuFrameHeader
{
/// <summary>
/// Gets or sets a value indicating whether motion vectors use integer-sample precision.
/// </summary>
public bool ForceIntegerMotionVector { get; set; }
/// <summary>
/// Gets or sets a value indicating whether intra-block copy is permitted.
/// </summary>
public bool AllowIntraBlockCopy { get; set; }
/// <summary>
/// Gets or sets a value indicating whether reference-frame motion vectors may be used.
/// </summary>
public bool UseReferenceFrameMotionVectors { get; set; }
/// <summary>
/// Gets or sets a value indicating whether motion vectors may use high precision.
/// </summary>
public bool AllowHighPrecisionMotionVector { get; set; }
/// <summary>
/// Gets or sets the decoded tile layout.
/// </summary>
public ObuTileGroupHeader TilesInfo { get; set; } = new ObuTileGroupHeader();
/// <summary>
/// Gets or sets a value indicating whether every segment uses lossless coding.
/// </summary>
public bool CodedLossless { get; set; }
/// <summary>
/// Gets or sets the lossless-coding flag for each segment.
/// </summary>
public bool[] LosslessArray { get; set; } = new bool[Av1Constants.MaxSegmentCount];
/// <summary>
/// Gets or sets the frame quantization parameters.
/// </summary>
public ObuQuantizationParameters QuantizationParameters { get; set; } = new ObuQuantizationParameters();
/// <summary>
/// Gets or sets the frame segmentation parameters.
/// </summary>
public ObuSegmentationParameters SegmentationParameters { get; set; } = new ObuSegmentationParameters();
/// <summary>
/// Gets or sets a value indicating whether coding is lossless and no super-resolution scaling is applied.
/// </summary>
public bool AllLossless { get; set; }
/// <summary>
/// Gets or sets a value indicating whether warped motion is permitted.
/// </summary>
public bool AllowWarpedMotion { get; set; }
/// <summary>
/// Gets or sets the permitted reference prediction mode.
/// </summary>
public ObuReferenceMode ReferenceMode { get; set; }
/// <summary>
/// Gets or sets the film-grain synthesis parameters.
/// </summary>
public ObuFilmGrainParameters FilmGrainParameters { get; set; } = new ObuFilmGrainParameters();
/// <summary>
/// Gets or sets a value indicating whether the reduced transform set is used.
/// </summary>
public bool UseReducedTransformSet { get; set; }
/// <summary>
/// Gets or sets the loop-filter parameters.
/// </summary>
public ObuLoopFilterParameters LoopFilterParameters { get; set; } = new ObuLoopFilterParameters();
/// <summary>
/// Gets or sets the loop-restoration parameters.
/// </summary>
public ObuLoopRestorationParameters LoopRestorationParameters { get; set; } = new ObuLoopRestorationParameters();
/// <summary>
/// Gets or sets the constrained directional enhancement filter parameters.
/// </summary>
public ObuConstraintDirectionalEnhancementFilterParameters CdefParameters { get; set; } = new ObuConstraintDirectionalEnhancementFilterParameters();
/// <summary>
/// Gets or sets the number of mode-information columns in one stored row.
/// </summary>
public int ModeInfoStride { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the frame-end probability update is disabled.
/// </summary>
public bool DisableFrameEndUpdateCdf { get; set; }
/// <summary>
/// Gets or sets the skip-mode parameters.
/// </summary>
public ObuSkipModeParameters SkipModeParameters { get; set; } = new ObuSkipModeParameters();
/// <summary>
/// Gets or sets the transform-size selection mode.
/// </summary>
public Av1TransformMode TransformMode { get; set; }
/// <summary>
/// Gets or sets the loop-filter delta parameters.
/// </summary>
public ObuDeltaParameters DeltaLoopFilterParameters { get; set; } = new ObuDeltaParameters();
/// <summary>
/// Gets or sets the quantizer delta parameters.
/// </summary>
public ObuDeltaParameters DeltaQParameters { get; set; } = new ObuDeltaParameters();
/// <summary>
/// Gets a value indicating whether the frame uses intra prediction only.
/// </summary>
public bool IsIntra => this.FrameType is ObuFrameType.IntraOnlyFrame or ObuFrameType.KeyFrame;
/// <summary>
/// Gets or sets the decoded and rendered frame dimensions.
/// </summary>
internal ObuFrameSize FrameSize { get; set; } = new ObuFrameSize();
/// <summary>
/// Gets or sets the frame width in mode-information units.
/// </summary>
internal int ModeInfoColumnCount { get; set; }
/// <summary>
/// Gets or sets the frame height in mode-information units.
/// </summary>
internal int ModeInfoRowCount { get; set; }
/// <summary>
/// Gets or sets a value indicating whether an existing reference frame is displayed without decoding a new frame.
/// </summary>
internal bool ShowExistingFrame { get; set; }
/// <summary>
/// Gets or sets the coded frame type.
/// </summary>
internal ObuFrameType FrameType { get; set; }
/// <summary>
/// Gets or sets the validity state of each reference-frame slot.
/// </summary>
internal bool[] ReferenceValid { get; set; } = new bool[Av1Constants.ReferenceFrameCount];
/// <summary>
/// Gets or sets the stored order-hint state for each reference-frame slot.
/// </summary>
internal bool[] ReferenceOrderHint { get; set; } = new bool[Av1Constants.ReferenceFrameCount];
/// <summary>
/// Gets or sets a value indicating whether the decoded frame is immediately displayed.
/// </summary>
internal bool ShowFrame { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the frame may be displayed by a later header.
/// </summary>
internal bool ShowableFrame { get; set; }
/// <summary>
/// Gets or sets the reference map index selected when showing an existing frame.
/// </summary>
internal uint FrameToShowMapIdx { get; set; }
/// <summary>
/// Gets or sets the display frame identifier.
/// </summary>
internal uint DisplayFrameId { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the frame can be decoded without state from earlier frames.
/// </summary>
internal bool ErrorResilientMode { get; set; }
/// <summary>
/// Gets or sets a value indicating whether screen-content coding tools are permitted.
/// </summary>
internal bool AllowScreenContentTools { get; set; }
/// <summary>
/// Gets or sets a value indicating whether probability adaptation is disabled for this frame.
/// </summary>
internal bool DisableCdfUpdate { get; set; }
/// <summary>
/// Gets or sets the identifier of the current frame.
/// </summary>
internal uint CurrentFrameId { get; set; }
/// <summary>
/// Gets or sets the reference-map index selected for each inter reference.
/// </summary>
internal uint[] ReferenceFrameIndex { get; set; } = new uint[Av1Constants.ReferenceFrameCount];
/// <summary>
/// Gets or sets the frame order hint.
/// </summary>
internal uint OrderHint { get; set; }
/// <summary>
/// Gets or sets the reference frame supplying the initial probability context.
/// </summary>
internal uint PrimaryReferenceFrame { get; set; } = Av1Constants.PrimaryReferenceFrameNone;
/// <summary>
/// Gets or sets the bit mask of reference slots refreshed by this frame.
/// </summary>
internal uint RefreshFrameFlags { get; set; }
// 5.9.31. Temporal point info syntax
/// <summary>
/// Gets or sets the presentation time signaled by temporal point information.
/// </summary>
internal uint FramePresentationTime { get; set; }
}

21
src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuFrameSize.cs

@ -3,17 +3,38 @@
namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit;
/// <summary>
/// Contains the coded, upscaled, and rendered dimensions of an AV1 frame.
/// </summary>
internal class ObuFrameSize
{
/// <summary>
/// Gets or sets the coded frame width.
/// </summary>
internal int FrameWidth { get; set; }
/// <summary>
/// Gets or sets the coded frame height.
/// </summary>
internal int FrameHeight { get; set; }
/// <summary>
/// Gets or sets the denominator used by AV1 super-resolution scaling.
/// </summary>
internal int SuperResolutionDenominator { get; set; }
/// <summary>
/// Gets or sets the frame width after super-resolution upscaling.
/// </summary>
internal int SuperResolutionUpscaledWidth { get; set; }
/// <summary>
/// Gets or sets the intended display width.
/// </summary>
internal int RenderWidth { get; set; }
/// <summary>
/// Gets or sets the intended display height.
/// </summary>
internal int RenderHeight { get; set; }
}

18
src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuFrameType.cs

@ -3,10 +3,28 @@
namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit;
/// <summary>
/// Identifies the AV1 frame type signaled by a frame header.
/// </summary>
internal enum ObuFrameType
{
/// <summary>
/// A key frame that is decoded without reference to another frame.
/// </summary>
KeyFrame = 0,
/// <summary>
/// An inter frame that can refer to previously decoded frames.
/// </summary>
InterFrame = 1,
/// <summary>
/// An intra-only frame that does not refresh all reference slots.
/// </summary>
IntraOnlyFrame = 2,
/// <summary>
/// A switch frame that permits switching between coded sequences.
/// </summary>
SwitchFrame = 3,
}

24
src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuHeader.cs

@ -3,19 +3,43 @@
namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit;
/// <summary>
/// Contains the parsed header and payload size of an AV1 open bitstream unit.
/// </summary>
internal class ObuHeader
{
/// <summary>
/// Gets or sets the number of bytes occupied by the OBU header and its size field.
/// </summary>
public int Size { get; set; }
/// <summary>
/// Gets or sets the OBU payload type.
/// </summary>
public ObuType Type { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the OBU carries an explicit payload-size field.
/// </summary>
public bool HasSize { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the OBU carries temporal and spatial identifiers.
/// </summary>
public bool HasExtension { get; set; }
/// <summary>
/// Gets or sets the temporal-layer identifier.
/// </summary>
public int TemporalId { get; set; }
/// <summary>
/// Gets or sets the spatial-layer identifier.
/// </summary>
public int SpatialId { get; set; }
/// <summary>
/// Gets or sets the OBU payload size, in bytes.
/// </summary>
public int PayloadSize { get; set; }
}

30
src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuLoopFilterParameters.cs

@ -3,27 +3,57 @@
namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit;
/// <summary>
/// Contains the AV1 deblocking-loop-filter parameters for a frame.
/// </summary>
internal class ObuLoopFilterParameters
{
/// <summary>
/// Initializes a new instance of the <see cref="ObuLoopFilterParameters"/> class with the AV1 default reference and mode deltas.
/// </summary>
public ObuLoopFilterParameters()
{
this.ReferenceDeltas = [1, 0, 0, 0, 0, -1, -1, -1];
this.ModeDeltas = [0, 0];
}
/// <summary>
/// Gets or sets the horizontal and vertical luma filter levels.
/// </summary>
public int[] FilterLevel { get; internal set; } = new int[2];
/// <summary>
/// Gets or sets the U-plane filter level.
/// </summary>
public int FilterLevelU { get; internal set; }
/// <summary>
/// Gets or sets the V-plane filter level.
/// </summary>
public int FilterLevelV { get; internal set; }
/// <summary>
/// Gets or sets the filter sharpness level.
/// </summary>
public int SharpnessLevel { get; internal set; }
/// <summary>
/// Gets or sets a value indicating whether reference-frame and mode deltas are enabled.
/// </summary>
public bool ReferenceDeltaModeEnabled { get; internal set; }
/// <summary>
/// Gets or sets a value indicating whether reference-frame and mode deltas are updated by this frame.
/// </summary>
public bool ReferenceDeltaModeUpdate { get; internal set; }
/// <summary>
/// Gets the filter-level deltas for the AV1 reference-frame categories.
/// </summary>
public int[] ReferenceDeltas { get; }
/// <summary>
/// Gets the filter-level deltas for the AV1 prediction modes.
/// </summary>
public int[] ModeDeltas { get; }
}

9
src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuLoopRestorationItem.cs

@ -3,9 +3,18 @@
namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit;
/// <summary>
/// Contains the loop-restoration type and unit size for one color plane.
/// </summary>
internal class ObuLoopRestorationItem
{
/// <summary>
/// Gets or sets the restoration-unit size, in samples.
/// </summary>
internal int Size { get; set; }
/// <summary>
/// Gets or sets the restoration filter type.
/// </summary>
internal ObuRestorationType Type { get; set; } = ObuRestorationType.None;
}

23
src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuLoopRestorationParameters.cs

@ -3,23 +3,46 @@
namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit;
/// <summary>
/// Contains the AV1 loop-restoration configuration for a frame.
/// </summary>
internal class ObuLoopRestorationParameters
{
/// <summary>
/// Initializes a new instance of the <see cref="ObuLoopRestorationParameters"/> class.
/// </summary>
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();
}
/// <summary>
/// Gets or sets a value indicating whether any plane uses loop restoration.
/// </summary>
internal bool UsesLoopRestoration { get; set; }
/// <summary>
/// Gets or sets a value indicating whether either chroma plane uses loop restoration.
/// </summary>
internal bool UsesChromaLoopRestoration { get; set; }
/// <summary>
/// Gets the loop-restoration configuration for each plane.
/// </summary>
internal ObuLoopRestorationItem[] Items { get; }
/// <summary>
/// Gets or sets the luma restoration-unit size shift.
/// </summary>
internal int UnitShift { get; set; }
/// <summary>
/// Gets or sets the chroma restoration-unit size shift relative to luma.
/// </summary>
internal int UVShift { get; set; }
}

60
src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuMatrixCoefficients.cs

@ -3,20 +3,78 @@
namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit;
/// <summary>
/// Identifies the CICP matrix coefficients used to derive luma and chroma components.
/// </summary>
internal enum ObuMatrixCoefficients
{
/// <summary>
/// The identity matrix used for GBR component ordering.
/// </summary>
Identity = 0,
/// <summary>
/// ITU-R BT.709 coefficients.
/// </summary>
Bt709 = 1,
/// <summary>
/// Unspecified coefficients.
/// </summary>
Unspecified = 2,
/// <summary>
/// United States FCC 73.628 coefficients.
/// </summary>
Fcc = 4,
/// <summary>
/// ITU-R BT.470 System B and G coefficients.
/// </summary>
Bt470BG = 5,
/// <summary>
/// ITU-R BT.601 coefficients.
/// </summary>
Bt601 = 6,
/// <summary>
/// SMPTE 240M coefficients.
/// </summary>
Smpte240 = 7,
/// <summary>
/// SMPTE YCgCo coefficients.
/// </summary>
SmpteYCgCo = 8,
/// <summary>
/// ITU-R BT.2020 non-constant-luminance coefficients.
/// </summary>
Bt2020NonConstantLuminance = 9,
/// <summary>
/// ITU-R BT.2020 constant-luminance coefficients.
/// </summary>
Bt2020ConstantLuminance = 10,
/// <summary>
/// SMPTE ST 2085 YDzDx coefficients.
/// </summary>
Smpte2085 = 11,
/// <summary>
/// Chromaticity-derived non-constant-luminance coefficients.
/// </summary>
ChromaticityDerivedNonConstantLuminance = 12,
ChromaticityDerivedConstandLuminance = 13,
/// <summary>
/// Chromaticity-derived constant-luminance coefficients.
/// </summary>
ChromaticityDerivedConstantLuminance = 13,
/// <summary>
/// ITU-R BT.2100 ICtCp coefficients.
/// </summary>
Bt2100ICtCp = 14,
}

37
src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuMetadataType.cs

@ -3,11 +3,38 @@
namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit;
/// <summary>
/// Identifies the payload carried by an AV1 metadata OBU.
/// </summary>
internal enum ObuMetadataType
{
ItutT35,
HdrCll,
HdrMdcv,
Scalability,
Timecode
/// <summary>
/// The reserved zero value.
/// </summary>
Reserved = 0,
/// <summary>
/// Content light-level metadata.
/// </summary>
HdrCll = 1,
/// <summary>
/// Mastering-display color-volume metadata.
/// </summary>
HdrMdcv = 2,
/// <summary>
/// Scalability-structure metadata.
/// </summary>
Scalability = 3,
/// <summary>
/// ITU-T T.35 terminal-provider metadata.
/// </summary>
ItutT35 = 4,
/// <summary>
/// Timecode metadata.
/// </summary>
Timecode = 5,
}

29
src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuOperatingPoint.cs

@ -3,27 +3,44 @@
namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit;
/// <summary>
/// Contains the sequence-level constraints for an AV1 operating point.
/// </summary>
internal class ObuOperatingPoint
{
/// <summary>
/// Gets or sets the operating-point index.
/// </summary>
internal int OperatorIndex { get; set; }
/// <summary>
/// Gets or sets the AV1 sequence-level index.
/// </summary>
internal int SequenceLevelIndex { get; set; }
/// <summary>
/// Gets or sets the sequence tier.
/// </summary>
internal int SequenceTier { get; set; }
/// <summary>
/// Gets or sets a value indicating whether decoder-model timing is present for this operating point.
/// </summary>
internal bool IsDecoderModelInfoPresent { get; set; }
/// <summary>
/// Gets or sets a value indicating whether an initial display delay is present for this operating point.
/// </summary>
internal bool IsInitialDisplayDelayPresent { get; set; }
/// <summary>
/// Gets or sets the initial display delay minus one, in decoded frames.
/// </summary>
internal uint InitialDisplayDelay { get; set; }
/// <summary>
/// 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.
/// </summary>
internal uint Idc { get; set; }
}

15
src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuOrderHintInfo.cs

@ -3,13 +3,28 @@
namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit;
/// <summary>
/// Contains the sequence-level order-hint and dependent prediction-tool settings.
/// </summary>
internal class ObuOrderHintInfo
{
/// <summary>
/// Gets or sets a value indicating whether order hints are enabled.
/// </summary>
public bool EnableOrderHint { get; internal set; }
/// <summary>
/// Gets or sets a value indicating whether joint compound prediction is enabled.
/// </summary>
internal bool EnableJointCompound { get; set; }
/// <summary>
/// Gets or sets a value indicating whether reference-frame motion vectors are enabled.
/// </summary>
internal bool EnableReferenceFrameMotionVectors { get; set; }
/// <summary>
/// Gets or sets the number of bits used to encode order hints.
/// </summary>
internal int OrderHintBits { get; set; }
}

24
src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuQuantizationParameters.cs

@ -3,19 +3,43 @@
namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit;
/// <summary>
/// Contains the AV1 quantization parameters for a frame.
/// </summary>
internal class ObuQuantizationParameters
{
/// <summary>
/// Gets or sets the base quantizer index.
/// </summary>
public int BaseQIndex { get; set; }
/// <summary>
/// Gets or sets the effective quantizer index for each segment.
/// </summary>
public int[] QIndex { get; set; } = new int[Av1Constants.MaxSegmentCount];
/// <summary>
/// Gets or sets a value indicating whether quantization matrices are enabled.
/// </summary>
public bool IsUsingQMatrix { get; internal set; }
/// <summary>
/// Gets or sets the DC quantizer-index deltas for the Y, U, and V planes.
/// </summary>
public int[] DeltaQDc { get; internal set; } = new int[3];
/// <summary>
/// Gets or sets the AC quantizer-index deltas for the Y, U, and V planes.
/// </summary>
public int[] DeltaQAc { get; internal set; } = new int[3];
/// <summary>
/// Gets or sets the quantization-matrix level for the Y, U, and V planes.
/// </summary>
public int[] QMatrix { get; internal set; } = new int[3];
/// <summary>
/// Gets or sets a value indicating whether the U and V planes use separate quantizer deltas.
/// </summary>
public bool HasSeparateUvDelta { get; internal set; }
}

14
src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuReferenceMode.cs

@ -3,8 +3,18 @@
namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit;
/// <summary>
/// Identifies whether inter blocks use only single references or can select compound references.
/// </summary>
internal enum ObuReferenceMode
{
ReferenceModeSelect,
SingleReference,
/// <summary>
/// Only single-reference prediction is permitted.
/// </summary>
SingleReference = 0,
/// <summary>
/// Each eligible block selects single- or compound-reference prediction.
/// </summary>
ReferenceModeSelect = 1,
}

20
src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuRestorationType.cs

@ -3,10 +3,28 @@
namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit;
/// <summary>
/// Identifies the loop-restoration mode encoded by the two-bit frame-restoration syntax.
/// </summary>
internal enum ObuRestorationType : uint
{
/// <summary>
/// Loop restoration is disabled.
/// </summary>
None = 0,
/// <summary>
/// Each restoration unit selects its filter type.
/// </summary>
Switchable = 1,
Weiner = 2,
/// <summary>
/// Separable Wiener filtering is used.
/// </summary>
Wiener = 2,
/// <summary>
/// Self-guided restoration projection is used.
/// </summary>
SgrProj = 3,
}

34
src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuSegmentationLevelFeature.cs

@ -3,14 +3,48 @@
namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit;
/// <summary>
/// Identifies a feature that AV1 can configure independently for each segment.
/// </summary>
internal enum ObuSegmentationLevelFeature
{
/// <summary>
/// Adjusts the segment quantizer index.
/// </summary>
AlternativeQuantizer,
/// <summary>
/// Adjusts the vertical luma loop-filter level.
/// </summary>
AlternativeLoopFilterYVertical,
/// <summary>
/// Adjusts the horizontal luma loop-filter level.
/// </summary>
AlternativeLoopFilterYHorizontal,
/// <summary>
/// Adjusts the U-plane loop-filter level.
/// </summary>
AlternativeLoopFilterU,
/// <summary>
/// Adjusts the V-plane loop-filter level.
/// </summary>
AlternativeLoopFilterV,
/// <summary>
/// Selects a reference frame for the segment.
/// </summary>
ReferenceFrame,
/// <summary>
/// Marks every block in the segment as skipped.
/// </summary>
Skip,
/// <summary>
/// Uses the global motion vector for the segment.
/// </summary>
GlobalMotionVector,
}

37
src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuSegmentationParameters.cs

@ -3,39 +3,62 @@
namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit;
/// <summary>
/// Contains the AV1 segmentation state and per-segment feature values for a frame.
/// </summary>
internal class ObuSegmentationParameters
{
/// <summary>
/// Gets or sets the effective quantization-matrix level for each plane and segment.
/// </summary>
public int[][] QMLevel { get; internal set; } = new int[3][];
/// <summary>
/// Gets or sets the enabled state of every feature for every segment.
/// </summary>
public bool[,] FeatureEnabled { get; internal set; } = new bool[Av1Constants.MaxSegmentCount, Av1Constants.SegmentationLevelMax];
/// <summary>
/// Gets or sets a value indicating whether segmentation is enabled for the frame.
/// </summary>
public bool Enabled { get; internal set; }
/// <summary>
/// Gets or sets the value of every feature for every segment.
/// </summary>
public int[,] FeatureData { get; internal set; } = new int[Av1Constants.MaxSegmentCount, Av1Constants.SegmentationLevelMax];
/// <summary>
/// Gets or sets a value indicating whether segment identifiers are decoded before skip-mode decisions.
/// </summary>
public bool SegmentIdPrecedesSkip { get; internal set; }
/// <summary>
/// Gets or sets the greatest segment identifier that has at least one active feature.
/// </summary>
public int LastActiveSegmentId { get; internal set; }
/// <summary>
/// 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.
/// </summary>
public int SegmentationUpdateMap { get; internal set; }
/// <summary>
/// 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.
/// </summary>
public int SegmentationTemporalUpdate { get; internal set; }
/// <summary>
/// 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.
/// </summary>
public int SegmentationUpdateData { get; internal set; }
/// <summary>
/// Determines whether a feature is active for a segment.
/// </summary>
/// <param name="segmentId">The segment identifier.</param>
/// <param name="feature">The feature to inspect.</param>
/// <returns><see langword="true"/> when the feature is active; otherwise, <see langword="false"/>.</returns>
internal bool IsFeatureActive(int segmentId, ObuSegmentationLevelFeature feature)
=> this.FeatureEnabled[segmentId, (int)feature];
}

122
src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuSequenceHeader.cs

@ -3,93 +3,215 @@
namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit;
/// <summary>
/// Stores AV1 sequence capabilities, dimensions, timing, and color configuration.
/// </summary>
internal class ObuSequenceHeader
{
/// <summary>
/// Backs <see cref="Use128x128Superblock"/> while its dependent geometry is updated.
/// </summary>
private bool use128x128Superblock;
/// <summary>
/// Gets or sets a value indicating whether filter-intra prediction is enabled.
/// </summary>
public bool EnableFilterIntra { get; set; }
/// <summary>
/// Gets or sets a value indicating whether constrained directional enhancement filtering is enabled.
/// </summary>
public bool EnableCdef { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the sequence contains one still picture.
/// </summary>
public bool IsStillPicture { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the reduced still-picture header syntax is used.
/// </summary>
public bool IsReducedStillPictureHeader { get; set; }
/// <summary>
/// Gets or sets the sequence profile.
/// </summary>
public ObuSequenceProfile SequenceProfile { get; set; }
/// <summary>
/// Gets or sets the signaled operating points.
/// </summary>
public ObuOperatingPoint[] OperatingPoint { get; set; } = new ObuOperatingPoint[1];
/// <summary>
/// Gets or sets the decoder-buffer model information when present.
/// </summary>
public ObuDecoderModelInfo? DecoderModelInfo { get; set; }
/// <summary>
/// Gets or sets a value indicating whether operating points may carry initial display delays.
/// </summary>
public bool InitialDisplayDelayPresentFlag { get; set; }
/// <summary>
/// Gets or sets a value indicating whether decoder-model information is present.
/// </summary>
public bool DecoderModelInfoPresentFlag { get; set; }
/// <summary>
/// Gets or sets a value indicating whether sequence timing information is present.
/// </summary>
public bool TimingInfoPresentFlag { get; set; }
/// <summary>
/// Gets or sets the sequence timing information when present.
/// </summary>
public ObuTimingInfo? TimingInfo { get; set; }
/// <summary>
/// Gets or sets a value indicating whether frame identifiers are signaled.
/// </summary>
public bool IsFrameIdNumbersPresent { get; set; }
/// <summary>
/// Gets or sets the number of bits used to signal frame widths minus one.
/// </summary>
public int FrameWidthBits { get; set; }
/// <summary>
/// Gets or sets the number of bits used to signal frame heights minus one.
/// </summary>
public int FrameHeightBits { get; set; }
/// <summary>
/// Gets or sets the maximum decoded frame width in pixels.
/// </summary>
public int MaxFrameWidth { get; set; }
/// <summary>
/// Gets or sets the maximum decoded frame height in pixels.
/// </summary>
public int MaxFrameHeight { get; set; }
/// <summary>
/// Gets or sets a value indicating whether 128x128 superblocks are used.
/// </summary>
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);
}
}
/// <summary>
/// Gets the selected superblock dimensions.
/// </summary>
public Av1BlockSize SuperblockSize { get; private set; }
/// <summary>
/// Gets the superblock width and height in mode-information units.
/// </summary>
public int SuperblockModeInfoSize { get; private set; }
/// <summary>
/// Gets the base-two logarithm of the superblock size in pixels.
/// </summary>
public int SuperblockSizeLog2 { get; private set; }
/// <summary>
/// Gets or sets the filter-intra capability level.
/// </summary>
public int FilterIntraLevel { get; set; }
/// <summary>
/// Gets or sets a value indicating whether intra edge filtering is enabled.
/// </summary>
public bool EnableIntraEdgeFilter { get; set; }
/// <summary>
/// Gets or sets the order-hint capabilities.
/// </summary>
public ObuOrderHintInfo OrderHintInfo { get; set; } = new ObuOrderHintInfo();
/// <summary>
/// Gets or sets a value indicating whether order hints are enabled.
/// </summary>
public bool EnableOrderHint { get; set; }
/// <summary>
/// Gets or sets a value indicating whether inter-intra compound prediction is enabled.
/// </summary>
public bool EnableInterIntraCompound { get; set; }
/// <summary>
/// Gets or sets a value indicating whether masked compound prediction is enabled.
/// </summary>
public bool EnableMaskedCompound { get; set; }
/// <summary>
/// Gets or sets a value indicating whether warped motion is enabled.
/// </summary>
public bool EnableWarpedMotion { get; set; }
/// <summary>
/// Gets or sets a value indicating whether independent horizontal and vertical interpolation filters are enabled.
/// </summary>
public bool EnableDualFilter { get; set; }
/// <summary>
/// Gets or sets the sequence-level integer-motion-vector selection.
/// </summary>
public int ForceIntegerMotionVector { get; set; }
/// <summary>
/// Gets or sets the sequence-level screen-content-tools selection.
/// </summary>
public int ForceScreenContentTools { get; set; }
/// <summary>
/// Gets or sets a value indicating whether frame super-resolution is enabled.
/// </summary>
public bool EnableSuperResolution { get; set; }
/// <summary>
/// Gets or sets the constrained directional enhancement filter capability level.
/// </summary>
public int CdefLevel { get; set; }
/// <summary>
/// Gets or sets a value indicating whether loop restoration is enabled.
/// </summary>
public bool EnableRestoration { get; set; }
/// <summary>
/// Gets or sets the decoded color configuration.
/// </summary>
public ObuColorConfig ColorConfig { get; set; } = new ObuColorConfig();
/// <summary>
/// Gets or sets a value indicating whether frame headers may carry film-grain parameters.
/// </summary>
public bool AreFilmGrainingParametersPresent { get; set; }
/// <summary>
/// Gets or sets the total number of bits in a frame identifier.
/// </summary>
public int FrameIdLength { get; set; }
/// <summary>
/// Gets or sets the number of bits in a delta frame identifier.
/// </summary>
public int DeltaFrameIdLength { get; set; }
/// <summary>
/// Gets or sets the additional frame-identifier bit count signaled by the sequence header.
/// </summary>
public uint AdditionalFrameIdLength { get; set; }
}

14
src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuSequenceProfile.cs

@ -3,9 +3,23 @@
namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit;
/// <summary>
/// Identifies the AV1 sequence profile and its permitted bit-depth and chroma formats.
/// </summary>
internal enum ObuSequenceProfile : uint
{
/// <summary>
/// The Main profile.
/// </summary>
Main = 0,
/// <summary>
/// The High profile.
/// </summary>
High = 1,
/// <summary>
/// The Professional profile.
/// </summary>
Professional = 2,
}

9
src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuSkipModeParameters.cs

@ -3,9 +3,18 @@
namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit;
/// <summary>
/// Contains the availability and enabled state of AV1 skip mode for a frame.
/// </summary>
internal class ObuSkipModeParameters
{
/// <summary>
/// Gets or sets a value indicating whether the frame is permitted to use skip mode.
/// </summary>
public bool SkipModeAllowed { get; set; }
/// <summary>
/// Gets or sets a value indicating whether skip mode is enabled for the frame.
/// </summary>
public bool SkipModeFlag { get; internal set; }
}

51
src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuTileGroupHeader.cs

@ -3,37 +3,88 @@
namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit;
/// <summary>
/// Contains the tile layout derived from an AV1 frame header.
/// </summary>
internal class ObuTileGroupHeader
{
/// <summary>
/// Gets or sets the maximum tile width, in superblocks.
/// </summary>
internal int MaxTileWidthSuperblock { get; set; }
/// <summary>
/// Gets or sets the maximum tile height, in superblocks.
/// </summary>
internal int MaxTileHeightSuperblock { get; set; }
/// <summary>
/// Gets or sets the minimum base-2 logarithm of the tile-column count.
/// </summary>
internal int MinLog2TileColumnCount { get; set; }
/// <summary>
/// Gets or sets the maximum base-2 logarithm of the tile-column count.
/// </summary>
internal int MaxLog2TileColumnCount { get; set; }
/// <summary>
/// Gets or sets the maximum base-2 logarithm of the tile-row count.
/// </summary>
internal int MaxLog2TileRowCount { get; set; }
/// <summary>
/// Gets or sets the minimum base-2 logarithm of the total tile count.
/// </summary>
internal int MinLog2TileCount { get; set; }
/// <summary>
/// Gets or sets a value indicating whether tile columns and rows use uniform spacing.
/// </summary>
public bool HasUniformTileSpacing { get; set; }
/// <summary>
/// Gets or sets the base-2 logarithm of the tile-column count.
/// </summary>
internal int TileColumnCountLog2 { get; set; }
/// <summary>
/// Gets or sets the number of tile columns.
/// </summary>
internal int TileColumnCount { get; set; }
/// <summary>
/// Gets or sets the starting superblock column for each tile column.
/// </summary>
internal int[] TileColumnStartModeInfo { get; set; } = new int[Av1Constants.MaxTileRowCount + 1];
/// <summary>
/// Gets or sets the minimum base-2 logarithm of the tile-row count.
/// </summary>
internal int MinLog2TileRowCount { get; set; }
/// <summary>
/// Gets or sets the base-2 logarithm of the tile-row count.
/// </summary>
internal int TileRowCountLog2 { get; set; }
/// <summary>
/// Gets or sets the starting superblock row for each tile row.
/// </summary>
internal int[] TileRowStartModeInfo { get; set; } = new int[Av1Constants.MaxTileColumnCount + 1];
/// <summary>
/// Gets or sets the number of tile rows.
/// </summary>
internal int TileRowCount { get; set; }
/// <summary>
/// Gets or sets the tile whose entropy context is retained after frame decoding.
/// </summary>
internal uint ContextUpdateTileId { get; set; }
/// <summary>
/// Gets or sets the number of bytes used to signal each tile size.
/// </summary>
internal int TileSizeBytes { get; set; }
}

3
src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuTimingInfo.cs

@ -3,6 +3,9 @@
namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit;
/// <summary>
/// Contains the timing syntax signaled by an AV1 sequence header.
/// </summary>
internal class ObuTimingInfo
{
/// <summary>

72
src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuTransferCharacteristics.cs

@ -3,23 +3,93 @@
namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit;
/// <summary>
/// Identifies the CICP transfer characteristics signaled by an AV1 sequence.
/// </summary>
internal enum ObuTransferCharacteristics
{
/// <summary>
/// ITU-R BT.709 transfer characteristics.
/// </summary>
Bt709 = 1,
/// <summary>
/// Unspecified transfer characteristics.
/// </summary>
Unspecified = 2,
/// <summary>
/// ITU-R BT.470 System M transfer characteristics.
/// </summary>
Bt470M = 4,
/// <summary>
/// ITU-R BT.470 System B and G transfer characteristics.
/// </summary>
Bt470BG = 5,
/// <summary>
/// ITU-R BT.601 transfer characteristics.
/// </summary>
Bt601 = 6,
/// <summary>
/// SMPTE 240M transfer characteristics.
/// </summary>
Smpte240 = 7,
/// <summary>
/// Linear light.
/// </summary>
Linear = 8,
/// <summary>
/// Logarithmic transfer with a 100:1 range.
/// </summary>
Log100 = 9,
/// <summary>
/// Logarithmic transfer with a 100 times square-root-of-ten to one range.
/// </summary>
Log100Sqrt10 = 10,
/// <summary>
/// IEC 61966-2-4 transfer characteristics.
/// </summary>
Iec61966 = 11,
/// <summary>
/// ITU-R BT.1361 transfer characteristics.
/// </summary>
Bt1361 = 12,
/// <summary>
/// IEC 61966-2-1 sRGB or sYCC transfer characteristics.
/// </summary>
Srgb = 13,
/// <summary>
/// ITU-R BT.2020 transfer characteristics for 10-bit systems.
/// </summary>
Bt202010Bit = 14,
/// <summary>
/// ITU-R BT.2020 transfer characteristics for 12-bit systems.
/// </summary>
Bt202012Bit = 15,
/// <summary>
/// SMPTE ST 2084 perceptual-quantizer transfer characteristics.
/// </summary>
Smpte2084 = 16,
Smpte248 = 17,
/// <summary>
/// SMPTE ST 428 transfer characteristics.
/// </summary>
Smpte428 = 17,
/// <summary>
/// ITU-R BT.2100 hybrid-log-gamma transfer characteristics.
/// </summary>
Hlg = 18,
}

44
src/ImageSharp/Formats/Heif/Av1/OpenBitstreamUnit/ObuType.cs

@ -3,16 +3,58 @@
namespace SixLabors.ImageSharp.Formats.Heif.Av1.OpenBitstreamUnit;
/// <summary>
/// Identifies an AV1 open bitstream unit payload.
/// </summary>
internal enum ObuType
{
/// <summary>
/// The reserved zero value.
/// </summary>
None = 0,
/// <summary>
/// A sequence header.
/// </summary>
SequenceHeader = 1,
/// <summary>
/// A temporal delimiter.
/// </summary>
TemporalDelimiter = 2,
/// <summary>
/// A frame header without tile data.
/// </summary>
FrameHeader = 3,
RedundantFrameHeader = 7,
/// <summary>
/// One or more encoded tiles.
/// </summary>
TileGroup = 4,
/// <summary>
/// Metadata associated with the coded sequence.
/// </summary>
Metadata = 5,
/// <summary>
/// A frame header followed by tile data.
/// </summary>
Frame = 6,
/// <summary>
/// A repeated copy of the current frame header.
/// </summary>
RedundantFrameHeader = 7,
/// <summary>
/// A list of tiles for large-scale tile decoding.
/// </summary>
TileList = 8,
/// <summary>
/// Padding bytes.
/// </summary>
Padding = 15,
}

Loading…
Cancel
Save