Skip to content

Playback: Dolby Vision found in the RPUs of a stream with no record is declared - #1472

Merged
GLinnik21 merged 5 commits into
plxnative:mainfrom
tiper:up/dolby-vision-rpu-without-record
Nov 23, 2026
Merged

GLinnik21 merged 5 commits into
plxnative:mainfrom
tiper:up/dolby-vision-rpu-without-record

Conversation

@tiper

@tiper tiper commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

A remux can drop the container's Dolby Vision configuration record and keep the RPUs. The server then reports no Dolby Vision, the Load carries no DolbyHdrInfo node, and the set shows only the base layer.

For an HEVC stream with no record, the demuxer reads the first packets and reports what the first RPU says: Profile 5, or Profile 8 over PQ or HLG (the transfer comes from the SPS when the container states none). Once the Load returns, the route declares it as the record would have, so Dolby Vision Off, an unconfirmed set and a re-encode change nothing, and the pump reloads once with the node.

Tested on a C1 (webOS 6.5.3) with a Profile 8 MKV with no record: dynamicRange went from hdr to dolbyHdr after one reload, and nothing withdrew it after seeks. Not tested: Profile 5 or HLG streams with no record.

The finding isn't remembered, so the range chip (#1348) and the poster caption (#1412) still say HDR for such a file, and each play reloads once. Would you want a follow-up that remembers it per file, so later plays declare it on the first Load and the badges agree?

@GLinnik21 GLinnik21 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this looks solid. On your question: no need for the per-file memory follow-up. One extra reload on the first play of a file that lost its record is a fair price, and a per-file cache would bring its own state, invalidation and storage for a rare case. The chip and caption reading "HDR" there is fine: they describe what the server reports.

Reviewed e9924f0f9...b650e4ff9; it merges cleanly into current main. No new FFI or struct fields: color_trc was already bound and read. The reload can't loop (stream_dovi.present stays set after a withdrawal), and it's held behind the Load thread, the in-flight guards and previews. The SPS/VUI walk matches H.265 7.3.2.2 / 7.3.4 / 7.3.7 / E.2.1.

One thing to settle, a doc/code mismatch:

docs/dolby-vision.md, "Limits": it says "a remux the server makes of it is not declared", but as far as I can read, it is. A server remux copies the video (plan.rs ~2959), and the route gets copied_video_dv(.., src_dovi, src_dv_decision) (~3186). With no record, src_dovi is NONE, so the route keeps the file's src_dv_decision with the probed Supported capability. Only a re-encode gets DvDecision::NONE / Unknown. The demuxer then sees the RPUs in the remuxed stream, RpuOnlyScan runs, and declare_rpu_dovi returns true, so the remux reloads with the node.

This matters most for Profile 5. plan.rs:2966-2976 deliberately never remuxes a declared P5 and re-encodes it instead. Without a record the server doesn't know it's P5, remuxes it, and this PR then declares P5 on the copy. That's probably the right picture on the set, since the RPUs are the same, but it's a path neither a test nor the device run covers.

Please pick one:

  • if declaring on a remux is intended: fix the "Limits" sentence and add a route test that declares on a remux (video-copy) route, ideally P5 as well as P8.1;
  • if it isn't: gate declare_rpu_dovi to direct play, keep the doc as it is, and add a test that a remux route stays undeclared.

Generated by Claude Code

@tiper

tiper commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

Thanks. Declaring on a remux is intended: the copy carries the same RPUs, and for a Profile 5 it's what keeps a record-less file the server remuxed off its base layer, the picture plan.rs re-encodes a declared P5 to avoid. The "Limits" note now says a remux is declared like a direct play and only a re-encode isn't. The new route test, rpu_dovi_is_declared_on_a_server_remux_as_on_direct_play, declares P8.1 and P5 on a remux route and leaves a re-encode undeclared. A remux hasn't been measured on a set.

@GLinnik21 GLinnik21 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

