Skip to content

fix(linux): video decode on ARM drivers (V4L2-backed VA-API, Turnip) - #1470

Open
TheWeaklessOne wants to merge 8 commits into
OpenCloudGaming:devfrom
TheWeaklessOne:fold/linux-decode-arm
Open

TheWeaklessOne wants to merge 8 commits into
OpenCloudGaming:devfrom
TheWeaklessOne:fold/linux-decode-arm

Conversation

@TheWeaklessOne

Copy link
Copy Markdown

On ARM drivers (an AYN Odin 2 Portal: Turnip on the Adreno 740, Qualcomm iris behind a V4L2-backed VA-API driver)
the Linux decode path breaks in five ways:

  • VA-API H.264 shows up as unavailable;
  • the app aborts at startup under gamescope;
  • 10-bit HDR comes out green;
  • a stream freezes after a queue overflow or a decode error.

This folds #1410 and #1412-#1415 into one PR on today's dev; I'll close those five with a link here.

On the Portal: the streamer's tests pass, and a free-tier session decoded AV1 1080p over VA-API at 59.7-60.1 fps for
231 s. It had no stall, no dropped frame and no keyframe request.

Description

The commits, one problem each. Each original PR has the reasoning and the measurements from 2026-11-05:

Commit From What it does
size the VA-API placeholder context for V4L2-backed drivers #1410 the 16x16 probe surface is below iris's 96x96 minimum; INITIAL_CONTEXT_SIZE goes to 128, which still covers radeonsi's 64x64 (#1301)
skip Vulkan Video on devices without a decode queue #1412 Turnip has no VIDEO_DECODE queue family; FFmpeg's Vulkan hwdevice fetched a NULL queue and the gamescope WSI layer aborted the app
import P010 as single-plane images without multi-planar support #1413 R16_UNORM + R16G16_UNORM over the same DMA-BUF when the 3-plane 10-bit format or its plane views are missing, as libplacebo does
clear the keyframe latch when recovery replaces queued frames #1414 a recovery keyframe that replaced decode work reported DroppedOldest, so the latch never cleared; plus a 250 ms re-request
keep VA-API streams alive through decode errors and stale backlogs #1415 a failed VA picture maps to ReferenceLost instead of a dead decoder; an overflow no longer reopens the decoder; a stale backlog drops to live
keep the keyframe gate shut on polled output; restart the backlog timer after recovery and count dropped frames; keep a newer generation when dropping a stale backlog review fixes on #1415 the cases the review bots found, each with a test
How it was tested

Device: AYN Odin 2 Portal (Snapdragon 8 Gen 2), SteamOS ARM (Zaviya 1.5), Mesa Turnip, the msm VA-API driver from
hashtagbasit/Zaviya#80 over iris. The build had these eight commits on main a9de957. Rebased onto dev 6355ed7,
the files they touch are byte for byte the same, because dev changes none of them since main. The build also
carried #1417, since the device has Qt 6.8.0.

Tests on the device:

  • cargo test -p opennow-streamer-platform --features linux-vaapi,linux-ffmpeg-bundled: 212 passed, 0 failed.
  • cargo test -p opennow-streamer-platform-linux --features vaapi,ffmpeg-bundled: 257 passed, 1 failed.
  • cargo test -p opennow-streamer-platform-linux: 191 passed, 1 failed.
  • The one failure in both is session::tests::fixed_audio_output_never_falls_back_and_stays_isolated, which fails on
    this device with "ALSA device enumeration failed: -2" under its own ALSA_CONFIG_PATH fixture. This PR changes no
    audio output code.
  • The new tests all pass: video_decode_requires_a_decode_queue_family,
    keyframe_at_the_overflow_boundary_reports_itself_queued, stale_backlog_drop_keeps_a_newer_generation_recovery,
    remove_where_keeps_the_other_items_in_order, linux_keyframe_retry_rearms_after_the_interval and
    vaapi_picture_errors_are_recoverable_and_others_are_not. The last one needs the vaapi feature.

