Browse Source

Clarify shared HEIF color conversion

pull/2633/head
James Jackson-South 2 months ago
parent
commit
42f9d41753
  1. 3
      HEIF_IMPLEMENTATION_PLAN.md
  2. 4
      src/ImageSharp/Formats/Heif/Color/HeifColorConverter.IdentityOperator.cs
  3. 10
      src/ImageSharp/Formats/Heif/Color/HeifColorConverter.Operator.cs

3
HEIF_IMPLEMENTATION_PLAN.md

@ -45,7 +45,8 @@ Checkboxes may be marked complete only when the implementation and the verificat
- [x] Implement allocation-free SIMD-first HEVC intra prediction for all 35 modes, 4/8/16/32 blocks, and 8/10/12-bit samples, including three-tap and strong-bilinear reference filtering, negative-angle reference extension, luma boundary filters, and SIMD horizontal transposition. Verify the normal and forced-scalar paths against one scalar oracle.
- [x] Implement allocation-free reconstructed-plane reference collection and normative substitution for complete, empty, and partially available borders, including asymmetric 4:2:2 availability units and the HEVC mode/size/component filter-selection rules.
- [ ] Derive each reference-unit availability flag from coding-tree, slice, tile, constrained-intra, and picture-boundary state, then connect prediction to transform-unit traversal and the bounded item decoder lifecycle.
- [ ] Complete the SIMD YUV/CICP paths for every supported AV1 bit depth, chroma format, range, matrix, transfer function, color primary, and chroma position, with scalar fallback only when hardware vectorization is unavailable or the operation is inherently non-vectorizable.
- [x] Implement the shared SIMD-first YUV/CICP paths in both directions for AV1 and HEVC bit depths, chroma formats, ranges, matrix coefficients, transfer functions, color primaries, and chroma positions, with scalar fallback only after the available vector widths are exhausted.
- [ ] Complete the independently generated AV1 and HEVC conformance matrix for every supported color-signaling combination before closing the Phase 5 color exit gate.
- [x] Apply ICC conversion only after the SIMD YUV/CICP stage, alpha composition, grid assembly, and presentation transforms have produced the presented RGB image; retain ImageSharp's shared ICC converter and optimize reusable bulk kernels rather than creating a HEIF-specific color-management implementation.
- [ ] Verify ICC preservation, conversion, compaction, and metadata skipping for grids, alpha-composited images, every presented sequence frame, and the completed HEVC path.
- [x] Independently encode AVIF primary, grid, alpha-auxiliary, and two-frame sequence vectors with libavif 1.4.2/libaom 3.14.1; verify exact profile preservation, non-sRGB conversion, canonical-sRGB compaction, non-sRGB compact preservation, metadata skipping, every presented frame, and unchanged composed alpha.

4
src/ImageSharp/Formats/Heif/Color/HeifColorConverter.IdentityOperator.cs

@ -20,7 +20,7 @@ internal abstract partial class HeifColorConverterBase
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void ConvertToRgb(ref float green, ref float blue, ref float red, in HeifColorConversionParameters parameters)
{
// Identity-matrix AV1 stores the planes in G, B, R order. Rotate the three references in place
// H.273 identity-matrix signaling stores the planes in G, B, R order. Rotate the three references in place
// so the shared traversal always leaves component0/component1/component2 as R, G, B.
float g = green;
green = red;
@ -81,7 +81,7 @@ internal abstract partial class HeifColorConverterBase
out float component1,
out float component2)
{
// Identity-matrix AV1 stores RGB input as G, B, R without matrix arithmetic.
// H.273 identity-matrix signaling stores RGB input as G, B, R without matrix arithmetic.
component0 = green;
component1 = blue;
component2 = red;

10
src/ImageSharp/Formats/Heif/Color/HeifColorConverter.Operator.cs

@ -8,7 +8,7 @@ using System.Runtime.Intrinsics;
namespace SixLabors.ImageSharp.Formats.Heif.Color;
/// <content>
/// Provides the static operator contract and SIMD traversal used by AV1 color converters.
/// Provides the static operator contract and SIMD traversal used by HEIF color converters.
/// </content>
internal abstract partial class HeifColorConverterBase
{
@ -23,7 +23,7 @@ internal abstract partial class HeifColorConverterBase
public static abstract bool ChromaUsesLumaRange { get; }
/// <summary>
/// Converts one normalized AV1 sample to RGB.
/// Converts one normalized encoded sample to RGB.
/// </summary>
/// <param name="component0">The first encoded component, replaced by red.</param>
/// <param name="component1">The second encoded component, replaced by green.</param>
@ -36,7 +36,7 @@ internal abstract partial class HeifColorConverterBase
in HeifColorConversionParameters parameters);
/// <summary>
/// Converts four normalized AV1 samples to RGB.
/// Converts four normalized encoded samples to RGB.
/// </summary>
/// <param name="component0">The first encoded component lanes, replaced by red.</param>
/// <param name="component1">The second encoded component lanes, replaced by green.</param>
@ -49,7 +49,7 @@ internal abstract partial class HeifColorConverterBase
in HeifColorConversionParameters parameters);
/// <summary>
/// Converts eight normalized AV1 samples to RGB.
/// Converts eight normalized encoded samples to RGB.
/// </summary>
/// <param name="component0">The first encoded component lanes, replaced by red.</param>
/// <param name="component1">The second encoded component lanes, replaced by green.</param>
@ -62,7 +62,7 @@ internal abstract partial class HeifColorConverterBase
in HeifColorConversionParameters parameters);
/// <summary>
/// Converts sixteen normalized AV1 samples to RGB.
/// Converts sixteen normalized encoded samples to RGB.
/// </summary>
/// <param name="component0">The first encoded component lanes, replaced by red.</param>
/// <param name="component1">The second encoded component lanes, replaced by green.</param>

Loading…
Cancel
Save