Repository navigation
HUD plugins: the caption band as a value through every caption reader - #1148
Merged
Merged
Conversation
The ceiling a lifted caption is held under, the top of the control row and the
distance a text caption rises were three constants (SUB_CEIL_Y, HUD_CONTROLS_TOP_Y,
HUD_LIFT) that each caption reader read directly. They are now one value,
text_style::HudBand { ceil_y, controls_top_y, lift }, built by a single
constructor, HudBand::from_controls_top (ceil_y = controls_top_y - 12,
lift = SUB_BASE_Y - ceil_y). HudBand::CLASSIC is that constructor's value for
classic's row (792, 780, 200) and is pinned against today's numbers.
Every reader takes the band as an argument: today_baseline and
today_ink_baseline, caption_geometry_for, hud_lift/overhangs, the libass lift
(lift_dys) and the synth test. HudGeometry::band() returns the band a layout
occupies, the compact row's top, which is classic's in every slot; the player
screen reads it from classic::frame_geometry() each frame and passes it to the
caption draw, the bitmap lift and the libass lift. classic's row top (BTN_Y) is
now HudBand::CLASSIC.controls_top_y, so the number exists in one place.
player_hud::min_controls_top_y() is the highest row top for which the largest
caption block (three lines, Huge, High) still fits inside SAFE: 646 px (645.2
rounded up to a whole pixel). A plain fn over caption_layout, size_scale and
position_lift, not a global.
No frame of classic changes: captions sit where they sat in every state.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t ignores the band The "at the bound" assertions for the image lift and the libass lift passed whether or not the reader used the band: with classic's numbers the block's top was still inside SAFE. They now assert what ties each reader to the band (the image block's bottom lands on the band's ceiling; the libass block rises by exactly band.lift) next to the on-screen check, and the clamp lines say they test the clamp, not the bound. Both fail with the reader neutered to classic's band. Co-Authored-By: Claude Opus 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.
PR4 of the player-HUD plugin plan (
docs/hud-plugins.md, "Captions: the band a HUD occupies", F28, D8). Captions' lift was three constants that every caption reader read directly. It is now one value,HudBand, that the layout reports and every reader takes as an argument. It changes no frame of classic.What changes
media/src/player/text_style.rs:HudBand { ceil_y, controls_top_y, lift }. One constructor,HudBand::from_controls_top(y), derivesceil_y = y - CAPTION_INK_CLEARANCE(12 px) andlift = SUB_BASE_Y - ceil_y.HudBand::CLASSICis that constructor's value for classic's row:controls_top_y792,ceil_y780,lift200, pinned by a test against today's numbers.SUB_CEIL_YandHUD_LIFTare gone;HUD_CONTROLS_TOP_Yis now private and isCLASSIC's only input. Media still names nothing above it.Every reader takes the band as an argument. The sites the grep found, re-found after PR2's split:
today_baseline,today_ink_baselinemedia/.../text_style.rsSUB_CEIL_Ycaption_geometry,caption_geometry_for,draw_subtitle_messageappkit/.../player_hud/mod.rsSUB_CEIL_Yhud_lift,overhangs,draw_subtitle_bitmapappkit/.../player_hud/mod.rsSUB_CEIL_Ylift_dys,AssSubtitles::draw(the libass lift)screens/src/player/ass_subtitles.rsHUD_LIFTBTN_Y(classic's row top)appkit/.../player_hud/classic.rsHUD_CONTROLS_TOP_Ynative_hud_up_deep_marks_clear_the_transport_controls, and the ink-baseline synth testmedia/.../ass/tests/synth.rsHUD_LIFT,HUD_CONTROLS_TOP_Yappkit/.../player_hud/tests.rs,screens/.../ass_subtitles.rs,text_style.rsThe comment in
plex/src/plex/session.rsthat namedSUB_CEIL_Yis reworded.HudGeometry::band()(appkit/.../geometry.rs) returnsHudBand::from_controls_top(row_anchor.top): the compact row's top, which is where the Skip and Up Next stand-ins land too, so it is the same in every slot. For classic that isHudBand::CLASSIC.PlayerScreen::drawreads it fromclassic::frame_geometry()(no measuring) each frame and passes it to the libass lift, the text caption draw and the bitmap lift, so the band is a value from the layout, not a global.classic::BTN_YisHudBand::CLASSIC.controls_top_y, so 792 is written once.player_hud::min_controls_top_y(): the highestcontrols_top_yfor which a caption block ofCAPTION_ANCHOR_LINESlines at the largestSubtitleSizeand the highestSubtitlePositionstill fits betweenSAFE's top and the lifted baseline. It is a plain fn overcaption_layout,size_scaleandposition_lift(it reads the ladders for "largest" and "highest"), not a lazy static. The real number is 646: 54 + 3 x 48 x 1.8 + 320 + 12 = 645.2, rounded up to a whole pixel so the bound is never optimistic (the plan's estimate was ~645). Its name does not matchMAX_*, soci/list-caps.inineeds no row.Why
D8 makes the band a per-package value derived from the compact state. The compiler (PR5c) and the renderer (PR7) can only supply one if every F28 reader takes it instead of reading a constant. This PR does that with classic as the only producer, so the swap is mechanical later and nothing about classic can move now.
Grep after the change
grep -rn 'SUB_CEIL_Y\|HUD_CONTROLS_TOP_Y\|HUD_LIFT' rust-modules:That is the constant,
CLASSIC's construction and its pin; no other reader names them.Tests
classic_band_is_todays_constantspinsHudBand::CLASSIC == { ceil_y: 780, controls_top_y: 792, lift: 200 }; the existing tie tests (today_baseline_is_the_old_geometry,text_style_baseline_ties_to_caption_geometry_and_layout,bottom_cues_rise_exactly_the_hud_lift_at_every_position_and_size, the image-lift tests) pass forCLASSIC, and the tie test runs again forfrom_controls_top(700).a_non_classic_band_moves_the_lifted_caption_by_its_difference(media and appkit),image_sub_lift_follows_the_band,bottom_cues_rise_exactly_the_bands_lift_for_a_non_classic_band(libass lift): the baseline, the floor, the ink row, the image lift and the libass lift move by exactly the 92 px difference betweenfrom_controls_top(700)and classic's band; the HUD-down placement does not move.let band = HudBand::CLASSIC;), the five band tests fail (left: 0.0 right: 92.0, andmin_controls_top_y_is_where_the_largest_block_just_fitsat its "one px higher does not" line); they pass once the readers use it. The temporary lines are not in the commit.min_controls_top_y_is_where_the_largest_block_just_fitspins 646; a band at it keeps the largest block insideSAFEthroughcaption_geometry_for, and one px higher does not.hud_liftand the libass lift clamp the block on screen (their clamp is to the screen, not toSAFE), and the libass block sits 3 px lower (INK_TRIM) than the bespoke one, so the bespoke draw is the binding one; the tests assert on-screen at the bound for both and that relationship, not a "one px higher fails" they cannot show.the_layouts_band_is_classics_in_every_slot:HudGeometry::band()isHudBand::CLASSICfromframe_geometry()and fromgeometry()in all four slot states.native_hud_up_deep_marks_clear_the_transport_controlsis#[ignore](it needs the native libass artifact); it now loops over classic's band andfrom_controls_top(700). It is band-invariant by construction (liftfollows the ceiling), so it is not run here.Issue
No issue tracks the HUD-plugin work; none was opened for this PR.
Gates
Local, on the committed tree (
git status --shortempty), crate tests only; CI is the full gate:make test-crate C=plx_media:test result: ok. 1960 passed; 0 failed; 78 ignored; 0 measured; 0 filtered out; finished in 40.08smake test-hostsim C=plx_media:test result: ok. 2183 passed; 0 failed; 78 ignored; 0 measured; 0 filtered out; finished in 64.70smake test-crate C='plx_appkit plx_screens':test result: ok. 549 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 10.21s(plx_appkit), threetest result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; ... 1759 filtered out; finished in 0.00slines, thentest result: ok. 1760 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 26.96s(plx_screens)Not run here, left to CI:
make check,make check-nodef, the ARM build. No TV or simulator pass: no frame of classic changes, andHudBand::CLASSICis pinned equal to the constants it replaces.🤖 Generated with Claude Code
Review
Head
20c9a8773.origin/mainhad not moved (git log HEAD..origin/mainempty), so no merge was needed. The review's verdict was MERGE with one finding.SAFE. The tests now also assert what ties each reader to the band:hud_liftlands the block's bottom on the band's ceiling (close(bottom - lift, band.ceil_y)at the bound and one px past it), and the libass block rises by exactlyband.lift(assert_eq!(lifted, top - band.lift)). The clamp lines are commented as testing the clamp, not the bound. Red check: withhud_lift/overhangsandlift_dystemporarily forced toHudBand::CLASSIC,min_controls_top_y_is_where_the_largest_block_just_fitsfails (bottom on the ceiling) andthe_libass_lift_keeps_the_largest_block_on_screen_at_the_boundfails (the rise is the band's lift,left: 203.80002); they pass with the readers restored. The temporary lines are not in the commit.Required checks, re-run on the committed tree (
git status --shortempty):make test-crate C=plx_media:test result: ok. 1960 passed; 0 failed; 78 ignored; 0 measured; 0 filtered out; finished in 42.12smake test-hostsim C=plx_media:test result: ok. 2183 passed; 0 failed; 78 ignored; 0 measured; 0 filtered out; finished in 65.04smake test-crate C='plx_appkit plx_screens':test result: ok. 549 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 15.04s(plx_appkit), threetest result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; ... 1759 filtered out; finished in 0.00slines, thentest result: ok. 1760 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 36.73s(plx_screens)