Skip to content

feat(avif)!: AVIF decode via gamut-avif container + hardware AV1; drop the image crate - #54

Merged
justin13888 merged 1 commit into
masterfrom
33-avif-decode-gamut-hwdec
Jul 19, 2026
Merged

feat(avif)!: AVIF decode via gamut-avif container + hardware AV1; drop the image crate#54
justin13888 merged 1 commit into
masterfrom
33-avif-decode-gamut-hwdec

Conversation

@justin13888

Copy link
Copy Markdown
Collaborator

Closes #33. This is the last codec migration in epic #38 — every format issue is now delivered or blocked on a filed upstream gate.

Stacked on #53; merge order #42 → … → #53 → this.

What is Delivered

  • AvifFile mirroring the HEIC split: container/item/thumbnail/alpha/depth-auxiliary/EXIF/XMP/ICC/bit-depth enumeration fully backend-less; pixel decode via HwAv1Adapter implementing gamut-avif's Av1StillDecoder over the exact hwdec handoff shape (av1C + OBU payload; re-serializer round-trip-tested). avif_hw_decode_available(); HwDecoderUnavailable without a backend. Shared plane-lifting extracted to formats/hw_planes.rs (HEIC deduplicated).
  • image crate deleted outright — dav1d/dav1d-sys/av-data subtree leaves the lockfile; CI drops libdav1d-dev. DecodeOptions::Avif; codec id avif/gamut; new avif_inspect example.

Verification Done — on real hardware

RX 7900 XT, VAAPI AV1 Profile 0. Run independently after implementation:

  • avif_8bit_420_hw_decodes_bit_exact_end_to_end — avifenc lossless fixture decodes bit-exact (expected values computed via gamut-color), also through decode_standard_image.
  • avif_grid_hw_decodes_bit_exact — 2×1 grid assembles bit-exact from two hardware-decoded tiles.
  • avif_alpha_auxiliary_hw_decodes — alpha enumerated, merged, and decoded standalone.
  • avif_10bit_hw_decode_gates_on_upstream_presentation — P010 hardware decode succeeds; the >8-bit RGBA presentation gate is asserted with the exact gamut#303 error (referenced, not shimmed).
  • avif_exif_xmp_items_read_backend_less — avifenc-authored items read with no decoder.
  • Honest scope finding: rawshift's own lossless AVIF encoder emits identity 4:4:4 = AV1 Profile 1, outside every current hardware still-decode profile — asserted precisely, with adaptive branches for future Profile-1 backends; two pre-existing dav1d-reliant tests updated to the same honest contract.

Counts: cargo test --workspace 387/0; --features full 563/0 (all 6 AVIF hw e2e tests RAN on this host); --features serde 360/0; clippy workspace + full -D warnings 0+0; standalone builds avif/avif-decode/avif-decode,hw/avif-encode/heic,hw all clean; image and dav1d absent from the lockfile. lefthook green.

Software AV1 fallback remains post-v1 (gamut#259); AVIF decode is hardware-only like HEIC, documented in the README.

…p the image crate

AVIF decode is rebuilt as gamut-avif container parsing plus AV1 still decode
through rawshift-hwdec, replacing the image crate's avif-native path. A new
AvifFile mirrors the HEIC split: container, item, thumbnail, alpha/depth
auxiliary, EXIF/XMP/ICC, and bit-depth enumeration are fully backend-less;
pixel decode routes through an HwAv1Adapter implementing gamut-avif's
Av1StillDecoder over the hwdec handoff shape (av1C config bytes + raw OBU
payload; the av1C re-serializer round-trips against gamut's parser). With no
backend, decode returns HwDecoderUnavailable; avif_hw_decode_available()
reports the state. Shared plane-lifting moved to formats/hw_planes.rs,
deduplicating the HEIC copies.

The image dependency is deleted outright — its whole subtree (dav1d,
dav1d-sys, av-data, ...) leaves the lockfile, and CI drops libdav1d-dev.
DecodeOptions::AvifImage -> Avif; codec id avif/gamut; new avif_inspect
example; MetadataNamespace::Avif carries container facts.

Runtime-verified on real hardware (RX 7900 XT, VAAPI AV1 Profile 0):
8-bit 4:2:0 decodes bit-exact end-to-end (avifenc lossless fixture, expected
values computed via gamut-color), 2x1 grids assemble bit-exact from
hardware-decoded tiles, alpha auxiliaries enumerate and merge, and
avifenc-authored EXIF/XMP items read backend-less. 10-bit decodes to P010 at
the hwdec layer and gates on the upstream >8-bit presentation surface
(gamut#303) with the exact error asserted. Honest scope finding: rawshift's
own lossless encoder emits identity 4:4:4 AV1 Profile 1, which no current
hardware still-decode profile covers — the tests assert the precise scope
error and adapt if a Profile-1-capable backend appears. Software AV1
fallback remains post-v1 (gamut#259); AVIF decode is hardware-only like
HEIC, documented in the README.

BREAKING CHANGE: AVIF decode config/variant renames; the image-crate decode
path and its software decode capability are gone — AVIF pixel decode now
requires a hardware backend.
Base automatically changed from 32-migrate-png-decode-gamut to master July 19, 2026 01:48
@justin13888
justin13888 merged commit 5eac807 into master Jul 19, 2026
@justin13888
justin13888 deleted the 33-avif-decode-gamut-hwdec branch July 19, 2026 01:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AVIF decode via gamut-avif container + hardware AV1

1 participant