diff --git a/HEIF_IMPLEMENTATION_PLAN.md b/HEIF_IMPLEMENTATION_PLAN.md index 0b3a418f1..0e799d82b 100644 --- a/HEIF_IMPLEMENTATION_PLAN.md +++ b/HEIF_IMPLEMENTATION_PLAN.md @@ -29,7 +29,7 @@ Checkboxes may be marked complete only when the implementation and the verificat ## Delivery dashboard -Last reconciled with the source tree on 2026-08-29 against production checkpoint `03737411e62155df8e998c37475ceeebf4f053bf`. Committed checkpoints include the AV1 transform architecture, OBU framing, intra-block copy, official extreme-displacement intra-block-copy conformance, the 12-profile reconstruction matrix, corrected twelve-bit inverse-transform SIMD arithmetic, layered-item properties, layered reference/header/CDF/motion-field state, inter-frame intra blocks, SIMD-first translational prediction, complete single-reference inter reconstruction, compound reference trees and modes, paired reference-MV derivation, reference-dependent bounded sequence decoding, allocation-free SIMD-first equal averaging, selected inter-intra prediction, selectable compound blending, OBMC, scaled-reference reconstruction, local warped prediction, non-translational global prediction, official motion-vector conformance, official spatial- and temporal-layer default-operating-point conformance, selected spatial-layer presentation, and progressive color and auxiliary-alpha conformance. This dashboard is the authoritative delivery order. The detailed phase checklists below provide subsystem evidence; they do not override the current-stage marker or permit work to skip ahead. +Last reconciled with the source tree on 2026-08-29 against production checkpoint `15613b01c0bc098fd9926b886216558e0d26eff9`. Committed checkpoints include the AV1 transform architecture, OBU framing, intra-block copy, official extreme-displacement intra-block-copy conformance, the 12-profile reconstruction matrix, corrected twelve-bit inverse-transform SIMD arithmetic, layered-item properties, layered reference/header/CDF/motion-field state, inter-frame intra blocks, SIMD-first translational prediction, complete single-reference inter reconstruction, compound reference trees and modes, paired reference-MV derivation, reference-dependent bounded sequence decoding, allocation-free SIMD-first equal averaging, selected inter-intra prediction, selectable compound blending, OBMC, scaled-reference reconstruction, local warped prediction, non-translational global prediction, official motion-vector conformance, official spatial- and temporal-layer default-operating-point conformance, official active-film-grain sequence conformance, selected spatial-layer presentation, and progressive color and auxiliary-alpha conformance. This dashboard is the authoritative delivery order. The detailed phase checklists below provide subsystem evidence; they do not override the current-stage marker or permit work to skip ahead. Commit `1c58d855f70b024170ced9eb0a7005f0f9c955ad` records the complete official motion-vector conformance checkpoint. The official IVF has SHA-1 `F064290D7FCD3B3DE19020E8AEC6C43C88D3A505`, matching the pinned libaom test-data manifest, and SHA-256 `222A9050059B254DAB17CFB802FF829C778E3F93AF18961A622C8268576C1395`; its pinned-libaom Y4M has SHA-256 `D97AC78C81782CF1507549368047769DC677DBE205706458D1EE9C807DE6EC78`. Both source targets build with zero warnings and errors, the `net10.0` test-project analyzer build completes with zero errors and 1,014 pre-existing repository warnings, Roslynk reports zero compiler errors, 3,985 focused `net10.0` cases pass without failures or skips, and `git diff --check` is clean. @@ -49,6 +49,8 @@ Commit `a5e4cc6cc6cf87ee02b41cfe4ca71d1ef3411ed7` records the official one-spati Commit `03737411e62155df8e998c37475ceeebf4f053bf` records the official two-spatial-layer, two-temporal-layer L2T2 checkpoint. The manifest-matching 119,907-byte IVF and pinned-libaom Y4M prove all eight 1280x720 YUV420 frames exactly under normal and scalar dispatch; constrained tracked allocation verifies balanced exactly-once returns. The existing decoder required no production correction. The scoped test-project analyzer build completes with zero errors and 1,011 repository warnings, Roslynk reports zero compiler errors, both focused cases pass without failures or skips, and `git diff --check` is clean. +Commit `15613b01c0bc098fd9926b886216558e0d26eff9` records the official ten-frame active-film-grain checkpoint. The manifest-matching 28,634-byte IVF and pinned-libaom grained Y4M prove every displayed 352x288 YUV420 frame exactly under normal and scalar dispatch; the differing skip-grain digest and explicit coverage prove synthesis is active. The checkpoint corrected the AV1 default loop-filter reference-delta order so Golden is -1 and Backward is 0, restoring exact dependent-frame deblocking before display-only grain. Constrained tracked allocation returns every allocation exactly once. Both Release source targets build with zero warnings and errors, the scoped test-project analyzer build completes with zero errors and 1,011 repository warnings, Roslynk reports zero compiler errors, 28 focused cases pass without failures or skips, and `git diff --check` is clean. + Status meanings: - **Complete:** the implementation and its phase exit evidence are recorded. @@ -59,7 +61,7 @@ Status meanings: Current development stage: **Stage 3 — complete AV1 still-image decoding.** The decoder retains reference/header/CDF/motion-field state, derives frame-level skip-mode references, consumes temporal segment prediction, decodes intra-coded blocks inside inter frames, and reconstructs translational single-reference, compound, inter-intra, OBMC, scaled-reference, local warped, and non-translational global prediction before residual traversal. Commit `1c58d855f70b024170ced9eb0a7005f0f9c955ad` adds exact official four-frame coverage through all ordinary inter modes, all three motion modes, every regular/smooth/sharp dual-filter pair, sub-8x8 chroma prediction, and no-round compound intermediates. Commit `019ac5648b4380a6ff4865072c96fde29ce09fad` adds exact selected-layer native reconstruction and scaled presentation. Neither AV1 nor HEVC production encoding is implemented. -Immediate checkpoint: **verification complete; commit pending — official ten-frame active-film-grain AV1 sequence.** All ten displayed 352x288 YUV420 frames match the pinned-libaom grained output exactly under normal and scalar dispatch, active synthesis is explicit, and constrained tracked allocation returns every allocation exactly once. The fixture exposed a swapped AV1 default loop-filter delta: Golden now defaults to -1 and Backward to 0, restoring normative dependent-frame deblocking before display-only grain synthesis. A direct default-table regression, adjacent deblocking/CDEF cases, retained-reference and presentation ownership, both zero-warning Release source builds, the zero-error test-project analyzer build with 1,011 repository warnings, zero Roslynk compiler errors, 28 focused cases, documentation review, and `git diff --check` pass. Only the checkpoint commit remains open. +Immediate checkpoint: **verification complete; commit pending — official eight-bit monochrome AV1 sequence.** The 10,000-byte official IVF matches the pinned manifest and all ten displayed 320x180 luma planes match pinned libaom exactly under normal and scalar dispatch. The shared compact-sequence oracle now validates native YUV400 without manufacturing chroma planes, while every prior YUV420 caller remains exact. A 2 KiB constrained tracked allocator returns every allocation exactly once. The existing decoder required no production correction. Both Release source targets build with zero warnings and errors, the scoped test-project analyzer build completes with zero errors and 1,011 repository warnings, Roslynk reports zero compiler errors, all 17 official-sequence cases pass without failures or skips, and `git diff --check` is clean. Only the checkpoint commit remains open. | Order | Delivery stage | State | Delivered state | Gate that remains open | | --- | --- | --- | --- | --- | @@ -612,8 +614,9 @@ Implement and verify in dependency order: - [x] Decode the official two-spatial-layer L2T1 sequence at its default operating point. The 159,037-byte IVF has manifest-matching SHA-1 `E14825F50FF845B8A6932C64CB254007A0B5E3A1` and SHA-256 `D65824E8E7C19BC958DB810D728B2132B513B5A93CB5F99CA3D7995E19A226E1`; its pinned-libaom Y4M has SHA-256 `7A427631ECBF144F435AA4612F1201415FB1A9BCF9A67BA010AEF830B0C3AB81`. All eight 1280x720 YUV420 frames match exactly under normal and scalar dispatch, and an 8 KiB constrained tracked allocator verifies balanced exactly-once returns. The existing decoder required no production correction. Both Release source targets build with zero warnings and errors, the scoped test-project analyzer build completes with zero errors and 1,011 repository warnings, Roslynk reports zero compiler errors, and all five focused compact-sequence cases pass without failures or skips. - [x] Decode the official one-spatial-layer, two-temporal-layer L1T2 sequence at its default operating point. The 48,883-byte IVF has manifest-matching SHA-1 `E94687EB0E90179B3800B6D5E11EB7E9BFB34EEC` and SHA-256 `EADE696AB60415D476E1D2A489EC2CCCD24D5EAAADFA4559C6488B7932274C5E`; its pinned-libaom Y4M has SHA-256 `4012DE2D4AFD095E7BB68EAE18B50B0674781BB4971CECABC0E5471E63373ED3`. All eight 640x360 YUV420 frames match exactly under normal/scalar dispatch, and an 8 KiB constrained tracked allocator verifies balanced exactly-once returns. The existing decoder required no production correction. The scoped test-project analyzer build completes with zero errors and 1,011 repository warnings, Roslynk reports zero compiler errors, and both focused cases pass without failures or skips. - [x] Decode the official two-spatial-layer, two-temporal-layer L2T2 sequence at its default operating point. The 119,907-byte IVF has manifest-matching SHA-1 `32EF2F14EE9CB11A24A22934F4C065E926E5D236` and SHA-256 `14257D5FD3901581DBEB88133378CD79D50EA32506ADB729909AB56B4A52AF3C`; its pinned-libaom Y4M has SHA-256 `1ABB981CFF76BA9557DA437B258D8A95FCA755DED8E3949D857E8388AB1D6AE3`. All eight 1280x720 YUV420 frames match exactly under normal/scalar dispatch, and an 8 KiB constrained tracked allocator verifies balanced exactly-once returns. The existing decoder required no production correction. The scoped test-project analyzer build completes with zero errors and 1,011 repository warnings, Roslynk reports zero compiler errors, and both focused cases pass without failures or skips. - - [ ] **Verification complete; commit pending:** decode the official ten-frame active-film-grain sequence. The 28,634-byte IVF has manifest-matching SHA-1 `11BB40026103182C23A88133EDAFCA369E5575E2` and SHA-256 `BA3EDD82A58414F009E1C821B947EC8DE4E0420F33803CA7BFEA39AF6AEEA155`; its pinned-libaom grained Y4M has SHA-256 `C71958DE496A949D12E819190F240BD56010E5AD57D8A0D55903BF380A9E0C26`, while pinned libaom's skip-grain output differs with SHA-256 `9E0762A82E582E854AFF2DC61EBA1E48C0F1D41BBC21E5C896573DA3BB2F1200`. All ten displayed 352x288 YUV420 frames match exactly under normal/scalar dispatch; active synthesis, dependent retained-reference reconstruction, and 2 KiB constrained tracked allocation with exactly-once returns pass. The fixture corrected the AV1 default loop-filter reference deltas from a swapped Golden/Backward pair to the normative `[1, 0, 0, 0, -1, 0, -1, -1]` order. Both Release source targets build with zero warnings and errors, the scoped test-project analyzer build completes with zero errors and 1,011 repository warnings, Roslynk reports zero compiler errors, 28 focused cases pass without failures or skips, documentation review is complete, and `git diff --check` is clean. -- [ ] Lossless and high-bit-depth reconstruction with correct clipping and intermediate precision. + - [x] Decode the official ten-frame active-film-grain sequence. The 28,634-byte IVF has manifest-matching SHA-1 `11BB40026103182C23A88133EDAFCA369E5575E2` and SHA-256 `BA3EDD82A58414F009E1C821B947EC8DE4E0420F33803CA7BFEA39AF6AEEA155`; its pinned-libaom grained Y4M has SHA-256 `C71958DE496A949D12E819190F240BD56010E5AD57D8A0D55903BF380A9E0C26`, while pinned libaom's skip-grain output differs with SHA-256 `9E0762A82E582E854AFF2DC61EBA1E48C0F1D41BBC21E5C896573DA3BB2F1200`. All ten displayed 352x288 YUV420 frames match exactly under normal/scalar dispatch; active synthesis, dependent retained-reference reconstruction, and 2 KiB constrained tracked allocation with exactly-once returns pass. The fixture corrected the AV1 default loop-filter reference deltas from a swapped Golden/Backward pair to the normative `[1, 0, 0, 0, -1, 0, -1, -1]` order. Both Release source targets build with zero warnings and errors, the scoped test-project analyzer build completes with zero errors and 1,011 repository warnings, Roslynk reports zero compiler errors, 28 focused cases pass without failures or skips, documentation review is complete, and `git diff --check` is clean. Commit `15613b01c0bc098fd9926b886216558e0d26eff9` records the checkpoint. + - [ ] **Verification complete; commit pending:** decode the official eight-bit monochrome sequence. The 10,000-byte IVF has manifest-matching SHA-1 `A17584012187CD886B64F8CB0F35BFD8D762F9DC` and SHA-256 `3DCC2A3C181F74788BD9575D94F0862D9E914415AC358A4DA4ED7D904F0535B7`; its ten-frame 576,000-byte pinned-libaom luma reference has SHA-256 `6A4F8A68366E801D60A14C00BE6EA88A861B1B631D86DEF8A8DB65EFB6B06FA8`. All ten displayed 320x180 native YUV400 frames match exactly under normal/scalar dispatch, the shared compact-sequence oracle keeps every prior YUV420 fixture exact, and a 2 KiB constrained tracked allocator verifies balanced exactly-once returns. The existing decoder required no production correction. Both Release source targets build with zero warnings and errors, the scoped test-project analyzer build completes with zero errors and 1,011 repository warnings, Roslynk reports zero compiler errors, all 17 official-sequence cases pass without failures or skips, documentation review is complete, and `git diff --check` is clean. +- [x] Lossless and high-bit-depth reconstruction with correct clipping and intermediate precision. - [x] Route lossless 4x4 blocks through allocation-free reversible inverse Walsh-Hadamard reconstruction for 8/10/12-bit samples, including the DC-only specialization, `Vector128` production traversal, scalar fallback, exact clipping, and `FeatureTestRunner` parity. - [x] Verify lossless syntax, inverse quantization, prediction, and presented reconstruction with independently encoded 8/10/12-bit AVIF fixtures. The tests require coded residuals with palette and intra-block copy disabled, compare every native YUV sample with the pinned generic libaom-backed decoder, and compare every presented RGBA byte with pinned generic libavif exactly under normal hardware dispatch and the scalar fallback. - [x] Deblocking loop filter. diff --git a/tests/ImageSharp.Tests/Formats/Heif/Av1/Av1ReconstructionConformanceTests.cs b/tests/ImageSharp.Tests/Formats/Heif/Av1/Av1ReconstructionConformanceTests.cs index a4831e3c9..52483bb52 100644 --- a/tests/ImageSharp.Tests/Formats/Heif/Av1/Av1ReconstructionConformanceTests.cs +++ b/tests/ImageSharp.Tests/Formats/Heif/Av1/Av1ReconstructionConformanceTests.cs @@ -236,6 +236,21 @@ public class Av1ReconstructionConformanceTests /// private const int OfficialFilmGrainFixtureFrameCount = 10; + /// + /// The width of the official libaom eight-bit monochrome sequence. + /// + private const int OfficialMonochromeFixtureWidth = 320; + + /// + /// The height of the official libaom eight-bit monochrome sequence. + /// + private const int OfficialMonochromeFixtureHeight = 180; + + /// + /// The number of frames in the official libaom eight-bit monochrome sequence. + /// + private const int OfficialMonochromeFixtureFrameCount = 10; + /// /// The coverage bit representing tile-local adaptive CDF updates. /// @@ -1475,6 +1490,58 @@ public class Av1ReconstructionConformanceTests Assert.NotEqual(0, coverage & FilmGrainCoverage); } + /// + /// Verifies the official eight-bit monochrome sequence against exact pinned-libaom native output under normal and + /// scalar dispatch. + /// + [Fact] + public void DecodeOfficialMonochromeSequenceMatchesPinnedLibaomReference() + => FeatureTestRunner.RunWithHwIntrinsicsFeature( + ValidateOfficialMonochromeFixture, + ReconstructionConfigurations); + + /// + /// Verifies the official eight-bit monochrome sequence through constrained tracked allocation. + /// + [Fact] + [ValidateDisposedMemoryAllocations] + public void DecodeOfficialMonochromeSequenceWithConstrainedAllocator() + { + TestMemoryAllocator allocator = new() { BufferCapacityInBytes = 2_048 }; + allocator.EnableNonThreadSafeLogging(); + Configuration configuration = Configuration.Default.Clone(); + configuration.MemoryAllocator = allocator; + + ValidateOfficialCompactSequence( + configuration, + TestImages.Heif.Av1OfficialMonochromeSequence, + TestImages.Heif.Av1OfficialMonochromeSequenceNativeReference, + OfficialMonochromeFixtureFrameCount, + OfficialMonochromeFixtureWidth, + OfficialMonochromeFixtureHeight, + Av1ColorFormat.Yuv400); + + Assert.Equal(allocator.AllocationLog.Count, allocator.ReturnLog.Count); + Assert.All( + allocator.AllocationLog, + allocation => Assert.Single( + allocator.ReturnLog, + returned => returned.AllocationId == allocation.AllocationId)); + } + + /// + /// Decodes the official eight-bit monochrome sequence. + /// + private static void ValidateOfficialMonochromeFixture() + => ValidateOfficialCompactSequence( + Configuration.Default, + TestImages.Heif.Av1OfficialMonochromeSequence, + TestImages.Heif.Av1OfficialMonochromeSequenceNativeReference, + OfficialMonochromeFixtureFrameCount, + OfficialMonochromeFixtureWidth, + OfficialMonochromeFixtureHeight, + Av1ColorFormat.Yuv400); + /// /// Decodes one compact official IVF sequence, compares every native sample, and returns its active frame-state /// coverage mask. @@ -1485,12 +1552,15 @@ public class Av1ReconstructionConformanceTests string nativeReferencePath, int expectedFrameCount, int expectedWidth = OfficialMotionVectorFixtureWidth, - int expectedHeight = OfficialMotionVectorFixtureHeight) + int expectedHeight = OfficialMotionVectorFixtureHeight, + Av1ColorFormat expectedColorFormat = Av1ColorFormat.Yuv420) { byte[] ivf = TestFile.Create(fixturePath).Bytes; byte[] nativeReference = TestFile.Create(nativeReferencePath).Bytes; - byte[] y4mFileHeader = - Encoding.ASCII.GetBytes($"YUV4MPEG2 W{expectedWidth} H{expectedHeight} F30:1 Ip C420jpeg\n"); + bool hasY4mHeaders = expectedColorFormat != Av1ColorFormat.Yuv400; + ReadOnlySpan y4mFileHeader = hasY4mHeaders + ? Encoding.ASCII.GetBytes($"YUV4MPEG2 W{expectedWidth} H{expectedHeight} F30:1 Ip C420jpeg\n") + : []; ReadOnlySpan y4mFrameHeader = "FRAME\n"u8; @@ -1504,13 +1574,16 @@ public class Av1ReconstructionConformanceTests expectedFrameCount, checked((int)BinaryPrimitives.ReadUInt32LittleEndian(ivf.AsSpan(24, 4)))); - Assert.True(nativeReference.AsSpan().StartsWith(y4mFileHeader)); + if (hasY4mHeaders) + { + Assert.True(nativeReference.AsSpan().StartsWith(y4mFileHeader)); + } int ivfOffset = 32; int nativeOffset = y4mFileHeader.Length; - int nativeFrameLength = - (expectedWidth * expectedHeight) + - (2 * (expectedWidth >> 1) * (expectedHeight >> 1)); + int nativeFrameLength = expectedColorFormat == Av1ColorFormat.Yuv400 + ? expectedWidth * expectedHeight + : (expectedWidth * expectedHeight) + (2 * (expectedWidth >> 1) * (expectedHeight >> 1)); int coverage = 0; using Av1Decoder decoder = new(configuration); @@ -1526,10 +1599,14 @@ public class Av1ReconstructionConformanceTests ivfOffset += payloadLength; Assert.Equal(expectedWidth, frame.Width); Assert.Equal(expectedHeight, frame.Height); - Assert.True(nativeReference.AsSpan(nativeOffset).StartsWith(y4mFrameHeader)); - nativeOffset += y4mFrameHeader.Length; + if (hasY4mHeaders) + { + Assert.True(nativeReference.AsSpan(nativeOffset).StartsWith(y4mFrameHeader)); + nativeOffset += y4mFrameHeader.Length; + } Av1FrameBuffer frameBuffer = Assert.IsType>(decoder.FrameBuffer); + Assert.Equal(expectedColorFormat, frameBuffer.ColorFormat); AssertNativePlanesEqual( decoder, frameBuffer, diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index 75f7cf1b6..ec35c95aa 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -1406,6 +1406,8 @@ public static class TestImages public const string Av1OfficialSpatialTemporalLayerSequenceNativeReference = "Heif/Av1/Conformance/libaom-av1-1-b8-22-svc-L2T2-libaom.y4m"; public const string Av1OfficialFilmGrainSequence = "Heif/Av1/Conformance/libaom-av1-1-b8-23-film-grain-50.ivf"; public const string Av1OfficialFilmGrainSequenceNativeReference = "Heif/Av1/Conformance/libaom-av1-1-b8-23-film-grain-50-libaom.y4m"; + public const string Av1OfficialMonochromeSequence = "Heif/Av1/Conformance/libaom-av1-1-b8-24-monochrome.ivf"; + public const string Av1OfficialMonochromeSequenceNativeReference = "Heif/Av1/Conformance/libaom-av1-1-b8-24-monochrome-libaom.yuv"; public const string Av1Cdef8BitPayload = "Heif/Av1/Conformance/libaom-cdef-kodim23-8b.bit"; public const string Av1Cdef8BitReference = "Heif/Av1/Conformance/libaom-cdef-kodim23-8b-libaom.yuv"; public const string Av1Cdef8BitAvif = "Heif/Av1/Conformance/libavif-cdef-kodim23-8b.avif"; diff --git a/tests/Images/Input/Heif/Av1/Conformance/libaom-av1-1-b8-24-monochrome-libaom.yuv b/tests/Images/Input/Heif/Av1/Conformance/libaom-av1-1-b8-24-monochrome-libaom.yuv new file mode 100644 index 000000000..fef4d4611 --- /dev/null +++ b/tests/Images/Input/Heif/Av1/Conformance/libaom-av1-1-b8-24-monochrome-libaom.yuv @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6a4f8a68366e801d60a14c00be6ea88a861b1b631d86def8a8db65efb6b06fa8 +size 576000 diff --git a/tests/Images/Input/Heif/Av1/Conformance/libaom-av1-1-b8-24-monochrome.ivf b/tests/Images/Input/Heif/Av1/Conformance/libaom-av1-1-b8-24-monochrome.ivf new file mode 100644 index 000000000..573787737 --- /dev/null +++ b/tests/Images/Input/Heif/Av1/Conformance/libaom-av1-1-b8-24-monochrome.ivf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3dcc2a3c181f74788bd9575d94f0862d9e914415ac358a4da4ed7d904f0535b7 +size 10000