second, deeper pass after the remux commit. declaring on a remux turns out to have two problems (inline below), so i'd now take the other option from my last review: gate declare_rpu_dovi to direct play, put the "Limits" sentence back, and add a test that a remux route stays undeclared. if you'd rather keep remux, both inline remux points need fixing, plus a pump test on a transcoding route.

  1. the reload isn't gated on original_recovery_pending() the way the plain seek path is (pump.rs:1684), so it can fire inside an Original trial that hasn't been confirmed yet.

otherwise the scan, the mailbox lifecycle and the no-loop logic look right.


Generated by Claude Code

})
.max(0);
super::log(&format!("dv: reload at {:.3}s with DolbyHdrInfo", target as f64 / 1e9));
settle_reload(super::engine::reload_at(ps, pa, target), "Dolby Vision found in the RPUs", ps);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on a remux this is the wrong reload. reload_at → arm_open(target) sets seek_to_ns and zeroes disp_base, but start.mkv is already 0-based at the offset (ff.rs:7100; the first start only arms on direct play, route_start.rs:959). resume at 40:00 and the reload seeks 40:00 into a stream that already starts at 40:00, or the seek fails and the timeline and scrobble read from 0. a start at 0 hides it.


Generated by Claude Code

*decided = frozen_dv_decision(mode, decided.capability, dovi, vcodec);
}
};
adopt(&mut ps.src_dovi, &mut ps.src_dv_decision, &ps.stream_vcodec);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for a remuxed P5 this doesn't survive the next rebuild. any transcode seek or audio switch goes through copied_video_dv (plan.rs:1159), which returns NONE for a base_layer_unusable() source, so the capability goes Unknown and the repeated RPU report can't declare again: the P5 plays undeclared from then on. the P5 adopted into auto_original also makes original_remux_shape false (decision.rs:12061), so later rebuilds ask for a capped re-encode.


Generated by Claude Code

Comment thread rust-modules/media/src/player/pump.rs Outdated
if let Some(rpu) = rpu {
if !crate::route::flight_outstanding()
&& !crate::route::preview_request(ps)
&& crate::route::declare_rpu_dovi(ps, rpu, crate::route::dolby_vision_mode())

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dolby_vision_mode() is the live pref, read every frame for the whole play while this keeps declining. flipping DV Off→Auto mid-play would then declare and reload, which a file with a record never does because its mode is frozen at resolve. freezing the mode on the session, or deciding once per Load, avoids that.


Generated by Claude Code

Comment thread rust-modules/play-feed/src/ff.rs Outdated
}
r.ue()?; // bit_depth_luma_minus8
r.ue()?; // bit_depth_chroma_minus8
let log2_max_poc_lsb = r.ue()? + 4;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unbounded: a corrupt SPS overflows this u32 add (a panic with overflow checks on), and on the TV the skip below wraps and reads garbage.

Suggested change
let log2_max_poc_lsb = r.ue()? + 4;
let log2_max_poc_lsb_minus4 = r.ue()?;
if log2_max_poc_lsb_minus4 > 12 {
return None; // H.265 limits it to 0..=12
}
let log2_max_poc_lsb = log2_max_poc_lsb_minus4 + 4;

Generated by Claude Code

Copy link
Copy Markdown
Collaborator

to make the review concrete, here's the smaller shape i'd take. it fixes everything inline without new machinery, and keeps your C1 fix:

  1. one per-play field, set at resolve and kept outside AppliedRouteProjection (survives a rollback the way auto_original and src_dovi do): rpu_dv: Open { mode } | Declared | Closed. declare_rpu_dovi acts only in Open, using the frozen mode instead of dolby_vision_mode(); a declaration moves it to Declared, a decline (DV Off, unconfirmed set) to Closed, and withdraw_dv_presentation sets Closed. that replaces the stream_dovi.present inference and the per-frame re-read of the live pref, and an Original-trial rollback can't re-open it.
  2. declare only when !is_transcoding(ps), the same "no rung for a remux" rule the landing guard uses (feed_open.rs:211). a report on a remux leaves it Open.
  3. on a P5 declaration, set no_video_copy as the plan does for a P5 with a record (plan.rs:2206), so a later rebuild re-encodes instead of copying a base layer it can't declare.
  4. drop the remux claim from "Limits" and the remux route test from 39cc4ce, add a pump test that a transcoding route doesn't reload, and bound the SPS field (inline suggestion).
  5. scan and mailbox are fine as they are.