Session: the free tier, a single-player game, launched from Steam in the gamescope session. NVST AV1 8-bit 4:2:0
1920x1080 (120 fps asked, the free rig sent 60), decoded through VA-API with /dev/video0 open. 231 s, 13,753 video
frames, 59.7-60.1 decoded fps in every 10 s window, transportFrameProgressStalled=false in 18 of 18 reports. One
keyframe (the start IDR), 0 keyframe requests, 0 decode-error or recovery lines, 0 dropped frames. The session ended
with End session. The rig showed the game's first-run dialog the whole time, so the picture was static. No decode
error happened on its own, so the recovery commits were covered by their tests and by the 2026-11-05 runs in #1414
and #1415, not by this session.

Built and tested with help from Claude and Codex (AI assistants). The device and the runs are mine.

TheWeaklessOne and others added 8 commits November 24, 2026 09:48
Qualcomm iris behind the msm VA-API driver (SteamOS ARM, Odin 2 Portal)
rejects contexts and surfaces below its 96x96 decoder minimum, so the 16x16
probe surface reported a working H.264 decoder as unavailable. Raise
INITIAL_CONTEXT_SIZE to 128, which still covers radeonsi's 64x64 minimum,
and size the probe surface from the same constant.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Turnip (Adreno 740) has no VIDEO_DECODE queue family. FFmpeg's Vulkan
hwdevice setup fetched a queue that does not exist, and the gamescope WSI
layer then aborted the whole application on the NULL VkQueue at startup.
Reject such devices in SharedVulkanDevice::create and check for a decode
queue before FfmpegDecoder touches Vulkan.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…upport

Turnip on the Adreno 740 has no G10X6_B10X6R10X6_2PLANE_420 and no R10X6
views, and an image of a format the driver cannot sample reads as zeros, so
10-bit HDR streams through VA-API DMA-BUF came out green. When the
multi-planar format is not sampleable with the frame's DRM modifier, import
the planes as R16 and R16G16 images over the same DMA-BUF, as libplacebo
does. Drivers that support the multi-planar format keep the existing path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ames

After a decoder queue overflow the recovery keyframe replaces the stale
decode work. queue_video_command reported that as DroppedOldest, so the
caller kept keyframe_requested and video_desynced set, and every later
overflow believed a request was already pending: the stream froze until an
IDR happened to arrive. Report the queued keyframe as Queued, including at
the overflow boundary, and request the keyframe again if none has come
within 250 ms.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… backlogs

A picture the hardware failed to decode reached the session as a generic
backend error. Map it to ReferenceLost, in decode and in DMA-BUF export.

Overflow recovery reopened the decoder, which takes long enough for the
queue to overflow again. Decoders that can flush in place now do that
(FFmpeg VA-API: avcodec_flush_buffers).

A backlog that does not drain only adds latency, so 12 or more encoded
frames still queued after 250 ms are dropped and a keyframe is requested.
The embedded Linux queue grows to 24 frames, 200 ms at 120 fps.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MediaCodec and polled H.264 V4L2 can still hold output from before a
stale backlog was dropped. Polling it cleared need_keyframe, so the deltas
that follow were decoded without the frames just removed. Only a submitted
frame opens the gate now; startup and recovery already pass a keyframe
through it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d frames

The stale-backlog timer survived decoder recovery, so the first keyframe
after a long recovery could be dropped right away with the backlog behind
it. Clear it while waiting for a keyframe.

QueueOverflow reported one frame for a whole dropped backlog. Carry the
real count through to MediaFeedback::QueueDropped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A queue overflow can put a keyframe with reset set and a newer generation
behind the frames still being measured. Dropping every Decode removed that
recovery too and forced another keyframe wait. Drop only the generation in
progress, and skip the keyframe request when a recovery is already queued.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 24, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 89114aca-cd1a-4276-893e-134b2c71b45d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-24T08:49:38.855404Z
We couldn’t complete this review. Comment @codex review to try again.
85e466f PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

This branch has not been deployed

No deployments
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.

1 participant