Repository navigation
Dolby Vision: clear active-area offsets that cannot describe the picture - #1391
Merged
Merged
Conversation
…cture An encode cropped from a letterboxed master keeps the master's Level 5 active-area offsets in every RPU. The TV's Dolby Vision engine blanks everything outside that area, so an LG C8 played a 1920x802 Profile 8.1 file (L5 top=276 bottom=277, left of a 3840x2160 master) as a strip 249 rows high; with Dolby Vision off the HDR10 base layer played whole. packet_to_annexb now checks every HEVC RPU, the Profile 7 conversion's output included, against the raster the demuxer reports. Offsets that leave nothing, or an area wider than 3:1 or narrower than 1:2 (no released picture is outside that range), can only have been authored for another raster: they are zeroed through the dolby_vision crate and the RPU is written again with every other field kept. An RPU whose offsets fit, with no L5 block, that does not parse, or on a stream with no reported raster goes out byte for byte as it came. The URI engine, where the TV reads the file itself, is not covered, and no television has shown the fix: our dev set's libkadaptor cannot reproduce the strip. Closes #1367 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
… stream Review of the first change found that an aspect-bounds-only rule keeps foreign offsets in real cases: a 1.85:1 master (t=b=42) cropped to 1920x1038 leaves 2.01:1 and a 2.00:1 master (t=b=120) cropped to 1920x960 leaves 2.67:1, both plausible, both still blanking picture; and a variable-aspect 4K master downscaled to 1080p has 1.90:1 scenes whose 69/70 look fine alone. A wrong keep cuts real picture and a wrong clear only shows the black bars the encode carries, so the rule now leans to clear. A raster that is not 16:9 was cropped and has no bars for an active area to describe: any nonzero offsets are cleared. On a 16:9 raster the offsets must still be able to describe it, and once one RPU of the stream has been cleared every later RPU with nonzero offsets is cleared too. The latch is the demux loop's per-stream DvActiveArea, passed to packet_to_annexb, which replaces the bare raster parameter; no new global. The docs and rustdoc said t=138/b=139 on 1920x802 leaves 7.7:1; it leaves 3.66:1, and 7.7:1 is the reporter's 276/277. Fixed, along with the claims that the HDR10 path carries no RPU (it is fed, nothing applies it) and that kept RPUs go out byte for byte (a converted Profile 7's is the conversion's output). AV1 Profile 10 on the Feed path is named as not covered. Closes #1367 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1367
What
ff::packet_to_annexbnow checks every HEVC Dolby Vision RPU it feeds against the picture it travels with: the raster the demuxer reports (codecparwidth and height, the displayed raster, not the coded one). An RPU whose Level 5 active-area offsets are foreign to that picture has the four offsets zeroed (DoviRpu::crop, whatdovi_tool --cropdoes) and is written again, every other field kept. The Profile 7 to 8.1 conversion's output goes through the same check.A wrong keep cuts real picture; a wrong clear only shows the black bars the encode itself carries. So the rule (
ff::dv_active_area_is_foreign) leans to clear:width * 9 != height * 16) was cropped and has no bars for an active area to describe, so any nonzero offsets are cleared. That covers 1920x802, 1920x1038, 1920x960, 3840x1600 and 4096x2160. This is what the area's shape alone cannot do: a 1.85:1 master (top=bottom=42) cropped to 1920x1038 leaves a plausible 2.01:1 and would still blank 84 rows; a 2.00:1 master (120 / 120) cropped to 1920x960 leaves 2.67:1.ff::dv_active_area_fits:l + r < W,t + b < H, and an area no wider than 3:1 (DV_AREA_WIDEST) and no narrower than 1:2 (DV_AREA_NARROWEST); no released picture is wider than 2.76:1, Ultra Panavision 70, or narrower than 9:16 portrait). A genuine 1920x1080 letterbox (138 / 139, 2.39:1) and a 3840x2160 master's own276 / 277are kept. Plus a per-stream latch: once one RPU of the stream has been cleared, every later RPU with nonzero offsets is cleared too. That catches a variable-aspect 4K master downscaled to 1080p, whose 1.90:1 scenes (69 / 70) look plausible alone.The latch is
ff::DvActiveArea { raster, foreign_seen }, owned by the demux loop beside the stream's other per-open values and passed&muttopacket_to_annexbin place of a bare raster. No new global state. The counter for the log is astaticbeside the neighbouring DV counters inff.rs;ci/check-deps.shaccepts it, so there is no ledger line.Any other RPU is fed as it reached the check, not re-serialised: the original bytes, or for a converted Profile 7 the conversion's output. That covers offsets that are kept, no L5 block, an RPU that does not parse (a Profile 7 one is still dropped, as before) and a raster the demuxer did not report.
The first three clears and every 5000th are logged:
ff: DV RPU #n active area l=0 r=0 t=276 b=277 cannot describe 1920x802; cleared.docs/dolby-vision.mdgets a short subsection, 1a: the bug class, the rule and its three branches, what is fed, the firmware evidence and the limits.Why
An LG C8 (webOS 4.4.3, Feed path) played a 1920x802 HEVC Dolby Vision Profile 8.1 file as a strip 249 rows high. The file is a re-encode of a 3840x2160 master with the letterbox bars cropped off, and its RPUs still carry the master's Level 5 offsets (
dovi_tool info -s:L5 offsets: top=276, bottom=277, left=0, right=0). The TV's DV engine blanks everything outside that area: 802 - 553 = 249 rows. With Dolby Vision off the RPU NALs are still fed, but the pipeline is built without Dolby Vision, so nothing applies them and the HDR10 base layer plays whole. Firmware evidence: W18Olibkadaptor.so.2.0.1,dolbyGenerateRegNLuts_IPat0xe620cwrites the L5 offsets into the DM registersActive_area_*.Tests
In
rust-modules/play-feed/src/ff_packet_framing_tests.rs, RPUs built in the test with thedolby_visioncrate from dovi_tool's own fixtures (tests/fixtures/dovi-p7-*), not from new binary files:t=276 b=277at 1920x802: all four offsets come out 0, and the profile, header, mapping and the rest of the DM data are unchanged (compared with the offsets zeroed through the crate), L1 still there;42 / 42, 1920x960 with120 / 120, 3840x1600 with100 / 100and 4096x2160 with138 / 139are cleared, each with an area that passesdv_active_area_fitsalone;138 / 139and 3840x2160 with276 / 277, both directly and throughpacket_to_annexb;276 / 277RPU is cleared, then a69 / 70RPU on the same state is cleared too, while69 / 70alone on a fresh state is byte-equal; also through the feed, one packet each;l=r=480: cleared;dv_active_area_fitsbounds (2.76:1 and 3.0:1 kept, 3.1:1 cleared, 0.5625 and 0.5 kept, 0.44 cleared,t+b >= Handl+r >= Wcleared) and a table fordv_active_area_is_foreign.Red first, twice. First change: with the parameter threaded and the two functions stubbed to the old behaviour,
make test-crate C=plx_play_feedreadtest result: FAILED. 310 passed; 5 failed, thenok. 315 passedwith the implementation. Second change (the widened rule), withdv_active_area_is_foreignset to the old bounds-only logic:test result: FAILED. 316 passed; 3 failed(the cropped-raster, latch and rule-table tests; the genuine-4K keep passes on the old rule by design), thentest result: ok. 319 passed; 0 failedwith the new rule.Gates on the committed tree:
make test-crate C=plx_play_feed,make check-nodef,bash ci/check-deps.sh(check-deps: all gates green),python3 ci/check-module-layers.py(green). CI runsmake checkand the ARM build.Not verified
No television has shown this fix. Our dev set (W19H) has no
active_areastring in itslibkadaptor, so it cannot reproduce the strip, and the reporter's C8 is the only set the failure was seen on; the fix has not been run on a C8 or on any other set.Also not covered or not measured:
top=bottom=42, 1.93:1 left) passes and blanks 21 rows of picture at each edge.av1_packet_to_tu, notpacket_to_annexb, and is not checked.🤖 Generated with Claude Code