Skip to content

fix(streamer): put dynamic quality thresholds on the AV1 QP scale - #1305

Open
etgbrown wants to merge 1 commit into
OpenCloudGaming:devfrom
etgbrown:av1-qp-scale
Open

etgbrown wants to merge 1 commit into
OpenCloudGaming:devfrom
etgbrown:av1-qp-scale

Conversation

@etgbrown

@etgbrown etgbrown commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Problem

DESCRIBE offers the host's DRC, DFC and GRC QP thresholds on the H.264/H.265
scale (0..=51, e.g. drc.upperQpThreshold 39). AV1 QP runs 0..=255, so the
host's dynamic quality control sees every AV1 frame as badly over-quantized and
steps quality down. On a v1.0.3-based build with save-bandwidth on
(dynamicStreamingMode 1) at 3840×2160@120:

Dev's docs (#1265) attribute 0x800e8605 to the chroma enum, and these runs
sent chromaFormat:1. That failure ends the session before the first frame;
these ended mid-stream and only with the policy on. The chroma enum does not
explain them: dev sends chromaFormat:0, and the same profile on a dev
nightly still ended with 0x800e8605 13 s after PLAY (see Verification).

Cause

ANNOUNCE passes the H.26x-scale thresholds through. The official Linux client
(2.0.89.141) rewrites 18 of them when the codec is AV1 and
drc.upperQpThreshold ≤ 49 ("Applying default AV1 QP settings" in
libBifrost2.so). The legacy Electron nvstOffer.ts and GStreamer sdp.rs
sent these values with a fixed 180 limit (#567, #451); the Rust rewrite dropped
them.

Change

  • av1_qp_settings (nvst_rtsp_negotiation.rs), called from
    negotiated_announce: for bitStreamFormat:2 with an offered threshold ≤ 49
    or none, drc/dfc/grc get headroom 20, lower 100, upper 200, adaptive limit 200
    from 3440×1440 pixels (else 180), qpCodecThresholdAdj 0, and 5 × each
    offered qpMaxResThresholdAdj with the official byte wrap. Logs
    av1-qp-settings applied=[...] or skipped.
  • set_session_attributes: replace a line of the same name, else insert
    before t=. fix(streamer): return the server's split-encode feature in ANNOUNCE #1306 adds the identical helper, so whichever of the two
    merges second drops its copy in a trivial rebase.
  • Docs: "AV1 QP scale" in docs/streamer-comparison/rtsp-negotiation.md
    (provenance: BuildID, SHA-256, addresses); the comparison README now lists
    the binary analyses it relies on. No binary, log or pseudocode is committed.

H.264/H.265 ANNOUNCE is unchanged. Shared core: Linux, Windows and macOS.

Verification

Linux x86_64, cargo 1.99.0:

  • cargo fmt --manifest-path native/opennow-streamer/Cargo.toml --all -- --check: clean
  • cargo clippy --locked --manifest-path native/opennow-streamer/Cargo.toml --workspace --all-targets -- -D warnings: clean
  • cargo test --locked --manifest-path native/opennow-streamer/Cargo.toml -p opennow-streamer-core: 236 passed (6 new)
  • cargo test --locked --manifest-path native/opennow-streamer/Cargo.toml --workspace: 1338 passed, 0 failed, 13 ignored

With this change on v1.0.3, the 10-bit profile ran three sessions (120, 150,
180 s) at 120 fps without termination, and 8-bit held 120 fps from 20 s on.

On dev (10-bit AV1, chromaFormat:0, save-bandwidth on, 3840×2160@120, same
day and zone), one session per arm:

  • Without: Linux nightly v1.0.4-nightly.1247.1 (dev 08822ce) ended with
    0x800e8605 13 s after PLAY.
  • With: the same nightly with libopennow_streamer_ffi.so built from this
    branch (dev 0467152 + this commit) ran 120 s without termination, logging
    av1-qp-settings applied=[...]. It received 920–932 frames per 10 s from
    20 s on, the separate 4K split-encode cap this change does not touch.

Not verified

  • More than one session per arm on dev; 8-bit AV1 on dev.
  • The 180 branch (< 3440×1440) and the pixel-count cases.
  • The six GRC values; the isolated live test used the 12 drc/dfc values.
  • HDR AV1, dynamicStreamingMode 2, a congested link, Windows/macOS clients.
  • Not ported: the same official routine sets video[0].minQp 25 on AV1 and
    changes encoder preset and split-encode settings by resolution level.
  • Qt ctest and Windows/macOS builds are left to CI.

Related

#1265 #1269 #1289 #1166 #1003 #567 #451

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Oct 25, 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: 775083e4-13c6-4e29-b761-b199c7c0710f

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

Problem: DESCRIBE offers the host's DRC, DFC and GRC QP thresholds on the
H.264/H.265 scale (0..=51, e.g. drc.upperQpThreshold 39). AV1 QP runs
0..=255, so the host's dynamic quality control sees every AV1 frame as
badly over-quantized and steps quality down. Measured on v1.0.3 with
save-bandwidth on (dynamicStreamingMode 1) at 3840x2160@120, 8-bit AV1
received 70-99 fps and 10-bit AV1 sessions ended with 0x800e8605 7-20 s
after PLAY, a code PR OpenCloudGaming#1269 decodes as
NVST_DISCONN_SERVER_VIDEO_PIPELINE_SCALE_FRAME_FAILED. Those runs sent
chromaFormat:1, which dev's docs (OpenCloudGaming#1265) also tie to 0x800e8605, but that
failure ends the session before the first frame; these ended mid-stream
and only with the policy on.

Cause: ANNOUNCE passes the H.26x-scale thresholds through. The official
Linux client 2.0.89.141 rewrites 18 of these fields when the codec is AV1
and drc.upperQpThreshold is at most 49 ("Applying default AV1 QP
settings" in libBifrost2.so). OpenNOW's legacy Electron and GStreamer
paths sent these AV1 values; the Rust rewrite dropped them.

Change: av1_qp_settings, called from negotiated_announce, applies the
official values when ANNOUNCE carries vqos[0].bitStreamFormat:2 and the
offered threshold is at most 49 or absent: headroom 20, lower 100,
upper 200, an adaptive limit of 200 from 3440x1440 pixels and 180 below,
qpCodecThresholdAdj 0, and five times each offered qpMaxResThresholdAdj
with the official byte wrap. It logs av1-qp-settings applied=[...] or
skipped. set_session_attributes replaces a line of the same name or
inserts before t=. H.264/H.265 ANNOUNCE is unchanged. The
streamer-comparison docs gain an "AV1 QP scale" section with provenance
(BuildID, SHA-256, addresses), and their README now lists the binary
analyses the set relies on.

Verification: cargo fmt --check (streamer, --all); cargo clippy --locked
--workspace --all-targets -- -D warnings (streamer); cargo test --locked
-p opennow-streamer-core: 236 passed, 6 of them new; cargo test --locked
--workspace (streamer): 1338 passed, 0 failed, 13 ignored. Not yet
measured live on dev.

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

Copy link
Copy Markdown
Contributor Author

Rebased onto the latest dev (8c3363b). GitHub reports no conflicts now.

The conflict came from #1306, which merged into dev and edits the same part of nvst_rtsp_negotiation.rs:

cargo test --workspace with linux-ffmpeg-bundled,linux-vaapi gives 1550 passed, 0 failed, 27 ignored.

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