From 48453990301db45227a81d57b4f1d72a16a44787 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Tue, 25 Aug 2026 10:49:06 +1000 Subject: [PATCH] Fix HEIF XML summary formatting --- .../Formats/Heif/Av1/Av1BlockSize.cs | 88 ++++++-- .../Formats/Heif/Hevc/HevcCabacContexts.cs | 164 +++++++++++---- .../Heif/Hevc/HevcCabacSyntaxReader.cs | 148 +++++++++---- .../Formats/Heif/Hevc/HevcCodingTreeState.cs | 64 ++++-- .../Heif/Hevc/HevcIntraPredictionState.cs | 84 ++++++-- .../Formats/Heif/Hevc/HevcPictureBuffer.cs | 72 +++++-- .../Heif/Hevc/HevcPictureParameterSet.cs | 180 ++++++++++++---- src/ImageSharp/Formats/Heif/Hevc/HevcPlane.cs | 12 +- .../Heif/Hevc/HevcSequenceParameterSet.cs | 196 +++++++++++++----- .../Heif/Hevc/HevcSliceSegmentHeader.cs | 76 +++++-- 10 files changed, 813 insertions(+), 271 deletions(-) diff --git a/src/ImageSharp/Formats/Heif/Av1/Av1BlockSize.cs b/src/ImageSharp/Formats/Heif/Av1/Av1BlockSize.cs index e4646508d1..3c1808c9cf 100644 --- a/src/ImageSharp/Formats/Heif/Av1/Av1BlockSize.cs +++ b/src/ImageSharp/Formats/Heif/Av1/Av1BlockSize.cs @@ -8,70 +8,114 @@ namespace SixLabors.ImageSharp.Formats.Heif.Av1; /// internal enum Av1BlockSize : byte { - /// A block of samples, 4 samples wide and 4 samples high. + /// + /// A block of samples, 4 samples wide and 4 samples high. + /// Block4x4 = 0, - /// A block of samples, 4 samples wide and 8 samples high. + /// + /// A block of samples, 4 samples wide and 8 samples high. + /// Block4x8 = 1, - /// A block of samples, 8 samples wide and 4 samples high. + /// + /// A block of samples, 8 samples wide and 4 samples high. + /// Block8x4 = 2, - /// A block of samples, 8 samples wide and 8 samples high. + /// + /// A block of samples, 8 samples wide and 8 samples high. + /// Block8x8 = 3, - /// A block of samples, 8 samples wide and 16 samples high. + /// + /// A block of samples, 8 samples wide and 16 samples high. + /// Block8x16 = 4, - /// A block of samples, 16 samples wide and 8 samples high. + /// + /// A block of samples, 16 samples wide and 8 samples high. + /// Block16x8 = 5, - /// A block of samples, 16 samples wide and 16 samples high. + /// + /// A block of samples, 16 samples wide and 16 samples high. + /// Block16x16 = 6, - /// A block of samples, 16 samples wide and 32 samples high. + /// + /// A block of samples, 16 samples wide and 32 samples high. + /// Block16x32 = 7, - /// A block of samples, 32 samples wide and 16 samples high. + /// + /// A block of samples, 32 samples wide and 16 samples high. + /// Block32x16 = 8, - /// A block of samples, 32 samples wide and 32 samples high. + /// + /// A block of samples, 32 samples wide and 32 samples high. + /// Block32x32 = 9, - /// A block of samples, 32 samples wide and 64 samples high. + /// + /// A block of samples, 32 samples wide and 64 samples high. + /// Block32x64 = 10, - /// A block of samples, 64 samples wide and 32 samples high. + /// + /// A block of samples, 64 samples wide and 32 samples high. + /// Block64x32 = 11, - /// A block of samples, 64 samples wide and 64 samples high. + /// + /// A block of samples, 64 samples wide and 64 samples high. + /// Block64x64 = 12, - /// A block of samples, 64 samples wide and 128 samples high. + /// + /// A block of samples, 64 samples wide and 128 samples high. + /// Block64x128 = 13, - /// A block of samples, 128 samples wide and 64 samples high. + /// + /// A block of samples, 128 samples wide and 64 samples high. + /// Block128x64 = 14, - /// A block of samples, 128 samples wide and 128 samples high. + /// + /// A block of samples, 128 samples wide and 128 samples high. + /// Block128x128 = 15, - /// A block of samples, 4 samples wide and 16 samples high. + /// + /// A block of samples, 4 samples wide and 16 samples high. + /// Block4x16 = 16, - /// A block of samples, 16 samples wide and 4 samples high. + /// + /// A block of samples, 16 samples wide and 4 samples high. + /// Block16x4 = 17, - /// A block of samples, 8 samples wide and 32 samples high. + /// + /// A block of samples, 8 samples wide and 32 samples high. + /// Block8x32 = 18, - /// A block of samples, 32 samples wide and 8 samples high. + /// + /// A block of samples, 32 samples wide and 8 samples high. + /// Block32x8 = 19, - /// A block of samples, 16 samples wide and 64 samples high. + /// + /// A block of samples, 16 samples wide and 64 samples high. + /// Block16x64 = 20, - /// A block of samples, 64 samples wide and 16 samples high. + /// + /// A block of samples, 64 samples wide and 16 samples high. + /// Block64x16 = 21, /// diff --git a/src/ImageSharp/Formats/Heif/Hevc/HevcCabacContexts.cs b/src/ImageSharp/Formats/Heif/Hevc/HevcCabacContexts.cs index 6d9d40a11b..5dfede1af7 100644 --- a/src/ImageSharp/Formats/Heif/Hevc/HevcCabacContexts.cs +++ b/src/ImageSharp/Formats/Heif/Hevc/HevcCabacContexts.cs @@ -8,67 +8,109 @@ namespace SixLabors.ImageSharp.Formats.Heif.Hevc; /// internal sealed class HevcCabacContexts { - /// The first transquant-bypass context. + /// + /// The first transquant-bypass context. + /// private const int TransquantBypassOffset = 0; - /// The first coding-unit split context. + /// + /// The first coding-unit split context. + /// private const int SplitOffset = 1; - /// The intra partition-size context. + /// + /// The intra partition-size context. + /// private const int PartitionSizeOffset = 4; - /// The luma intra-prediction context. + /// + /// The luma intra-prediction context. + /// private const int IntraPredictionOffset = 5; - /// The first chroma intra-prediction context. + /// + /// The first chroma intra-prediction context. + /// private const int ChromaPredictionOffset = 6; - /// The first luma quantization-delta context. + /// + /// The first luma quantization-delta context. + /// private const int DeltaQuantizationOffset = 8; - /// The chroma quantization-adjustment flag context. + /// + /// The chroma quantization-adjustment flag context. + /// private const int ChromaQuantizationAdjustmentFlagOffset = 11; - /// The chroma quantization-adjustment index context. + /// + /// The chroma quantization-adjustment index context. + /// private const int ChromaQuantizationAdjustmentIndexOffset = 12; - /// The first transform-tree coded-block-flag context. + /// + /// The first transform-tree coded-block-flag context. + /// private const int TransformCodedBlockFlagOffset = 13; - /// The first horizontal last-significant-coefficient context. + /// + /// The first horizontal last-significant-coefficient context. + /// private const int LastSignificantXOffset = 23; - /// The first vertical last-significant-coefficient context. + /// + /// The first vertical last-significant-coefficient context. + /// private const int LastSignificantYOffset = 53; - /// The first significant-coefficient-group context. + /// + /// The first significant-coefficient-group context. + /// private const int SignificantCoefficientGroupOffset = 83; - /// The first significant-coefficient context. + /// + /// The first significant-coefficient context. + /// private const int SignificantCoefficientOffset = 87; - /// The first greater-than-one coefficient-level context. + /// + /// The first greater-than-one coefficient-level context. + /// private const int GreaterThanOneOffset = 131; - /// The first greater-than-two coefficient-level context. + /// + /// The first greater-than-two coefficient-level context. + /// private const int GreaterThanTwoOffset = 155; - /// The sample-adaptive-offset merge context. + /// + /// The sample-adaptive-offset merge context. + /// private const int SampleAdaptiveOffsetMergeOffset = 161; - /// The sample-adaptive-offset type context. + /// + /// The sample-adaptive-offset type context. + /// private const int SampleAdaptiveOffsetTypeOffset = 162; - /// The first transform-tree subdivision context. + /// + /// The first transform-tree subdivision context. + /// private const int TransformSubdivisionOffset = 163; - /// The first transform-skip context. + /// + /// The first transform-skip context. + /// private const int TransformSkipOffset = 166; - /// The first cross-component prediction context. + /// + /// The first cross-component prediction context. + /// private const int CrossComponentPredictionOffset = 168; - /// The number of contexts used by the independently coded intra-picture syntax. + /// + /// The number of contexts used by the independently coded intra-picture syntax. + /// private const int ContextCount = 178; /// @@ -154,72 +196,112 @@ internal sealed class HevcCabacContexts } } - /// Gets the coding-unit transquant-bypass context. + /// + /// Gets the coding-unit transquant-bypass context. + /// public Span TransquantBypass => this.contexts.AsSpan(TransquantBypassOffset, 1); - /// Gets the coding-unit split contexts, ordered by neighboring split depth. + /// + /// Gets the coding-unit split contexts, ordered by neighboring split depth. + /// public Span Split => this.contexts.AsSpan(SplitOffset, 3); - /// Gets the intra partition-size context. + /// + /// Gets the intra partition-size context. + /// public Span PartitionSize => this.contexts.AsSpan(PartitionSizeOffset, 1); - /// Gets the luma intra-prediction context. + /// + /// Gets the luma intra-prediction context. + /// public Span IntraPrediction => this.contexts.AsSpan(IntraPredictionOffset, 1); - /// Gets the chroma intra-prediction contexts. + /// + /// Gets the chroma intra-prediction contexts. + /// public Span ChromaPrediction => this.contexts.AsSpan(ChromaPredictionOffset, 2); - /// Gets the luma quantization-delta contexts. + /// + /// Gets the luma quantization-delta contexts. + /// public Span DeltaQuantization => this.contexts.AsSpan(DeltaQuantizationOffset, 3); - /// Gets the chroma quantization-adjustment flag context. + /// + /// Gets the chroma quantization-adjustment flag context. + /// public Span ChromaQuantizationAdjustmentFlag => this.contexts.AsSpan(ChromaQuantizationAdjustmentFlagOffset, 1); - /// Gets the chroma quantization-adjustment index context. + /// + /// Gets the chroma quantization-adjustment index context. + /// public Span ChromaQuantizationAdjustmentIndex => this.contexts.AsSpan(ChromaQuantizationAdjustmentIndexOffset, 1); - /// Gets the transform-tree coded-block-flag contexts, with luma preceding chroma. + /// + /// Gets the transform-tree coded-block-flag contexts, with luma preceding chroma. + /// public Span TransformCodedBlockFlag => this.contexts.AsSpan(TransformCodedBlockFlagOffset, 10); - /// Gets the horizontal last-significant-coefficient contexts, with luma preceding chroma. + /// + /// Gets the horizontal last-significant-coefficient contexts, with luma preceding chroma. + /// public Span LastSignificantX => this.contexts.AsSpan(LastSignificantXOffset, 30); - /// Gets the vertical last-significant-coefficient contexts, with luma preceding chroma. + /// + /// Gets the vertical last-significant-coefficient contexts, with luma preceding chroma. + /// public Span LastSignificantY => this.contexts.AsSpan(LastSignificantYOffset, 30); - /// Gets the significant-coefficient-group contexts, with luma preceding chroma. + /// + /// Gets the significant-coefficient-group contexts, with luma preceding chroma. + /// public Span SignificantCoefficientGroup => this.contexts.AsSpan(SignificantCoefficientGroupOffset, 4); - /// Gets the significant-coefficient contexts, with luma preceding chroma. + /// + /// Gets the significant-coefficient contexts, with luma preceding chroma. + /// public Span SignificantCoefficient => this.contexts.AsSpan(SignificantCoefficientOffset, 44); - /// Gets the greater-than-one coefficient-level contexts, with luma preceding chroma. + /// + /// Gets the greater-than-one coefficient-level contexts, with luma preceding chroma. + /// public Span GreaterThanOne => this.contexts.AsSpan(GreaterThanOneOffset, 24); - /// Gets the greater-than-two coefficient-level contexts, with luma preceding chroma. + /// + /// Gets the greater-than-two coefficient-level contexts, with luma preceding chroma. + /// public Span GreaterThanTwo => this.contexts.AsSpan(GreaterThanTwoOffset, 6); - /// Gets the sample-adaptive-offset merge context. + /// + /// Gets the sample-adaptive-offset merge context. + /// public Span SampleAdaptiveOffsetMerge => this.contexts.AsSpan(SampleAdaptiveOffsetMergeOffset, 1); - /// Gets the sample-adaptive-offset type context. + /// + /// Gets the sample-adaptive-offset type context. + /// public Span SampleAdaptiveOffsetType => this.contexts.AsSpan(SampleAdaptiveOffsetTypeOffset, 1); - /// Gets the transform-tree subdivision contexts. + /// + /// Gets the transform-tree subdivision contexts. + /// public Span TransformSubdivision => this.contexts.AsSpan(TransformSubdivisionOffset, 3); - /// Gets the transform-skip contexts, with luma preceding chroma. + /// + /// Gets the transform-skip contexts, with luma preceding chroma. + /// public Span TransformSkip => this.contexts.AsSpan(TransformSkipOffset, 2); - /// Gets the cross-component prediction contexts, with Cb preceding Cr. + /// + /// Gets the cross-component prediction contexts, with Cb preceding Cr. + /// public Span CrossComponentPrediction => this.contexts.AsSpan(CrossComponentPredictionOffset, 10); } diff --git a/src/ImageSharp/Formats/Heif/Hevc/HevcCabacSyntaxReader.cs b/src/ImageSharp/Formats/Heif/Hevc/HevcCabacSyntaxReader.cs index d108dda3f6..0ef0fd6d21 100644 --- a/src/ImageSharp/Formats/Heif/Hevc/HevcCabacSyntaxReader.cs +++ b/src/ImageSharp/Formats/Heif/Hevc/HevcCabacSyntaxReader.cs @@ -8,16 +8,24 @@ namespace SixLabors.ImageSharp.Formats.Heif.Hevc; /// internal ref struct HevcCabacSyntaxReader { - /// The truncated-unary cutoff for a coding-unit luma quantization delta. + /// + /// The truncated-unary cutoff for a coding-unit luma quantization delta. + /// private const int DeltaQuantizationCutoff = 5; - /// The prefix length at which coefficient levels switch from Rice to exponential-Golomb coding. + /// + /// The prefix length at which coefficient levels switch from Rice to exponential-Golomb coding. + /// private const int CoefficientRemainingReduction = 3; - /// The binary arithmetic decoder for the current entropy substream. + /// + /// The binary arithmetic decoder for the current entropy substream. + /// private HevcCabacDecoder decoder; - /// The adaptive intra-picture probability contexts for the current entropy substream. + /// + /// The adaptive intra-picture probability contexts for the current entropy substream. + /// private readonly HevcCabacContexts contexts; /// @@ -32,10 +40,14 @@ internal ref struct HevcCabacSyntaxReader this.contexts = new HevcCabacContexts(quantizationParameter); } - /// Gets the number of entropy-substream bytes loaded by the arithmetic decoder. + /// + /// Gets the number of entropy-substream bytes loaded by the arithmetic decoder. + /// public readonly int BytesConsumed => this.decoder.BytesConsumed; - /// Decodes the coding-unit transquant-bypass flag. + /// + /// Decodes the coding-unit transquant-bypass flag. + /// /// The decoded flag value. public bool ReadTransquantBypass() { @@ -43,7 +55,9 @@ internal ref struct HevcCabacSyntaxReader return this.decoder.ReadDecision(ref selectedContexts[0]); } - /// Decodes a coding-unit split flag. + /// + /// Decodes a coding-unit split flag. + /// /// The context derived from the available neighboring coding-unit depths. /// The decoded flag value. public bool ReadSplit(int contextIndex) @@ -53,7 +67,9 @@ internal ref struct HevcCabacSyntaxReader return this.decoder.ReadDecision(ref selectedContexts[contextIndex]); } - /// Decodes whether a minimum-size intra coding unit uses four square prediction partitions. + /// + /// Decodes whether a minimum-size intra coding unit uses four square prediction partitions. + /// /// /// A value indicating whether the coding unit is at the minimum coding-block size. /// @@ -71,7 +87,9 @@ internal ref struct HevcCabacSyntaxReader return !this.decoder.ReadDecision(ref selectedContexts[0]); } - /// Decodes whether a luma intra mode is selected from the three most-probable modes. + /// + /// Decodes whether a luma intra mode is selected from the three most-probable modes. + /// /// The decoded flag value. public bool ReadPreviousIntraLumaPredictionFlag() { @@ -79,7 +97,9 @@ internal ref struct HevcCabacSyntaxReader return this.decoder.ReadDecision(ref selectedContexts[0]); } - /// Decodes the zero-based selector for one of the three most-probable luma intra modes. + /// + /// Decodes the zero-based selector for one of the three most-probable luma intra modes. + /// /// The selector in the inclusive range zero through two. public int ReadMostProbableIntraLumaPredictionIndex() { @@ -91,11 +111,15 @@ internal ref struct HevcCabacSyntaxReader return this.decoder.ReadBypass() ? 2 : 1; } - /// Decodes the five-bit selector for a luma intra mode outside the most-probable set. + /// + /// Decodes the five-bit selector for a luma intra mode outside the most-probable set. + /// /// The decoded selector in the inclusive range zero through thirty-one. public int ReadRemainingIntraLumaPredictionMode() => (int)this.decoder.ReadBypassBits(5); - /// Decodes the chroma intra prediction selector. + /// + /// Decodes the chroma intra prediction selector. + /// /// /// Negative one when chroma derives its mode from luma; otherwise, the decoded selector in the inclusive range /// zero through three. @@ -111,7 +135,9 @@ internal ref struct HevcCabacSyntaxReader return (int)this.decoder.ReadBypassBits(2); } - /// Decodes a transform-tree subdivision flag. + /// + /// Decodes a transform-tree subdivision flag. + /// /// The base-two logarithm of the current transform-block size. /// The decoded flag value. public bool ReadTransformSubdivision(int log2TransformBlockSize) @@ -121,7 +147,9 @@ internal ref struct HevcCabacSyntaxReader return this.decoder.ReadDecision(ref selectedContexts[5 - log2TransformBlockSize]); } - /// Decodes a transform-tree coded-block flag. + /// + /// Decodes a transform-tree coded-block flag. + /// /// A value indicating whether the flag describes a chroma transform block. /// The transform-depth-derived context index. /// The decoded flag value. @@ -133,7 +161,9 @@ internal ref struct HevcCabacSyntaxReader return this.decoder.ReadDecision(ref selectedContexts[channelOffset + contextIndex]); } - /// Decodes whether a transform block bypasses the inverse transform. + /// + /// Decodes whether a transform block bypasses the inverse transform. + /// /// A value indicating whether the transform block belongs to a chroma channel. /// The decoded flag value. public bool ReadTransformSkip(bool isChroma) @@ -142,7 +172,9 @@ internal ref struct HevcCabacSyntaxReader return this.decoder.ReadDecision(ref selectedContexts[isChroma ? 1 : 0]); } - /// Decodes the signed coding-unit luma quantization-parameter delta. + /// + /// Decodes the signed coding-unit luma quantization-parameter delta. + /// /// The signed delta value. /// The coded magnitude exceeds a 32-bit signed value. public int ReadDeltaQuantizationParameter() @@ -168,7 +200,9 @@ internal ref struct HevcCabacSyntaxReader return this.decoder.ReadBypass() ? -signedMagnitude : signedMagnitude; } - /// Decodes the coding-unit chroma quantization-adjustment selector. + /// + /// Decodes the coding-unit chroma quantization-adjustment selector. + /// /// The number of chroma offset pairs declared by the picture parameters. /// Zero when no adjustment applies; otherwise, the one-based offset-list selector. public int ReadChromaQuantizationAdjustment(int listLength) @@ -188,7 +222,9 @@ internal ref struct HevcCabacSyntaxReader return (int)this.ReadTruncatedUnary(indexContexts, 0, 0, listLength - 1) + 1; } - /// Decodes the cross-component residual-prediction scale for one chroma plane. + /// + /// Decodes the cross-component residual-prediction scale for one chroma plane. + /// /// Zero for Cb or one for Cr. /// Zero when prediction is disabled; otherwise, a signed power of two from one through eight. public int ReadCrossComponentPredictionScale(int chromaPlaneIndex) @@ -212,7 +248,9 @@ internal ref struct HevcCabacSyntaxReader return this.decoder.ReadDecision(ref selectedContexts[contextOffset + 4]) ? -magnitude : magnitude; } - /// Decodes a sample-adaptive-offset merge flag. + /// + /// Decodes a sample-adaptive-offset merge flag. + /// /// The decoded flag value. public bool ReadSampleAdaptiveOffsetMerge() { @@ -220,7 +258,9 @@ internal ref struct HevcCabacSyntaxReader return this.decoder.ReadDecision(ref selectedContexts[0]); } - /// Decodes the sample-adaptive-offset mode selector. + /// + /// Decodes the sample-adaptive-offset mode selector. + /// /// Zero for off, one for band offset, or two for edge offset. public int ReadSampleAdaptiveOffsetType() { @@ -233,7 +273,9 @@ internal ref struct HevcCabacSyntaxReader return this.decoder.ReadBypass() ? 2 : 1; } - /// Decodes a truncated-unary absolute sample-adaptive-offset value. + /// + /// Decodes a truncated-unary absolute sample-adaptive-offset value. + /// /// The inclusive maximum offset magnitude. /// The decoded offset magnitude. public int ReadSampleAdaptiveOffsetAbsolute(int maximumValue) @@ -252,19 +294,27 @@ internal ref struct HevcCabacSyntaxReader return value; } - /// Decodes the five-bit sample-adaptive band-offset starting position. + /// + /// Decodes the five-bit sample-adaptive band-offset starting position. + /// /// The decoded band position. public int ReadSampleAdaptiveOffsetBandPosition() => (int)this.decoder.ReadBypassBits(5); - /// Decodes the two-bit sample-adaptive edge-offset class. + /// + /// Decodes the two-bit sample-adaptive edge-offset class. + /// /// The decoded edge class. public int ReadSampleAdaptiveOffsetEdgeClass() => (int)this.decoder.ReadBypassBits(2); - /// Decodes a sample-adaptive band-offset sign. + /// + /// Decodes a sample-adaptive band-offset sign. + /// /// for a negative offset; otherwise, . public bool ReadSampleAdaptiveOffsetSign() => this.decoder.ReadBypass(); - /// Decodes a horizontal last-significant-coefficient prefix flag. + /// + /// Decodes a horizontal last-significant-coefficient prefix flag. + /// /// A value indicating whether the coefficient belongs to a chroma channel. /// The block-size and prefix-derived context index within the channel. /// The decoded flag value. @@ -274,7 +324,9 @@ internal ref struct HevcCabacSyntaxReader return this.decoder.ReadDecision(ref selectedContexts[(isChroma ? 15 : 0) + contextIndex]); } - /// Decodes a vertical last-significant-coefficient prefix flag. + /// + /// Decodes a vertical last-significant-coefficient prefix flag. + /// /// A value indicating whether the coefficient belongs to a chroma channel. /// The block-size and prefix-derived context index within the channel. /// The decoded flag value. @@ -284,7 +336,9 @@ internal ref struct HevcCabacSyntaxReader return this.decoder.ReadDecision(ref selectedContexts[(isChroma ? 15 : 0) + contextIndex]); } - /// Decodes a significant-coefficient-group flag. + /// + /// Decodes a significant-coefficient-group flag. + /// /// A value indicating whether the coefficient group belongs to a chroma channel. /// The neighboring-group-derived context index. /// The decoded flag value. @@ -294,7 +348,9 @@ internal ref struct HevcCabacSyntaxReader return this.decoder.ReadDecision(ref selectedContexts[(isChroma ? 2 : 0) + contextIndex]); } - /// Decodes a significant-coefficient flag. + /// + /// Decodes a significant-coefficient flag. + /// /// A value indicating whether the coefficient belongs to a chroma channel. /// The scan-position-derived context index within the channel. /// The decoded flag value. @@ -304,7 +360,9 @@ internal ref struct HevcCabacSyntaxReader return this.decoder.ReadDecision(ref selectedContexts[(isChroma ? 28 : 0) + contextIndex]); } - /// Decodes whether a significant coefficient has an absolute level greater than one. + /// + /// Decodes whether a significant coefficient has an absolute level greater than one. + /// /// A value indicating whether the coefficient belongs to a chroma channel. /// The coefficient-group and preceding-level-derived context index. /// The decoded flag value. @@ -314,7 +372,9 @@ internal ref struct HevcCabacSyntaxReader return this.decoder.ReadDecision(ref selectedContexts[(isChroma ? 16 : 0) + contextIndex]); } - /// Decodes whether the first eligible coefficient has an absolute level greater than two. + /// + /// Decodes whether the first eligible coefficient has an absolute level greater than two. + /// /// A value indicating whether the coefficient belongs to a chroma channel. /// The coefficient-group-derived context index within the channel. /// The decoded flag value. @@ -324,7 +384,9 @@ internal ref struct HevcCabacSyntaxReader return this.decoder.ReadDecision(ref selectedContexts[(isChroma ? 4 : 0) + contextIndex]); } - /// Decodes an absolute coefficient-level remainder. + /// + /// Decodes an absolute coefficient-level remainder. + /// /// The current Golomb-Rice parameter. /// /// A value indicating whether extended-precision processing limits the prefix length. @@ -396,23 +458,33 @@ internal ref struct HevcCabacSyntaxReader return (uint)result; } - /// Decodes a most-significant-bit-first sequence of equal-probability flags. + /// + /// Decodes a most-significant-bit-first sequence of equal-probability flags. + /// /// The number of flags to decode. /// The decoded unsigned value. public uint ReadBypassBits(int bitCount) => this.decoder.ReadBypassBits(bitCount); - /// Selects the byte-aligned range used by aligned bypass syntax. + /// + /// Selects the byte-aligned range used by aligned bypass syntax. + /// public void AlignBypass() => this.decoder.AlignBypass(); - /// Decodes the flag that terminates a coding-tree block or entropy substream. + /// + /// Decodes the flag that terminates a coding-tree block or entropy substream. + /// /// The decoded termination flag. public bool ReadTerminate() => this.decoder.ReadTerminate(); - /// Validates the stop bit and zero padding after a terminating entropy-coded value. + /// + /// Validates the stop bit and zero padding after a terminating entropy-coded value. + /// /// The entropy substream has invalid termination alignment. public readonly void ValidateTerminationAlignment() => this.decoder.ValidateTerminationAlignment(); - /// Decodes a context-adaptive truncated-unary value. + /// + /// Decodes a context-adaptive truncated-unary value. + /// /// The context set selected for the syntax element. /// The context used by the first binary decision. /// The context used by each subsequent decision. @@ -440,7 +512,9 @@ internal ref struct HevcCabacSyntaxReader return value; } - /// Decodes an equal-probability exponential-Golomb value. + /// + /// Decodes an equal-probability exponential-Golomb value. + /// /// The initial suffix width. /// The decoded unsigned value. /// The coded value exceeds a 32-bit unsigned value. diff --git a/src/ImageSharp/Formats/Heif/Hevc/HevcCodingTreeState.cs b/src/ImageSharp/Formats/Heif/Hevc/HevcCodingTreeState.cs index 371e426039..5935ffb7bd 100644 --- a/src/ImageSharp/Formats/Heif/Hevc/HevcCodingTreeState.cs +++ b/src/ImageSharp/Formats/Heif/Hevc/HevcCodingTreeState.cs @@ -10,19 +10,29 @@ namespace SixLabors.ImageSharp.Formats.Heif.Hevc; /// internal sealed class HevcCodingTreeState : IDisposable { - /// The coding-unit flag indicating transform and quantization bypass. + /// + /// The coding-unit flag indicating transform and quantization bypass. + /// private const byte TransquantBypassFlag = 1 << 0; - /// The coding-unit flag indicating pulse-code-modulated samples. + /// + /// The coding-unit flag indicating pulse-code-modulated samples. + /// private const byte PcmFlag = 1 << 1; - /// The decoded coding-unit depth at minimum-coding-block resolution. + /// + /// The decoded coding-unit depth at minimum-coding-block resolution. + /// private readonly Buffer2D depths; - /// The effective luma quantization parameter at minimum-coding-block resolution. + /// + /// The effective luma quantization parameter at minimum-coding-block resolution. + /// private readonly Buffer2D quantizationParameters; - /// The packed bypass and PCM flags at minimum-coding-block resolution. + /// + /// The packed bypass and PCM flags at minimum-coding-block resolution. + /// private readonly Buffer2D flags; /// @@ -54,16 +64,24 @@ internal sealed class HevcCodingTreeState : IDisposable this.HeightInMinCodingBlocks); } - /// Gets the base-two logarithm of the state map's luma sample unit. + /// + /// Gets the base-two logarithm of the state map's luma sample unit. + /// public int MinCodingBlockLog2 { get; } - /// Gets the state-map width in minimum coding blocks. + /// + /// Gets the state-map width in minimum coding blocks. + /// public int WidthInMinCodingBlocks { get; } - /// Gets the state-map height in minimum coding blocks. + /// + /// Gets the state-map height in minimum coding blocks. + /// public int HeightInMinCodingBlocks { get; } - /// Gets the split-flag context derived from available left and above coding units. + /// + /// Gets the split-flag context derived from available left and above coding units. + /// /// The current coding-unit left coordinate in luma samples. /// The current coding-unit top coordinate in luma samples. /// The current coding-tree depth. @@ -88,7 +106,9 @@ internal sealed class HevcCodingTreeState : IDisposable return context; } - /// Records the state shared by every minimum coding block covered by one leaf coding unit. + /// + /// Records the state shared by every minimum coding block covered by one leaf coding unit. + /// /// The coding-unit left coordinate in luma samples. /// The coding-unit top coordinate in luma samples. /// The base-two logarithm of the square coding-unit size. @@ -122,21 +142,27 @@ internal sealed class HevcCodingTreeState : IDisposable } } - /// Gets the recorded coding-tree depth at a luma sample coordinate. + /// + /// Gets the recorded coding-tree depth at a luma sample coordinate. + /// /// The luma sample X coordinate. /// The luma sample Y coordinate. /// The leaf coding-unit depth. public int GetDepth(int x, int y) => this.depths.DangerousGetRowSpan(y >> this.MinCodingBlockLog2)[x >> this.MinCodingBlockLog2]; - /// Gets the effective luma quantization parameter at a luma sample coordinate. + /// + /// Gets the effective luma quantization parameter at a luma sample coordinate. + /// /// The luma sample X coordinate. /// The luma sample Y coordinate. /// The effective luma quantization parameter. public int GetQuantizationParameter(int x, int y) => this.quantizationParameters.DangerousGetRowSpan(y >> this.MinCodingBlockLog2)[x >> this.MinCodingBlockLog2]; - /// Gets a value indicating whether the coding unit at a luma sample coordinate bypasses transform and quantization. + /// + /// Gets a value indicating whether the coding unit at a luma sample coordinate bypasses transform and quantization. + /// /// The luma sample X coordinate. /// The luma sample Y coordinate. /// when bypass is enabled; otherwise, . @@ -144,7 +170,9 @@ internal sealed class HevcCodingTreeState : IDisposable => (this.flags.DangerousGetRowSpan(y >> this.MinCodingBlockLog2)[x >> this.MinCodingBlockLog2] & TransquantBypassFlag) != 0; - /// Gets a value indicating whether the coding unit at a luma sample coordinate contains PCM samples. + /// + /// Gets a value indicating whether the coding unit at a luma sample coordinate contains PCM samples. + /// /// The luma sample X coordinate. /// The luma sample Y coordinate. /// for pulse-code-modulated samples; otherwise, . @@ -152,7 +180,9 @@ internal sealed class HevcCodingTreeState : IDisposable => (this.flags.DangerousGetRowSpan(y >> this.MinCodingBlockLog2)[x >> this.MinCodingBlockLog2] & PcmFlag) != 0; - /// Releases the owned coding-tree state maps. + /// + /// Releases the owned coding-tree state maps. + /// public void Dispose() { this.depths.Dispose(); @@ -160,7 +190,9 @@ internal sealed class HevcCodingTreeState : IDisposable this.flags.Dispose(); } - /// Divides a nonnegative sample count by a power of two with upward rounding. + /// + /// Divides a nonnegative sample count by a power of two with upward rounding. + /// /// The sample count. /// The base-two divisor logarithm. /// The upward-rounded quotient. diff --git a/src/ImageSharp/Formats/Heif/Hevc/HevcIntraPredictionState.cs b/src/ImageSharp/Formats/Heif/Hevc/HevcIntraPredictionState.cs index a8939716cb..86e5a543b7 100644 --- a/src/ImageSharp/Formats/Heif/Hevc/HevcIntraPredictionState.cs +++ b/src/ImageSharp/Formats/Heif/Hevc/HevcIntraPredictionState.cs @@ -10,31 +10,49 @@ namespace SixLabors.ImageSharp.Formats.Heif.Hevc; /// internal sealed class HevcIntraPredictionState : IDisposable { - /// The base-two logarithm of the minimum luma prediction-block size. + /// + /// The base-two logarithm of the minimum luma prediction-block size. + /// private const int MinPredictionBlockLog2 = 2; - /// The planar intra prediction mode. + /// + /// The planar intra prediction mode. + /// private const byte PlanarMode = 0; - /// The DC intra prediction mode. + /// + /// The DC intra prediction mode. + /// private const byte DcMode = 1; - /// The horizontal intra prediction mode. + /// + /// The horizontal intra prediction mode. + /// private const byte HorizontalMode = 10; - /// The vertical intra prediction mode. + /// + /// The vertical intra prediction mode. + /// private const byte VerticalMode = 26; - /// The replacement chroma mode used when an explicit chroma candidate equals the luma mode. + /// + /// The replacement chroma mode used when an explicit chroma candidate equals the luma mode. + /// private const byte ChromaReplacementMode = 34; - /// The chroma mode that derives its direction from the colocated luma prediction block. + /// + /// The chroma mode that derives its direction from the colocated luma prediction block. + /// private const byte DerivedChromaMode = 36; - /// The luma intra mode at minimum-prediction-block resolution. + /// + /// The luma intra mode at minimum-prediction-block resolution. + /// private readonly Buffer2D lumaModes; - /// The coded chroma intra mode at minimum-prediction-block resolution in luma coordinates. + /// + /// The coded chroma intra mode at minimum-prediction-block resolution in luma coordinates. + /// private readonly Buffer2D chromaModes; /// @@ -61,13 +79,19 @@ internal sealed class HevcIntraPredictionState : IDisposable this.HeightInMinPredictionBlocks); } - /// Gets the map width in minimum luma prediction blocks. + /// + /// Gets the map width in minimum luma prediction blocks. + /// public int WidthInMinPredictionBlocks { get; } - /// Gets the map height in minimum luma prediction blocks. + /// + /// Gets the map height in minimum luma prediction blocks. + /// public int HeightInMinPredictionBlocks { get; } - /// Decodes and records the luma intra modes of one leaf coding unit. + /// + /// Decodes and records the luma intra modes of one leaf coding unit. + /// /// The current entropy-substream syntax reader. /// The coding-unit left coordinate in luma samples. /// The coding-unit top coordinate in luma samples. @@ -134,7 +158,9 @@ internal sealed class HevcIntraPredictionState : IDisposable } } - /// Decodes and records the chroma intra mode of one leaf coding unit. + /// + /// Decodes and records the chroma intra mode of one leaf coding unit. + /// /// The current entropy-substream syntax reader. /// The coding-unit left coordinate in luma samples. /// The coding-unit top coordinate in luma samples. @@ -160,21 +186,27 @@ internal sealed class HevcIntraPredictionState : IDisposable this.SetMode(this.chromaModes, x, y, log2Size, mode); } - /// Gets the luma intra mode at a luma sample coordinate. + /// + /// Gets the luma intra mode at a luma sample coordinate. + /// /// The luma sample X coordinate. /// The luma sample Y coordinate. /// The luma intra mode in the inclusive range zero through thirty-four. public byte GetLumaMode(int x, int y) => this.lumaModes.DangerousGetRowSpan(y >> MinPredictionBlockLog2)[x >> MinPredictionBlockLog2]; - /// Gets the coded chroma intra mode at a luma sample coordinate. + /// + /// Gets the coded chroma intra mode at a luma sample coordinate. + /// /// The luma sample X coordinate. /// The luma sample Y coordinate. /// An explicit chroma direction or the derived-mode value. public byte GetChromaMode(int x, int y) => this.chromaModes.DangerousGetRowSpan(y >> MinPredictionBlockLog2)[x >> MinPredictionBlockLog2]; - /// Gets the effective chroma intra mode at a luma sample coordinate. + /// + /// Gets the effective chroma intra mode at a luma sample coordinate. + /// /// The luma sample X coordinate. /// The luma sample Y coordinate. /// The explicit chroma mode, or the colocated luma mode when chroma uses derived mode. @@ -184,14 +216,18 @@ internal sealed class HevcIntraPredictionState : IDisposable return mode == DerivedChromaMode ? this.GetLumaMode(x, y) : mode; } - /// Releases the owned intra-mode maps. + /// + /// Releases the owned intra-mode maps. + /// public void Dispose() { this.lumaModes.Dispose(); this.chromaModes.Dispose(); } - /// Derives the three most-probable luma intra modes from available spatial neighbors. + /// + /// Derives the three most-probable luma intra modes from available spatial neighbors. + /// /// The prediction-block left coordinate in luma samples. /// The prediction-block top coordinate in luma samples. /// A value indicating whether the left prediction block is available. @@ -236,7 +272,9 @@ internal sealed class HevcIntraPredictionState : IDisposable } } - /// Records one prediction mode over a square luma-coordinate region. + /// + /// Records one prediction mode over a square luma-coordinate region. + /// /// The luma or chroma mode map. /// The region left coordinate in luma samples. /// The region top coordinate in luma samples. @@ -255,7 +293,9 @@ internal sealed class HevcIntraPredictionState : IDisposable } } - /// Sorts three intra-mode values into ascending order. + /// + /// Sorts three intra-mode values into ascending order. + /// /// The three-element mode span. private static void SortThree(Span values) { @@ -275,7 +315,9 @@ internal sealed class HevcIntraPredictionState : IDisposable } } - /// Divides a nonnegative sample count by a power of two with upward rounding. + /// + /// Divides a nonnegative sample count by a power of two with upward rounding. + /// /// The sample count. /// The base-two divisor logarithm. /// The upward-rounded quotient. diff --git a/src/ImageSharp/Formats/Heif/Hevc/HevcPictureBuffer.cs b/src/ImageSharp/Formats/Heif/Hevc/HevcPictureBuffer.cs index 77c908e11d..272ee74c92 100644 --- a/src/ImageSharp/Formats/Heif/Hevc/HevcPictureBuffer.cs +++ b/src/ImageSharp/Formats/Heif/Hevc/HevcPictureBuffer.cs @@ -10,10 +10,14 @@ namespace SixLabors.ImageSharp.Formats.Heif.Hevc; /// internal sealed class HevcPictureBuffer : IDisposable { - /// The horizontal chroma subsampling shift. + /// + /// The horizontal chroma subsampling shift. + /// private readonly int chromaSubsamplingX; - /// The vertical chroma subsampling shift. + /// + /// The vertical chroma subsampling shift. + /// private readonly int chromaSubsamplingY; /// @@ -44,54 +48,82 @@ internal sealed class HevcPictureBuffer : IDisposable } } - /// Gets the coded luma width in samples. + /// + /// Gets the coded luma width in samples. + /// public int Width { get; } - /// Gets the coded luma height in samples. + /// + /// Gets the coded luma height in samples. + /// public int Height { get; } - /// Gets the luma sample precision in bits. + /// + /// Gets the luma sample precision in bits. + /// public int BitDepthLuma { get; } - /// Gets the chroma sample precision in bits. + /// + /// Gets the chroma sample precision in bits. + /// public int BitDepthChroma { get; } - /// Gets the HEVC chroma-format identifier. + /// + /// Gets the HEVC chroma-format identifier. + /// public byte ChromaFormat { get; } - /// Gets a value indicating whether the three planes are coded as independent full-resolution color planes. + /// + /// Gets a value indicating whether the three planes are coded as independent full-resolution color planes. + /// public bool SeparateColorPlane { get; } - /// Gets the luma or first separate-color-plane allocation. + /// + /// Gets the luma or first separate-color-plane allocation. + /// public Buffer2D Luma { get; } - /// Gets the blue-difference chroma or second separate-color-plane allocation. + /// + /// Gets the blue-difference chroma or second separate-color-plane allocation. + /// public Buffer2D? ChromaBlue { get; } - /// Gets the red-difference chroma or third separate-color-plane allocation. + /// + /// Gets the red-difference chroma or third separate-color-plane allocation. + /// public Buffer2D? ChromaRed { get; } - /// Gets the horizontal chroma subsampling shift for the selected plane. + /// + /// Gets the horizontal chroma subsampling shift for the selected plane. + /// /// The reconstruction plane. /// Zero for luma and full-resolution planes; otherwise, the chroma shift. public int GetSubsamplingX(HevcPlane plane) => plane == HevcPlane.Y ? 0 : this.chromaSubsamplingX; - /// Gets the vertical chroma subsampling shift for the selected plane. + /// + /// Gets the vertical chroma subsampling shift for the selected plane. + /// /// The reconstruction plane. /// Zero for luma and full-resolution planes; otherwise, the chroma shift. public int GetSubsamplingY(HevcPlane plane) => plane == HevcPlane.Y ? 0 : this.chromaSubsamplingY; - /// Gets the selected plane width in samples. + /// + /// Gets the selected plane width in samples. + /// /// The reconstruction plane. /// The coded plane width. public int GetWidth(HevcPlane plane) => DivideCeilingByPowerOfTwo(this.Width, this.GetSubsamplingX(plane)); - /// Gets the selected plane height in samples. + /// + /// Gets the selected plane height in samples. + /// /// The reconstruction plane. /// The coded plane height. public int GetHeight(HevcPlane plane) => DivideCeilingByPowerOfTwo(this.Height, this.GetSubsamplingY(plane)); - /// Gets one coded row from the selected reconstruction plane. + /// + /// Gets one coded row from the selected reconstruction plane. + /// /// The reconstruction plane. /// The zero-based row index in plane samples. /// The complete coded plane row. @@ -103,7 +135,9 @@ internal sealed class HevcPictureBuffer : IDisposable _ => this.ChromaRed!.DangerousGetRowSpan(row), }; - /// Releases the owned luma and chroma plane allocations. + /// + /// Releases the owned luma and chroma plane allocations. + /// public void Dispose() { this.Luma.Dispose(); @@ -111,7 +145,9 @@ internal sealed class HevcPictureBuffer : IDisposable this.ChromaRed?.Dispose(); } - /// Divides a nonnegative sample count by a power of two with upward rounding. + /// + /// Divides a nonnegative sample count by a power of two with upward rounding. + /// /// The sample count. /// The base-two divisor logarithm. /// The upward-rounded quotient. diff --git a/src/ImageSharp/Formats/Heif/Hevc/HevcPictureParameterSet.cs b/src/ImageSharp/Formats/Heif/Hevc/HevcPictureParameterSet.cs index 16e3fa56f1..7b0f34f3b3 100644 --- a/src/ImageSharp/Formats/Heif/Hevc/HevcPictureParameterSet.cs +++ b/src/ImageSharp/Formats/Heif/Hevc/HevcPictureParameterSet.cs @@ -220,139 +220,229 @@ internal sealed class HevcPictureParameterSet reader.ReadRbspTrailingBits(); } - /// Gets the picture-parameter-set identifier. + /// + /// Gets the picture-parameter-set identifier. + /// public byte Id { get; } - /// Gets the referenced sequence-parameter-set identifier. + /// + /// Gets the referenced sequence-parameter-set identifier. + /// public byte SequenceParameterSetId { get; } - /// Gets the sequence parameters governing this picture parameter set. + /// + /// Gets the sequence parameters governing this picture parameter set. + /// public HevcSequenceParameterSet SequenceParameterSet { get; } - /// Gets a value indicating whether dependent slice segments can occur. + /// + /// Gets a value indicating whether dependent slice segments can occur. + /// public bool DependentSliceSegmentsEnabled { get; } - /// Gets a value indicating whether slice headers contain the picture-output flag. + /// + /// Gets a value indicating whether slice headers contain the picture-output flag. + /// public bool OutputFlagPresent { get; } - /// Gets the number of reserved extra bits at the start of each independent slice header. + /// + /// Gets the number of reserved extra bits at the start of each independent slice header. + /// public int ExtraSliceHeaderBitCount { get; } - /// Gets a value indicating whether transform-coefficient sign hiding is enabled. + /// + /// Gets a value indicating whether transform-coefficient sign hiding is enabled. + /// public bool SignDataHidingEnabled { get; } - /// Gets a value indicating whether slices can select an alternate CABAC initialization table. + /// + /// Gets a value indicating whether slices can select an alternate CABAC initialization table. + /// public bool CabacInitializationPresent { get; } - /// Gets the default active reference-index count for reference list zero. + /// + /// Gets the default active reference-index count for reference list zero. + /// public int DefaultReferenceIndexCountList0 { get; } - /// Gets the default active reference-index count for reference list one. + /// + /// Gets the default active reference-index count for reference list one. + /// public int DefaultReferenceIndexCountList1 { get; } - /// Gets the picture quantization-parameter initializer relative to 26. + /// + /// Gets the picture quantization-parameter initializer relative to 26. + /// public int InitialQuantizationParameterMinus26 { get; } - /// Gets a value indicating whether inter-coded neighbors are excluded from intra prediction. + /// + /// Gets a value indicating whether inter-coded neighbors are excluded from intra prediction. + /// public bool ConstrainedIntraPredictionEnabled { get; } - /// Gets a value indicating whether residual transform skipping can be selected. + /// + /// Gets a value indicating whether residual transform skipping can be selected. + /// public bool TransformSkipEnabled { get; } - /// Gets a value indicating whether coding units can change the quantization parameter. + /// + /// Gets a value indicating whether coding units can change the quantization parameter. + /// public bool CodingUnitQuantizationParameterDeltaEnabled { get; } - /// Gets the coding-tree depth at which quantization-parameter deltas are signaled. + /// + /// Gets the coding-tree depth at which quantization-parameter deltas are signaled. + /// public int QuantizationParameterDeltaDepth { get; } - /// Gets the picture-level Cb quantization-parameter offset. + /// + /// Gets the picture-level Cb quantization-parameter offset. + /// public int ChromaCbQuantizationParameterOffset { get; } - /// Gets the picture-level Cr quantization-parameter offset. + /// + /// Gets the picture-level Cr quantization-parameter offset. + /// public int ChromaCrQuantizationParameterOffset { get; } - /// Gets a value indicating whether slices can add Cb and Cr quantization-parameter offsets. + /// + /// Gets a value indicating whether slices can add Cb and Cr quantization-parameter offsets. + /// public bool SliceChromaQuantizationParameterOffsetsPresent { get; } - /// Gets a value indicating whether weighted prediction can be used by predictive slices. + /// + /// Gets a value indicating whether weighted prediction can be used by predictive slices. + /// public bool WeightedPredictionEnabled { get; } - /// Gets a value indicating whether weighted prediction can be used by bidirectional slices. + /// + /// Gets a value indicating whether weighted prediction can be used by bidirectional slices. + /// public bool WeightedBiPredictionEnabled { get; } - /// Gets a value indicating whether coding units can bypass transform and quantization. + /// + /// Gets a value indicating whether coding units can bypass transform and quantization. + /// public bool TransquantizationBypassEnabled { get; } - /// Gets a value indicating whether the coded picture is partitioned into tiles. + /// + /// Gets a value indicating whether the coded picture is partitioned into tiles. + /// public bool TilesEnabled { get; } - /// Gets a value indicating whether wavefront entropy-coding synchronization is enabled. + /// + /// Gets a value indicating whether wavefront entropy-coding synchronization is enabled. + /// public bool EntropyCodingSynchronizationEnabled { get; } - /// Gets a value indicating whether the tile grid uses uniform proportional spacing. + /// + /// Gets a value indicating whether the tile grid uses uniform proportional spacing. + /// public bool UniformTileSpacing { get; } - /// Gets the tile-column widths in coding-tree blocks. + /// + /// Gets the tile-column widths in coding-tree blocks. + /// public IReadOnlyList TileColumnWidths { get; } - /// Gets the tile-row heights in coding-tree blocks. + /// + /// Gets the tile-row heights in coding-tree blocks. + /// public IReadOnlyList TileRowHeights { get; } - /// Gets a value indicating whether in-loop filtering crosses tile boundaries. + /// + /// Gets a value indicating whether in-loop filtering crosses tile boundaries. + /// public bool LoopFilterAcrossTilesEnabled { get; } - /// Gets a value indicating whether in-loop filtering crosses slice boundaries. + /// + /// Gets a value indicating whether in-loop filtering crosses slice boundaries. + /// public bool LoopFilterAcrossSlicesEnabled { get; } - /// Gets a value indicating whether picture or slice syntax controls deblocking. + /// + /// Gets a value indicating whether picture or slice syntax controls deblocking. + /// public bool DeblockingFilterControlPresent { get; } - /// Gets a value indicating whether slice headers can override picture-level deblocking. + /// + /// Gets a value indicating whether slice headers can override picture-level deblocking. + /// public bool DeblockingFilterOverrideEnabled { get; } - /// Gets a value indicating whether deblocking is disabled by default for the picture. + /// + /// Gets a value indicating whether deblocking is disabled by default for the picture. + /// public bool DeblockingFilterDisabled { get; } - /// Gets half the picture-level deblocking beta-threshold offset. + /// + /// Gets half the picture-level deblocking beta-threshold offset. + /// public int DeblockingFilterBetaOffsetDiv2 { get; } - /// Gets half the picture-level deblocking clipping-threshold offset. + /// + /// Gets half the picture-level deblocking clipping-threshold offset. + /// public int DeblockingFilterTcOffsetDiv2 { get; } - /// Gets a value indicating whether this picture parameter set supplies scaling-list data. + /// + /// Gets a value indicating whether this picture parameter set supplies scaling-list data. + /// public bool ScalingListDataPresent { get; } - /// Gets the effective quantization scaling matrices for slices using this picture parameter set. + /// + /// Gets the effective quantization scaling matrices for slices using this picture parameter set. + /// public HevcScalingList ScalingList { get; } - /// Gets a value indicating whether slice headers can modify the initial reference-picture lists. + /// + /// Gets a value indicating whether slice headers can modify the initial reference-picture lists. + /// public bool ReferenceListModificationPresent { get; } - /// Gets the base-two logarithm of the parallel merge-estimation region width and height. + /// + /// Gets the base-two logarithm of the parallel merge-estimation region width and height. + /// public int ParallelMergeLevelLog2 { get; } - /// Gets a value indicating whether slice-segment headers carry extension bytes. + /// + /// Gets a value indicating whether slice-segment headers carry extension bytes. + /// public bool SliceSegmentHeaderExtensionPresent { get; } - /// Gets the base-two logarithm of the maximum transform-skip block width and height. + /// + /// Gets the base-two logarithm of the maximum transform-skip block width and height. + /// public int MaxTransformSkipBlockLog2 { get; private set; } - /// Gets a value indicating whether cross-component residual prediction is enabled. + /// + /// Gets a value indicating whether cross-component residual prediction is enabled. + /// public bool CrossComponentPredictionEnabled { get; private set; } - /// Gets the coding-tree depth at which chroma quantization-offset indices are signaled. + /// + /// Gets the coding-tree depth at which chroma quantization-offset indices are signaled. + /// public int ChromaQuantizationParameterOffsetDepth { get; private set; } - /// Gets the Cb offsets in the selectable chroma quantization-parameter offset list. + /// + /// Gets the Cb offsets in the selectable chroma quantization-parameter offset list. + /// public IReadOnlyList ChromaQuantizationParameterOffsetsCb { get; private set; } = Array.Empty(); - /// Gets the Cr offsets in the selectable chroma quantization-parameter offset list. + /// + /// Gets the Cr offsets in the selectable chroma quantization-parameter offset list. + /// public IReadOnlyList ChromaQuantizationParameterOffsetsCr { get; private set; } = Array.Empty(); - /// Gets the base-two logarithm of the luma sample-adaptive-offset value scale. + /// + /// Gets the base-two logarithm of the luma sample-adaptive-offset value scale. + /// public int SampleAdaptiveOffsetScaleLumaLog2 { get; private set; } - /// Gets the base-two logarithm of the chroma sample-adaptive-offset value scale. + /// + /// Gets the base-two logarithm of the chroma sample-adaptive-offset value scale. + /// public int SampleAdaptiveOffsetScaleChromaLog2 { get; private set; } /// diff --git a/src/ImageSharp/Formats/Heif/Hevc/HevcPlane.cs b/src/ImageSharp/Formats/Heif/Hevc/HevcPlane.cs index 9a761f5ca8..cdf81f1ea3 100644 --- a/src/ImageSharp/Formats/Heif/Hevc/HevcPlane.cs +++ b/src/ImageSharp/Formats/Heif/Hevc/HevcPlane.cs @@ -8,12 +8,18 @@ namespace SixLabors.ImageSharp.Formats.Heif.Hevc; /// internal enum HevcPlane { - /// The luma or first separate-color plane. + /// + /// The luma or first separate-color plane. + /// Y = 0, - /// The blue-difference chroma or second separate-color plane. + /// + /// The blue-difference chroma or second separate-color plane. + /// Cb = 1, - /// The red-difference chroma or third separate-color plane. + /// + /// The red-difference chroma or third separate-color plane. + /// Cr = 2, } diff --git a/src/ImageSharp/Formats/Heif/Hevc/HevcSequenceParameterSet.cs b/src/ImageSharp/Formats/Heif/Hevc/HevcSequenceParameterSet.cs index 3d385d8a98..1c70351b82 100644 --- a/src/ImageSharp/Formats/Heif/Hevc/HevcSequenceParameterSet.cs +++ b/src/ImageSharp/Formats/Heif/Hevc/HevcSequenceParameterSet.cs @@ -280,151 +280,249 @@ internal sealed class HevcSequenceParameterSet reader.ReadRbspTrailingBits(); } - /// Gets the referenced video-parameter-set identifier. + /// + /// Gets the referenced video-parameter-set identifier. + /// public byte VideoParameterSetId { get; } - /// Gets the sequence-parameter-set identifier. + /// + /// Gets the sequence-parameter-set identifier. + /// public byte Id { get; } - /// Gets the declared number of temporal sublayers. + /// + /// Gets the declared number of temporal sublayers. + /// public int MaxSubLayers { get; } - /// Gets a value indicating whether temporal identifiers are nested. + /// + /// Gets a value indicating whether temporal identifiers are nested. + /// public bool TemporalIdNestingFlag { get; } - /// Gets the general profile, tier, constraint, and level description. + /// + /// Gets the general profile, tier, constraint, and level description. + /// public HevcProfileTierLevel ProfileTierLevel { get; } - /// Gets the coded chroma format, from monochrome through YUV 4:4:4. + /// + /// Gets the coded chroma format, from monochrome through YUV 4:4:4. + /// public byte ChromaFormat { get; } - /// Gets a value indicating whether 4:4:4 components are coded as separate color planes. + /// + /// Gets a value indicating whether 4:4:4 components are coded as separate color planes. + /// public bool SeparateColorPlaneFlag { get; } - /// Gets the coded luma width before conformance cropping. + /// + /// Gets the coded luma width before conformance cropping. + /// public int Width { get; } - /// Gets the coded luma height before conformance cropping. + /// + /// Gets the coded luma height before conformance cropping. + /// public int Height { get; } - /// Gets the displayed width after conformance cropping. + /// + /// Gets the displayed width after conformance cropping. + /// public int DisplayWidth { get; } - /// Gets the displayed height after conformance cropping. + /// + /// Gets the displayed height after conformance cropping. + /// public int DisplayHeight { get; } - /// Gets the conformance-window left offset in luma samples. + /// + /// Gets the conformance-window left offset in luma samples. + /// public int ConformanceWindowLeftOffset { get; } - /// Gets the conformance-window right offset in luma samples. + /// + /// Gets the conformance-window right offset in luma samples. + /// public int ConformanceWindowRightOffset { get; } - /// Gets the conformance-window top offset in luma samples. + /// + /// Gets the conformance-window top offset in luma samples. + /// public int ConformanceWindowTopOffset { get; } - /// Gets the conformance-window bottom offset in luma samples. + /// + /// Gets the conformance-window bottom offset in luma samples. + /// public int ConformanceWindowBottomOffset { get; } - /// Gets the luma sample precision in bits. + /// + /// Gets the luma sample precision in bits. + /// public int BitDepthLuma { get; } - /// Gets the chroma sample precision in bits. + /// + /// Gets the chroma sample precision in bits. + /// public int BitDepthChroma { get; } - /// Gets the coded picture-order-count least-significant-bit width. + /// + /// Gets the coded picture-order-count least-significant-bit width. + /// public int PictureOrderCountLsbBits { get; } - /// Gets the base-two logarithm of the minimum luma coding-block size. + /// + /// Gets the base-two logarithm of the minimum luma coding-block size. + /// public int MinCodingBlockLog2 { get; } - /// Gets the base-two logarithm of the coding-tree-block size. + /// + /// Gets the base-two logarithm of the coding-tree-block size. + /// public int CodingTreeBlockLog2 { get; } - /// Gets the base-two logarithm of the minimum luma transform-block size. + /// + /// Gets the base-two logarithm of the minimum luma transform-block size. + /// public int MinTransformBlockLog2 { get; } - /// Gets the base-two logarithm of the maximum luma transform-block size. + /// + /// Gets the base-two logarithm of the maximum luma transform-block size. + /// public int MaxTransformBlockLog2 { get; } - /// Gets the maximum inter-predicted transform hierarchy depth. + /// + /// Gets the maximum inter-predicted transform hierarchy depth. + /// public int MaxTransformHierarchyDepthInter { get; } - /// Gets the maximum intra-predicted transform hierarchy depth. + /// + /// Gets the maximum intra-predicted transform hierarchy depth. + /// public int MaxTransformHierarchyDepthIntra { get; } - /// Gets a value indicating whether scaling lists affect inverse quantization. + /// + /// Gets a value indicating whether scaling lists affect inverse quantization. + /// public bool ScalingListEnabled { get; } - /// Gets the effective quantization scaling matrices. + /// + /// Gets the effective quantization scaling matrices. + /// public HevcScalingList ScalingList { get; } - /// Gets a value indicating whether asymmetric motion partitions are enabled. + /// + /// Gets a value indicating whether asymmetric motion partitions are enabled. + /// public bool AsymmetricMotionPartitionsEnabled { get; } - /// Gets a value indicating whether sample-adaptive offset filtering is enabled. + /// + /// Gets a value indicating whether sample-adaptive offset filtering is enabled. + /// public bool SampleAdaptiveOffsetEnabled { get; } - /// Gets a value indicating whether pulse-code-modulated coding blocks are enabled. + /// + /// Gets a value indicating whether pulse-code-modulated coding blocks are enabled. + /// public bool PcmEnabled { get; } - /// Gets the PCM luma sample precision in bits. + /// + /// Gets the PCM luma sample precision in bits. + /// public int PcmBitDepthLuma { get; } - /// Gets the PCM chroma sample precision in bits. + /// + /// Gets the PCM chroma sample precision in bits. + /// public int PcmBitDepthChroma { get; } - /// Gets the base-two logarithm of the minimum PCM coding-block size. + /// + /// Gets the base-two logarithm of the minimum PCM coding-block size. + /// public int MinPcmCodingBlockLog2 { get; } - /// Gets the base-two logarithm of the maximum PCM coding-block size. + /// + /// Gets the base-two logarithm of the maximum PCM coding-block size. + /// public int MaxPcmCodingBlockLog2 { get; } - /// Gets a value indicating whether in-loop filtering is disabled for PCM blocks. + /// + /// Gets a value indicating whether in-loop filtering is disabled for PCM blocks. + /// public bool PcmLoopFilterDisabled { get; } - /// Gets the SPS short-term reference-picture sets. + /// + /// Gets the SPS short-term reference-picture sets. + /// public IReadOnlyList ShortTermReferencePictureSets { get; } - /// Gets the long-term reference picture-order-count values. + /// + /// Gets the long-term reference picture-order-count values. + /// public IReadOnlyList LongTermReferencePictureOrderCounts { get; } - /// Gets the long-term reference-picture current-usage flags. + /// + /// Gets the long-term reference-picture current-usage flags. + /// public IReadOnlyList LongTermReferencePicturesUsedByCurrent { get; } - /// Gets a value indicating whether temporal motion-vector prediction is enabled. + /// + /// Gets a value indicating whether temporal motion-vector prediction is enabled. + /// public bool TemporalMotionVectorPredictionEnabled { get; } - /// Gets a value indicating whether strong intra smoothing is enabled. + /// + /// Gets a value indicating whether strong intra smoothing is enabled. + /// public bool StrongIntraSmoothingEnabled { get; } - /// Gets the optional still-image VUI presentation description. + /// + /// Gets the optional still-image VUI presentation description. + /// public HevcVideoUsabilityInformation? VideoUsabilityInformation { get; } - /// Gets a value indicating whether transform-skip coefficient rotation is enabled. + /// + /// Gets a value indicating whether transform-skip coefficient rotation is enabled. + /// public bool TransformSkipRotationEnabled { get; } - /// Gets a value indicating whether transform-skip-specific entropy contexts are enabled. + /// + /// Gets a value indicating whether transform-skip-specific entropy contexts are enabled. + /// public bool TransformSkipContextEnabled { get; } - /// Gets a value indicating whether implicit residual DPCM is enabled. + /// + /// Gets a value indicating whether implicit residual DPCM is enabled. + /// public bool ImplicitResidualDpcmEnabled { get; } - /// Gets a value indicating whether explicit residual DPCM is enabled. + /// + /// Gets a value indicating whether explicit residual DPCM is enabled. + /// public bool ExplicitResidualDpcmEnabled { get; } - /// Gets a value indicating whether extended-precision processing is enabled. + /// + /// Gets a value indicating whether extended-precision processing is enabled. + /// public bool ExtendedPrecisionProcessingEnabled { get; } - /// Gets a value indicating whether intra smoothing is disabled. + /// + /// Gets a value indicating whether intra smoothing is disabled. + /// public bool IntraSmoothingDisabled { get; } - /// Gets a value indicating whether high-precision prediction offsets are enabled. + /// + /// Gets a value indicating whether high-precision prediction offsets are enabled. + /// public bool HighPrecisionOffsetsEnabled { get; } - /// Gets a value indicating whether persistent Rice adaptation is enabled. + /// + /// Gets a value indicating whether persistent Rice adaptation is enabled. + /// public bool PersistentRiceAdaptationEnabled { get; } - /// Gets a value indicating whether CABAC bypass alignment is enabled. + /// + /// Gets a value indicating whether CABAC bypass alignment is enabled. + /// public bool CabacBypassAlignmentEnabled { get; } /// diff --git a/src/ImageSharp/Formats/Heif/Hevc/HevcSliceSegmentHeader.cs b/src/ImageSharp/Formats/Heif/Hevc/HevcSliceSegmentHeader.cs index 53fa3645b9..02a37b1a27 100644 --- a/src/ImageSharp/Formats/Heif/Hevc/HevcSliceSegmentHeader.cs +++ b/src/ImageSharp/Formats/Heif/Hevc/HevcSliceSegmentHeader.cs @@ -130,55 +130,89 @@ internal sealed class HevcSliceSegmentHeader } } - /// Gets the complete decoded NAL unit containing this slice segment. + /// + /// Gets the complete decoded NAL unit containing this slice segment. + /// public HevcNalUnit NalUnit { get; } - /// Gets a value indicating whether this is the first slice segment of the coded picture. + /// + /// Gets a value indicating whether this is the first slice segment of the coded picture. + /// public bool FirstSliceSegmentInPicture { get; } - /// Gets a value indicating whether this segment inherits syntax from an earlier independent slice. + /// + /// Gets a value indicating whether this segment inherits syntax from an earlier independent slice. + /// public bool DependentSliceSegment { get; } - /// Gets the picture parameters selected by this slice segment. + /// + /// Gets the picture parameters selected by this slice segment. + /// public HevcPictureParameterSet PictureParameterSet { get; } - /// Gets the raster-scan address of the first coding-tree block in this slice segment. + /// + /// Gets the raster-scan address of the first coding-tree block in this slice segment. + /// public int SliceSegmentAddress { get; } - /// Gets the independent slice prediction type, or for a dependent segment. + /// + /// Gets the independent slice prediction type, or for a dependent segment. + /// public HevcSliceType? SliceType { get; private set; } - /// Gets the selected color-plane identifier for separate-plane 4:4:4 coding. + /// + /// Gets the selected color-plane identifier for separate-plane 4:4:4 coding. + /// public byte ColorPlaneId { get; private set; } - /// Gets a value indicating whether luma sample-adaptive offset filtering is enabled. + /// + /// Gets a value indicating whether luma sample-adaptive offset filtering is enabled. + /// public bool? SampleAdaptiveOffsetLumaEnabled { get; private set; } - /// Gets a value indicating whether chroma sample-adaptive offset filtering is enabled. + /// + /// Gets a value indicating whether chroma sample-adaptive offset filtering is enabled. + /// public bool? SampleAdaptiveOffsetChromaEnabled { get; private set; } - /// Gets the effective luma quantization parameter, or for a dependent segment. + /// + /// Gets the effective luma quantization parameter, or for a dependent segment. + /// public int? QuantizationParameter { get; private set; } - /// Gets the slice-level Cb quantization-parameter offset. + /// + /// Gets the slice-level Cb quantization-parameter offset. + /// public int ChromaCbQuantizationParameterOffset { get; private set; } - /// Gets the slice-level Cr quantization-parameter offset. + /// + /// Gets the slice-level Cr quantization-parameter offset. + /// public int ChromaCrQuantizationParameterOffset { get; private set; } - /// Gets a value indicating whether coding units can select the PPS chroma-offset list. + /// + /// Gets a value indicating whether coding units can select the PPS chroma-offset list. + /// public bool? ChromaQuantizationParameterOffsetListEnabled { get; private set; } - /// Gets a value indicating whether deblocking is disabled for this independent slice. + /// + /// Gets a value indicating whether deblocking is disabled for this independent slice. + /// public bool? DeblockingFilterDisabled { get; private set; } - /// Gets half the effective deblocking beta-threshold offset. + /// + /// Gets half the effective deblocking beta-threshold offset. + /// public int DeblockingFilterBetaOffsetDiv2 { get; private set; } - /// Gets half the effective deblocking clipping-threshold offset. + /// + /// Gets half the effective deblocking clipping-threshold offset. + /// public int DeblockingFilterTcOffsetDiv2 { get; private set; } - /// Gets a value indicating whether in-loop filtering crosses slice boundaries. + /// + /// Gets a value indicating whether in-loop filtering crosses slice boundaries. + /// public bool? LoopFilterAcrossSlicesEnabled { get; private set; } /// @@ -186,10 +220,14 @@ internal sealed class HevcSliceSegmentHeader /// public IReadOnlyList EntryPointOffsets { get; private set; } = Array.Empty(); - /// Gets the slice-header length in decoded raw-byte-sequence payload bytes. + /// + /// Gets the slice-header length in decoded raw-byte-sequence payload bytes. + /// public int HeaderLength { get; } - /// Gets the entropy-coded slice data following byte alignment. + /// + /// Gets the entropy-coded slice data following byte alignment. + /// public ReadOnlyMemory SliceData { get; } ///