a record-less file the server remuxes (the TrueHD/DTS case) keeps its base layer, same as before this PR. declaring on a remux needs a designed reload path and a measurement on a set, so i'll take that as a follow-up on our side.


Generated by Claude Code

@tiper
tiper force-pushed the up/dolby-vision-rpu-without-record branch from 39cc4ce to d6d8298 Compare November 22, 2026 10:49
@tiper

tiper commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Done in d6d8298, on your shape: a per-play RpuDv (Open with the mode frozen at resolve / Declared / Closed) outside the projection, closed by a decline and by withdraw_dv_presentation; declared only when !is_transcoding (a remux report leaves it Open); the pump also waits out an unconfirmed Original trial; a P5 declaration sets no_video_copy; your SPS bound, with a test that fails without it. 39cc4ce is dropped, and "Limits" is back to: a remux is not declared. Thanks for taking the remux follow-up.

Retested on the C1 (webOS 6.5.3) on the same record-less P8 MKV: "found in the RPUs", one reload with DolbyHdrInfo, Load dv=present:1 P8/1, dynamicRange=dolbyHdr; the repeated report is not declared again and nothing is withdrawn.

Copy link
Copy Markdown
Collaborator

Thanks for the update and the C1 retest. One Profile 5 edge case I'd like to fix in this PR before merging.

declare_rpu_dovi sets no_video_copy on the current contract, but returning to Original restores the inferred P5 declaration and resets the contract. If the viewer then picks an audio track that needs server conversion, the progressive rebuild can send directStream=1. PMS can copy the P5 video, and copied_video_dv drops the declaration for that copy, so the picture can have wrong colors.

Could you keep the copy restriction when restoring Original and add a regression test for inferred P5 → lower quality → Original → audio conversion that checks the rebuild sends directStream=0?

@tiper

tiper commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Good catch. It also applied to a Profile 5 with a record: direct play leaves cur_contract.no_video_copy false, so an audio pick that needs conversion rebuilt with directStream=1 there as well.

Fixed where the flag is read rather than where it's written. is_no_video_copy now also forbids the copy when the file's own declaration (src_dovi) has an unusable base layer. The RPU declaration already adopts the inferred record into src_dovi, so I dropped the contract write in declare_rpu_dovi, and a route rebuild (Original recovery, quality change, rollback) can no longer lose the restriction. The remaining direct readers of the flag (the Original remux shape, the burn check, the failed-open ladder) now go through is_no_video_copy too.

Regression tests are in route/decision_dv_copy_flight_tests.rs. They run against the loopback FlightRig server and assert on the /decision request the rebuild actually sends:

  • inferred P5, lower quality, back to Original, then an audio conversion: directStream=0
  • P5 with a record, direct play, then an audio conversion: directStream=0, and the same again after lowering quality and going back to Original
  • control: an inferred P8.1 through the same flow still sends directStream=1

Both P5 tests fail on the previous head with directStream=1 and pass now.

One limit, now written in the docs: for an inferred P5 this keeps the request the same shape as for a recorded one, but it can't make the server route correct. The server has no record either, so it encodes the base layer and nothing declares it. That's the same picture the copy gave.

…s declared

A remux can drop the container's Dolby Vision configuration record and
keep the RPUs in the bitstream. The server then reports no Dolby Vision,
the Load declares no DolbyHdrInfo node and the panel shows the base
layer while every RPU is still fed.

