Skip to content

AV1 videos play with the headset's hardware decoder on SteamOS 0.5.10 - #89

Merged
seaweeduk merged 1 commit into
masterfrom
feature/iris-av1
Nov 19, 2026
Merged

seaweeduk merged 1 commit into
masterfrom
feature/iris-av1

Conversation

@seaweeduk

@seaweeduk seaweeduk commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

The Iris decoder in SteamOS 0.5.10 decodes AV1. The Frame now uses it for 8-bit AV1, which played in software before: 8K AV1 at about 28 fps, with frequent dropped frames.

  • FFmpeg: a new av1_v4l2m2m decoder in the Frame's V4L2 wrapper. AV1 maps to the driver's AV01 format. Each buffer gets one temporal unit, which opens with exactly one temporal delimiter. MP4 and Matroska leave the delimiter out; one already in the packet, extension header and padded size included, is parsed and replaced. The first unit also carries the sequence header from the av1C record, without the record's four-byte header. A malformed av1C is refused. It is registered after libdav1d and FFmpeg's own AV1 decoder, so it is never picked by default or for probing.
  • App: at startup the player reads the decoder node's sysfs name, opens only that node, and checks whether it lists AV01. Only then does it add av1 to mpv's hwdec-codecs. The vendor driver in earlier SteamOS doesn't list it, so AV1 stays in software there. The "Software decoding" tooltip only names AV1 as unsupported when the decoder doesn't take it.
  • mpv (mpv-v4l2-av1.patch): AV1 frames come out in decoding order, so the capture pool is the driver's minimum plus three. A refused pool is retried and remembered as it is for HEVC and H.264. If the hardware refuses an AV1 file, mpv still falls back to software, even for files of 8K and up.
  • 10-bit AV1 stays in software. If the demuxer gives no pixel format, the av1C must say Main, 8-bit 4:2:0. Seeks reopen the decoder, as they do for H.264.

8000×4000 AV1, 60 fps, over SMB, on the Frame at 3780 px per eye and 120 Hz:

Before (libdav1d) This PR (Iris)
Frames per second 12–41, median 28 60
Dropped frames 357 0

Not changed, on purpose:

  • With --hwdec=no the player doesn't probe the decoder, so the "Software decoding" tooltip names AV1 as unsupported. That flag is a diagnostic switch, not a setting users reach.
  • An MP4 track that switches to 10-bit mid-stream, a last OBU without its size field, a truncated av1C, or a padded delimiter before a three-byte packet. Common encoders and muxers don't write these.

Important

AI disclosure

Model Variant Role
anthropic/claude-opus-5-5 high Implementation
openai/gpt-6.2-sol high Driver investigation
openai/gpt-6.2-astra high Independent review

Agent harness OpenCode 2.3.2

@seaweeduk seaweeduk added the feature New feature (release notes: New) label Nov 19, 2026
@opencode-agent

Copy link
Copy Markdown
  1. Medium — Recheck AV1 bit depth when the configuration changes. v4l2_m2m_dec.c:288–305 strips the av1C header without checking its format. The 8-bit gate runs only at decoder initialization. An MP4 track can switch sample descriptions; FFmpeg delivers the replacement av1C as AV_PKT_DATA_NEW_EXTRADATA, which try_enqueue_src() passes to this same copy function. If an 8-bit track switches to a 10-bit sequence, the wrapper therefore sends it to the existing 8-bit Iris session instead of falling back to software. Check the replacement record before discarding its header, and keep an unsupported configuration from enqueueing packets so mpv can fall back.

  2. Medium — Add the missing size field when converting MP4 samples to OBU-stream format. v4l2_m2m_dec.c:759–774 changes the delimiter but copies the remaining OBUs verbatim. AV1's MP4 binding, §2.4, permits the last OBU in a sample to omit its size; FFmpeg's MOV demuxer and AV1 parser preserve those bytes. That sample is valid in MP4, but the low-overhead OBU stream expected by V4L2_PIX_FMT_AV1 requires the size field. For such files, even ordinary frame buffers are submitted in the wrong format. When the final OBU omits its size, set the flag and encode the remaining payload length before enqueueing it.

  3. Low — Compare the delimiter length with the original packet size. v4l2_m2m_dec.c:764–771 subtracts delimiter before checking whether the packet consisted only of that delimiter. For example, a three-byte delimiter with a padded size field followed by a three-byte show_existing_frame OBU leaves s->buf_pkt.size == 3. After the first packet, prefix_size is zero, so the comparison suppresses the replacement delimiter and sends the frame header alone. Determine delimiter_only before trimming, and trim a local packet view so an EAGAIN retry starts from the same input.

  4. Low — Reject truncated OBUs in av1C before appending the first sample. v4l2_m2m_dec.c:291–305 checks the record's version and four-byte minimum, but not that its configOBUs fit inside the record. An MP4 with a truncated sequence-header OBU can therefore pass validation: once the prefix and sample are concatenated, the declared OBU length can consume bytes from the first frame. Validate the OBU headers and declared lengths against the configuration-record boundary before copying them; a full sequence-header parser is not needed for this check.

github run

@seaweeduk
seaweeduk changed the base branch from fix/iris-capture-pool to master November 19, 2026 23:23
@seaweeduk
seaweeduk merged commit e7779d9 into master Nov 19, 2026
2 checks passed
@seaweeduk
seaweeduk deleted the feature/iris-av1 branch November 19, 2026 23:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature (release notes: New)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant