Repository navigation
Playback: Dolby Vision found in the RPUs of a stream with no record is declared - #1472
Conversation
GLinnik21
left a comment
There was a problem hiding this comment.
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_dovito direct play, keep the doc as it is, and add a test that a remux route stays undeclared.
Generated by Claude Code
|
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 |
GLinnik21
left a comment
There was a problem hiding this comment.
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.
- 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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
| 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()) |
There was a problem hiding this comment.
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
| } | ||
| r.ue()?; // bit_depth_luma_minus8 | ||
| r.ue()?; // bit_depth_chroma_minus8 | ||
| let log2_max_poc_lsb = r.ue()? + 4; |
There was a problem hiding this comment.
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.
| 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
|
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:
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 |
39cc4ce to
d6d8298
Compare
|
Done in d6d8298, on your shape: a per-play Retested on the C1 (webOS 6.5.3) on the same record-less P8 MKV: "found in the RPUs", one reload with DolbyHdrInfo, Load |
|
Thanks for the update and the C1 retest. One Profile 5 edge case I'd like to fix in this PR before merging.
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 |
|
Good catch. It also applied to a Profile 5 with a record: direct play leaves Fixed where the flag is read rather than where it's written. Regression tests are in
Both P5 tests fail on the previous head with 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.
9774bc9 to
6f54892
Compare
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?