For an HEVC stream with no record, the demuxer now reads its first
packets (ff::RpuOnlyScan) and reports, once per open, what the first
RPU says (FeedRaw::rpu_dovi): Profile 5, or Profile 8 over a PQ or HLG
base layer. An RPU that maps an enhancement layer, an enhancement-layer
NAL and an RPU that does not parse report nothing; a Profile 8 over any
other transfer is logged as refused. Once the Load has returned, the
pump has the route declare it (route::declare_rpu_dovi: the decision
the record would have frozen, so Dolby Vision Off, a set without
confirmed support and a re-encode change nothing) and reloads once with
the node. The installed route, the file's own declaration and the
stored Auto Original candidate all follow, and a later withdrawal is
not undone.

The base layer's transfer is the container's, or, where the container
states none (a Matroska remux with no Colour element reports trc=2),
the first SPS's VUI transfer_characteristics (ff::stream_transfer).

Measured on an LG C1 (webOS 6.5.3), stable build, on an MKV with Profile
8 RPUs, no record, trc=2 in the container and PQ in the SPS:
- before: Load dv=present:0, dynamicRange=hdr, pictureMode=hdrCinemaBright
- after: "the SPS says trc=16", "Dolby Vision P8 bl_compat=1 in the
  RPUs", "dv: reload at 323.291s with DolbyHdrInfo", Load
  dv=present:1 P8/1, dynamicRange=dolbyHdr,
  pictureMode=dolbyHdrCinemaBright; no withdrawal after the reload.
Not measured: a Profile 5 or HLG Profile 8 stream with no record, and
the 49SM9000 dev set.

Not remembered: the finding lives for the play that made it. The
server's metadata still reports no Dolby Vision for such a file, so the
detail and Home hero range chip (plxnative#1348) and the poster caption (plxnative#1412)
read HDR while the set plays Dolby Vision, and each play declares it
again with one reload.

Signed-off-by: Tiago Pereira <[email protected]>
…rozen at the resolve

A play's RPU declaration is now one per-play state (RpuDv), set at the
resolve and kept outside the route projection: Open with the Dolby
Vision setting the resolve read, for a file with no record; Declared;
Closed after a decline, a withdrawal, or for a file with a record. A
rollback cannot re-open it, and turning Dolby Vision on mid-play no
longer declares.

Only a direct play declares: a server remux's start.mkv begins at its
offset, so the reload's seek would land wrong. A report on a transcoding
route leaves the play open. The pump also waits for an Original trial to
be confirmed, as the plain seek does. A Profile 5 declaration forbids a
video copy from then on, so a later re-encode never hands the set its
base layer undeclared.

The SPS walk refuses a log2_max_pic_order_cnt_lsb_minus4 past H.265's
limit of 12 instead of overflowing on a corrupt SPS.

Signed-off-by: Tiago Pereira <[email protected]>
The copy restriction lived only on the route's contract, which an Original
recovery resets, so an audio conversion after a return to Original asked the
server for directStream=1. Read it from the file's own Dolby Vision record
as well, which the RPU declaration already adopts.
The file's Dolby Vision fields are set at the resolve and rewritten by the
RPU declaration, not frozen. An inferred Profile 5 refused a copy still has
no correct server route: the server has no record, so it encodes the base
layer.
The Original remux shape, the burn check and the failed-open ladder read
the rule through is_no_video_copy, so the candidate's own Profile 5 term
goes: the candidate's record is the file's. The enhancement fixture plants
the file's record beside the candidate's, as a resolve does.
@tiper
tiper force-pushed the up/dolby-vision-rpu-without-record branch from 9774bc9 to 6f54892 Compare November 23, 2026 10:52

@GLinnik21 GLinnik21 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@GLinnik21
GLinnik21 merged commit fd785c1 into plxnative:main Nov 23, 2026
17 checks passed
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.

2 participants